GLPK/Modeling Logical Constraints

Logical constraints involving binaries can be modelled as follows

var x, binary; var y, binary; var z, binary;

s.t. c1: x    <= z; s.t. c2: y     <= z; s.t. c3: x + y >= z;
 * 1) z = x or y

s.t. c1: x    >= z; s.t. c2: y     >= z; s.t. c3: x + y <= z + 1;
 * 1) z = x and y

s.t. c1: x + y = 2 * c + s;
 * 1) s = x xor y
 * 2) c = x and y

s.t. c1: x = 1 - z;
 * 1) z = not x