pub trait ConstrainedProblem {
// Required methods
fn dim(&self) -> usize;
fn bounds(&self) -> &[Bound] ⓘ;
fn objective(&self, x: &[f64]) -> f64;
fn violations(&self, x: &[f64]) -> Vec<f64>;
// Provided method
fn total_violation(&self, x: &[f64]) -> f64 { ... }
}Expand description
A box-constrained problem with additional nonlinear constraints.
Report constraints through violations:
one entry per constraint, 0.0 when satisfied and the (positive)
magnitude of the breach otherwise. For an inequality g(x) ≤ 0 return
g(x).max(0.0); for an equality h(x) = 0 with tolerance δ return
(h(x).abs() − δ).max(0.0).
Required Methods§
Sourcefn bounds(&self) -> &[Bound] ⓘ
fn bounds(&self) -> &[Bound] ⓘ
Per-variable inclusive bounds, length ConstrainedProblem::dim.
Sourcefn objective(&self, x: &[f64]) -> f64
fn objective(&self, x: &[f64]) -> f64
Objective value to minimize (non-finite ⇒ infeasible, as usual).
Sourcefn violations(&self, x: &[f64]) -> Vec<f64>
fn violations(&self, x: &[f64]) -> Vec<f64>
Constraint violations: 0.0 per satisfied constraint, positive
magnitudes otherwise. Negative entries are clamped to 0.0.
Provided Methods§
Sourcefn total_violation(&self, x: &[f64]) -> f64
fn total_violation(&self, x: &[f64]) -> f64
Total violation Σ max(vᵢ, 0) — the quantity Deb’s rules compare.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".