3

I'm using GLPK under Linux to solve some linear programming problems. In one of my restrictions I have:

s.t. example: binary_var+binary_val <=1;

Where binary_val is a variable defined as 'binary'.

If binary_val takes the value 1, will its sum be 2, or as it is in binary, will it return either 0 or 1?

JJJ
  • 32,902
  • 20
  • 89
  • 102
alfongj
  • 2,255
  • 1
  • 19
  • 23

1 Answers1

2

If binary_var + binary_val <= 1 then here's what that constraint means:

Either binary_var or binary_val can be 1, but both cannot be simultaneously 1. Both can be zero, since the constraint is satisfied.

To answer your specific question, a binary variable can only assume values 0 or 1. But the sum of two binary variables can be 2.

Ram Narasimhan
  • 22,341
  • 5
  • 49
  • 55