The AMPL language does not have a feature comparable to a Fortran subroutine or
C function. At most, you can use "commands" to specify the execution of one
AMPL script within a loop in another AMPL script.
You can also use AMPL's "shell" command within a loop, to call the executable
binary of a function that has been written and compiled in another language.
Communication between AMPL and the external function has to be via files,
though.
A third possibility (to which Hans Mittelmann alluded) is to write a C program
that can be compiled into an executable binary -- a Windows dll or Unix shared
library -- that is accessible as a "user-defined function" within AMPL. The
most detailed description of user-defined functions can be found in "Hooking
Your Solver to AMPL", www.ampl.com/REFS/abstracts.html#hooking2, pages 18-19.
There are also some further comments on this facility in later pages, with
references to example files available at www.netlib.org/ampl/solvers/examples.
Another example of implementing user-defined functions is given by Bob
Vanderbei at www.sor.princeton.edu/~rvdb/ampl/nlmodels.
Bob Fourer
4...@ampl.com
I wasted 4 hours trying to find the same thing in GAMS.
It mystifies me why this is not supported.
My objective function is 90 characters long if typed out on one line.
I wanted to break it down into a series of comprehensible intermediate
calculations, to make it human-readable.
--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To view this discussion on the web visit https://groups.google.com/d/msg/ampl/-/SdmsVizTaXgJ.
To post to this group, send email to am...@googlegroups.com.
To unsubscribe from this group, send email to ampl+uns...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ampl?hl=en.