AMPL Functions as Equations

Required Environment

Required Solver

  • IPOPT, CONOPT, SNOPT, or else

User Options

  • Error Halt: activates (yes) or deactives (no) quitting on errors within AMPL.
  • Presolve Accuracy: Sets the accuracy of the presolve phase, which tries to simplify the system of equations by eliminating constant values and replacing trivial terms.
  • Presolve: Activates (1) or deactivates (0) the presolve phase.
  • Solver: Sets the solver option in the run file for AMPL. Please, inform yourself which solvers are available on your local system or on the NEOS Server. For Ipopt enter ipopt, for Conopt enter conopt, etc.

Usage for Simulation

  1. Open an NLE Evaluation in MOSAIC
  2. Set the variable specs to obtain a degree of freedom of zero.
  3. Select the Predefined Language Specification “AMPL Functions as Equations”.
  4. Choose the Code Generator and Solver Properties in accordance with the User Options above.
  5. Press Generate Code.
  6. Copy everything from the View Code tab and paste it to a text editor.
  7. Separate the code into four parts as described in the code. Search for lines starting with ##. The seperate parts need to be saved as simulation.mod,, simulation.dat, and initial.dat.
  8. Start up a command line (bash or else in Linux, Terminal on Mac OS X, cmd in Windows) or use the AMPL IDE.
  9. In the command line environment, change directories to wherever you stored all files.
  10. Type ampl
  11. After completion AMPL results for reuse in AMPL are saved in results.dat, for reimport into MOSAIC refer to RESULTSforMOSAIC.txt.
  12. Copy the contents of the latter file and paste them into the Import tab of MOSAIC’s evaluation environment.
  13. Select the Predefined Language Specification “AMPL Functions as Equations” and press Import.
  14.  The results will automatically update the Initial values in the Variable Specification tab and can be saved for future use by pressing Save As.