cilpy.solver.chm.ConstraintHandler Documentation
The constraint handling mechanism module: Defines the constraint handling mechanism interface.
This module provides the abstract "contract" for all constraint handling
mechanisms within the cilpy library.
In the future, this module could be modified to be a comparator for multi-objective optimization problems.
ConstraintHandler
Bases: ABC, Generic[FitnessType]
An abstract interface for a constraint handling mechanism.
This class defines the strategy for comparing two evaluations in the context of a constrained optimization problem. Solvers will delegate comparison logic to an implementation of this class.
Source code in cilpy/solver/chm/__init__.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
is_better(eval_a, eval_b)
abstractmethod
Compares two evaluations to determine if eval_a is better than eval_b.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
eval_a
|
Evaluation[FitnessType]
|
The first evaluation. |
required |
eval_b
|
Evaluation[FitnessType]
|
The second evaluation. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if |
bool
|
specific constraint handling strategy, False otherwise. |
Source code in cilpy/solver/chm/__init__.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
DefaultComparator
Bases: ConstraintHandler[float]
A default comparator for single-objective, unconstrained problems.
This handler performs a simple fitness comparison, assuming that a lower fitness value is better. It does not consider constraints.
Source code in cilpy/solver/chm/__init__.py
45 46 47 48 49 50 51 52 53 54 | |