style: apply rustfmt drift across the crate

This commit is contained in:
2026-05-05 11:40:14 -06:00
parent 84cee3f29e
commit 4a59041d1a
60 changed files with 1520 additions and 608 deletions
+4 -1
View File
@@ -18,7 +18,10 @@ pub struct Candidate<D> {
impl<D> Candidate<D> {
/// Pair a decision with its evaluation.
pub fn new(decision: D, evaluation: Evaluation) -> Self {
Self { decision, evaluation }
Self {
decision,
evaluation,
}
}
}
+8 -2
View File
@@ -18,12 +18,18 @@ pub struct Evaluation {
impl Evaluation {
/// Build a feasible evaluation from objective values.
pub fn new(objectives: Vec<f64>) -> Self {
Self { objectives, constraint_violation: 0.0 }
Self {
objectives,
constraint_violation: 0.0,
}
}
/// Build an evaluation with a known total constraint violation.
pub fn constrained(objectives: Vec<f64>, constraint_violation: f64) -> Self {
Self { objectives, constraint_violation }
Self {
objectives,
constraint_violation,
}
}
/// Returns `true` when `constraint_violation <= 0.0`.
+9 -6
View File
@@ -26,12 +26,18 @@ pub struct Objective {
impl Objective {
/// Create a minimize objective with the given name.
pub fn minimize(name: impl Into<String>) -> Self {
Self { name: name.into(), direction: Direction::Minimize }
Self {
name: name.into(),
direction: Direction::Minimize,
}
}
/// Create a maximize objective with the given name.
pub fn maximize(name: impl Into<String>) -> Self {
Self { name: name.into(), direction: Direction::Maximize }
Self {
name: name.into(),
direction: Direction::Maximize,
}
}
}
@@ -125,10 +131,7 @@ mod tests {
assert!(!single.is_empty());
assert_eq!(single.len(), 1);
let multi = ObjectiveSpace::new(vec![
Objective::minimize("f1"),
Objective::minimize("f2"),
]);
let multi = ObjectiveSpace::new(vec![Objective::minimize("f1"), Objective::minimize("f2")]);
assert!(multi.is_multi_objective());
assert!(!multi.is_single_objective());
+7 -1
View File
@@ -31,7 +31,13 @@ impl<D> OptimizationResult<D> {
evaluations: usize,
generations: usize,
) -> Self {
Self { population, pareto_front, best, evaluations, generations }
Self {
population,
pareto_front,
best,
evaluations,
generations,
}
}
/// The final population.