pub struct ConstraintHandler { /* private fields */ }Expand description
Constraint handler for automatic penalty generation
Implementations§
Source§impl ConstraintHandler
impl ConstraintHandler
Sourcepub fn add_constraint(&mut self, constraint: Constraint)
pub fn add_constraint(&mut self, constraint: Constraint)
Add constraint
Sourcepub fn add_equality(
&mut self,
name: String,
expression: Expression,
target: f64,
) -> Result<(), Box<dyn Error>>
pub fn add_equality( &mut self, name: String, expression: Expression, target: f64, ) -> Result<(), Box<dyn Error>>
Add equality constraint
Sourcepub fn add_inequality(
&mut self,
name: String,
expression: Expression,
bound: f64,
less_than: bool,
) -> Result<(), Box<dyn Error>>
pub fn add_inequality( &mut self, name: String, expression: Expression, bound: f64, less_than: bool, ) -> Result<(), Box<dyn Error>>
Add inequality constraint
Sourcepub fn add_one_hot(
&mut self,
name: String,
variables: Vec<String>,
) -> Result<(), Box<dyn Error>>
pub fn add_one_hot( &mut self, name: String, variables: Vec<String>, ) -> Result<(), Box<dyn Error>>
Add one-hot constraint
Sourcepub fn add_cardinality(
&mut self,
name: String,
variables: Vec<String>,
k: usize,
) -> Result<(), Box<dyn Error>>
pub fn add_cardinality( &mut self, name: String, variables: Vec<String>, k: usize, ) -> Result<(), Box<dyn Error>>
Add cardinality constraint
Sourcepub fn add_integer_encoding(
&mut self,
name: String,
base_name: String,
min: i32,
max: i32,
encoding_type: EncodingType,
) -> Result<Vec<String>, Box<dyn Error>>
pub fn add_integer_encoding( &mut self, name: String, base_name: String, min: i32, max: i32, encoding_type: EncodingType, ) -> Result<Vec<String>, Box<dyn Error>>
Add integer encoding constraint
Sourcepub fn generate_penalty_terms(
&self,
penalty_weights: &HashMap<String, f64>,
) -> Result<Expression, Box<dyn Error>>
pub fn generate_penalty_terms( &self, penalty_weights: &HashMap<String, f64>, ) -> Result<Expression, Box<dyn Error>>
Generate penalty terms for all constraints
Sourcepub fn get_all_variables(&self) -> Vec<String>
pub fn get_all_variables(&self) -> Vec<String>
Get all variables including slack
Sourcepub fn decode_integer(
&self,
variable_name: &str,
assignment: &HashMap<String, bool>,
) -> Option<i32>
pub fn decode_integer( &self, variable_name: &str, assignment: &HashMap<String, bool>, ) -> Option<i32>
Decode integer value from bit assignment
Sourcepub fn analyze_constraints(&self) -> ConstraintAnalysis
pub fn analyze_constraints(&self) -> ConstraintAnalysis
Analyze constraint structure
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ConstraintHandler
impl RefUnwindSafe for ConstraintHandler
impl Send for ConstraintHandler
impl Sync for ConstraintHandler
impl Unpin for ConstraintHandler
impl UnwindSafe for ConstraintHandler
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> 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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
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>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
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
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.