BPt.p.Array.set_bounds#

Array.set_bounds(*args, **kwargs)[source]#

Bounds all real values into [lower, upper] using a provided method

Parameters
lower: array, float or None

minimum value

upper: array, float or None

maximum value

method: str

One of the following choices:

  • “bouncing”: bounce on border (at most once). This is a variant of clipping,

    avoiding bounds over-samping (default).

  • “clipping”: clips the values inside the bounds. This is efficient but leads to over-sampling on the bounds.

  • “constraint”: adds a constraint (see register_cheap_constraint) which leads to rejecting mutations reaching beyond the bounds. This avoids oversampling the boundaries, but can be inefficient in large dimension.

  • “arctan”: maps the space [lower, upper] to to all [-inf, inf] using arctan transform. This is efficient but it completely reshapes the space (a mutation in the center of the space will be larger than a mutation close to the bounds), and reaching the bounds is equivalent to reaching the infinity.

  • “tanh”: same as “arctan”, but with a “tanh” transform. “tanh” saturating much faster than “arctan”, it can lead to unexpected behaviors.

full_range_sampling: Optional bool

Changes the default behavior of the “sample” method (aka creating a child and mutating it from the current instance) or the sampling optimizers, to creating a child with a value sampled uniformly (or log-uniformly) within the while range of the bounds. The “sample” method is used by some algorithms to create an initial population. This is activated by default if both bounds are provided.

Notes

  • “tanh” reaches the boundaries really quickly, while “arctan” is much softer

  • only “clipping” accepts partial bounds (None values)