[][src]Struct gurobi::Model

pub struct Model { /* fields omitted */ }

Gurobi model object associated with certain environment.

Methods

impl Model[src]

pub fn new(modelname: &str, env: &Env) -> Result<Model>[src]

Create an empty Gurobi model from the environment.

Note that all of the parameters in given environment will copy by Gurobi API and a new environment associated with the model will create. If you want to query/modify the value of parameters, use get_env().

Arguments

  • modelname : Name of the model
  • env : An environment object.

Example

use gurobi::*;

let mut env = gurobi::Env::new("").unwrap();
env.set(param::OutputFlag, 0).unwrap();
env.set(param::Heuristics, 0.5).unwrap();
// ...

let model = Model::new("model1", &env).unwrap();

pub fn read_from(filename: &str, env: &Env) -> Result<Model>[src]

Read a model from a file

pub fn copy(&self) -> Result<Model>[src]

create a copy of the model

pub fn fixed(&self) -> Result<Model>[src]

Create an fixed model associated with the model.

In fixed model, each integer variable is fixed to the value that it takes in the original MIP solution. Note that the model must be MIP and have a solution loaded.

pub fn relax(&self) -> Result<Model>[src]

Create an relaxation of the model (undocumented).

pub fn presolve(&self) -> Result<Model>[src]

Perform presolve on the model.

pub fn feasibility(&self) -> Result<Model>[src]

Create a feasibility model (undocumented).

pub fn get_env(&self) -> &Env[src]

Get immutable reference of an environment object associated with the model.

pub fn get_env_mut(&mut self) -> &mut Env[src]

Get mutable reference of an environment object associated with the model.

pub fn update(&mut self) -> Result<()>[src]

Apply all modification of the model to process

pub fn optimize(&mut self) -> Result<()>[src]

Optimize the model synchronously

pub fn optimize_async(&mut self) -> Result<()>[src]

Optimize the model asynchronously

pub fn optimize_with_callback<F>(&mut self, callback: F) -> Result<()> where
    F: FnMut(Callback) -> Result<()> + 'static, 
[src]

Optimize the model with a callback function

pub fn sync(&self) -> Result<()>[src]

Wait for a optimization called asynchronously.

pub fn compute_iis(&mut self) -> Result<()>[src]

Compute an Irreducible Inconsistent Subsystem (IIS) of the model.

pub fn terminate(&self)[src]

Send a request to the model to terminate the current optimization process.

pub fn reset(&self) -> Result<()>[src]

Reset the model to an unsolved state.

All solution information previously computed are discarded.

pub fn tune(&self) -> Result<()>[src]

Perform an automated search for parameter settings that improve performance on the model. See also references on official manual.

pub fn get_tune_result(&self, n: i32) -> Result<()>[src]

Prepare to retrieve the results of tune(). See also references on official manual.

pub fn get_concurrent_env(&self, num: i32) -> Result<Env>[src]

Deprecated

Create/retrieve a concurrent environment for the model

Note that the number of concurrent environments (num) must be contiguously numbered.

Example

This example is not tested
let env1 = model.get_concurrent_env(0).unwrap();
let env2 = model.get_concurrent_env(1).unwrap();
let env3 = model.get_concurrent_env(2).unwrap();
...

pub fn discard_concurrent_envs(&self)[src]

Deprecated

Discard all concurrent environments for the model.

pub fn message(&self, message: &str)[src]

Insert a message into log file.

When message cannot convert to raw C string, a panic is occurred.

pub fn read(&mut self, filename: &str) -> Result<()>[src]

Import optimization data of the model from a file.

pub fn write(&self, filename: &str) -> Result<()>[src]

Export optimization data of the model to a file.

pub fn add_var(
    &mut self,
    name: &str,
    vtype: VarType,
    obj: f64,
    lb: f64,
    ub: f64,
    colconstrs: &[Constr],
    colvals: &[f64]
) -> Result<Var>
[src]

add a decision variable to the model.

pub fn add_vars(
    &mut self,
    names: &[&str],
    vtypes: &[VarType],
    objs: &[f64],
    lbs: &[f64],
    ubs: &[f64],
    colconstrs: &[&[Constr]],
    colvals: &[&[f64]]
) -> Result<Vec<Var>>
[src]

add decision variables to the model.

pub fn add_constr(
    &mut self,
    name: &str,
    expr: LinExpr,
    sense: ConstrSense,
    rhs: f64
) -> Result<Constr>
[src]

add a linear constraint to the model.

pub fn add_constrs(
    &mut self,
    name: &[&str],
    expr: &[LinExpr],
    sense: &[ConstrSense],
    rhs: &[f64]
) -> Result<Vec<Constr>>
[src]

add linear constraints to the model.

pub fn add_range(
    &mut self,
    name: &str,
    expr: LinExpr,
    lb: f64,
    ub: f64
) -> Result<(Var, Constr)>
[src]

Add a range constraint to the model.

This operation adds a decision variable with lower/upper bound, and a linear equality constraint which states that the value of variable must equal to expr.

Returns

  • An decision variable associated with the model. It has lower/upper bound constraints.
  • An linear equality constraint associated with the model.

pub fn add_ranges(
    &mut self,
    names: &[&str],
    expr: &[LinExpr],
    lb: &[f64],
    ub: &[f64]
) -> Result<(Vec<Var>, Vec<Constr>)>
[src]

