Call Matlab from AMPL

173 views
Skip to first unread message

Christian Hoffmann

unread,
Apr 2, 2015, 10:02:48 PM4/2/15
to am...@googlegroups.com
Hi,

I know that many people call AMPL from within Matlab....but does it work the other way around as well?

I have the problem that I want to use sIPOPT for calculating the reduced hessian. However, sIPOPT does not return the reduced Hessian in an extra file but only in the general IPOPT output file which means that the values need to be parsed which I intend to do with a Matlab file, thus:

1. Run AMPL
2. Obtain reduced Hessian by solving the optimization problem
3. call Matlab from within AMPL run file to invoke the parsing function
4. continue in AMPL run file

Is this easily achievable or should I better call AMPL from within Matlab?

Greetings,

Christian

Robert Fourer

unread,
Apr 3, 2015, 7:14:19 PM4/3/15
to am...@googlegroups.com
There is an AMPL command

shell "...";

where ... is replaced by any command that can be run from a command-window prompt on your system. You can use this in particular to run the "matlab" command on your system to invoke a MATLAB function. Details depend on what kind of computer you are using, but can be found in the relevant MATLAB documentation. Note that this runs MATLAB as a separate process, so you will have to manage communication between AMPL and MATLAB, possibly through files.

As an alternative you could consider using the MATLAB version of the AMPL API, as described at http://ampl.com/products/api/, to run AMPL from inside a MATLAB function.

Bob Fourer
am...@googlegroups.com

=======

Christian Hoffmann

unread,
Apr 8, 2015, 12:31:49 PM4/8/15
to am...@googlegroups.com, 4...@ampl.com
Thanks Bob!

I will take a look at this!

Christian
Reply all
Reply to author
Forward
0 new messages