How to to define multivariate polynomials
AnsweredHi,
Is it possible to define multivariate polynomials in Gurobi?
I have y1=a1 l1+a2 l2 +a3 l3, y2= a1 l4 + a2 l5 + a3 l6, y3= a1 l7 + a2 l8 + a3 l9
where y1, y2, y3, a1, a2, a3 are binary variables. I have three linear polynomials f1,f2 and f3 over
y1, y2 and y3. I have to assign l1,...,l9=0/1 with l1+l2+l3=l4+l5+l6=l7+l8+l9=1 such that the
cardinality of the set {f1,f2,f3} is 2. Ofcourse this is toy example. If we can define multivariate
polynomials, we can try like this
D1 : i1 = 1 -> f1-f2=0, D2: i2 = 1 -> f1-f3=0, D3: i3=1 -> f2-f3=0
D4: i1+i2+i3=2
-
Hi,
I am not sure if I understand fully understand your issue.
It is currently not possible to directly define multivariate polynomials in Gurobi but it is certainly possible to model them.
For example, let's consider the multivariate polynomial \( p:\mathbb{R}^2 \to \mathbb{R}, (x,y) \mapsto x^2\cdot y + x \cdot y + x \cdot y^2 \). You can formulate a constraint such as \(p(x,y) = 0\) by the addition of auxiliary variables and the use of quadratic expressions as
\(\begin{align}
\omega_1 \cdot y + &x \cdot y + x \cdot \omega_2 = 0 \\
\omega_1 &= x^2 \\
\omega_2 &= y^2 \\
x \in &[x^L, x^U] \\
y \in &[y^L,y^U] \\
\omega_1 \in &\begin{cases} [0, \max{(x^L)^2,(x^U)^2}], &\text{if } x^L < 0 < x^U \\ [(x^L)^2, (x^U)^2], &\text{if } x^L\geq 0 \\ [(x^U)^2, (x^L)^2], &\text{if } x^U\leq 0 \end{cases} \\
\omega_2 \in &\begin{cases} [0, \max{(y^L)^2,(y^U)^2}], &\text{if } y^L < 0 < y^U \\ [(y^L)^2, (y^U)^2], &\text{if } y^L\geq 0 \\ [(y^U)^2, (y^L)^2], &\text{if } y^U\leq 0 \end{cases}
\end{align}\)Note that I added finite bounds for \(x\) and \(y\) as this is recommended when working with nonlinear expressions.
I hope the above could answer your questions. Feel free to ask further questions if not.
Best regards,
Jaromił0
Please sign in to leave a comment.
Comments
1 comment