[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-glpk] if...then...else
From: |
Jeff Hamann |
Subject: |
[Help-glpk] if...then...else |
Date: |
Fri, 25 Jun 2010 04:32:07 +0400 |
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
address@hidden
- [Help-glpk] if...then...else,
Jeff Hamann <=