User Tools

Site Tools


How do I define several independent models in one GAMS file?

Q: We'd like to split the model into three independent parts without having to write each of the equations and variables three times.

Section 9 of the GAMS User's Guide explains the syntax of a model statement. If you want to declare several independent models you can also use an extended syntax like below (this was introduced with distribution 22.1).

Let's assume you have declared the equations as follows:

* common equations:

* not common equations: 

Now you declare a model with just the common equations:

model basic /c_eq1, c_eq2, c_eq3/; 

and for each independent model you just declare another model, which includes the basic model and the additions equation(s):

model nc1 /basic, nc_eq1/; 
model nc2 /basic, nc_eq2/; 
model nc3 /basic, nc_eq3/; 

Another example is:

$call '=gamslib 1';
$include trnsport.gms

model trans1   /cost/,
      trans2   /supply, demand/,
      transport2 /trans1, trans2/;
solve transport2 using lp minimizing z ;
gams/define_several_independent_models_in_one_gams_file.txt · Last modified: 2008/06/18 10:57 by support