NEOS allows you to run GAMS jobs on a remote server, so you don’t need a GAMS system installed. The web based submission is a useful tool for self-contained models. That is when everything is in the GAMS model: data, equations, solve statement and reporting through display statements.
For larger jobs where data is coming from different sources and where we need to do more complex post-processing you may need other approaches. If you have GAMS/BASE license you can develop and run the GAMS part locally and only do the solver part remotely by using the kestrel solver. Basically add to the model something like option LP=kestrel and run the model. If you want to change some defaults (e.g. by specifying a non-default solver), you can create a kestrel.opt option file.
If you don’t have a GAMS license file and want to run more complicated models we need to split the complete model in three parts:
To run the data step and report step we need an installed GAMS system but we need no license file.
Data Step
The data step is a GAMS file that basically contains set and parameter declarations and data manipulation steps. It can also read data from spreadsheets and databases. We add at the end the following statements:
$setenv gdxcompress 1 execute_unload "in.gdx"; |
This will save all data in a compressed GDX file. This file can be run just from the command line or from the GAMS IDE on the local machine.
Model Step
The model step first needs to read the GDX file in.gdx. The quickest way to do this is to run gdxdump in.gdx nodata and copy the output of this tool into the .gms file containing the model. Unfortunately NEOS does not allow include files, so we need to physically copy the lines into the .gms file.
The rest of the file can contain variable and equation declarations and the equation definitions. Finally we can add the model and solve statements.
NEOS will save everything in a GDX file call out.gdx so we don’t have to add this ourselves.
To run the model step, upload the .gms file and the in.gdx file to NEOS. I used the following options:
For larger results the e-mail will not provide a link to the zip file with the gdx file out.gdx so I did not bother to fill out the e-mail address. After waiting a little bit you will see
*************************************************************
NEOS Server Version 5.0
Job# : 5150902
Password : EwfLRsCT
Solver : nco:MINOS:GAMS
Start : 2016-11-27 05:52:35
End : 2016-11-27 05:52:55
Host : NEOS HTCondor Pool
Disclaimer:
This information is provided without any express or
implied warranty. In particular, there is no warranty
of any kind concerning the fitness of this
information for any particular purpose.
*************************************************************
[. . .] **** SOLVER STATUS 1 Normal Completion
**** MODEL STATUS 2 Locally Optimal
**** OBJECTIVE VALUE 12942.8050
[. . .]
Additional Output: 5150902-EwfLRsCT-solver-output.zip |
You may want to check the solver and model status, and then download the zip file. The zip file will contain the file out.gdx with all the results.
Report Step
The report step needs to read the file out.gdx. The simplest is again to do gdxdump out.gdx nodata and include the output of this command in the report file. Now you can locally run the report.
How to script this
There are probably two ways to automate this:
- Use the NEOS API to write a script that executes the model on NEOS
- Use something like COM automation for Internet Explorer or a web scraping tool to script the browser steps
References
- http://yetanothermathprogrammingconsultant.blogspot.com/2010/04/gamsgdx-compression.html
- https://neos-server.org/neos/solvers/index.html