Sequantial solve statements

Problems with modeling
Post Reply
Francisco.Patrocinio
User
User
Posts: 15
Joined: 4 years ago

Sequantial solve statements

Post by Francisco.Patrocinio »

Good evening

I have a model with the following details (I'll skip most sets, parameters and variables, of relevance are the sets, variable and objective function below):

set i /AF,A,B,C/
set j /A,B,C,EF/

Variable
F(i,j)

OF .. FT =e= sum((i,j),F(i,j));

I want to solve the model individually for each set element. E.G.: first I solve for F('AF','A'), second for F('AF','B'). Is it possible to automate this with a loop, or must I descriminate an individual OF for each pair i,j? If so, can you provide me with some details?

Thanks
User avatar
bussieck
Moderator
Moderator
Posts: 1046
Joined: 7 years ago

Re: Sequantial solve statements

Post by bussieck »

The typical solution for this in GAMS is to write you the model equations with a dynamic subset of the domain sets:

Code: Select all

set i /AF,A,B,C/, ii(i)
set j /A,B,C,EF/m jj(j);

Variable
F(i,j)

OF .. FT =e= sum((ii,jj),F(ii,jj));

model m /OF/;
loop((i,j),
  option clear=ii, clear=jj;
  ii(i) = yes; jj(j) = yes;
  solve m min FT us lp;
);
-Michael
Francisco.Patrocinio
User
User
Posts: 15
Joined: 4 years ago

Re: Sequantial solve statements

Post by Francisco.Patrocinio »

Thank you Michael!
Post Reply