amplneos-server

AMPL:How to print variable output using NEOS Server, when you can't include data and model command in the command file?


I'm doing some optimization using a model whose number of constraints and variables exceeds the cap for the student version of, say, AMPL, so I've found a webpage [http://www.neos-server.org/neos/solvers/milp:Gurobi/AMPL.html] which can solve my type of model.

I've found however that when using a solver where you can provide a commandfile (which I assume is the same as a .run file) the documentation of NEOS server tells that you should see the documentation of the input file. I'm using AMPL input which according to [http://www.neos-guide.org/content/FAQ#ampl_variables] should be able to print the decision variables using a command file with the appearance:

 solve;
 display _varname, _var;

The problem is that NEOS claim that you cannot add the:

 data datafile;
 model modelfile;

commands into the .run file, resulting in that the compiler cannot find the variables.

Does anyone know of a way to work around this? Thanks in advance!

EDIT: If anyone else has this problem (which I believe many people have based on my Internet search). Try to remove any eventual reset; command from the .run file!


Solution

  • You don't need to specify model or data commands in the script file submitted to NEOS. It loads the model and data files automatically, solves the problem, and then executes the script (command file) you provide. For example submitting diet1.mod model diet1.dat data and this trivial command file

    display _varname, _var;
    

    produces the output which includes

    :                _varname              _var    :=
    1   "Buy['Quarter Pounder w/ Cheese']"   0
    2   "Buy['McLean Deluxe w/ Cheese']"     0
    3   "Buy['Big Mac']"                     0
    4   "Buy['Filet-O-Fish']"                0
    5   "Buy['McGrilled Chicken']"           0
    6   "Buy['Fries, small']"                0
    7   "Buy['Sausage McMuffin']"            0
    8   "Buy['1% Lowfat Milk']"              0
    9   "Buy['Orange Juice']"                0
    ;
    

    As you can see this is the output from the display command.