Add range constraints to the model.

pub fn add_qconstr(
    &mut self,
    constrname: &str,
    expr: QuadExpr,
    sense: ConstrSense,
    rhs: f64
) -> Result<QConstr>
[src]

add a quadratic constraint to the model.

pub fn add_sos(
    &mut self,
    vars: &[Var],
    weights: &[f64],
    sostype: SOSType
) -> Result<SOS>
[src]

add Special Order Set (SOS) constraint to the model.

pub fn set_objective<Expr: Into<QuadExpr>>(
    &mut self,
    expr: Expr,
    sense: ModelSense
) -> Result<()>
[src]

Set the objective function of the model.

pub fn get<A: Attr>(&self, attr: A) -> Result<A::Out>[src]

Query the value of attributes which associated with variable/constraints.

pub fn set<A: Attr>(&mut self, attr: A, value: A::Out) -> Result<()>[src]

Set the value of attributes which associated with variable/constraints.

pub fn get_values<A: AttrArray, P>(
    &self,
    attr: A,
    item: &[P]
) -> Result<Vec<A::Out>> where
    P: Deref<Target = Proxy>, 
[src]

Query the value of attributes which associated with variable/constraints.

pub fn set_values<A: AttrArray, P>(
    &mut self,
    attr: A,
    item: &[P],
    val: &[A::Out]
) -> Result<()> where
    P: Deref<Target = Proxy>, 
[src]

Set the value of attributes which associated with variable/constraints.

pub fn feas_relax(
    &mut self,
    relaxtype: RelaxType,
    minrelax: bool,
    vars: &[Var],
    lbpen: &[f64],
    ubpen: &[f64],
    constrs: &[Constr],
    rhspen: &[f64]
) -> Result<(f64, Iter<Var>, Iter<Constr>, Iter<QConstr>)>
[src]

Modify the model to create a feasibility relaxation.

$$ \text{minimize}\quad f(x) + \sum_{i \in IIS} penalty_i(s_i) $$ where $s_i > 0$ is the slack variable of $i$ -th constraint.

This method will modify the model. If you don't want to modify the model, copy the model before invoking this method (see also copy()).

Arguments

  • relaxtype : The type of cost function used when finding the minimum cost relaxation. See also RelaxType.
  • minrelax : The type of feasibility relaxation to perform.
  • vars : Variables whose bounds are allowed to be violated.
  • lbpen / ubpen : Penalty for violating a variable lower/upper bound. INFINITY means that the bounds doesn't allow to be violated.
  • constrs : Linear constraints that are allowed to be violated.
  • rhspen : Penalty for violating a linear constraint. INFINITY means that the bounds doesn't allow to be violated.

Returns

  • The objective value for the relaxation performed (if minrelax is true).
  • Slack variables for relaxation and linear/quadratic constraints related to theirs.

pub fn set_pwl_obj(&mut self, var: &Var, x: &[f64], y: &[f64]) -> Result<()>[src]

Set a piecewise-linear objective function for the variable.

The piecewise-linear objective function $f(x)$ is defined as follows: \begin{align} f(x) = \begin{cases} y_1 + \dfrac{y_2 - y_1}{x_2 - x_1} \, (x - x_1) & \text{if $x \leq x_1$}, \\ \\ y_i + \dfrac{y_{i+1} - y_i}{x_{i+1}-x_i} \, (x - x_i) & \text{if $x_i \leq x \leq x_{i+1}$}, \\ \\ y_n + \dfrac{y_n - y_{n-1}}{x_n-x_{n-1}} \, (x - x_n) & \text{if $x \geq x_n$}, \end{cases} \end{align} where $\bm{x} = \{ x_1, ..., x_n \}$, $\bm{y} = \{ y_1, ..., y_n \}$ is the points.

The attribute Obj will be set to 0. To delete the piecewise-linear function on the variable, set the value of Obj attribute to non-zero.

Arguments

  • var :
  • x : $n$-points from domain of the variable. The order of entries should be non-decreasing.
  • y : $n$-points of objective values at each point $x_i$

pub fn status(&self) -> Result<Status>[src]

Retrieve the status of the model.

pub fn get_vars(&self) -> Iter<Var>[src]

Retrieve an iterator of the variables in the model.

pub fn get_constrs(&self) -> Iter<Constr>[src]

Retrieve an iterator of the linear constraints in the model.

pub fn get_qconstrs(&self) -> Iter<QConstr>[src]

Retrieve an iterator of the quadratic constraints in the model.

pub fn get_sos(&self) -> Iter<SOS>[src]

Retrieve an iterator of the special order set (SOS) constraints in the model.

pub fn remove<P: DerefMut<Target = Proxy>>(&mut self, item: P)[src]

Remove a variable from the model.

pub fn get_coeff(&self, var: &Var, constr: &Constr) -> Result<f64>[src]

Retrieve a single constant matrix coefficient of the model.

pub fn set_coeff(
    &mut self,
    var: &Var,
    constr: &Constr,
    value: f64
) -> Result<()>
[src]

Change a single constant matrix coefficient of the model.

pub fn set_coeffs(
    &mut self,
    vars: &[&Var],
    constrs: &[&Constr],
    values: &[f64]
) -> Result<()>
[src]

Change a set of constant matrix coefficients of the model.

Trait Implementations

impl Drop for Model[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.