set V; # nodes
set E within V cross V; # edges
var x{V} binary;
# describes whether a vertex belongs to the stable set.
# the keyword 'binary' declares that the variables are either 0 or 1, no fractional values are allowed
param w{V} default 1;
# if no weights are specified, we consider the problem of finding
# a stable set of maximum size.
maximize TotalWeight:
sum {v in V} x[v]*w[v];
# two vertices of the stable set must not be adjecent.
# this can be implemented by the following constraint:
s.t. NonAdjacent{(u,v) in E}:
x[u] + x[v] <= 1;