Skip to main content

LPSolver

Struct LPSolver 

Source
pub struct LPSolver { /* private fields */ }
Expand description

Unified LP/MIP solver

Implementations§

Source§

impl LPSolver

Source

pub fn new() -> Self

Create a new LP/MIP solver

Source

pub fn with_config(config: LPConfig) -> Self

Create with custom configuration

Source

pub fn set_direction(&mut self, dir: OptDir)

Set optimization direction

Source

pub fn add_variable(&mut self, var: Variable) -> VarId

Add a variable

Source

pub fn new_continuous(&mut self) -> VarId

Create and add a continuous variable

Source

pub fn new_integer(&mut self) -> VarId

Create and add an integer variable

Source

pub fn new_binary(&mut self) -> VarId

Create and add a binary variable

Source

pub fn add_constraint(&mut self, constraint: Constraint) -> ConstraintId

Add a constraint

Source

pub fn new_constraint( &mut self, coeffs: impl IntoIterator<Item = (VarId, BigRational)>, sense: ConstraintSense, rhs: BigRational, ) -> ConstraintId

Create and add a constraint

Source

pub fn set_objective(&mut self, var: VarId, coeff: BigRational)

Set objective coefficient

Source

pub fn solve(&mut self) -> LPResult

Solve the LP/MIP

Source

pub fn stats(&self) -> &LPStats

Get statistics

Source

pub fn get_variable(&self, id: VarId) -> Option<&Variable>

Get a variable

Source

pub fn num_variables(&self) -> usize

Get number of variables

Source

pub fn num_constraints(&self) -> usize

Get number of constraints

Source

pub fn reset(&mut self)

Clear all variables and constraints

Trait Implementations§

Source§

impl Default for LPSolver

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.