0-1 variable definition

34 views
Skip to first unread message

Kevin Zheng

unread,
Aug 12, 2019, 8:19:26 AM8/12/19
to YALMIP
When I choose to define a 0-1 variable with binvar, why does the yalmip solution show that the variable is an sdpvar variable?Is there a way to define the variable strictly as 0-1?Thank you very much!

Johan Löfberg

unread,
Aug 12, 2019, 8:27:29 AM8/12/19
to YALMIP
binvar is simply syntactic sugar for an sdpvar with an associated binary constraint. Everything is sdpvar objects

Kevin Zheng

unread,
Aug 12, 2019, 8:41:47 AM8/12/19
to YALMIP
Thank you Dr.Löfberg.Is there a way to strictly define the 0-1 variable in yalmip?

Johan Löfberg

unread,
Aug 12, 2019, 8:45:52 AM8/12/19
to YALMIP
If you define a variable with binvar, or equivalently with sdpvar  + binary constraint, you have defined a binary variable.

Kevin Zheng

unread,
Aug 12, 2019, 8:52:44 AM8/12/19
to YALMIP
Thank you very much!I defined a number of 0-1 variables in yalmip with binvar, but the solution results showed that some variables were not strictly 0-1 variables, and the value was 0.999995 instead of 1. May I ask how to solve this problem?

Johan Löfberg

unread,
Aug 12, 2019, 8:54:55 AM8/12/19
to YALMIP
solvers have options for declaring integer tolerance, and will terminate when they are satisfied

Kevin Zheng

unread,
Aug 12, 2019, 9:14:18 AM8/12/19
to YALMIP
May I ask if we can manually modify the integer tolerance?How should I modify it?

Johan Löfberg

unread,
Aug 12, 2019, 9:17:21 AM8/12/19
to YALMIP
you use sdpsettings like always, and which option depends on the solver of course

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

ans = 

  struct with fields:

           absmipgap: 1.0000e-06
         integrality: 1.0000e-05
         lowercutoff: -1.0000e+75
              mipgap: 1.0000e-04
       objdifference: 0
    relobjdifference: 0
         uppercutoff: 1.0000e+75


Kevin Zheng

unread,
Aug 12, 2019, 9:36:43 AM8/12/19
to YALMIP
Thank you very much!
Reply all
Reply to author
Forward
0 new messages