pub trait Model {
fn add_var(&mut self, lb: f64, ub: f64, init: f64) -> Var;
fn add_par(&mut self, val: f64) -> Par;
fn add_con<E: Into<Expression>>(&mut self, expr: E, lb: f64, ub: f64) -> Con;
fn set_obj<E: Into<Expression>>(&mut self, expr: E);
fn set_par(&mut self, par: Par, val: f64);
fn set_init(&mut self, var: Var, init: f64);
fn solve(&mut self) -> (SolutionStatus, Option<Solution>);
fn warm_solve(&mut self, sol: Solution) -> (SolutionStatus, Option<Solution>);
}
Expand description
Interface for a mathematical program with continuous variables.
Panics
Expect a panic, either our of bounds or otherwise, if a variable or
parameter is used in this model that was not directly returned by the
add_var
or add_par
methods. Check individual implementations of trait
for details of when these panics could occur.
Required Methods
sourcefn add_var(&mut self, lb: f64, ub: f64, init: f64) -> Var
fn add_var(&mut self, lb: f64, ub: f64, init: f64) -> Var
Add variable to model with lower / upper bounds and initial value.
sourcefn add_con<E: Into<Expression>>(&mut self, expr: E, lb: f64, ub: f64) -> Con
fn add_con<E: Into<Expression>>(&mut self, expr: E, lb: f64, ub: f64) -> Con
Add a constraint to the model with lower and upper bounds.
To have no lower / upper bounds set them to std::f64::NEG_INFINITY
/
std::f64::INFINITY
respectively.
sourcefn set_obj<E: Into<Expression>>(&mut self, expr: E)
fn set_obj<E: Into<Expression>>(&mut self, expr: E)
Set objective of model.
sourcefn solve(&mut self) -> (SolutionStatus, Option<Solution>)
fn solve(&mut self) -> (SolutionStatus, Option<Solution>)
Solve the model.
sourcefn warm_solve(&mut self, sol: Solution) -> (SolutionStatus, Option<Solution>)
fn warm_solve(&mut self, sol: Solution) -> (SolutionStatus, Option<Solution>)
Solve the model using a previous solution as a warm start.