Model Definition
AnsweredHello, I am blocked on how to model the following function.

-
Hi Francisco,
Gurobi currently does not support the function \(x^y\) where both \(x\) and \(y\) are optimization variables. Thus, if \(z\) in your formulation is an optimization variable, then you cannot formulate \(f\) in Gurobi.
Since you defined \(f(x)\) and not \(f(x,y,z\) I will assume that both \(y\) and \(z\) are constants. If \(z\) is an integer constant you can formulate your model as a quadratic one via additional auxiliary variables as described in How do I model multilinear terms in Gurobi? For example, if \(z=3\), you could formulate your model as
\[\begin{align*}
w_1 &= x -y\\
w_2 &= w_1 \cdot w_1\\
w_3 &= w_2 \cdot w_1\\
w_4 &= x \cdot w_3
\end{align*}\]If \(z\) is not integer, you could use the addGenConstrPow method. For example, if \(z=1.3\), you could formulate your model as
\[\begin{align*}
w_1 &= x - y\\
w_2 &= w_1^{1.3} \quad (*)\\
w_3 &= x \cdot w_2
\end{align*}\]The \((*)\) constraint is implemented via
model.addGenConstrPow(w_1, w_2, 1.3)
Best regards,
Jaromił0
Please sign in to leave a comment.
Comments
1 comment