Decision Variable is a very small number but not zero

29 views
Skip to first unread message

PWG

unread,
Jun 29, 2014, 11:42:47 PM6/29/14
to yal...@googlegroups.com

Hi All,

I use CPLEX to solve a MILP problem which basically is a network flow problem. However, I notice that some decision variables are very small variables like -1.00006e-09, -9.02266e-12, instead of zero. BUT I defined them as: decVar.add(IloNumVar(env, 0, 100, IloNumVar::Float)

 Is there anyone who knows how to make these decision variables zero in this case? Thank you in advance!

Erling D. Andersen

unread,
Jun 30, 2014, 1:03:30 AM6/30/14
to yal...@googlegroups.com

Johan Löfberg

unread,
Jun 30, 2014, 2:31:38 AM6/30/14
to yal...@googlegroups.com
In general, you cannot expect constraints to be satisfied fully. Solvers are numerical machines working with floats.

However, if you absolutely must have a decision variable to be zero, you should not define a decision variable, and then add the constraint that an element is zero. Much bettter to replace the variable with zero explicitly. How that is done directly in cplex is hopefully answered on your other thread, but in YALMIP
% BAD
x
= sdpvar(10,1);Constraints = [...,x(5)==0]
% GOOD
x = sdpvar(10,1);x(5)=0;Constraints = [...]

Still, all other constraints will only be satisfied within some tolerance.

PWG

unread,
Jun 30, 2014, 2:43:24 AM6/30/14
to yal...@googlegroups.com
Hi Johan, thank you for the reply. To clarify, it is not known in advance whether the decision variable will take value zero or not, so I cannot replace the variable with zero explicitly.  Anyway, based on what you said, I can only accept the output of numerical machines.
Reply all
Reply to author
Forward
0 new messages