metaheuristic_designer.constraint_handlers.composite_constraint module#

class CompositeConstraint(constraints, **kwargs)[source]#

Bases: ConstraintHandler

applies every constraint handler in succession.

Parameters:
constraints: Iterable

List of constraint handlers.

Attributes:
params

Access parameter values by attribute-style lookup.

Parameters:

constraints (Iterable)

Methods

get_params()

Return a copy of the current parameter dictionary.

penalty(solution)

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

repair_solutions(solution)

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.

gather_params

get_state

repair_population

gather_params()[source]#
repair_solutions(solution)[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:

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

penalty(solution)[source]#

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

Return type:

number | float | int

Parameters:
solution: Any

The input solution.

Returns:
penalty: float

The amount of penalty to apply to the current solution.

Parameters:

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