Need Work-Around for Conditional Check on a Variable

Problems with syntax of GAMS
Post Reply
JCunningham8
User
User
Posts: 2
Joined: 1 year ago

Need Work-Around for Conditional Check on a Variable

Post by JCunningham8 »

Hi all,

I posted a couple of weeks back asking how to force a variable to take a non-zero value. I have since managed to achieve this using additional constraints, however I am now wondering how to solve the following problem I'm having with my MILP model. Below, I would essentially like to include "if f2 = 0, qin = 0, qout = 0". I have included the relevant code and a short description below.

Code: Select all

Variable f2,qin,qout;
Positive variable pr,avgpi;
Equation avgflow,avgpconst,lpconst1,lpconst2;

AvgFlow(aij(a,gn,gm),t) ..
    f2(a,gn,gm,t) =e= (qin(a,gn,gm,t)+qout(a,gn,gm,t))/2
;
AvgPConst(aij(a,gn,gm),t) ..
    Avgpi(a,gn,gm,t) =e= (pr(gn,t)+Pr(gm,t))/2
;

LPConst1(aij(a,gn,gm),t) ..
    m(a,gn,gm,t) =e= CLP(a,gn,gm)*AvgPi(a,gn,gm,t)
;

LPConst2(aij(a,gn,gm),t) ..
    m(a,gn,gm,t) =e= m(a,gn,gm,t-1)$(ord(t)>1) + qin(a,gn,gm,t)-qout(a,gn,gm,t)
;
Essentially, equation LPconst2 ensures that variables qin and qout have values at all times (can be positive or negative, also not the main purpose of the equation), while the equation AvgPConst ensures (qin+qout)/2 equals f2. However, when f2.l = 0 I would like qin.l and qout.l to equal 0 also, but currently they equal m/2 due to equations LPConst1,LPConst2. Pr is a variable that always contains a positive value, and CLP is a constant.

So, I'm looking to see if there is a way to constrain the variables qin, qout to only take values when f2 is nonzero. Or, in other words, constrain qin and qout to equal 0 when f2 equals 0. Any help would be greatly appreciated. Cheers!
Post Reply