New in AMPL: 22 October 2012 EXTENDED FUNCTION LIBRARY
This library extends AMPL with over 300 functions chosen from the GNU Scientific Library. Included are scientific, statistical, and utility functions of many kinds, and a variety of random number generators. Once installed and declared, these functions may be applied to any arguments anywhere in an AMPL model or script. When applied to variables in objectives or constraints, they are sent to solvers, which automatically gain access to them. Thus solvers that rely on function evaluations can optimize over expressions that use this library. Many of the library's continuous functions also provide for 1st and 2nd derivative evaluations that some solvers require.
The function library is packaged in a single file named
amplgsl_32.dll for 32-bit systems or
amplgsl_64.dll for 64-bit systems. This file is
available in compressed form through the following links: |
Platform | 32-bit version | 64-bit version |
---|---|---|
AIX | amplgsl.aix.tgz | |
Linux-Intel | amplgsl.linux-intel32.tgz | amplgsl.linux-intel64.tgz |
Mac OS X | amplgsl.macosx32.tgz | amplgsl.macosx64.tgz |
Windows | amplgsl.mswin32.zip | amplgsl.mswin64.zip |
To install, use one of these links to download the appropriate tgz or zip file, copy that file to the same folder or directory as your AMPL executable (ampl or ampl.exe), and then extract amplgsl_32.dll or amplgsl_64.dll from that file. (To carry out the extraction under Unix-based systems including AIX, Linux, and Mac OS X, use a command of the form
gzip -dc amplgsl.linux-intel64.tgz | tar xf -in a command window or Mac terminal window; to carry out the extraction under Windows, use the built-in zipfile utility or any popular file-compression application.)
load amplgsl.dll;Subsequently, before a particular function is used, it must be declared to the current model with a command of the form
function gsl_funcname;where funcname is replaced by any of the names in the library listing. As an example, the following model, based on problem 69 of the first Hock-Schittkowski test set, uses a cumulative unit Gaussian density function from the extended library:
function gsl_cdf_ugaussian_P; param l {1..4}; param u {1..4}; var x {j in 1..4} >= l[j], <= u[j] := 1; param a := 0.1; param b := 1000; param d := 1; param n := 4; minimize obj: ( a*n - (b*(exp(x[1])-1) - x[3])*x[4]/(exp(x[1]) - 1 + x[4]) )/x[1] ; subject to constr1: x[3] = 2*gsl_cdf_ugaussian_P(-x[2]); subject to constr2: x[4] = gsl_cdf_ugaussian_P(-x[2] + d*sqrt(n)) + gsl_cdf_ugaussian_P(-x[2] - d*sqrt(n));With the appropriate data file,
param: l u := 1 0.0001 100 2 0 100 3 0 2 4 0 2 ;the problem can be solved like this:
ampl: model hs069.mod; ampl: data hs069.dat; ampl: load amplgsl.dll; ampl: option solver knitro; ampl: solve; KNITRO 8.0.0: Locally optimal solution. objective -956.7128867; feasibility error 3.41e-11 10 iterations; 11 function evaluations ampl: display x; 1 0.0293714 2 1.19025 3 0.233947 4 0.791668* For versions of AMPL earlier than 20120126, the appropriate library file must be chosen explicitly using the command load amplgsl_32.dll or load amplgsl_64.dll as appropriate. If library functions are applied to model variables, then for solvers using versions of the AMPL-solver library older then 20120126, also the type of the solver (32-bit or 64-bit) must match that of AMPL. (Contact support@ampl.com for advice and quotes on updating to newer versions.)
This free-standing library is provided under the GNU General Public License (GPL). In general terms, the GNU GPL does not restrict the use of this library for internal purposes within any organization (whether a company, university, or government agency). However if this library is included within a "release" of software to the public, then you may be required to offer that release under the GPL. See the extensive list of Frequently Asked Questions about the GNU Licenses for more information about these provisions.
For uses that may require functions covered by more permissive open-source licenses, or functions from commerical libraries, please contact us for assistance with alternatives.