Updated 2019-06-24

Run AMPL on the Cluster

Overview

  • AMPL (A Mathematical Programming Language) is is an algebraic modeling language to describe and solve high-complexity problems for large-scale mathematical computing.
  • This guide will cover how to run an AMPL script on the cluster.
  • The example used in this guide comes from here.

Summary

  • This guide will focus on running AMPL as a batch program rather than interactively.
  • This can be accomplished by putting the commands that are normally run in the AMPL prompt into a .run file.
  • Everything written here will be executed in AMPL and will print to the amplTest.out file.
  • We simply pass our model and .run file as inputs to the ampl command in our PBS script.

Tips

  • You must end each statement in the AMPL prompt with ;
  • For this example, we will use the conopt solver.
  • To use the conopt solver, you must provide the full path to it which is /usr/local/pacerepov1/ampl/20110121/conopt.
  • More information about how to use AMPL on UNIX is available here.

Walkthrough: Run AMPL on the Cluster

  • This walkthrough will take a simple model and pass it into the conopt solver and display a variable in the model with a run file.
  • The model can be found here
  • The run file can be found here
  • PBS script can be found here
  • You can transfer the files to your account on the cluster to follow along. The file transfer guide may be helpful.

Part 1: The PBS Script

#PBS -N amplTest
#PBS -l nodes=1:ppn=2
#PBS -l pmem=2gb
#PBS -l walltime=3:00
#PBS -q force-6
#PBS -j oe
#PBS -o amplTest.out

cd $PBS_O_WORKDIR
module load ampl/20110121
ampl amplTest.mod amplTest.run

  • The #PBS directives are standard, requesting just 3 minutes of walltime and 1 node with 2 cores. More on #PBS directives can be found in the PBS guide
  • $PBS_O_WORKDIR is a variable that represents the directory you submit the PBS script from. Make sure the files you want to use (in this case amplTest.mod and amplTest.run) are in the same directory you put the PBS script.
  • Output Files will also show up in this dir as well
  • module load ampl/20110121 loads the 20110121 version of AMPL. To see what AMPL versions are available, run module avail ampl, and load the one you want.
  • Passing amplTest.mod and amplTest.run as inputs to the ampl command executes the instructions in amplTest.run using the model in amplTest.mod.

Part 2: Submit Job and Check Status

  • Be sure to change to the directory that contains the PBS Script
  • qsub amplTest.pbs
  • Check job status with qstat -t <jobid>, replacing the number with the job id returned after running qsub
  • You can delete the job with qdel <jobid> , again replacing the number with the jobid returned after running qsub

Part 3: Collecting Results

  • In the directory where you submitted the PBS script, you should see a amplTest.out file, which contains the results of the job. Use cat amplTest.out or open the file in a text editor to take a look.
  • amplTest.out should look like this:
---------------------------------------
Begin PBS Prologue Wed Jun 19 12:03:40 EDT 2019
Job ID:     26089234.shared-sched.pace.gatech.edu
User ID:    svemuri8
Job name:   amplTest
Queue:      force-6
End PBS Prologue Wed Jun 19 12:03:40 EDT 2019
---------------------------------------
Ifconfig uses the ioctl access method to get the full address information, which limits hardware addresses to 8 bytes.
Because Infiniband address has 20 bytes, only the first 8 bytes are displayed correctly.
Ifconfig is obsolete! For replacement check ip.
netlicchk: Trying to start license manager ampl_lic.
netlicchk: Invoking "/usr/local/pacerepov1/ampl/20110121//ampl_lic".
Ifconfig uses the ioctl access method to get the full address information, which limits hardware addresses to 8 bytes.
Because Infiniband address has 20 bytes, only the first 8 bytes are displayed correctly.
Ifconfig is obsolete! For replacement check ip.
Ifconfig uses the ioctl access method to get the full address information, which limits hardware addresses to 8 bytes.
Because Infiniband address has 20 bytes, only the first 8 bytes are displayed correctly.
Ifconfig is obsolete! For replacement check ip.
CONOPT 3.14V: Optimal; objective 17433.33333
5 iterations; evals: nf = 3, ng = 0, nc = 3, nJ = 0, nH = 0, nHv = 0
PaintB = 453.333

---------------------------------------
Begin PBS Epilogue Wed Jun 19 12:03:45 EDT 2019
Job ID:     26089234.shared-sched.pace.gatech.edu
User ID:    svemuri8
Job name:   amplTest
Resources:  neednodes=1:ppn=2,nodes=1:ppn=2,pmem=2gb,walltime=00:03:00
Rsrc Used:  cput=00:00:00,energy_used=0,mem=0kb,vmem=0kb,walltime=00:00:05
Queue:      force-6
Nodes:
iw-c42-25.pace.gatech.edu
End PBS Epilogue Wed Jun 19 12:03:45 EDT 2019
---------------------------------------
  • After the result files are produced, you can move the files off the cluster, refer to the file transfer guide for help.
  • Congratulations! You successfully ran an AMPL batch program on the cluster.