Struct highs::Model

source ·
pub struct Model { /* private fields */ }
Expand description

A model to solve

Implementations§

source§

impl Model

source

pub fn set_sense(&mut self, sense: Sense)

Set the optimization sense (minimize by default)

source

pub fn new<P: Into<Problem<ColMatrix>>>(problem: P) -> Self

Create a Highs model to be optimized (but don’t solve it yet). If the given problem is a RowProblem, it will have to be converted to a ColProblem first, which takes an amount of time proportional to the size of the problem. Panics if the problem is incoherent

source

pub fn try_new<P: Into<Problem<ColMatrix>>>( problem: P ) -> Result<Self, HighsStatus>

Create a Highs model to be optimized (but don’t solve it yet). If the given problem is a RowProblem, it will have to be converted to a ColProblem first, which takes an amount of time proportional to the size of the problem. Returns an error if the problem is incoherent

source

pub fn make_quiet(&mut self)

Prevents writing anything to the standard output or to files when solving the model

source

pub fn set_option<STR: Into<Vec<u8>>, V: HighsOptionValue>( &mut self, option: STR, value: V )

Set a custom parameter on the model. For the list of available options and their documentation, see: https://www.maths.ed.ac.uk/hall/HiGHS/HighsOptions.html

let mut model = ColProblem::default().optimise(Maximise);
model.set_option("presolve", "off"); // disable the presolver
model.set_option("solver", "ipm"); // use the ipm solver
model.set_option("time_limit", 30.0); // stop after 30 seconds
model.set_option("parallel", "on"); // use multiple cores
model.set_option("threads", 4); // solve on 4 threads
source

pub fn solve(self) -> SolvedModel

Find the optimal value for the problem, panic if the problem is incoherent

source

pub fn try_solve(self) -> Result<SolvedModel, HighsStatus>

Find the optimal value for the problem, return an error if the problem is incoherent

source

pub fn add_row( &mut self, bounds: impl RangeBounds<f64>, row_factors: impl IntoIterator<Item = (Col, f64)> ) -> Row

Adds a new constraint to the highs model.

Returns the added row index.

Panics

If HIGHS returns an error status value.

source

pub fn try_add_row( &mut self, bounds: impl RangeBounds<f64>, row_factors: impl IntoIterator<Item = (Col, f64)> ) -> Result<Row, HighsStatus>

Tries to add a new constraint to the highs model.

Returns the added row index, or the error status value if HIGHS returned an error status.

source

pub fn add_col( &mut self, col_factor: f64, bounds: impl RangeBounds<f64>, row_factors: impl IntoIterator<Item = (Row, f64)> ) -> Col

Adds a new variable to the highs model.

Returns the added column index.

Panics

If HIGHS returns an error status value.

source

pub fn try_add_column( &mut self, col_factor: f64, bounds: impl RangeBounds<f64>, row_factors: impl IntoIterator<Item = (Row, f64)> ) -> Result<Col, HighsStatus>

Tries to add a new variable to the highs model.

Returns the added column index, or the error status value if HIGHS returned an error status.

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 From<SolvedModel> for Model

source§

fn from(solved: SolvedModel) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

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, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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.