Skip to main content

ConstrainedProblem

Trait ConstrainedProblem 

Source
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§

Source

fn dim(&self) -> usize

Number of decision variables.

Source

fn bounds(&self) -> &[Bound]

Per-variable inclusive bounds, length ConstrainedProblem::dim.

Source

fn objective(&self, x: &[f64]) -> f64

Objective value to minimize (non-finite ⇒ infeasible, as usual).

Source

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§

Source

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".

Implementors§

Source§

impl<F, G> ConstrainedProblem for ConstrainedFunc<F, G>
where F: Fn(&[f64]) -> f64, G: Fn(&[f64]) -> Vec<f64>,