1 comment

• Gurobi Staff

Hi Irene,

Modeling such nonlinear terms in Gurobi is possible. However, it requires the addition of many auxiliary variables and equality constraints. For example, you can model the term

$\frac{k\cdot\mu}{(k\cdot\mu - \lambda)^2}$

in Gurobi as

\begin{align} z_1 &= k\cdot\mu - \lambda\\ z_2 &= z_1^2\\ z_2 \cdot k \cdot \mu &= 1 \end{align}

For more details on how to model divions in Gurobi, please refer to the Knowledge Base article How do I divide by a variable in Gurobi?

Please note that arbitrary powers have to be modeled by either using the addGenConstrPow method which requires the introduction of an additional auxiliary variable or introducing a chain of auxiliary variables and equality constraint as discussed in How do I model multilinear terms in Gurobi?
The addGenConstrPow method models an equality constraint $$z = x^k$$ and takes only singleton optimization variables as input, i.e., to model $$\left(\frac{\lambda}{\mu}\right)^3$$, you would have to introduce 2 auxiliary variables and then model this term as

\begin{align} \mu\cdot z_1 &= \lambda\\ z_2 &= z_1^3 \, \leftarrow\text{ defined by the addGenConstrPot method} \end{align}

Please note that whenever you perform such reformulations, you have to make sure to provide finite valid bounds for all newly introduced auxiliary variables.

Introducing so many auxiliary variables and equality constraints in order to model (very) nonlinear terms often ends up with troublesome numerics and ultimately the optimal solution point having large constraint violations. Thus, I would recommend to at least having a quick look at other solvers designed for the solution of (very) nonlinear terms which do not require the introduction of many auxiliary variables and equality constraints to model such nonlinearities.

Best regards,
Jaromił