# Running a simulation with GAMS

This page assumes you have already created input files using the file 'Aggregation.xls' and, possibly, SAS. These files must be present in MIRAGE directory. See spreadsheet interface (Outdated) to learn how to do it.

A complete MIRAGE simulation is the running of five successive files. They are linked by the Saves and Restarts function of GAMS. The file 'MIRAGE.gms' shows how a complete simulation can been done in one single GAMS file.<ref>This file will only function if GAMS directory is in your search path. If not change environnement settings.</ref> At the end of the execution of 'Calib.gms', GAMS memory is saved the file 'Calib.g00' in subdirectory 'Restart'. The command line instruction 's=.\Restart\calib' commands this behaviour. In the following example, a gdx file is created at the end of each file run. It helps greatly to debug the model.

### MIRAGE.gms

 EXECUTE 'gams Calib.gms         			s=.\Restart\calib 	gdx=.\GDX\calib				lo=3'
EXECUTE 'gams MSD.gms		r=.\Restart\calib	s=.\Restart\model 	gdx=.\GDX\model				lo=3'
EXECUTE 'gams Ref.gms		r=.\Restart\model	s=.\Restart\ref   	gdx=.\GDX\ref				lo=3'
EXECUTE 'gams Simul.gms         r=.\Restart\ref		s=.\Restart\simul   	gdx=.\GDX\sim				lo=3'
EXECUTE 'gams Results.gms     	r=.\Restart\simul    				gdx=.\GDX\resultats 	//simu=simu	lo=3'

Same thing can be done in a batch file:

 gams Calib.gms         				s=.\Restart\calib 	gdx=.\GDX\calib				lo=3
gams MSD.gms		r=.\Restart\calib	s=.\Restart\model 	gdx=.\GDX\model				lo=3
gams Ref.gms		r=.\Restart\model	s=.\Restart\ref   	gdx=.\GDX\ref				lo=3
gams Simul.gms         	r=.\Restart\ref		s=.\Restart\simul   	gdx=.\GDX\sim				lo=3
gams Results.gms     	r=.\Restart\simul    				gdx=.\GDX\resultats 	//simu=simu	lo=3

In GAMSIDE, you can launch each file successively. The save and restart options must be written in the box just to the right of the execute button.