pub struct ConstrainedMadsState<V, F = f64> { /* private fields */ }Expand description
Solver state for the constrained MADS variant
(Mads<Constrained>), which handles nonlinear inequality constraints
c(x) ≤ 0 by the progressive barrier (see
Mads::constrained).
It carries the same poll/mesh bookkeeping as MadsState plus the
aggregate constraint violation h(x) = Σⱼ max(cⱼ(x), 0)² at the reported
incumbent (constraint_violation; 0 ⇔
feasible). Construct it with new from the starting point — an
infeasible start is allowed (the progressive barrier relaxes its way to
feasibility).
§Current vs best
Unlike the unconstrained MadsState, the reported objective is not
monotone — a newly found feasible point can have a higher f than a prior
infeasible incumbent. The solver’s progressive-barrier driver owns the
incumbent selection, so update_best mirrors the
current iterate unconditionally (the same rule
CobylaState uses), rather than ranking by cost.
The scalar F defaults to f64 so call sites resolve unchanged.
Implementations§
Source§impl<V, F: Scalar> ConstrainedMadsState<V, F>
impl<V, F: Scalar> ConstrainedMadsState<V, F>
Sourcepub fn new(x0: V) -> Self
pub fn new(x0: V) -> Self
Build an initial constrained-MADS state at the starting point x0 (which
may be infeasible). The solver evaluates x0’s cost and violation and
fills the poll size in Solver::init.
Sourcepub fn constraint_violation(&self) -> F
pub fn constraint_violation(&self) -> F
The aggregate constraint violation h = Σⱼ max(cⱼ, 0)² at the reported
incumbent. 0 once the incumbent is feasible; +∞ before
Solver::init.
Sourcepub fn mesh_index(&self) -> i32
pub fn mesh_index(&self) -> i32
The current mesh index ℓ (OrthoMADS eq. (1)).
Trait Implementations§
Source§impl<V, F> CountsMirror for ConstrainedMadsState<V, F>where
ConstrainedMadsState<V, F>: State,
impl<V, F> CountsMirror for ConstrainedMadsState<V, F>where
ConstrainedMadsState<V, F>: State,
Source§fn mirror(&mut self, delta: &EvalCounts)
fn mirror(&mut self, delta: &EvalCounts)
Solver::init /
Solver::next_iter.Source§impl<P, V, F> Solver<P, ConstrainedMadsState<V, F>> for Mads<Constrained, F>where
F: Scalar,
P: CostFunction<Param = V, Output = F> + NonlinearInequalityConstraints,
V: Clone + VectorLen + Index<usize, Output = F> + IndexMut<usize, Output = F>,
impl<P, V, F> Solver<P, ConstrainedMadsState<V, F>> for Mads<Constrained, F>where
F: Scalar,
P: CostFunction<Param = V, Output = F> + NonlinearInequalityConstraints,
V: Clone + VectorLen + Index<usize, Output = F> + IndexMut<usize, Output = F>,
Source§type Error = <P as CostFunction>::Error
type Error = <P as CostFunction>::Error
type Error. See the trait docs.Source§fn init(
&mut self,
problem: &mut Problem<P>,
state: ConstrainedMadsState<V, F>,
) -> Result<ConstrainedMadsState<V, F>, Self::Error>
fn init( &mut self, problem: &mut Problem<P>, state: ConstrainedMadsState<V, F>, ) -> Result<ConstrainedMadsState<V, F>, Self::Error>
Source§fn next_iter(
&mut self,
problem: &mut Problem<P>,
state: ConstrainedMadsState<V, F>,
) -> Result<(ConstrainedMadsState<V, F>, Option<TerminationReason>), Self::Error>
fn next_iter( &mut self, problem: &mut Problem<P>, state: ConstrainedMadsState<V, F>, ) -> Result<(ConstrainedMadsState<V, F>, Option<TerminationReason>), Self::Error>
Source§impl<V: Clone, F: Scalar> State for ConstrainedMadsState<V, F>
impl<V: Clone, F: Scalar> State for ConstrainedMadsState<V, F>
Source§fn cost(&self) -> F
fn cost(&self) -> F
Cost at the current param.
§Panics
Panics if read before
Solver::init has evaluated the
starting point.
Source§fn update_best(&mut self)
fn update_best(&mut self)
Mirror the current incumbent unconditionally — the progressive-barrier
driver owns incumbent selection, and the reported cost is not monotone
across the feasibility transition, so a cost-ranked best would be wrong.
Source§type Param = V
type Param = V
Vec<f64>,
nalgebra::DVector<f64>).Source§type Float = F
type Float = F
f64 (see
the module docs).Source§fn iter(&self) -> u64
fn iter(&self) -> u64
Solver::next_iter
that bails mid-iteration with Some(reason) does not increment
this counter — see the
executor module for the exact ordering.Source§fn increment_iter(&mut self)
fn increment_iter(&mut self)
iter by one. Called by the executor
after a successful Solver::next_iter.Source§fn cost_evals(&self) -> u64
fn cost_evals(&self) -> u64
iter() whenever a single iteration evaluates the
cost more than once (line searches, Nelder-Mead shrinks, etc.) —
this is what users actually budget against. Read moreSource§fn param(&self) -> &V
fn param(&self) -> &V
Solver::next_iter
calls; safe to read at any iteration including iter 0.Source§fn best_param(&self) -> &V
fn best_param(&self) -> &V
Source§fn best_cost(&self) -> F
fn best_cost(&self) -> F
best_param — the lowest cost ever
observed on this state.Source§fn best_iter(&self) -> u64
fn best_iter(&self) -> u64
0 before the
first update_best call; thereafter, the
value of iter at the moment of the last strict
improvement in best_cost().Source§fn best_cost_evals(&self) -> u64
fn best_cost_evals(&self) -> u64
Source§fn reset_best(&mut self)
fn reset_best(&mut self)
best_cost = +∞, all best counters zero). Read moreAuto Trait Implementations§
impl<V, F> Freeze for ConstrainedMadsState<V, F>
impl<V, F> RefUnwindSafe for ConstrainedMadsState<V, F>where
V: RefUnwindSafe,
F: RefUnwindSafe,
impl<V, F> Send for ConstrainedMadsState<V, F>
impl<V, F> Sync for ConstrainedMadsState<V, F>
impl<V, F> Unpin for ConstrainedMadsState<V, F>
impl<V, F> UnsafeUnpin for ConstrainedMadsState<V, F>where
V: UnsafeUnpin,
F: UnsafeUnpin,
impl<V, F> UnwindSafe for ConstrainedMadsState<V, F>where
V: UnwindSafe,
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.