Gurobi Manual Pdf

0 views
Skip to first unread message

Umbelina Baublitz

unread,
Aug 4, 2024, 7:50:02 PM8/4/24
to handnemepa
HiJason,The error 10003 corresponds to GRB_ERROR_INVALID_ARGUMENT. You are

probably getting this error because the argument i to getConstr() is

greater than the number of rows (or constraints) in your model. You

need to add the constraints to the model before adding a term to a

column.If you wish to create your model by defining the nonzeros in each

column, rather than defining constraints, you might want to use the C

matrix interface. The C function GRBaddvar() might be what you are

looking for:

-manual/node15Chris




Since the modeler has domain/business knowledge of the problem being solved, is it possible to manually implement Isomorphism Pruning or Orbital branching and beat the default methods implemented by the solvers under the hood. Also, some of the advice, especially here on OR-SE is to not even add symmetry breaking constraints and let the solver exploit/handle it. Thoughts?


There might be automatic settings and tunings inside the solver that are not perfect and might choose not to use orbital branching for an instance although it might be beneficial. In that case the first thing to try would be to change a symmetry setting in a solver to something like "aggressive" (or at least non-default).


Implementing orbital branching for those solvers that provide branching callbacks is not all that hard as long as you have a way to identify the orbits which can be done using open-source graph isomorphism packages (like nauty and saucy). It's not likely to be more efficient than what the solvers are using inside, but it is at least possible. Still I would not expect a huge gain except for solvers that don't have symmetry handling at all (like some open source solvers).


As far as symmetry breaking constraints v. leaving the solver to deal with the symmetry, I think that is an empirical question, meaning you can try both (with reasonably short time limits) and see which is better. The solver may have parameter settings for how (or how aggressively) it deals with symmetry, so you might be trying more than two scenarios before deciding which looks most promising.


For what it is worth, I have in the past had decent luck with symmetry breaking constraints using CPLEX, although in fairness I usually don't bother to test them versus the most aggressive parameter settings.


Hi @odow,

The Gurobi support suggested me that usercuts are only allowed from MIPNODE callback. They also say that the node count is given by GRB_CB_MIPNODE_NODCNT, that should take the value 0 when in the root node.

Therefore I considered the following as a test:


I also noticed on the gurobi manual that GRB_CB_MIPNODE_NODCNT is declared as double in the result type. Therefore, I modified the code as follows but without any improvement (the result is still 0 even if I am not in the root node):


The Gurobi suite of optimization products include state-of-the-art simplex and parallel barrier solvers for linear programming (LP) and quadratic programming (QP), parallel barrier solver for quadratically constrained programming (QCP), as well as parallel mixed-integer linear programming (MILP), mixed-integer quadratic programming (MIQP), mixed-integer quadratically constrained programming (MIQCP) and (mixed-integer) nonlinear programming (NLP) solvers.


The Gurobi MIP solver includes shared memory parallelism, capable of simultaneously exploiting any number of processors and cores per processor. The implementation is deterministic: two separate runs on the same model will produce identical solution paths.


While numerous solving options are available, Gurobi automatically calculates and sets most options at the best values for specific problems. All Gurobi options available through GAMS/Gurobi are summarized at the end of this chapter.


Gurobi can solve LP and convex QP problems using several alternative algorithms, while the only choice for solving convex QCP is the parallel barrier algorithm. The majority of LP problems solve best using Gurobi's state-of-the-art dual simplex algorithm, while most convex QP problems solve best using the parallel barrier algorithm. Certain types of LP problems benefit from using the parallel barrier or the primal simplex algorithms, while for some types of QP, the dual or primal simplex algorithm can be a better choice. If you are solving LP problems on a multi-core system, you should also consider using the concurrent optimizer. It runs different optimization algorithms on different cores, and returns when the first one finishes.


GAMS/Gurobi also provides access to the Gurobi infeasibility finder. The infeasibility finder takes an infeasible linear program and produces an irreducibly inconsistent set of constraints (IIS). An IIS is a set of constraints and variable bounds which is infeasible but becomes feasible if any one member of the set is dropped. GAMS/Gurobi reports the IIS in terms of GAMS equation and variable names and includes the IIS report as part of the normal solution listing. The infeasibility finder is activated by the option IIS. Another option for analyzing infeasible model the FeasOpt option which instructs GAMS/Gurobi to find a minimal feasible relaxation of an infeasible model. See section Feasible Relaxation for details.


