Hello Gamsworld,
I have programmed a model with GAMS and want to exclude some binary variables in it.
That coud be a stupid question.
Sets
j Auftrittsstandorte /London , Hamburg , Berlin , Munchen , Koln , Leipzig , Frankfurt /
Alias (j, i);
t Tage /0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 / ;
Binary variables
x(i,j,t);
I Want to exclude the binary variables for i=j, for example x(London , London, t) should not exist.
I don't really get how to do this.
Hope you can help me!
Exclude binary Variables
Re: Exclude binary Variables
There are different ways to accomplish this:
- If there just a few elements to exclude you can fix the variable to 0:
- Better is to not even generate these variables. You do this by excluding the variable in your equation algebra, e.g.
If the exclusion logic shows up in many places, it is useful to make a subset of the combinations you want in your model:
-Michael
- If there just a few elements to exclude you can fix the variable to 0:
Code: Select all
x.fx(i,i,t)$(ord(t)<=2) = 0;
Code: Select all
eq1(i,t).. sum(j$(not sameas(i,j)), x(i,j,t)) =l= cap(i);
eq2(i,j,t)$(not sameas(i,j) and ord(t)>2).. x(i,j,t)) =l= y(i,j,t);
Code: Select all
set ijmap(i,j), ijtmap(i,j,t);
* Exclude i,i
ijmap(i,j) = not sameas(i,j);
* Exclude first two time steps
ijtmap(ijmap,t) = ord(t)>2;
eq1(i,t).. sum(ijmap(i,j), x(i,j,t)) =l= cap(i);
eq2(ijtmap(i,j,t)).. x(i,j,t)) =l= y(i,j,t);