How To Write Your Driver

Your driver is an executable that will run your solver. This can be a script (Perl, Python, bash, etc.) or a compiled binary. The input from the NEOS user will be stored as files in the local directory. For example, if in your solver XML description you had the section:


<neos:input TYPE="textarea">
  <neos:token>mytext<neos:token>
  <neos:filename>mytextfile<neos:filename>
  <neos:prompt>Enter some text<neos:prompt>
<neos:input>

then there will be a file in the local directory named mytextfile which has the text that the NEOS user entered into the text box. If the text box is left blank, then the file will not exist.

Anything written to standard out will be sent back to NEOS and forwarded to the client in real-time. Anything written to the file job.results will be sent to the client as the final results. If nothing is written to this file, then the user will only receive what was sent to standard out. Any standard error will also be sent to the client with the the prefix 'Error:'.


Creating the driver list

When NEOS sends an optimization job to your workstation, it will need to know what command to use to execute your driver. It will look up this information in the file designated by DRIVER_FILE entry in the SolverTools/config.py file. The syntax of this file is one entry per line of
Category:SolverName:InputMethod /path/to/driver

For example, if you have an LP solver named 'MyAwesomeSolver' that takes as input either AMPL files or an MPS file, and you have a separate driver for each input, then your driver list could look like:
lp:MyAwesomeSolver:AMPL /home/me/ampldriver
lp:MyAwesomeSolver:MPS /home/me/mpsdriver

Using the provided AMPL and GAMS base classes

If your solver uses AMPL, then you can use the provided Python base class to simplify the driver. To do this, you must use the filenames ampl.mod, ampl.dat, and ampl.com in the XML solver description (see tron-ampl.txt).

To use the base class, you must set the AMPL executable in the SolverTools/config.py file and the solver executable must be accessible from AMPL (either in the $PATH environment variable or in the same directory as AMPL).

Here is an example of what the AMPL driver should look like, yes it is this simple:

#!/usr/bin/env python
import sys
import os

sys.path.append('/path/to/neos-5')
import SolverTools.AMPL

tron = SolverTools.AMPL.AMPLSolver("tron")
tron.execute()

The argument to sys.path.append should be the directory where you downloaded or unzipped NEOS (This value should be the parent directory of SolverTools), and the argument to SolverTools.AMPL.AMPLSolver should the name of the executable



@NEOS_WEB_DISCLAIMER@