a little number equals zero???

94 views
Skip to first unread message

yongjie wang

unread,
Mar 16, 2014, 12:33:57 PM3/16/14
to yal...@googlegroups.com
Hi Johan
There is a problem very disgusting,I transform a nonlinear logic constraints to  normal linear constraints as following:
con=con+[Pjd(:,1)==0];
con=con+[XX(:,1)==0];
for abc=2:nbus  
    for ss=1:(RR-1)
        con=con+[0<=fenduanV*Isqr(abc-1)-Pjd(ss,abc)<=fenduanV*Imax^2*(1-XX(ss,abc))];   
        con=con+[0<=Pjd(ss,abc)<=fenduanV*Imax^2*XX(ss,abc)];                                        
    end 
end
Above,RR is a constant,fenduanV and Imax are also constant,Isqr is a sdpvar vector variable,XX is a binary matrix,Pjd is a sdpvar matrix.It is essentially a ''big M'' problem,it meas Pjd=Isqr*fenduanV*XX,and when XX is zero,the Pjd=0,when XX is one,the Pjd=Isqr*fenduanV.it equals the above ''for cycle''.However...
,when XX is one, Pjd some times equals zero,and when XX is zero, Pjd sometimes does not equal zero,but very little,but in my model,the little error should not be neglected,I do not the problem,so can you help me? and i want to know the code display means.
     Nodes                                         Cuts/
   Node  Left     Objective  IInf  Best Integer    Best Bound    ItCnt     Gap

      0     0        0.0005   178                      0.0005     1650         
      0     0        0.0006    51                     Cuts: 8     1675         
      0     0        0.0006    51                     Cuts: 5     1679         
      0     0        0.0006    53                 ZeroHalf: 1     1814         
*     0+    0                            0.0010        0.0006     1814   44.24%
*     0+    0                            0.0006        0.0006     1814    3.34%
      0     2        0.0006    52        0.0006        0.0006     1814    1.94%
Elapsed time = 2.74 sec. (1216.40 ticks, tree = 0.01 MB, solutions = 2)
*    51    25      integral     0        0.0006        0.0006     3020    1.53%
*   104    33      integral     0        0.0006        0.0006     3147    1.32%
what does the gap mean,how can i change it?
thanks for you patience.
waiting for your reply.

 

Johan Löfberg

unread,
Mar 16, 2014, 1:00:05 PM3/16/14
to yal...@googlegroups.com
How large is "very little"? You will never be able to avoid the fact that numerical solvers work with tolerances and have to settle with some finite value

gap is gap between lower bound and current best feasible solution

yongjie wang

unread,
Mar 16, 2014, 10:40:11 PM3/16/14
to yal...@googlegroups.com
yes,it is also simple to view it as this,
II=I*VV*XX,and VV is a constant, II and XX is a binary variable,and I want to make it nonlinear to a linear constraints,so I involve more variable P and a constant ''big'' M:
0<=I*VV-P<=M*(1-XX),
0<=II<=M*XX
and meanwhile the I also have its range,so M is not too big,like 5.07e-07,of couse we can take it as very big,but i have to add a extral constraint:0<=I<=
2.83e-05 ,and VV  is a constant  0.0179  ,the problem is 
when I and VV is certain,and their product is 5.07e-07 ,when XX is 1,II should be  5.07e-07,but it may be 0,    and when when XX is 0,II should be  0,but it may be 5.07e-07,so the constraint is very rigorous,but the value is not accurate.

Should I change the sdpsettings,some value such as tolerances and gaps,but I do not know what should I change. my settings is as following:
sdpsettings('solver','cplex','verbose',2,'cplex.mip.tolerances.mipgap',1e-20,'cplex.mip.tolerances.absmipgap',1e-20,'cplex.mip.tolerances.integrality',1e-20);
but it can not solve the problem. so change what is a big problem or it is yalmip and matlab's inner question.the output is my first question displayed first time.
thanks very much.

Johan Löfberg

unread,
Mar 17, 2014, 3:03:10 AM3/17/14
to yal...@googlegroups.com
Numbers like 1e-7 are essentially in the vicinity of the solvers definition of "close-enough-to-zero". Your only options would be to try to rescale your problem to get numbers in a more reasonable scale (for instance, if some decision variable of your indicate the length of a road, 1e-7 means an error of 0.1mm on a road segement of length 1 kilometer. Does that small difference really make any difference or sense in practice?) or tweak with various tolerances in the options of the solver and hope that you can trick the solver to work harder to obtain more correct digits correct

yongjie wang

