Expand description
Data structure for representing an at least constraint on form
$$ c * v_0 + c * v_1 + … + c * v_n + bias \ge 0 $$
where $c \in [-1,1]$ depending on positive or negative bias.
ids vector property holds what variables are connected to this constraint.
Fields
ids: Vec<u32>bias: i64Implementations
sourceimpl AtLeast
impl AtLeast
sourcepub fn to_lineq(&self, variable_hm: &HashMap<u32, Variable>) -> GeLineq
pub fn to_lineq(&self, variable_hm: &HashMap<u32, Variable>) -> GeLineq
Transform into a linear inequality constraint.
variable_hm is a hash map of id’s and variables.
Example:
use puanrs::AtLeast;
use puanrs::GeLineq;
use puanrs::Variable;
use std::{collections::HashMap};
let at_least: AtLeast = AtLeast {
ids : vec![0,1,2],
bias : -1,
};
let mut variable_hm: HashMap<u32, Variable> = HashMap::default();
variable_hm.insert(0, Variable {id: 0, bounds: (0,1)});
variable_hm.insert(1, Variable {id: 1, bounds: (0,1)});
variable_hm.insert(2, Variable {id: 2, bounds: (0,1)});
let actual: GeLineq = at_least.to_lineq(&variable_hm);
assert_eq!(actual.coeffs, vec![1,1,1]);
assert_eq!(actual.bias, -1);
assert_eq!(actual.bounds, vec![(0,1),(0,1),(0,1)]);
assert_eq!(actual.indices, vec![0,1,2]);Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for AtLeast
impl Send for AtLeast
impl Sync for AtLeast
impl Unpin for AtLeast
impl UnwindSafe for AtLeast
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more