Skip to main content

Model

Struct Model 

Source
pub struct Model { /* private fields */ }

Implementations§

Source§

impl Model

Source

pub fn new() -> Self

Creates a new, empty model with default settings.

Source

pub fn with_config(self, config: SolverConfig) -> Self

Source

pub fn set_max_iterations(&mut self, max_iterations: u32)

Sets the maximum number of iterations for the solver.

Default is 10,000.

Source

pub fn set_tolerance(&mut self, tolerance: f64)

Sets the numerical tolerance (epsilon) for the solver.

Default is 1e-10. Values smaller than this are treated as zero.

Source

pub fn add_variable(&mut self) -> VariableBuilder<'_>

Source

pub fn add_constraint( &mut self, lhs: impl Into<LinearExpr<VariableKey>>, ) -> ConstraintBuilder<'_>

Source

pub fn set_objective( &mut self, sense: ObjectiveSense, expression: impl Into<LinearExpr<VariableKey>>, )

Source

pub fn format<'a, T>(&'a self, item: T) -> ModelDisplay<'a, T>

Returns a helper object that implements Display, allowing you to print keys (Variables/Constraints) using their actual Names from the Model.

Source

pub fn solve(&mut self) -> Result<SolverSolution<VariableKey>, SolverError>

Source

pub fn variables(&self) -> &DenseSlotMap<VariableKey, Variable>

Source

pub fn constraints(&self) -> &DenseSlotMap<ConstraintKey, Constraint>

Source

pub fn objective(&self) -> Option<&Objective>

Source

pub fn config(&self) -> &SolverConfig

Trait Implementations§

Source§

impl Debug for Model

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Model

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Model

§

impl RefUnwindSafe for Model

§

impl Send for Model

§

impl Sync for Model

§

impl Unpin for Model

§

impl UnsafeUnpin for Model

§

impl UnwindSafe for Model

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.