amplRead
Read an AMPL (.nl or .mod) file into Matlab
Syntax
prob = amplRead(filename)
Description
Read an AMPL .nl or .mod file into Matlab. If the file is a .mod, the AMPL executable is used to convert it to a .nl, before reading it into Matlab. If the AMPL executable cannot be found on the MATLAB path, you will need to enter its path as the third argument (see below). LP, MILP, QP, MIQP, QCQP, MIQCQP, UNO, NLP, and MINLP problems will be automatically identified and the corresponding structure created. Other problem and constraint types are not currently supported, including complementarity constraints, network problems or linear arcs. For information on converting your AMPL model to a .NL file see the AMPL user's guide section.
prob = amplRead(filename) reads the file specified by filename and creates an optiprob problem. If you supply only a filename the file must be on Matlab's path in order for this function to find it. Otherwise if you supply a full path + filename, it may reside anywhere on your PC. If you omit .nl it will be automatically added to the filename.
prob = amplRead(filename,extraArgs) allows you to pass extra arguments to AMPL when converting your model file from .mod to .nl, such as options or data. Pass multiple arguments as a cell array. Files not on the Matlab path must be passed as a full path.
prob = amplRead(filename,extraArgs,amplPath) allows you to specify the full path to the AMPL executable on your system.
Important Notes
Routines for reading NL problems use the AMPL Solver Library.
In order to convert .mod models into .nl, the AMPL executable (ampl.exe) is required. You can obtain a free, size limited student version online here, or purchase the full version of AMPL from here.
If the model opened is a nonlinear model, the file will remain open in the MEX function asl. Call asl('close') in order to free the file, or this will be performed automatically when you close Matlab.
If the routine fails I would be interested to fix the problem, and if you are willing to send me the .nl or .mod file I can take a look for you!
Examples
A number of small examples are supplied with the toolbox in the folder OPTI/Test Problems/ which can be used for testing.
Reading an NL file
>> prob = amplRead('ch3.nl')
Copyright © 2011-2013 Jonathan Currie (I2C2)