Signomial terms in objective function
AnsweredHello everybody,
I am using gurobi in the YALMIP optimization framework in Matlab. I have an optimization problem of 28 variables (x is a vector of length 28) that looks like this:
curve = (x ./ (some vector of length 28) ./ (some vector of length 28)) ---> where "./" is element-wise division.
objective_func = sum(curve);
constraints = [sum(x)==TOTAL, x >=0, x <=TOTAL];
Everything is okay for the moment (I hope). However, when I introduce an exponent to the problem so that:
curve = (x ./ (some vector of length 28) ./ (some vector of length 28)).^EXP ---> where ".^" is element-wise exponentiation.
Assuming EXP is known (it is not another variable), I am seeing that when EXP > 2 there is no problem but for 0 <= EXP < 2 I am obtaining the following errror:
Warning: Solver not applicable (gurobi does not support signomial terms in objective)
Does anybody know what is going on here? Thank you very much!
-
Official comment
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?. -
Optimization solvers are often classified by the functional forms they can handle (also the variable types, but that's less relevant here). Some solvers can only solve linear problems, some can do certain nonlinear functions, and some can solve with most or all nonlinear functions. Gurobi, for example, can solve models with linear, bilinear, and quadratic functions.
You are likely getting this error from YALMIP because Gurobi cannot directly solve models with nonlinear functions other than quadratic or bilinear. Therefore, Gurobi can handle EXP values of 0, 1, and 2.
However, you have a few options to solve your problem when EXP is at or above 3:
- Use on of YALMIPs nonlinear solvers. See YALMIP's Solvers >
- Create a piecewise linear approximation for your other functional forms. Luckily, Gurobi can help you create piecewise linear objectives and constraints.
- Depending on your value of EXP, you may be able to create auxiliary variables as described in How do I model multilinear terms in Gurobi? For example, say I wanted to set \(z = x^3\) in my model. Since this constraint has a third-degree polynomial, I cannot solve it directly with Gurobi. Instead, I can create a new auxiliary variable \(y = x^2\). Then, I can set \(z = y\cdot x\). Now, I have two constraints with only linear, quadratic, and bilinear terms — so Gurobi can solve it!
Assuming EXP is known (it is not another variable), I am seeing that when EXP > 2 there is no problem but for 0 <= EXP < 2 I am obtaining the following errror: ...
That said, I want to clarify a point here. Are you saying that you get this YALMIP error when EXP = 0, 1, and 2? Or that there is no problem when EXP = 0, 1, 2?
1 -
Thank you very much for answering! When I try EXP = 0,1,2 there is no problem at all. The thing is that I am interested in EXP = 0.2 actually. So if the solution in this case is creating piecewise linear approximations, should I switch to python? (as I don't see the implementation of these functions in matlab and less in the YALMIP framework). Thank you very much!
0 -
Good news, you can do this directly through the Gurobi Matlab interface. I am less familiar with YALMIP and whether or not this feature is implemented in YALMIP.
For the Gurobi Matlab interface, you can find details about the piecewise-linear objective (model.pwlobj) and constraints (genconpwl) in the the model argument documentation. Additionally, here are links to piecewise-linear examples that may help:
- piecewise - Demonstrates the use of piecewise-linear objective functions. C, C++, C#, Java, MATLAB, Python, R, VB.
- gc_pwl - Demonstrates the use of piecewise-linear constraint. C, C++, C#, Java, MATLAB, Python, R, VB.
- gc_pwl_func - Demonstrates the use of function constraints. C, C++, C#, Java, MATLAB, Python, R, VB.
Also, if you want more details, check out the full Gurobi Matlab interface documentation.
1 -
Alright! All these resources were very helpful, thank you! One last question: For the piecewise function, the set of points can always be between 0-1 (i.e. u = linspace(0.0, 1.0, 101))?. Is this always correct?
0 -
Hi Roger,
No, the intervals of points for the piecewise-linear constraints are arbitrary and don't have to be \(\left[0, 1\right]\).
Cheers,
Matthias1
Post is closed for comments.
Comments
6 comments