AMPL

From FarmShare

(Difference between revisions)
Jump to: navigation, search
(2016 update)
Line 3: Line 3:
   module load amplgurobi
   module load amplgurobi
-
But I think that will only have the gurobi solver.
+
But I think that will only have the gurobi solver.  So you probably want to
 +
  module load ampl amplgurobi gurobi
 +
 
 +
Then you'll be able to call the 'gurobi_ampl' solver from inside 'ampl'.
I see we do have SNOPT in
I see we do have SNOPT in

Revision as of 11:44, 1 March 2016

Contents

2016 update

There is a newer version of ampl+gurobi installed:

 module load amplgurobi

But I think that will only have the gurobi solver. So you probably want to

 module load ampl amplgurobi gurobi

Then you'll be able to call the 'gurobi_ampl' solver from inside 'ampl'.

I see we do have SNOPT in

 module load ampl/20150630

You may also be able to specify solver by absolute path in your run file, e.g.

 option solver '/farmshare/software/non-free/AMPL-2015/minos';

2015 update

As of mid-2015, the software is installed in /farmshare/software/AMPL-2015 and the license manager is running on host license4.

 module load ampl
 which ampl

We also now include some more solvers like cplex and gurobi and minos and snopt, and they have larger variable limits or something. Read through the documents in

 /farmshare/software/non-free/AMPL-2015/documentation/ 

or on their website.

I also had to make that AMPL-2015 directory world-writeable as I think each user starting up ampl needs to write a license lock file in there. To clean up:

 chmod go+rwx /farmshare/software/non-free/AMPL-2015/*_lock

New paths and module names

As of 2013, the software is now in /farmshare/software and accessible via the 'module' command.

Try 'module help ampl'.

The test example is in /farmshare/user_data/chekh/chekh-from-gluster/ampl_test

Example

I tried running an ampl example, specifically cut3.run from here: http://www.ampl.com/NEW/LOOP2/index.html

But you need to replace the command "option solver cplex" with "option solver cplexamp"

Put cplex in my path:

[chekh@corn14.stanford.edu] /mnt/glusterfs/chekh/ampl_test [0] 
$ module load cplex
[chekh@corn14.stanford.edu] /mnt/glusterfs/chekh/ampl_test [0] 
$ which cplex
/mnt/glusterfs/software/non-free/CPLEX_Studio124/cplex/bin/x86-64_sles10_4.1/cplex
[chekh@corn14.stanford.edu] /mnt/glusterfs/chekh/ampl_test [0] 
$ which cplexamp 
/mnt/glusterfs/software/non-free/CPLEX_Studio124/cplex/bin/x86-64_sles10_4.1/cplexamp

put ampl in my path:

 module load ampl

Interactive

Run interactive ampl using the absolute path:

[chekh@corn14.stanford.edu] /mnt/glusterfs/chekh/ampl_test [0] 
$ ampl 
ILOG AMPL 11.210, licensed to "stanford-palo alto, ca", options: MaintenanceEnd=20110531 
AMPL Version 20081120 (Linux 2.6.18-5-amd64)
ampl: include cut3.run

  52.10  -2.00e-01    1  0  0  0  1
  50.50  -2.00e-01    1  2  0  0  0
  47.00  -1.00e-01    3  0  1  0  0
  46.25  -1.00e-06  


Rounded up to integer:  48 rolls

Cut     0   0   9   5   0   8  18   8

 20     5   0   0   0   0   1   1   3
 45     0   2   0   0   0   0   2   0
 50     0   0   2   0   0   0   0   1
 55     0   0   0   2   0   0   0   0
 75     0   0   0   0   1   1   0   0

WASTE =  7.48%


Best integer:  47 rolls

Cut     0   0   8   5   0   8  18   8

 20     5   0   0   0   0   1   1   3
 45     0   2   0   0   0   0   2   0
 50     0   0   2   0   0   0   0   1
 55     0   0   0   2   0   0   0   0
 75     0   0   0   0   1   1   0   0

WASTE =  5.51%

ampl: quit; 

If you use "option solver cplex" in your run file, it will just sit there indefinitely and produce no output.

non-interactive, aka batch

You can just give ampl the filename of the run file as an argument, instead of invoking ampl interactively. E.g.

 ampl cut3.run

It will still print the output out to stdout, so you may want to redirect to a file, e.g.

 ampl cut3.run > output_of_cut3.out

submit to barley

Since we can run the program non-interactively, we can submit it to the resource management system. Write a job script like this:

#!/bin/bash
# use the current directory
#$ -cwd
# use the current environment
#$ -V
# mail this address
#$ -M chekh@stanford.edu
# send mail on begin, end, suspend
#$ -m bes
# request 5GB of RAM for this job
#$ -l mem_free=5G

ampl model.run 

You'll need to use the '-V' flag either on the command line or in the job script, and you'll need to run 'module load CPLEX_Studio-12.4' and 'module load AMPL' before you submit the job. The latter will add cplex and cplexamp to your PATH and the former will pass that environment variable through to the job environment.

Submit with:

 qsub my_ampl.script


2012-08-15 AMPL upgrade

I upgraded AMPL to a newer version, now it looks like this:


[chekh@corn12.stanford.edu] ~ [0] 
$ module load AMPL
[chekh@corn12.stanford.edu] ~ [0] 
$ ampl --version
AMPL Version 20120629 (Linux x86_64)
[chekh@corn12.stanford.edu] ~ [0] 
$ ampl
netlicchk: Trying to start license manager ampl_lic.
netlicchk: Invoking "/mnt/glusterfs/software/non-free/AMPL/ampl_lic".
ampl:

Also, I had to make /mnt/glusterfs/software/non-free/AMPL/ world-writeable because ampl_lic needs to write a lock file there.

licensing errors

I need to do something like this to clean out old lock files:

 senpai1:/mnt/glusterfs/software/non-free/AMPL# ls -alh *lock|grep Sep | awk '{print $NF}' |xargs rm

Otherwise the user gets errors like this:

> 
> netlicchk: Trying to start license manager ampl_lic.
> netlicchk: Invoking "/mnt/glusterfs/software/non-free/AMPL/ampl_lic".
> 20121113  9:09:20: Cannot create lock file "/mnt/glusterfs/software/non-free/AMPL/corn16.stanford.edu.ampl_lock" for ampl_lic.

Or better yet, just make all the lock files world-writeable?

Personal tools
Toolbox
LANGUAGES