metaheuristic_designer.constraint_handlers.linear_bound_penalty_constraint module#
- class LinearBoundPenaltyConstraint(dimension, alpha=1, lower_bound=-100, upper_bound=100, **kwargs)[source]#
Bases:
PenalizeConstraintEncodes a bound constraint by adding a penalty proportional to the distance of the solution’s distance to the bounds.
- Parameters:
- dimension: int
size of the input vector (decoded).
- alpha: float, optional
factor to multiply to the penalty before being applied.
- lower_bound: float | ndarray, optional
lower limit of the bounds.
- upper_bound: float | ndarray, optional
upper limit of the bounds.
- Attributes:
paramsAccess parameter values by attribute-style lookup.
- Parameters:
alpha (ScalarLike)
lower_bound (ScalarLike | VectorLike)
upper_bound (ScalarLike | VectorLike)
Methods
get_params()Return a copy of the current parameter dictionary.
penalty(population_matrix)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.
get_state
repair_population
- penalty(population_matrix)[source]#
Offset to the objective value for the solution corresponding to violations of the problem’s constraints.
- Return type:
ndarray[tuple[int],floating] |ndarray[tuple[int],integer] |ndarray[tuple[int],uint8|bool]- Parameters:
- solution: Any
The input solution.
- Returns:
- penalty: float
The amount of penalty to apply to the current solution.
- Parameters:
population_matrix (ndarray[tuple[int, int], floating] | ndarray[tuple[int, int], integer] | ndarray[tuple[int, int], uint8 | bool])