I'm trying to add a cardinality constraint to an existing model and I'm getting 
stuck. 

var w{S} ;
param inc{S}, binary;

where I want to set the binary variable:

if w[s] = 0 then inc[s] = 0 else inc[s] = 1

s.t. IsIncluded {s in S}: if w[s] > 0 then inc[s]=1;

/* a cardinality constraint -- only include 4 in the solution */
s.t. C6: sum {s in S} inc[s]  = 4;


I must admit I'm a newbie at coding models with MathProg, so I think I'm 
suffering from the syntax. 

Basically, I would like to set the binary variable to 1 if w[s] > 0 and 0 
otherwise.

Is this the proper use of the if-then-else statement?


Jeff Hamann
[email protected]






_______________________________________________
Help-glpk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-glpk

Reply via email to