feat(traits): add Repair<D> trait + ClampToBounds and ProjectToSimplex impls
Spec §22 Round 4-D listed bounded mutation / repair operators as future
work; this is the second piece of that. A `Repair<D>` trait that nudges
infeasible decisions back to feasibility, intended to be called from a
user's Variation operator (or a CompositeVariation pipeline) when
projection-style constraint handling is preferred over the
penalty-style `constraint_violation` approach.
Trait:
pub trait Repair<D> {
fn repair(&mut self, decision: &mut D);
}
Provided impls:
- `ClampToBounds` — clamps each variable of a Vec<f64> to per-axis bounds
- `ProjectToSimplex` — projects a Vec<f64> onto the (clipped) probability
simplex (Σ x_i = total, x_i ≥ 0), useful for portfolio-style problems
and reference-direction normalization
Both stay in the existing `operators` module (alongside Variation
operators) since they share the same "transforms decisions" theme. Re-
exported from the prelude.
This commit is contained in:
+4
-3
@@ -9,7 +9,7 @@ pub use crate::core::{
|
||||
Population, Problem, Rng, rng_from_seed,
|
||||
};
|
||||
|
||||
pub use crate::traits::{Initializer, Optimizer, Variation};
|
||||
pub use crate::traits::{Initializer, Optimizer, Repair, Variation};
|
||||
|
||||
pub use crate::pareto::{
|
||||
Dominance, ParetoArchive, best_candidate, crowding_distance, das_dennis,
|
||||
@@ -17,8 +17,9 @@ pub use crate::pareto::{
|
||||
};
|
||||
|
||||
pub use crate::operators::{
|
||||
BitFlipMutation, BoundedGaussianMutation, CompositeVariation, GaussianMutation,
|
||||
LevyMutation, PolynomialMutation, RealBounds, SimulatedBinaryCrossover, SwapMutation,
|
||||
BitFlipMutation, BoundedGaussianMutation, ClampToBounds, CompositeVariation,
|
||||
GaussianMutation, LevyMutation, PolynomialMutation, ProjectToSimplex, RealBounds,
|
||||
SimulatedBinaryCrossover, SwapMutation,
|
||||
};
|
||||
|
||||
pub use crate::algorithms::{
|
||||
|
||||
Reference in New Issue
Block a user