Mutual Information as PWL Constraint
AnsweredI am trying to write a mutual information constraint in gurobi which I would guess is something of general interest. Broadly, I am curious on the best way to combine PWL constraints. The constraint I want is for the non-negative variables \(X(i,j)\):
\[\begin{align*}
\sum_i \sum_j X(i,j) ln (X(i,j) \ \sum_k X(i,k) ) < c
\end{align*}\]
Where ln is the natural log and c is a constant. One way to do this would be to create auxiliary variables \(W(i), Y(i,j), Z(i,j)\) and then set the following constraints using the built in log and bilinear constraint functions:
\[\begin{align*}
W(i) &= ln (\sum_k X(i,k))\\
Y(i,j) &= ln (X(i,j))\\
Z(i,j) &= X(i,j) * (Y(i,j) - W(i))\\
\sum_i \sum_j Z(i,j) &< c
\end{align*}\]
But is this the best approach? Is there a standard way to deal with multiple layers of non-linearity?
-
But is this the best approach? Is there a standard way to deal with multiple layers of non-linearity?
Currently yes, introducing (possibly many) auxiliary variables and equations is the best and only approach to deal with nonlinear composite functions in Gurobi.
Best regards,
Jaromił1 -
Thank You!
1 -
I am having trouble writing constraints of the form:
ln(x+y)=z
where x,y and z are all variables. Why is this? Is there a solution or should I just add an auxiliary variable equal to x+y? The error I get is:
<gurobi.Var *Awaiting Model Update*> + <gurobi.Var *Awaiting Model Update*> is not a variable
1 -
General function constraints only accept a single variable as argument input. Expressions are currently not allowed. Thus, you have to introduce an additional auxiliary variable \(w = x+y\). This API may be extended in a future release.
0
Please sign in to leave a comment.
Comments
4 comments