metaheuristic_designer.constraint_handlers.bounce_bound_constraint module#

class BounceBoundConstraint(dimension, lower_bound=-100, upper_bound=100, **kwargs)[source]#

Bases: RepairConstraint

Encodes a bound constraint by bouncing through the bounds, subtracting the leftover part of the vector that lies outside the bounds. If the subtraction still lies outside the bounds, the leftover part is added, subtraction and addition are alternated until the solution lies in bounds.

Parameters:
dimension: int

size of the input vector (decoded).

lower_bound: float | ndarray, optional

lower limit of the bounds.

upper_bound: float | ndarray, optional

upper limit of the bounds.

Attributes:
params

Access parameter values by attribute-style lookup.

Parameters:
  • lower_bound (ScalarLike | VectorLike)

  • upper_bound (ScalarLike | VectorLike)

Methods

get_params()

Return a copy of the current parameter dictionary.

penalty(solutions)

Offset to the objective value for the solution corresponding to violations of the problem's constraints.

repair_solutions(population_matrix)

Modifies the incoming solution so that it follows the problem's constraints.

store_kwargs([progress])

Store keyword arguments and evaluate them at the given progress.

update(progress)

Re-evaluate all stored parameters at the current progress.

update_kwargs([progress])

Add or replace parameters and immediately evaluate them.

get_state

repair_population

repair_solutions(population_matrix)[source]#

Modifies the incoming solution so that it follows the problem’s constraints.

Return type:

ndarray[tuple[int, int], floating] | ndarray[tuple[int, int], integer] | ndarray[tuple[int, int], uint8 | bool]

Parameters:
solution: Any

The input solution.

Returns:
fixed_solution: Any

Modified version of the input solution that fits the problem’s constraints

Parameters:

population_matrix (ndarray[tuple[int, int], floating] | ndarray[tuple[int, int], integer] | ndarray[tuple[int, int], uint8 | bool])