correct_bounds

modcma.modularcmaes.correct_bounds(x: numpy.ndarray, ub: numpy.ndarray, lb: numpy.ndarray, correction_method: str) → numpy.ndarray

Bound correction function.

Rescales x to fall within the lower lb and upper bounds ub specified. Available strategies are: - None: Don’t perform any boundary correction - unif_resample: Resample each coordinate out of bounds uniformly within bounds - mirror: Mirror each coordinate around the boundary - COTN: Resample each coordinate out of bounds using the one-sided normal distribution with variance 1/3 (bounds scaled to [0,1]) - saturate: Set each out-of-bounds coordinate to the boundary - toroidal: Reflect the out-of-bounds coordinates to the oposite bound inwards

Parameters
  • x (np.ndarray) – vector of which the bounds should be corrected

  • ub (float) – upper bound

  • lb (float) – lower bound

  • correction_method (string) – type of correction to perform

Returns

  • np.ndarray – bound corrected version of x

  • bool – whether the population was out of bounds

Raises

ValueError – When an unkown value for correction_method is provided