alfongj
alfongj

Reputation: 2273

Adding binary variables in GLPK

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?

Upvotes: 3

Views: 1845

Answers (1)

Ram Narasimhan
Ram Narasimhan

Reputation: 22506

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.

Upvotes: 2

Related Questions