change MaxFunEvals for YALMIP

528 views
Skip to first unread message

Jincheng Zhang

unread,
Jun 22, 2014, 10:41:27 PM6/22/14
to yal...@googlegroups.com
I use YALMIP to solve a optimization problem, and the following says

"fmincon stopped because it exceeded the function evaluation limit,
options.MaxFunEvals = 3000 (the default value)"

How can I change the value of MaxFunEvals? BTW, I use the BNB solver.

options = sdpsettings('verbose', '2', 'solver','bnb');
solution = solvesdp(constraints, obj, options);


Thanks,
Jincheng


Johan Löfberg

unread,
Jun 23, 2014, 1:56:53 AM6/23/14
to yal...@googlegroups.com
options = sdpsettings('fmincon.maxfunevals',3001,'verbose', '2', 'solver','bnb');

However, this indicates fmincon is struggling with this model, and I don't think more evaluations will help. I would try to reformulate the model to see if there are other formulations better suited for fmincon, or try another solver.

What does your model look like?

Jincheng Zhang

unread,
Jun 23, 2014, 3:04:26 AM6/23/14
to yal...@googlegroups.com
Hi Johan,

Thanks for your prompt reply.

My model is a little complicated. Please see the attachment.
A is a binary decision variable, X is a decision variable that has non-negative real values.

CR is a range of Xstr. The last constraint also involves the product of multiple decision variables.

Is there any solver that can solve this problem? 

Thanks, Johan.

Regards,
Jincheng
model.jpg

Johan Löfberg

unread,
Jun 23, 2014, 3:12:47 AM6/23/14
to yal...@googlegroups.com
Solving this with bnb is a bad idea. The problem is still nonconvex when you relax the integrality constraint (since you have bilinear products). bnb is for problems with convex relaxations.

I would go for a MILP approach. Everything is MILP-representable (nonconvex max, and bilinear product between continuous variable and binary variable)

x*a where x is binary and a is continuous can be handled by replacing the product by a new variable z and adding
[m*(1-x) <= z-a <= (1-x)*M, 0<=z<=M*x

where m and M are suitable chosen big-M constants
http://users.isy.liu.se/johanl/yalmip/pmwiki.php?n=Tutorials.Big-MAndConvexHulls

This conversion from bilinear to MILP is can be done in YALMIP using binmodel. The nonconvex max operations are taken care of automatically, and will lead to more binaries being introduced.

For all operations above, you have to add explicit upper and lower bounds on A.

Jincheng Zhang

unread,
Jun 23, 2014, 3:16:03 AM6/23/14
to yal...@googlegroups.com
Thanks a lot, Johan.

I will take a look at it.

Regards,
Jincheng

Johan Löfberg

unread,
Jun 23, 2014, 3:30:00 AM6/23/14
to yal...@googlegroups.com
since A is non-negative and bounded by 1 from above, as far as I can see, the model is trivial

Z = sdpvar(n1,n2,n3,'full');

[0 <= A <= 1, A >= X, -(1-X)<= Z-A <= 1-X, 0 <= Z <= X]

and then just replace A*X with Z in you code. The explicit upper bound on A is to ensure modelling of the nonconvex max operation works

Johan Löfberg

unread,
Jun 23, 2014, 3:32:46 AM6/23/14
to
Whoops, thought X was binary and A real. You would have to do changes accordingly to reverse logic, and add upper bound on X

Jincheng Zhang

unread,
Jun 23, 2014, 3:43:51 AM6/23/14
to yal...@googlegroups.com
In my model, A is binary variable, X is positive real variable. 

For the last constraint, it involves products of real variables.

How can I use the binmodel to solve this problem?

Can you give me some links on how to use binmodel, I just found the explanation about binmodel in the YALMIP homepage and don't quite understand it.

Thanks,
Jincheng


Johan Löfberg

unread,
Jun 23, 2014, 3:59:55 AM6/23/14
to yal...@googlegroups.com
If you have products of real variables, then you are pretty much doomed. I would linearize as far as possible, and then perhaps try bmibnb, or scip, or baron, or bnb (assumed convexity, so no guarantees) or bonmin (assumed convexity, so no guarantees), or if the continuous product is easy (you haven't showed what it looks like), you might model it approximately using picewice linear approximations

using binmodel here for the trivial part would be something like

X = sdpvar(2,3,4,'full');
A
= binvar(2,3,4,'full');

[Z, cuts] = binmodel(X(:).*A(:),[0 <= X, X <= 42])
Z
= reshape(Z,size(A));
Model = [cuts, sum(Z) >= ..


VIKASH KUMAR

unread,
Mar 5, 2017, 10:16:22 AM3/5/17
to YALMIP
Hi Johan

I am a new user of YALMIP toolbox. I am trying to solve a problem using fmincon. But the problem is it's default maximum iteration value.Will you please tell me how to change the default maximum iteration value.

fmincon stopped because it exceeded the iteration limit,
options.MaxIter = 1000 (the default value).

I used the fmincon solver, and the code written as
ops = sdpsettings('solver','fmincon');
optimize(Constraints,Objective);

Mark L. Stone

unread,
Mar 5, 2017, 10:42:02 AM3/5/17
to YALMIP
ops = sdpsettings('solver','fmincon','fmincon.MaxIter',5000);
optimize
(Constraints,Objective,ops);
sets MaxIter for fmincon to 5000.
Note that you need to include ops in the call to optimize in order for the options in ops to take effect.
Reply all
Reply to author
Forward
0 new messages