I am working on a model where I have a good that is transported from a set of producers A to a set of consumers B. However, not all combinations of A and B are feasible and I do not want the relevant equations to index over these combinations. How can I make an equation only index over specific combinations of these sets?
Hi @Ian_Hardman ,
You can introduce a two dimensional set that keeps track of the available combinations of A and B.
I attach an example based on the well known trnsport model but instead of allowing all combinations of plants and markets, in this example we define a two dimensional set ij(i,j)
of available arcs.
Set
i 'canning plants' / seattle, san-diego /
j 'markets' / new-york, chicago, topeka /
ij(i,j) 'existing arcs' / seattle.new-york
seattle.chicago
san-diego.chicago
san-diego.topeka /
Then we use the two dimensional set ij(i,j)
in the equations to make sure only available arcs are considered in the generated model instance.
cost.. z =e= sum(ij(i,j), c(i,j)*x(i,j));
supply(i).. sum(j$ij(i,j), x(i,j)) =l= a(i);
demand(j).. sum(i$ij(i,j), x(i,j)) =g= b(j);
I hope this helps!
Fred
trnsport.gms (2.0 KB)