Nonlinear constraint and objective
AnsweredHello all,
I am trying to model a modified locationallocation problem where each facility acts as a M/M/s queuing system (similar to J Wang et al. 2020). The objective is to minimize the waiting time spent at each facility, and because of that, the problem becomes very nonlinear.
where W is the expected waiting time, k (number of servers) and mu (service rate) are constants depending on j and s, while lambda (arrival rate) is part of the optimization and defined through many more constraints.
I'm having trouble defining W and P as constraints. Is this kind of problem something that Gurobi can solve? I've read that I can use Model.addGenConstrPow() for more general powers, but I'm not sure how I would implement it. If this is possible, how do I go about doing it? Else, are there suggestions of other methods I can use to solve the problem?
Any help is appreciated, thank you!

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ł0
Please sign in to leave a comment.
Comments
1 comment