Module cma :: Class BoundPenalty
[hide private]
[frames] | no frames]

Class BoundPenalty

source code

         object --+    
                  |    
BoundaryHandlerBase --+
                      |
                     BoundPenalty

Computes the boundary penalty. Must be updated each iteration, using the update method.

Details

The penalty computes like sum(w[i] * (x[i]-xfeas[i])**2), where xfeas is the closest feasible (in-bounds) solution from x. The weight w[i] should be updated during each iteration using the update method.

Example:

>>> import cma
>>> cma.fmin(cma.felli, 6 * [1], 1,
...          {
...              'boundary_handling': 'BoundPenalty',
...              'bounds': [-1, 1],
...              'fixed_variables': {0: 0.012, 2:0.234}
...          })

Reference: Hansen et al 2009, A Method for Handling Uncertainty... IEEE TEC, with addendum, see http://www.lri.fr/~hansen/TEC2009online.pdf

Instance Methods [hide private]
 
__init__(self, bounds=None)
Argument bounds can be None or bounds[0] and bounds[1] are lower and upper domain boundaries, each is either None or a scalar or a list or array of appropriate size.
source code
 
repair(self, x, copy_if_changed=True, copy_always=False)
sets out-of-bounds components of x on the bounds.
source code
 
__call__(self, x, archive, gp)
returns the boundary violation penalty for x ,where x is a single solution or a list or array of solutions.
source code
 
feasible_ratio(self, solutions)
counts for each coordinate the number of feasible values in solutions and returns an array of length len(solutions[0]) with the ratios.
source code
 
update(self, function_values, es)
updates the weights for computing a boundary penalty.
source code

Inherited from BoundaryHandlerBase: get_bounds, has_bounds, inverse, is_in_bounds, to_dim_times_two

Inherited from BoundaryHandlerBase (private): _get_bounds

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, bounds=None)
(Constructor)

source code 
Argument bounds can be None or bounds[0] and bounds[1] are lower and upper domain boundaries, each is either None or a scalar or a list or array of appropriate size.
Overrides: object.__init__

repair(self, x, copy_if_changed=True, copy_always=False)

source code 
sets out-of-bounds components of x on the bounds.
Overrides: BoundaryHandlerBase.repair

__call__(self, x, archive, gp)
(Call operator)

source code 
returns the boundary violation penalty for x ,where x is a single solution or a list or array of solutions.
Overrides: BoundaryHandlerBase.__call__

feasible_ratio(self, solutions)

source code 

counts for each coordinate the number of feasible values in solutions and returns an array of length len(solutions[0]) with the ratios.

solutions is a list or array of repaired Solution instances,

update(self, function_values, es)

source code 

updates the weights for computing a boundary penalty.

Arguments

function_values
all function values of recent population of solutions
es
CMAEvolutionStrategy object instance, in particular mean and variances and the methods from the attribute gp of type GenoPheno are used.
Overrides: BoundaryHandlerBase.update