Reputation: 53
In the model I'm trying to build, I have a variable defined as:
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?
Upvotes: 3
Views: 360
Reputation: 2292
You should use "variables with limited domains" for this, look here for more details, it is a rather new GAMS feature: https://www.gams.com/latest/docs/UG_ModelSolve.html#UG_ModelSolve_LimitedDomain
So, in your example, it would look like this:
Set limX(i,j) limiting domain of x;
limX(i,j) = ord(j) >= ord(i);
Model m /all, x(limX)/;
...
Edit: Corrected syntax of model statement.
Upvotes: 2
Reputation: 73
So, I add this, right after declaring the variable:
x.fx(i,j)$(ord(i)>ord(j))=0;
It is fixing the values of the variables you are not using to zero. In your model:
And the results are:
I believe that should do it :)
Upvotes: 1