Search code examples
variablesmodelinggams-math

How to order GAMS variables over all set elements?


I'm having following problem:

I have a binary variable in GAMS called "construct" which stand for constructing a plant (then binary variable = 1) or not (=0). I also have a set for 30 different years from year 1 to year 30.

Set a 'years' /1*30/;

Binary Variables construct(a) 'Decision for building plant 1=yes, 0=no'

I want the model to know if for example the plant is built in year a1, so construct(1) = 1 then logically all following variables in the set also have to be at least 1 since the plant cannot be torn down again. So mathematically:

construct('1') <= construct('2') <= ..... <= construct('30'); This is how i also wrote in the code but I get following error code: *** Error 36 '=' or '..' or ':=' or '$=' operator expected rest of statement ignored

How to do this correctly in GAMS? Many thanks in advance!

I have tried different syntax like =L= or .l for the variables in the line but I either get other errors or it still wont work. Any workaround for this?


Solution

  • The following should work:

    Equation e(a);
    e(a).. construct(a) =g= construct(a-1);