How to solve Nonlinear objective optimization?

157 views
Skip to first unread message

TowangEE

unread,
Mar 26, 2018, 9:50:29 PM3/26/18
to YALMIP
Dear Johan:
       Hi, I have come across a problem when optimizing a nonlinear objective with a nonlinear constraint.
       Code's attached.
       someone told me that I should try bonmin solver through opti toolbox.
       But I still failed to solve this  after  "ops=sdpsettings('solver','bonmin');", and opti toolbox had been installed in MATLAB. How to use that?
       I really don't know how to solve such kind problem, and this kind is so important to me cause I need to deal with this nonlinear thing in my next paper.
      
       PS: I also tried bmibnb, and related nonlinear variable is limited within a certain range, but it just didn't work.I don't know why?
       It's a unit commitment problem but a little bit more complex than the example in https://yalmip.github.io/example/unitcommitment/.
       a lot of thanks!
Best wishes.
biogas.m

TowangEE

unread,
Mar 27, 2018, 2:42:56 AM3/27/18
to YALMIP
sorry I uploaded the wrong version of code.
Here's the new one.
biogas.m

Johan Löfberg

unread,
Mar 27, 2018, 4:19:36 AM3/27/18
to YALMIP
Code doesn't make sense as objective is a vector

>> Objective
Linear matrix variable 24x1 (full, real, binary, 192 variables)
>> 


Johan Löfberg

unread,
Mar 27, 2018, 4:23:20 AM3/27/18
to YALMIP
pretty sure the problem is infeasible also (when bmibnb detects infeasibility of the constraints already in the pre-processing, it's almost certainly trivially infeasible)

TowangEE

unread,
Mar 27, 2018, 4:27:21 AM3/27/18
to YALMIP
Do you mean the model is not suitable?
I now make the objective a variable instead of a vector, but still not works,
Should I rebuilt this model, and it's not about solver?

Johan Löfberg

unread,
Mar 27, 2018, 4:32:24 AM3/27/18
to YALMIP
A vector objective just doesn't make sense. What does it mean to minimize the [cost length horsepower] of a car...

That is unrelated to the fact that the model is infeasible though. optimize(Constraints,[],sdpsettings('solver','bmibnb')) and bmibnb immeditely tells you that there is no solution to the problem. You've either made a mistake in the code, or you have simply formulated a problem instance which is infeasible

TowangEE

unread,
Mar 27, 2018, 4:40:48 AM3/27/18
to YALMIP

But I still wonder why bonmin or bmibnb couldn't solver problem below, it's a simple math problem I made up to test. It can only be solved by cplex.



clc;

clear;

%%Define Variables

x1=sdpvar(10,1); 

x2=sdpvar(10,1);   

Objective=sum(x1.^2+x1.*x2+x2.^2);

Constraints=[];

Constraints=[Constraints,-10<=x1<=5];  

Constraints=[Constraints,1<=x2<=8];

ops=sdpsettings('solver','bmibnb');

optimize(Constraints,Objective,ops);

Johan Löfberg

unread,
Mar 27, 2018, 4:48:32 AM3/27/18
to YALMIP
bmibnb solves that problem in the root node (as it is a trivial convex QP)

* Starting YALMIP global branch & bound.
* Branch-variables : 0
* Upper solver     : GUROBI
* Lower solver     : GUROBI
* LP solver        : GUROBI
 Node       Upper      Gap(%)       Lower    Open
    1 :    7.500E+00     0.00      7.500E+00   0  Improved solution  
* Finished.  Cost: 7.5 Gap: 0
* Termination with all nodes pruned 
* Timing: 1% spent in upper solver (1 problems solved)
*         1% spent in lower solver (1 problems solved)
*         26% spent in LP-based domain reduction (40 problems solved)
>> 


Johan Löfberg

unread,
Mar 27, 2018, 4:50:26 AM3/27/18
to YALMIP
bonmin appears to crash, probably because it is too trivial with no integer variables (opti toolbox 2.22)

TowangEE

unread,
Mar 27, 2018, 4:57:25 AM3/27/18
to YALMIP
I thought bonmin was installed in a wrong way by me.
First, I downloaded a opti toolbox and add it to the catalog of MATLAB for mac 2017b.
Then, I found the bonmin file in opti toolbox-solvers and copied it to  Yalmip-solvers file.
Is this the whole procedures I need to do if I wanna use bonmin?

Johan Löfberg

unread,
Mar 27, 2018, 5:18:58 AM3/27/18
to YALMIP
I don't understand what (or why) you have copied to yalmip. You never install anything in the yalmip directory. opti installation and yalmip installation are two different things.

Before you try to use opti solvers via yalmip, you have to make sure you've actually installed them on your machine correctly, by running their examples

TowangEE

unread,
Mar 27, 2018, 6:09:06 AM3/27/18
to YALMIP
What I meant is that if I install opti toolbox successfully, could I use bonmin directly by typing "ops=sdpsettings('solver','bonmin');"?

Johan Löfberg

unread,
Mar 27, 2018, 6:24:46 AM3/27/18
to YALMIP
That is the way to select a solver yes
https://yalmip.github.io/tutorial/basics/


But if you experience problems with a particular solver, you always check first that the solver actually works, without getting yalmip involved.

TowangEE

unread,
Mar 28, 2018, 4:52:08 AM3/28/18
to YALMIP
I'm here to say thank you Johan. The reason for the infeasibility lies in the wrong data I used. The code is fine, and the solver is great. 
Also, I took the advice you made last month in another question I put up in this forum, and it perfectly solved the problem I met.
You're so kind sharing your advice. Thank you.
Reply all
Reply to author
Forward
0 new messages