popt.cost_functions.epf

 1import numpy as np
 2
 3def epf(r, c_eq=0, c_iq=0):
 4    r"""
 5    The external penalty function, given as
 6    .. math::
 7        0.5r(\sum_i c_{eq}^2 + \sum(\max(c_{iq},0)^2)
 8    We assume that the ensemble members are stacked as columns.
 9    """
10    
11    return r*0.5*( np.sum(c_eq**2, axis=0) + np.sum(np.maximum(-c_iq,0)**2, axis=0) )
def epf(r, c_eq=0, c_iq=0):
 4def epf(r, c_eq=0, c_iq=0):
 5    r"""
 6    The external penalty function, given as
 7    .. math::
 8        0.5r(\sum_i c_{eq}^2 + \sum(\max(c_{iq},0)^2)
 9    We assume that the ensemble members are stacked as columns.
10    """
11    
12    return r*0.5*( np.sum(c_eq**2, axis=0) + np.sum(np.maximum(-c_iq,0)**2, axis=0) )

The external penalty function, given as $$0.5r(\sum_i c_{eq}^2 + \sum(\max(c_{iq},0)^2)$$

We assume that the ensemble members are stacked as columns.