pub struct ConstraintProgram { /* private fields */ }Expand description
A named collection of compiled constraints that can be evaluated together.
All constraints share the same input vector but may have different dimensionality requirements.
Implementations§
Source§impl ConstraintProgram
impl ConstraintProgram
Sourcepub fn add(&mut self, expr: ConstraintExpr, name: &str, num_dims: usize)
pub fn add(&mut self, expr: ConstraintExpr, name: &str, num_dims: usize)
Compile and add a constraint expression to the program.
Sourcepub fn evaluate_all(
&self,
x: &Array1<f32>,
) -> LogicResult<HashMap<String, bool>>
pub fn evaluate_all( &self, x: &Array1<f32>, ) -> LogicResult<HashMap<String, bool>>
Evaluate all constraints and return a map from name → feasibility.
Sourcepub fn violated(&self, x: &Array1<f32>) -> LogicResult<Vec<String>>
pub fn violated(&self, x: &Array1<f32>) -> LogicResult<Vec<String>>
Return the names of all violated (infeasible) constraints.
Sourcepub fn is_feasible(&self, x: &Array1<f32>) -> LogicResult<bool>
pub fn is_feasible(&self, x: &Array1<f32>) -> LogicResult<bool>
Return true iff all constraints are satisfied.
Sourcepub fn num_constraints(&self) -> usize
pub fn num_constraints(&self) -> usize
Return the number of constraints in this program.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ConstraintProgram
impl RefUnwindSafe for ConstraintProgram
impl Send for ConstraintProgram
impl Sync for ConstraintProgram
impl Unpin for ConstraintProgram
impl UnsafeUnpin for ConstraintProgram
impl UnwindSafe for ConstraintProgram
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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