logistics function
AnsweredI am solving an optimization problem in C++ with
Min L(z);
such that L(y_si<w,x_si>) = log(1+exp(L(z)) .
In this case is it necessary to create new grbvar ywx and ywx and addconstr (model.addQVar( z2== L(z)), and model.addGenConstrExp(z2, z2_exp) for the exp(L(z) part? and similar logic for the log(1+z2_exp) part? or any other way to deal with the log and exp.

Currently, the way you describe is the only way to model that kind of nonconvex function in Gurobi, i.e., you have to model
\[\begin{align*}
w_1 &= L(z)\\
w_2 &= \exp(w_1)\\
w_3 &= 1 + w_2\\
w_4 &= \log(w_3)
\end{align*}\]where \(w_i\) are auxiliary variables and the functions \(\exp, \log\) are implemented via the general constraints feature. Note that it is of high importance to provide tight variable bounds for variable \(w_1\) because it is the argument variable for the \(\exp\) function which already for very small input values achieves huge output. For \(w_3\), it is important to make sure that it is not too close to \(0\) to avoid the very steep part of \(\log\).
Your title states "logistic function". Note that Gurobi has a general constraint describing the logistic function. However, it is different from the one you use but maybe you can still make use of it.
Best regards,
Jaromił0
Please sign in to leave a comment.
Comments
1 comment