Call AMPL files from Mtlab

33 views
Skip to first unread message

Hajem Daham

unread,
Dec 1, 2016, 8:33:44 AM12/1/16
to AMPL Modeling Language
Hi all,

I code a Mixed integer programming model in AMPL  and I try to call the model and data from Matlab without any manual interruption, could you advice me please.  

Robert Fourer

unread,
Dec 2, 2016, 12:48:29 PM12/2/16
to am...@googlegroups.com
There is an AMPL API for MATLAB, described at http://ampl.com/products/api/, that permits the activities of an AMPL session to be controlled directly by MATLAB statements. You can use the API to run AMPL interactively from the MATLAB console, though more often the API is used to write MATLAB application programs (m-files) that embed AMPL models and calls to solvers.

Also for some applications you can use a simpler approach, where you (1) have MATLAB write a file of data for AMPL, (2) execute a MATLAB command like "!ampl test.run" to start the AMPL program and give it a script file, and (3) have MATLAB read a file of results. The AMPL script file test.run must at least (a) read an AMPL model, (b) read the data file that MATLAB wrote for the model, (c) invoke a solver, and (d) write the result file for MATLAB -- though the AMPL script may do other processing as well.

Bob Fourer
am...@googlegroups.com

=======

Hajem Daham

unread,
Dec 5, 2016, 5:05:49 AM12/5/16
to AMPL Modeling Language, 4...@ampl.com
Thank you very much for this information.
Reply all
Reply to author
Forward
0 new messages