A MP problem I cannot figure out by YALMIP

56 views
Skip to first unread message

zybjtu

unread,
Mar 12, 2014, 4:55:48 AM3/12/14
to yal...@googlegroups.com


Hi, johan:
     I'm a new bee in yalmip. I have a model described in attachments,and the 'test.m' file is my code.  
     However, I couldnot get the right answer, because `sum(Si) != 6000000`. Can you help me? Thank you very much for your help.
     In my attachments, test.m is my code, model.jpg is my model, and result.jpg is the result of my code.
      
test.m
result.jpg
GOJ]10HO@22[8[UEZDJCO18.jpg

Johan Löfberg

unread,
Mar 12, 2014, 5:22:33 AM3/12/14
to yal...@googlegroups.com
1. SET is obsolete
http://users.isy.liu.se/johanl/yalmip/pmwiki.php?n=Commands.Set

2. Strict inequalities should be avoided
http://users.isy.liu.se/johanl/yalmip/pmwiki.php?n=Blog.Prepare-your-code

So I would simply write
constraints = [1 <= B <= 200, S >= 0, sum(S) == 6000000];

3. You have not solved the problem. Look at the display. It clearly indicates problems, the upper bound is infinite, meaning no feasible solution was found. The solver bnb has terminated after 300 iterations (bnb.maxiter). You must look at the diagnostic code from solvesdp

4. You have a nasty nonlinear integer program, and you don't have any efficient solver for this. YALMIP has picked the only possible choice on your machine, which is the internal solver bnb, which is really slow, and assumes convexity of your relaxations (which I doubt you have). Thus, failure...

5. You can easily write this as a milp. Work with the inverse of B as the variables instead. An element in Binv will be quantized to 1, 1/2, 1/3,..,1/200. Hence, create a variable which is constrained to those values

% Possible values
quants
= 1./(1:200);
% write every Binv_i = di1*1 + di2*1/2 + di3*1/3+...
% and add di1+di2+...+di200 == 1
d
= binvar(200, length(F));
Binv = quants*d;
obj
= lambda' * (F .* (Binv)');
S
= (F - (20 * F) .* (Binv') - (20 / 0.02)) .* lambda;
constraints = [sum(d,1)==1, S >= 0, sum(S) == 6000000];
solvesdp
(constraints,obj)

The problem is infeasible though (which thus explains why bnb failed). The closest you can get the sum to is 7.5417e+06

sdpvar t
constraints
= [sum(d,1)==1, S >= 0, sum(S) == t];
solvesdp
(constraints,abs(t-6000000))
Reply all
Reply to author
Forward
Message has been deleted
0 new messages