metaheuristic_designer.constraint_handlers.clip_bound_constraint module#

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

Bases: RepairConstraint

Encodes a bound constraint by clipping solutions to the nearest point in the boundary.

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])