Availability
AMPL is available on Flux that has licensed software. To see the available versions, use
$ module av ampl
Running AMPL interactively
You should only run AMPL on the login hosts for very small jost to test syntax and that it is working. If you need to run AMPL interactively for real work, you should submit an interactive job (see our documentation on submitting an interactive job for details). There are two solver packages licensed with AMPL: CPLEX and Gurobi.
To run AMPL interactively, you first need to load the AMPL module.
$ module load ampl $ ampl ampl: option solver cplex; ampl: model diet1.mod; data diet1.dat; solve; ampl: ampl: CPLEX 12.5.1.0: optimal integer solution; objective 15.05 8 MIP simplex iterations 0 branch-and-bound nodes Objective = Total_Cost ampl: exit; Removed AMPL temporary directory $ ampl ampl: option solver gurobi; ampl: model diet1.mod; data diet1.dat; solve; ampl: ampl: Gurobi 5.6.0: optimal solution; objective 15.05 35 simplex iterations 22 branch-and-cut nodes Objective = Total_Cost ampl: exit; Removed AMPL temporary directory
Running AMPL in batch mode
To run AMPL in batch mode, simple put your AMPL commands into a file and use redirection. Suppose we have a file, diet.ampl that contains the following lines.
option solver cplex; model diet1.mod; data diet1.dat; solve; display Buy; display n_min,Diet.body,n_max; let n_max["Cal"] := 2500; solve; display Buy; display n_min,Diet.body,n_max; let n_max["Cal"] := 2000; solve; let n_max["Cal"] := Infinity; objective Nutr_Amt["Cal"]; solve; display Total_Cost; display Buy;
To run those commands in AMPL with output sent to diet.out, you would use
$ ampl diet.out
Running AMPL from PBS
To run AMPL from PBS, load the AMPL module prior to running the qsub command, then simply put the above AMPL batch command into a PBS file, and submit it.
#### PBS preamble #PBS -N PBS_test_script #PBS -M uniqname@umich.edu #PBS -m abe #PBS -A example_flux #PBS -l qos=flux #PBS -q flux #PBS -l nodes=1:ppn=1,pmem=2gb #PBS -l walltime=1:15:00 #PBS -j oe #PBS -V #### End PBS preamble if [ -s "$PBS_NODEFILE" ] ; then echo "Running on" uniq -c $PBS_NODEFILE fi if [ -d "$PBS_O_WORKDIR" ] ; then cd $PBS_O_WORKDIR echo "Running from $PBS_O_WORKDIR" fi # Put your job commands after this line ampl diet.out
Note that AMPL does not have parallel capabilities, so you should not ask for more than one processor on one node.