Struct puanrs::AtLeast

source ·
pub struct AtLeast {
    pub ids: Vec<u32>,
    pub bias: i64,
}
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: i64

Implementations

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

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.