pub struct Constraint<S: Stage<Self> = Created> {
pub equality: Equality,
pub stage: S::Data,
}Expand description
A constraint parameterized by its lifecycle stage.
Holds only the constraint’s intrinsic data (equality plus stage-specific
data in stage). Modeling labels and transformation provenance live on the
enclosing collection’s ConstraintContextStore keyed by id; per-element
storage was retired in the v3 context redesign.
The constraint’s ConstraintID is not stored in this struct — it is
held by the enclosing collection (e.g. the BTreeMap key in
Instance), which is the single source of truth. Standalone
constraints are identity-less until inserted into a collection.
Fields§
§equality: Equality§stage: S::DataImplementations§
Source§impl Constraint<Created>
impl Constraint<Created>
Sourcepub fn reduce_binary_power(
&mut self,
binary_ids: &VariableIDSet,
) -> Result<bool, CoefficientError>
pub fn reduce_binary_power( &mut self, binary_ids: &VariableIDSet, ) -> Result<bool, CoefficientError>
Reduce binary powers in the constraint function.
For binary variables, x^n = x for any n >= 1, so we can reduce higher powers to linear terms.
Returns true if any reduction was performed, false otherwise.
Source§impl Constraint<Created>
impl Constraint<Created>
Sourcepub fn function_mut(&mut self) -> &mut Function
pub fn function_mut(&mut self) -> &mut Function
Mutable access to the constraint function.
pub fn equal_to_zero(function: Function) -> Self
pub fn less_than_or_equal_to_zero(function: Function) -> Self
Source§impl Constraint<Evaluated>
impl Constraint<Evaluated>
Sourcepub fn is_feasible_with_tolerance(&self, atol: ATol) -> bool
pub fn is_feasible_with_tolerance(&self, atol: ATol) -> bool
Check if this constraint is feasible given a specific tolerance
Source§impl Constraint<Sampled>
impl Constraint<Sampled>
Sourcepub fn is_feasible(&self, sample_id: SampleID, atol: ATol) -> Option<bool>
pub fn is_feasible(&self, sample_id: SampleID, atol: ATol) -> Option<bool>
Check feasibility for a specific sample.
Returns None if sample_id is not present in the sampled data.
Sourcepub fn feasible_ids(&self, atol: ATol) -> FnvHashSet<SampleID>
pub fn feasible_ids(&self, atol: ATol) -> FnvHashSet<SampleID>
Get all sample IDs that are feasible
Sourcepub fn infeasible_ids(&self, atol: ATol) -> FnvHashSet<SampleID>
pub fn infeasible_ids(&self, atol: ATol) -> FnvHashSet<SampleID>
Get all sample IDs that are infeasible
Trait Implementations§
Source§impl AbsDiffEq for Constraint<Created>
impl AbsDiffEq for Constraint<Created>
Source§fn default_epsilon() -> Self::Epsilon
fn default_epsilon() -> Self::Epsilon
Source§fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
Source§fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
AbsDiffEq::abs_diff_eq.Source§impl Arbitrary for Constraint<Created>
impl Arbitrary for Constraint<Created>
Source§type Parameters = PolynomialParameters
type Parameters = PolynomialParameters
arbitrary_with accepts for configuration
of the generated Strategy. Parameters must implement Default.Source§type Strategy = BoxedStrategy<Constraint>
type Strategy = BoxedStrategy<Constraint>
Strategy used to generate values of type Self.Source§fn arbitrary_with(params: Self::Parameters) -> Self::Strategy
fn arbitrary_with(params: Self::Parameters) -> Self::Strategy
Source§impl<S: Clone + Stage<Self>> Clone for Constraint<S>
impl<S: Clone + Stage<Self>> Clone for Constraint<S>
Source§fn clone(&self) -> Constraint<S>
fn clone(&self) -> Constraint<S>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl ConstraintType for Constraint
Constraint (= Constraint<Created>) serves as the type family for regular constraints.
impl ConstraintType for Constraint
Constraint (= Constraint<Created>) serves as the type family for regular constraints.
Source§type ID = ConstraintID
type ID = ConstraintID
Source§type Created = Constraint
type Created = Constraint
Source§type Evaluated = Constraint<Evaluated>
type Evaluated = Constraint<Evaluated>
Source§type Sampled = Constraint<Sampled>
type Sampled = Constraint<Sampled>
Source§impl Display for Constraint<Created>
impl Display for Constraint<Created>
Source§impl Evaluate for Constraint<Created>
impl Evaluate for Constraint<Created>
type Output = Constraint<Evaluated>
type SampledOutput = Constraint<Sampled>
Source§fn evaluate(&self, solution: &State, atol: ATol) -> Result<Self::Output>
fn evaluate(&self, solution: &State, atol: ATol) -> Result<Self::Output>
Source§fn evaluate_samples(
&self,
samples: &Sampled<State>,
atol: ATol,
) -> Result<Self::SampledOutput>
fn evaluate_samples( &self, samples: &Sampled<State>, atol: ATol, ) -> Result<Self::SampledOutput>
Source§fn partial_evaluate(&mut self, state: &State, atol: ATol) -> Result<()>
fn partial_evaluate(&mut self, state: &State, atol: ATol) -> Result<()>
Source§fn required_ids(&self) -> VariableIDSet
fn required_ids(&self) -> VariableIDSet
Source§impl From<Constraint<Evaluated>> for EvaluatedRegularConstraint
impl From<Constraint<Evaluated>> for EvaluatedRegularConstraint
Source§fn from(constraint: EvaluatedConstraint) -> Self
fn from(constraint: EvaluatedConstraint) -> Self
Source§impl From<Constraint<Sampled>> for SampledRegularConstraint
impl From<Constraint<Sampled>> for SampledRegularConstraint
Source§fn from(constraint: SampledConstraint) -> Self
fn from(constraint: SampledConstraint) -> Self
Source§impl From<Constraint> for RegularConstraint
impl From<Constraint> for RegularConstraint
Source§fn from(constraint: Constraint<Created>) -> Self
fn from(constraint: Constraint<Created>) -> Self
Source§impl Stage<Constraint<Evaluated>> for Evaluated
impl Stage<Constraint<Evaluated>> for Evaluated
type Data = EvaluatedData
Source§impl Stage<Constraint<Sampled>> for Sampled
impl Stage<Constraint<Sampled>> for Sampled
type Data = SampledData
Source§impl Stage<Constraint> for Created
impl Stage<Constraint> for Created
type Data = CreatedData
impl<S: PartialEq + Stage<Self>> StructuralPartialEq for Constraint<S>
Auto Trait Implementations§
impl<S> Freeze for Constraint<S>
impl<S> RefUnwindSafe for Constraint<S>
impl<S> Send for Constraint<S>
impl<S> Sync for Constraint<S>
impl<S> Unpin for Constraint<S>
impl<S> UnsafeUnpin for Constraint<S>
impl<S> UnwindSafe for Constraint<S>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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 more