pub struct EqualityConstraint { /* private fields */ }Expand description
Represents a linear equality constraint in standard form: ax = b where a is a vector of coefficients and b is a constant.
Implementations§
Source§impl EqualityConstraint
impl EqualityConstraint
Sourcepub fn new(coefficients: Vec<f64>, rhs: f64) -> EqualityConstraint
pub fn new(coefficients: Vec<f64>, rhs: f64) -> EqualityConstraint
Creates a new equality constraint, normalizing it so the right-hand side is non-negative.
§Arguments
coefficients- Vector of coefficients for the constraintrhs- Right-hand side constant value
§Example
use rooc::EqualityConstraint;
let constraint = EqualityConstraint::new(vec![2.0, -1.0, 3.0], -4.0);
// Normalizes to: -2x + y - 3z = 4Sourcepub fn coefficients(&self) -> &Vec<f64>
pub fn coefficients(&self) -> &Vec<f64>
Returns a reference to the coefficient vector.
Sourcepub fn coefficients_mut(&mut self) -> &mut Vec<f64>
pub fn coefficients_mut(&mut self) -> &mut Vec<f64>
Returns a mutable reference to the coefficient vector.
Sourcepub fn remove_coefficients_by_index(&mut self, indexes: &[usize])
pub fn remove_coefficients_by_index(&mut self, indexes: &[usize])
Removes coefficients at the specified indices from the constraint.
§Arguments
indexes- Slice of indices to remove
Sourcepub fn coefficient(&self, index: usize) -> f64
pub fn coefficient(&self, index: usize) -> f64
Returns the coefficient at the specified index.
§Arguments
index- Index of the coefficient to retrieve
Sourcepub fn ensure_size(&mut self, size: usize)
pub fn ensure_size(&mut self, size: usize)
Ensures the coefficient vector has the specified size by padding with zeros if necessary.
§Arguments
size- Required size of the coefficient vector
Trait Implementations§
Source§impl Clone for EqualityConstraint
impl Clone for EqualityConstraint
Source§fn clone(&self) -> EqualityConstraint
fn clone(&self) -> EqualityConstraint
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for EqualityConstraint
impl RefUnwindSafe for EqualityConstraint
impl Send for EqualityConstraint
impl Sync for EqualityConstraint
impl Unpin for EqualityConstraint
impl UnsafeUnpin for EqualityConstraint
impl UnwindSafe for EqualityConstraint
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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