Struct gurobi::Callback
[−]
[src]
pub struct Callback<'a> { // some fields omitted }
The context object for Gurobi callback.
Methods
impl<'a> Callback<'a>
[src]
fn get_where(&self) -> Where
Retrieve the location where the callback called.
fn get_node_rel(&self, vars: &[Var]) -> Result<Vec<f64>>
Retrive node relaxation solution values at the current node.
fn get_solution(&self, vars: &[Var]) -> Result<Vec<f64>>
Retrieve values from the current solution vector.
fn set_solution(&self, vars: &[Var], solution: &[f64]) -> Result<()>
Provide a new feasible solution for a MIP model.
fn get_runtime(&self) -> Result<f64>
Retrieve the elapsed solver runtime [sec].
fn add_cut(&self, lhs: LinExpr, sense: ConstrSense, rhs: f64) -> Result<()>
Add a new cutting plane to the MIP model.
fn add_lazy(&self, lhs: LinExpr, sense: ConstrSense, rhs: f64) -> Result<()>
Add a new lazy constraint to the MIP model.
Methods from Deref<Target=Model<'a>>
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 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>
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)
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) -> Result<Var>
add a decision variable to the model.
fn add_vars(&mut self, names: &[&str], vtypes: &[VarType]) -> 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: AttrBase>(&self, attr: A) -> Result<A::Out>
Query the value of attributes which associated with variable/constraints.
fn set<A: AttrBase>(&mut self, attr: A, value: A::Out) -> Result<()>
Set the value of attributes which associated with variable/constraints.
fn get_values<A: AttrArrayBase, P: Proxy>(&self, attr: A, item: &[P]) -> Result<Vec<A::Out>>
Query the value of attributes which associated with variable/constraints.
fn set_values<A: AttrArrayBase, P: Proxy>(&mut self, attr: A, item: &[P], val: &[A::Out]) -> Result<()>
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 alsoRelaxType
.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
istrue
). - 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_var(&mut self, item: Var) -> Result<()>
Remove a variable from the model.
fn remove_constr(&mut self, item: Constr) -> Result<()>
Remove a linear constraint from the model.
fn remove_qconstr(&mut self, item: QConstr) -> Result<()>
Remove a quadratic constraint from the model.
fn remove_sos(&mut self, item: SOS) -> Result<()>
Remove a special order set (SOS) cnstraint 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.