Change Working Directory of GAMS

Problems with syntax of GAMS
Post Reply
Posts: 5
Joined: 1 year ago

Change Working Directory of GAMS

Post by barsssk » 1 year ago

Hello all,

Is it possible to change working directory that GAMS puts all those .gdx, .txt, .lst files by default ?


User avatar
Site Admin
Site Admin
Posts: 12
Joined: 3 years ago

Re: Change Working Directory of GAMS

Post by gamsadmin » 1 year ago

Hi Barsssk

You could use a setlocal or setglobal parameter at the beginning of your file.
For example, if you want to have all your files in the directory results, which is below your model directory, I add:

Code: Select all

$setglobal results .\results\

* Send to results directory
execute_unload "%results%myresults.gdx";
Gams now replaces every occurence of %results% by .\results\

I use this technique for all my subdirectories (data, temp, results), so I keep all stuff nicely separated. In the subdirectory "temp" I save everything that is created during the run and can be recreated easily. The results subdirectory is for excel files that will be filled everytime with new results (if available).



Post Reply