help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] if...then...else


From: Andrew Makhorin
Subject: Re: [Help-glpk] if...then...else
Date: Fri, 25 Aug 2006 15:27:16 +0400

> i have time sets below,
>  
> set W; #week
> set D; #day
> set H; #hour
> 
> and a binary decision variable.
> 
> var delta{w in W, d in D, h in H},binary;
> 
> 
> My question is that;
> if delta[w.d,h] = 0 for a specific hour, it has to be equal to zero for the 
> following 23 hours too.
> That is if delta is 0 it has to be 0 for a day-time. How can i model this 
> situation with "if...then...else".
> Also should i put this expression into variable definition part or s.t.
> part 
> or anywhere in the .mod file.
> 
> I think if i had only one time indice say "t" there is not any problem at
> all 
> but in my situation time index has three sub indices

You cannot use the if statement, because your condition involves
variables. To model the condition you can introduce a binary variable,
say, z, like follows:

var z{w in W, d in D}, binary;

and then define an additional constraint like follows:

s.t. foo{w in W, d in D, h in H}: delta[w,d,h] <= z[w,d];

Note, however, that depending on your model this restriction can be
modeled in different ways.







reply via email to

[Prev in Thread] Current Thread [Next in Thread]