pub struct Model { /* private fields */ }
Expand description
A model to solve
Implementations§
source§impl Model
impl Model
sourcepub fn new<P: Into<Problem<ColMatrix>>>(problem: P) -> Self
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
sourcepub fn try_new<P: Into<Problem<ColMatrix>>>(
problem: P
) -> Result<Self, HighsStatus>
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
sourcepub fn make_quiet(&mut self)
pub fn make_quiet(&mut self)
Prevents writing anything to the standard output or to files when solving the model
sourcepub fn set_option<STR: Into<Vec<u8>>, V: HighsOptionValue>(
&mut self,
option: STR,
value: V
)
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
sourcepub fn solve(self) -> SolvedModel
pub fn solve(self) -> SolvedModel
Find the optimal value for the problem, panic if the problem is incoherent
sourcepub fn try_solve(self) -> Result<SolvedModel, HighsStatus>
pub fn try_solve(self) -> Result<SolvedModel, HighsStatus>
Find the optimal value for the problem, return an error if the problem is incoherent
sourcepub fn add_row(
&mut self,
bounds: impl RangeBounds<f64>,
row_factors: impl IntoIterator<Item = (Col, f64)>
) -> Row
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.
sourcepub fn try_add_row(
&mut self,
bounds: impl RangeBounds<f64>,
row_factors: impl IntoIterator<Item = (Col, f64)>
) -> Result<Row, HighsStatus>
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.
sourcepub fn add_col(
&mut self,
col_factor: f64,
bounds: impl RangeBounds<f64>,
row_factors: impl IntoIterator<Item = (Row, f64)>
) -> Col
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.
sourcepub fn try_add_column(
&mut self,
col_factor: f64,
bounds: impl RangeBounds<f64>,
row_factors: impl IntoIterator<Item = (Row, f64)>
) -> Result<Col, HighsStatus>
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.