Gurobi is a powerful commercial suite of optimization products, which includes simplex and parallel barrier solvers to handle linear programming (LP) and quadratic progermming (QP), also quadratically constrained (QCP) and the mixed-integer variations thereof (MIP, MIQP, MIQCP). It also supports some types of general constraints. The framework used by the drivers supports automatic reformulation for many expression types; the relative guide can be found here.
[Read More] [Options] [Changes] [Download]
Our enhanced Gurobi driver (previously know as x-gurobi) is now the default Gurobi driver. The new driver provides significantly extended modeling support for logical and nonlinear operators natively through Gurobi’s built-in “general constraints” and through linearizations performed by the MP library. There are two binaries in this package:
gurobi [options] is the new version,
gurobiasl [options] is the legacy version. If you are upgrading an existing installation and encounter any issues with the new version please report them to firstname.lastname@example.org.
How to use it¶
ampl: option solver gurobi; # change the solver ampl: option gurobi_options 'option1=value1 option2=value2'; # specify options ampl: solve; # solve the problem
At a glance¶
LP, QP, QCP
MIP, MIQP, MIQCP
log / exp
min / max
and / or
Features for all models:
Dealing with infeasibility/unboundedness
Features for MIP models:
Full list of solver options:
Many solver parameters can be changed directly from AMPL, by specifying them as a space separated string in the option
A list of all supported options is available here or can be obtained by executing the solver driver with the
-= command line parameter:
or from AMPL:
shell "gurobi -=";
Solver options can have multiple aliases, to accomodate for different user types.
The main numenclature is given first in the -= output, then followed by aliases in brackets,
see for example the listing for
lim:iter (iterlim, iterlimit) Iteration limit (default: no limit).
The main numenclature contains a prefix (
lim: in this case) to help categorize and find the
options relevant to a context. To list only the options with a specific prefix (
lim: for this example),
Specifying solver options and solving a model¶
After formulating the model in AMPL, execute the following to select gurobi as solver and pass the two options:
option solver gurobi; option gurobi_options "retmipgap=3 outlev=1"; solve;
The outcome of the last optimization is stored in the AMPL parameter
solve_result_num and the relative message in
display solve_result_num, solve_result;
When a model is unfeasible, one usedful information is finding the irreducible inconsistent sets, which are subsets of constraints that are incompatible. This is supported by the framework, see the description here.
Another approach to tackle infeasibilities is to use feasibility relaxation to find a solution which only penalizes infeasibilities. This is supported via the framework, see the description here.
Gurobi compute server and Gurobi cloud¶
Gurobi supports solving your model on other machines in two alternative ways:
Compute server - where a computer (or a cluster) can be configured to the specific task of solving models via gurobi
Gurobi cloud - where the compute server is by Gurobi itself
To use a compute server, the option
tech:server must be set, together with appropriate values for the
For gurobi instant cloud, the options
tech:cloudkey must be set, and optionally the other options
tech:cloud*, for example:
# Solve with compute server option gurobi_options "tech:server=192.168.1.55"; solve; # Solve with gurobi instant cloud option gurobi_options "tech:cloudid=mygurobiid tech:cloudkey=myprivatekey"; solve;