Struct gurobi::Model [] [src]

pub struct Model {
    // some fields omitted
}

Gurobi model object associated with certain environment.

Methods

impl Model
[src]

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

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();

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

Read a model from a file

fn copy(&self) -> Result<Model>

create a copy of the model

fn fixed(&self) -> Result<Model>

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.

fn relax(&self) -> Result<Model>

Create an relaxation of the model (undocumented).

fn presolve(&self) -> Result<Model>

Perform presolve on the model.

fn feasibility(&self) -> Result<Model>

Create a feasibility model (undocumented).

fn get_env(&self) -> &Env

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

fn get_env_mut(&mut self) -> &mut Env

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

fn update(&mut self) -> Result<()>

Apply all modification of the model to process

fn optimize(&mut self) -> Result<()>

Optimize the model synchronously

fn optimize_async(&mut self) -> Result<()>

Optimize the model asynchronously

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

Optimize the model with a callback function

fn sync(&self) -> Result<()>

Wait for a optimization called asynchronously.

fn compute_iis(&mut self) -> Result<()>

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

fn terminate(&self)

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

fn reset(&self) -> Result<()>

Reset the model to an unsolved state.

All solution information previously computed are discarded.

fn tune(&self) -> Result<()>

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

fn get_tune_result(&self, n: i32) -> Result<()>

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

fn get_concurrent_env(&self, num: i32) -> Result<Env>

Deprecated

Create/retrieve a concurrent environment for the model

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

Example

let env1 = model.get_concurrent_env(0).unwrap();
let env2 = model.get_concurrent_env(1).unwrap();
let env3 = model.get_concurrent_env(2).unwrap();
...

fn discard_concurrent_envs(&self)

Deprecated

Discard all concurrent environments for the model.

fn message(&self, message: &str)

Insert a message into log file.

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

fn read(&mut self, filename: &str) -> Result<()>

Import optimization data of the model from a file.

fn write(&self, filename: &str) -> Result<()>

Export optimization data of the model to a file.

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

add a decision variable to the model.

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

add decision variables to the model.

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

add a linear constraint to the model.

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

add linear constraints to the model.

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

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.

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

Add range constraints to the model.

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

add a quadratic constraint to the model.

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

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

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

Set the objective function of the model.

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

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

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

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

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

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

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

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

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

Modify the model to create a feasibility relaxation.

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.

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

Set a piecewise-linear objective function of a certain variable in the model.

fn status(&self) -> Result<Status>

Retrieve the status of the model.

fn get_vars(&self) -> Iter<Var>

Retrieve an iterator of the variables in the model.

fn get_constrs(&self) -> Iter<Constr>

Retrieve an iterator of the linear constraints in the model.

fn get_qconstrs(&self) -> Iter<QConstr>

Retrieve an iterator of the quadratic constraints in the model.

fn get_sos(&self) -> Iter<SOS>

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

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

Remove a variable from the model.

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

Retrieve a single constant matrix coefficient of the model.

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

Change a single constant matrix coefficient of the model.

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

Change a set of constant matrix coefficients of the model.

Trait Implementations

impl Drop for Model
[src]

fn drop(&mut self)

A method called when the value goes out of scope. Read more