Thursday, December 4, 2008

Hook AMPL with NPSOL 5.0

Thank Dave. M. Gray for the help to modify the makefile

1. NPSOL 5.0 needs to be ordered from http://www.sbsi-sol-optimize.com/asp/sol_product_npsol.htm
After you get npUnix.tar.gz, you can extract it.
You got a directory contains GNUmakefile....
In order to compile and install NPSOL, you need install F2C first, and set the environment variable F2C , for example, in my computer, F2C is installed in /usr/
In command line
export F2C=/usr/
gmake
gmake clean
Therefore, NPSOL will be installed, a new directory will be created (npsol/Linux-i686/optimized/lib) the created directory is dependent on your own system.

2. Download npsol (it is an AMPL interface to NPSOL 5.0) from
http://netlib.bell-labs.com/netlib/ampl, it is a file called netlibfiles.tar
extract netlibfiles.tar , you get solvers/
in solvers/ directory, you may have many .gz files
gunzip *.gz
make -f makefile.u (it depends on your system)
Then amplsolver.a is created in this directory

3. Now go to solvers/npsol
copy all NPSOL library files (/npsol/Linux-i686/optimized/lib) to this directory.
make -f makefile.u
Attention, you may read makefile.u carefully, make some necessary changes according to your system.
cp makefile.u makefile
in makefile

"n = npsol.o version.o $S/amplsolver.a libnpsol_f77.a libblas_f77.a libnlssol_f77.a liblssol_f77.a

npsol: $n
$(CC) -o npsol $n -lf2c -lm -ldl" for my system,Linux localhost 2.6.24-21-generic #1 SMP Tue Oct 21 23:43:45 UTC 2008 i686 GNU/Linux

type make -f makefile
the executable npsol will be created in this directory.

4. Set PATH variables to make the system find this executable
in command line, gedit .bashrc, add npsol path, source .bashrc

5. in AMPL program, just use option solver npsol.

It should work.