How to add a condition to a variable's index Topic is solved

Problems with syntax of GAMS
Post Reply
rkza
User
User
Posts: 4
Joined: 3 years ago

How to add a condition to a variable's index

Post by rkza »

Hi everyone,

In the model I'm trying to build, I have a variable defined as:

Code: Select all

Sets
        i months / 1, 2, 3 /
        j months / 1, 2, 3 /
        ;
        
Variables
    x(i,j)  number of motors produced in month i to be delivered in month j 
    ;
In that variable, j must always be equal or greater than i for it to make sense (you can't produce something in this month to be delivered in the previous month).
However, I have no clue as to how I can properly model this. I've searched and couldn't find an easy solution to this.

Any ideas?
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: How to add a condition to a variable's index

Post by Renger »

Hi

You can fix those values to zero (if that makes sense in your model):

Code: Select all

X.FX(i,j)$(j.val > i.val) = 0;
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
rkza
User
User
Posts: 4
Joined: 3 years ago

Re: How to add a condition to a variable's index

Post by rkza »

Renger wrote: 3 years ago Hi

You can fix those values to zero (if that makes sense in your model):

Code: Select all

X.FX(i,j)$(j.val > i.val) = 0;
Cheers
Renger
It does make sense and it works. Thanks!
Post Reply