metaheuristic_designer.constraint_handlers.extended_constraint module#
- class ExtendedConstraintHandler(solution_handler, param_handler_dict, encoding, **kwargs)[source]#
Bases:
ConstraintHandler- Attributes:
paramsAccess parameter values by attribute-style lookup.
- Parameters:
solution_handler (ConstraintHandler)
param_handler_dict (dict)
encoding (ParameterExtendingEncoding)
Methods
get_params()Return a copy of the current parameter dictionary.
penalty(genotype_matrix)Offset to the objective value for the solution corresponding to violations of the problem's constraints.
repair_solutions(genotype_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(genotype_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:
genotype_matrix (ndarray[tuple[int, int], floating] | ndarray[tuple[int, int], integer] | ndarray[tuple[int, int], uint8 | bool])
- penalty(genotype_matrix)[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:
genotype_matrix (ndarray[tuple[int, int], floating] | ndarray[tuple[int, int], integer] | ndarray[tuple[int, int], uint8 | bool])