unread,
Mar 17, 2014, 3:44:29 AM3/17/14
to yal...@googlegroups.com
I thinlk the two constraints is rigorous,and I extract the result XX(binary),0<=II<=M*XX,when XX is 0,the right part of the constaints is 0,but sometimes II is 1e-7,what is the reason of the situation,maybe it is not the problem of the M value...

Johan Löfberg

unread,
Mar 17, 2014, 3:54:28 AM3/17/14
to yal...@googlegroups.com
What you see is simply the fact that your solver uses a tolerance for declaring a value as zero. CPLEX, as it looks like you are using, simply regards 1e-7 as close enough to zero, e.g.,

>> ops = sdpsettings;
>> ops.cplex.simplex.tolerances

ans
=

    feasibility
: 1.0000e-06
      markowitz
: 0.0100
     optimality
: 1.0000e-06



yongjie wang

unread,
Mar 17, 2014, 4:33:38 AM3/17/14
to yal...@googlegroups.com
So, which parameter is crucial,that is,which parameter should I set in the sdpsettings to avoid my problem,thanks,I am not so farmilar with sdpsettings .thans,Johan.thanks

Johan Löfberg

unread,
Mar 17, 2014, 4:37:06 AM3/17/14
to yal...@googlegroups.com
the feasibility tolrerance looks like a reasonable guess. However, you will probably not be able to tweak it, since cplex has a bug in their interface which causes options to be disregarded

https://www.ibm.com/developerworks/community/forums/html/topic?id=7dce2826-4858-4136-bbd4-a31fb7fadd90&ps=50

I would also try rescaling the problem and write LL<=M*XX with M is a more well-scaled number

yongjie wang

unread,
Mar 17, 2014, 4:46:21 AM3/17/14
to yal...@googlegroups.com
thanks very much,I am here waiting your reply,and I also will try to debug it,and my major is electrical engineering,I can send my code to you if you need.

yongjie wang

unread,
Mar 17, 2014, 4:48:06 AM3/17/14
to yal...@googlegroups.com
The problem is LL=M*XX,M is a constant value product a variable.thanks

Johan Löfberg

unread,
Mar 17, 2014, 4:50:39 AM3/17/14
to yal...@googlegroups.com
I would try LL <= 1e-7, LL <= X*1 and see if the solver then can be tricked to return a solution which is satisfied entirely.

Johan Löfberg

unread,
Mar 17, 2014, 5:09:13 AM3/17/14
to yal...@googlegroups.com
But as I said before, the main problem is scaling. It is a very bad model if you have to that something is either 0 or 1e-7.

yongjie wang

unread,
Mar 17, 2014, 5:18:45 AM3/17/14
to yal...@googlegroups.com
So,we can not change the situation by changing the settings,in my model,we use the per unit(pu),not actual value.but it is the interface problem...

Mark L. Stone

unread,
Mar 17, 2014, 2:13:11 PM3/17/14
to yal...@googlegroups.com
Yohan, did you see the workaround stated in a post in the IBM devloperWorks CPLEX thread you referenced?

"For the time being you can work around the issue by using parameter numbers.  Taking the mip emphasis parameter as an example, you can see from the documentation that the internal parameter number for this parameter is 2058.  You can set this using options.parameter2058 = 2;"

yongjie wang

unread,
Mar 18, 2014, 4:04:06 AM3/18/14
to yal...@googlegroups.com
Hi Johan
Later I use the voltage,power,current in actual value not in pu,When I run a program,it may be infeasible,but the information:Row 'c21538' infeasible, all entries at implied bounds.......I do not know which constraint is wrong,so how can I find the problem???which row is 'c21538' in my program.
thanks...

Johan Löfberg

unread,
Mar 19, 2014, 5:10:08 AM3/19/14
to yal...@googlegroups.com
Yes, I've seen that. YALMIP will not do it for the user though, adding such a messy tweak to code around a bug in a particular version leads to more issues than it solves.

Johan Löfberg

unread,
Mar 19, 2014, 5:11:04 AM3/19/14
to yal...@googlegroups.com
That is typically very hard to figure out. Easier to start removing constraints from your YALMIP model and see if there is any obvious offender

Mark L. Stone

unread,
Mar 21, 2014, 9:35:40 PM3/21/14
to yal...@googlegroups.com
Yohan, there is good news, sort of, maybe with respect to the CPLEX MATLAB parameters bug.  Per IBM employee Ed Klotz in https://www.ibm.com/developerworks/community/forums/html/topic?id=7d401a80-4ee0-44a1-bb8e-65305ba81c7a&ps=25 with regard to the parameters bug "We will do a fixpack that will address this, and we'll update the forum when it is available."
Reply all
Reply to author
Forward
0 new messages