GAMS/Gurobi supports sensitivity analysis (post-optimality analysis) for linear programs which allows one to find out more about an optimal solution for a problem. In particular, objective ranging and constraint ranging give information about how much an objective coefficient or a right-hand-side and variable bounds can change without changing the optimal basis. In other words, they give information about how sensitive the optimal basis is to a change in the objective function or the bounds and right-hand side. GAMS/Gurobi reports the sensitivity information as part of the normal solution listing. Sensitivity analysis is activated by the option Sensitivity.


The Gurobi presolve can sometimes diagnose a problem as being infeasible or unbounded. When this happens, GAMS/Gurobi can, in order to get better diagnostic information, rerun the problem with presolve turned off. The rerun without presolve is controlled by the option ReRun. In default mode only problems that are small (i.e. demo sized) will be rerun.


Gurobi can either presolve a model or start from an advanced basis or primal/dual solution pair. Often the solve from scratch of a presolved model outperforms a solve from an unpresolved model started from an advanced basis/solution. It is impossible to determine a priori if presolve or starting from a given advanced basis/solution without presolve will be faster. By default, GAMS/Gurobi will automatically use an advanced basis or solution from a previous solve statement. The GAMS BRatio option can be used to specify when not to use an advanced basis/solution. The GAMS/Gurobi option UseBasis can be used to ignore or force a basis/solution passed on by GAMS (it overrides BRatio). In case of multiple solves in a row and slow performance of the second and subsequent solves, the user is advised to set the GAMS BRatio option to 1.


The methods used to solve pure integer and mixed integer programming problems require dramatically more mathematical computation than those for similarly sized pure linear or quadratic programs. Many relatively small integer programming models take enormous amounts of time to solve.


For problems with discrete variables, Gurobi uses a branch and cut algorithm which solves a series of subproblems, LP subproblems for MILP, QP subproblems for MIQP, and QCP subproblems or LP outer approximation subproblems for MIQCP. Because a single mixed integer problem generates many subproblems, even small mixed integer problems can be very compute intensive and require significant amounts of physical memory. With option nonConvex Gurobi can also solve nonconvex (MI)QP and (MI)QCP problems using a spatial branch-and-bound method.


If you specify some or all values for the discrete variables together with GAMS/Gurobi option MipStart, Gurobi will check the validity of the values as an integer-feasible solution. If this process succeeds, the solution will be treated as an integer solution of the current problem.


Gurobi can solve (mixed-integer) nonlinear programs to global optimality either directly or by approximating the model by piecewise-linear functions and/or reformulating nonlinear constraints into supported linear and/or quadratic constraints (see also funcnonlinear.)


For Gurobi to accept a nonlinear constraint, it has to be in one of the forms listed below. Furthermore, GAMS/Gurobi can automatically reformulate a nonlinear constraint into the supported form by enabling nlreform.


The Infeasibility Finder identifies the causes of infeasibility by means of inconsistent set of constraints (IIS). However, you may want to go beyond diagnosis to perform automatic correction of your model and then proceed with delivering a solution. One approach for doing so is to build your model with explicit slack variables and other modeling constructs, so that an infeasible outcome is never a possibility. An automated approach offered in GAMS/Gurobi is known as FeasOpt (for Feasible Optimization) and turned on by parameter FeasOpt in a GAMS/Gurobi option file.


With the FeasOpt option GAMS/Gurobi accepts an infeasible model and selectively relaxes the bounds and constraints in a way that minimizes a weighted penalty function. In essence, the feasible relaxation tries to suggest the least change that would achieve feasibility. It returns an infeasible solution to GAMS and marks the relaxations of bounds and constraints with the INFES marker in the solution section of the listing file.


By default all equations are candidates for relaxation and weighted equally but none of the variables can be relaxed. This default behavior can be modified by assigning relaxation preferences to variable bounds and constraints. These preferences can be conveniently specified with the .feaspref option. The input value denotes the users willingness to relax a constraint or bound. The larger the preference, the more likely it will be that a given bound or constraint will be relaxed. More precisely, the reciprocal of the specified value is used to weight the relaxation of that constraint or bound. The user may specify a preference value less than or equal to 0 (zero), which denotes that the corresponding constraint or bound must not be relaxed. It is not necessary to specify a unique preference for each bound or range. In fact, it is conventional to use only the values 0 (zero) and 1 (one) except when your knowledge of the problem suggests assigning explicit preferences.

3a8082e126
Reply all
Reply to author
Forward
0 new messages