24 """Apply explicit inequalities to MOME without changing its objective weights.
26 Evaluators return fitness, descriptors, and named constraint scores.
27 Each residual g(x) must be finite, with g(x) <= 0 denoting feasibility.
28 Only feasible candidates enter the reporting ParetoGrid. Infeasible
29 candidates compete by the sum of their positive residuals in a
30 separate slot per cell. Scale residuals in the evaluator when units differ.
32 :param container: Empty ParetoGrid for feasible trade-offs.
33 :param budget: Exact evaluation attempts.
34 :param dimension: Number of real-valued genome coordinates.
35 :param batch_size: Number of proposals before committing feedback.
36 :param constraint_names: Score names holding the inequality residuals.
37 :param infeasible_parent_probability: Chance of drawing a least-violation
38 breeder when both pools have entries. Zero disables these parents.
39 :param seed: Private mutation, selection, and truncation seed.
40 :param kwargs: MOME settings, including decision bounds and variation scales.
43 _requires_proposed_genome =
True
45 def __init__(self, container, budget, dimension, batch_size=1, *,
46 constraint_names, infeasible_parent_probability=.25, seed=0, **kwargs):
47 if not isinstance(container, ParetoGrid):
48 raise ValueError(
"FeasibleMOME requires a ParetoGrid.")
49 names = _names(constraint_names,
"constraint scores")
50 if not names
or set(names).intersection((*container.fitness_score_names, *container.features_score_names)):
51 raise ValueError(
"Supply separate, nonempty constraint score names.")
53 raise ValueError(
"FeasibleMOME starts with an empty ParetoGrid.")
54 if not 0. <= infeasible_parent_probability <= 1.:
55 raise ValueError(
"infeasible_parent_probability must be in [0, 1].")
59 super().__init__(container, budget, dimension, batch_size, **kwargs)
61 raise ValueError(
"Provide decision bounds with a finite span.")
64 """Reset the proposal stream and auxiliary breeding slots."""
66 self.
_rng = np.random.default_rng(self.
seed)
72 """Return an independent mapping of cells to their least-violation breeders."""
73 return {cell: candidate
for cell, (_, candidate)
in self.
_infeasible.items()}
84 return front[self.
_rng.integers(len(front))]
94 def _check_candidate(self, individual):
95 super()._check_candidate(individual)
97 raise ValueError(
"The aggregate constraint violation must be finite.")
101 for candidate
in evaluated:
102 if candidate
is None:
106 feasible.append(candidate)
108 cell = self.
container.index_grid(candidate)
110 if previous
is None or violation < previous[0]:
113 return {slot
for slot, candidate
in enumerate(evaluated)
if id(candidate)
in admitted}