implements a bijective, monotonous transformation between [lb - al, ub + au]
and [lb, ub] which is the identity (and therefore linear) in [lb + al, ub - au]
(typically about 90% of the interval) and quadratic in [lb - 3*al, lb + al]
and in [ub - au, ub + 3*au]. The transformation is periodically
expanded beyond the limits (somewhat resembling the shape sin(x-pi/2))
with a period of 2 * (ub - lb + al + au).
Examples
Example to use with cma:
>>> import cma
>>>
>>> tf = cma.BoxConstraintsLinQuadTransformation([[1,2], [1,None]])
>>> cma.fmin(cma.felli, 9 * [2], 1, {'transformation': [tf.transform, tf.inverse], 'verb_disp': 0})
>>>
>>> es = cma.CMAEvolutionStrategy(9 * [2], 1)
>>> while not es.stop():
... X = es.ask()
... f = [cma.felli(tf(x)) for x in X]
... es.tell(X, f)
Example of the internal workings:
>>> import cma
>>> tf = cma.BoxConstraintsLinQuadTransformation([[1,2], [1,11], [1,11]])
>>> tf.bounds
[[1, 2], [1, 11], [1, 11]]
>>> tf([1.5, 1.5, 1.5])
[1.5, 1.5, 1.5]
>>> tf([1.52, -2.2, -0.2, 2, 4, 10.4])
[1.52, 4.0, 2.0, 2.0, 4.0, 10.4]
>>> res = np.round(tf._au, 2)
>>> assert list(res[:4]) == [ 0.15, 0.6, 0.6, 0.6]
>>> res = [round(x, 2) for x in tf.shift_or_mirror_into_invertible_domain([1.52, -12.2, -0.2, 2, 4, 10.4])]
>>> assert res == [1.52, 9.2, 2.0, 2.0, 4.0, 10.4]
>>> tmp = tf([1])
|
__init__(self,
bounds)
x is defined in [lb - 3*al, ub + au + r - 2*al] with r = ub - lb + al + au,
and x == transformation(x) in [lb + al, ub - au].
beta*x - alphal = beta*x - alphau is then defined in [lb, ub], |
source code
|
|
|
|
|
|
|
|
|
idx_infeasible(self,
solution_genotype)
return indices of "infeasible" variables, that is,
variables that do not directly map into the feasible domain such that
tf.inverse(tf(x)) == x. |
source code
|
|
|
is_feasible_i(self,
x,
i)
return True if value x is in the invertible domain of
variable i |
source code
|
|
|
is_loosely_feasible_i(self,
x,
i)
never used |
source code
|
|
|
shift_or_mirror_into_invertible_domain(self,
solution_genotype,
copy=False)
return the reference solution that has the same box_constraints_transformation(solution)
value, i.e. tf.shift_or_mirror_into_invertible_domain(x) = tf.inverse(tf.transform(x)).
This is an idempotent mapping (leading to the same result independent how often it is
repeatedly applied). |
source code
|
|
|
_shift_or_mirror_into_invertible_i(self,
x,
i)
shift into the invertible domain [lb - ab, ub + au], mirror close to
boundaries in order to get a smooth transformation everywhere |
source code
|
|
|
|
|
|
Inherited from BoxConstraintsTransformationBase :
bounds_i ,
inverse
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__sizeof__ ,
__str__ ,
__subclasshook__
|