Struct Model

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

Representation of a linear program.

Implementations§

Source§

impl Model

Source

pub fn new(name: &str, objective: Objective) -> Self

Creates a new Model. A representation of a linear program.

Source

pub fn update(&mut self) -> &mut Self

Submits the registered variables or constraints to the Model and changes it’s phase to the next. This method can be called implicitly by calling reg_constr or optimize.

The Model’s lifetime follows three strictly seperated phases:

  • In the first phase, variables can be registered.
  • In the second phase, constraints can be registered.
  • In the third phase, the Model can be optimized.

After the variables or constraints are submitted to the Model, they can not be changed again (The phases can not be reverted or modified).

Source

pub fn reg_var(&mut self, objective_value: f64) -> Var

Registers a variable for the Model.

§Panics

This method panics if the variables were already submitted. See update.

Source

pub fn reg_var_with_name(&mut self, objective_value: f64, name: &str) -> Var

Registers a variable, with a given name, for the Model.

§Panics

This method panics if the variables were already submitted. See update.

Source

pub fn x(&self, req: &Var) -> Result<f64, &'static str>

Returns the optimal value for a given, registered variable.

§Errors

This method will return an Error if the Model has not been optimized. See optimize.

§Panics

This method panics if the variable is not registered for the calling Model.

Source

pub fn reg_constr( &mut self, sum: Vec<Summand<'_>>, op: Operator, b: f64, ) -> &mut Self

Registers a constraint.

§Panics

This method panics if the constraints were already submitted. See update.

Or if one of the variables in sum is not registered for the calling Model.

Source

pub fn optimize(&mut self) -> &mut Self

Optimizes the Model.

§Panics

This method panics if the model is infeasable or might be degenerate.

Source

pub fn optimum(&self) -> Result<f64, &'static str>

Returns the optimal value.

§Errors

This method will return an Error if the calling Model has not been optimized. See optimize.

Trait Implementations§

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 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.