< GLPK
Logical constraints involving binaries can be modelled as follows
var x, binary; var y, binary; var z, binary; # z = x or y s.t. c1: x <= z; s.t. c2: y <= z; s.t. c3: x + y >= z; # z = x and y s.t. c1: x >= z; s.t. c2: y >= z; s.t. c3: x + y <= z + 1; # s = x xor y # c = x and y s.t. c1: x + y = 2 * c + s; # z = not x s.t. c1: x = 1 - z;
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.