Skip to main content
Log in

TACO: a toolkit for AMPL control optimization

  • Full Length Paper
  • Published:
Mathematical Programming Computation Aims and scope Submit manuscript

Abstract

We describe a set of extensions to the AMPL modeling language to conveniently model mixed-integer optimal control problems for ODE or DAE dynamic processes. These extensions are realized as AMPL user functions and suffixes and do not require intrusive changes to the AMPL language standard or implementation itself. We describe and provide TACO, a Toolkit for AMPL Control Optimization that reads AMPL stub.nl files and detects the structure of the optimal control problem. This toolkit is designed to facilitate the coupling of existing optimal control software packages to AMPL. We discuss requirements, capabilities, and the current implementation. Using the example of the multiple shooting code for optimal control MUSCOD-II, a direct and simultaneous method for DAE-constrained optimal control, we demonstrate how the problem information provided by the TACO toolkit is interfaced to the solver. In addition, we show how the MS-MINTOC algorithm for mixed-integer optimal control can be used to efficiently solve mixed-integer optimal control problems modeled in AMPL. We use the AMPL extensions to model three control problem examples and we discuss how those extensions affect the representation of optimal control problems. Solutions to these problems are obtained by using MUSCOD-II and MS-MINTOC inside the AMPL environment. A collection of further AMPL control models is provided on the web site http://mintoc.de. MUSCOD-II and MS-MINTOC have been made available on the NEOS Server for Optimization, using the TACO toolkit to enable input of AMPL models.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Institutional subscriptions

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6
Fig. 7
Fig. 8
Fig. 9
Fig. 10
Fig. 11
Fig. 12
Fig. 13
Fig. 14
Fig. 15

Similar content being viewed by others

References

  1. Abhishek, K., Leyffer, S., Linderoth, T.: FilMINT: an outer approximation-based solver for mixed-integer nonlinear programs. INFORMS J. Comput. 22(4), 555–567 (2010). http://joc.journal.informs.org/content/22/4/555.abstract

  2. Achtziger, W., Kanzow, C.: Mathematical programs with vanishing constraints: optimality conditions and constraint qualifications. Math. Program. Ser. A 114, 69–99 (2008). http://www.mathematik.uni-wuerzburg.de/~kanzow/paper/VanishCP.pdf

  3. Åkesson, J., Årzén, K., Gräfvert, M., Bergdahl, T., Tummescheit. H.: Modeling and optimization with Optimica and JModelica.org–languages and tools for solving large-scale dynamic optimization problems. Comput. Chem. Eng. 34(11), 1737–1749 (2008). http://www.sciencedirect.com/science/article/pii/S009813540900283X

  4. Albersmeyer, J.: Adjoint based algorithms and numerical methods for sensitivity generation and optimization of large scale dynamic systems. PhD thesis, Ruprecht-Karls-Universität Heidelberg (2010). http://www.ub.uni-heidelberg.de/archiv/11651

  5. Andreani, R., Birgin, E., Martinez, J., Schuverdt, M.: On augmented Lagrangian methods with general lower-level constraints. SIAM J. Optim. 18, 1286–1309 (2007). http://www.optimization-online.org/DB_FILE/2005/03/1085.pdf

  6. Andreani, R., Birgin, E., Martinez, J., Schuverdt, M.: Augmented Lagrangian methods under the constant positive linear dependence constraint qualification. Math Program 111, 5–32 (2008). http://www.ime.usp.br/~egbirgin/publications/abms.pdf

  7. Barton, P., Pantelides, C.: gPROMS—a combined discrete/continuous modelling environment for chemical processing systems. Simul. Ser. 25, 25–34 (1993)

    Google Scholar 

  8. Bauer, I., Bock, H., Körkel, S., Schlöder, J.: Numerical methods for initial value problems and derivative generation for DAE models with application to optimum experimental design of chemical processes. In: Scientific Computing in Chemical Engineering II, pp 282–289. Springer, Berlin (1999). http://hgs.iwr.uni-heidelberg.de/expdesign/people/skoerkel/publications/?name=scce99-bauer.ps.gz&type=application/postscript

  9. Belotti, P.: Couenne: a user’s manual. Tech. rep., Lehigh University (2009). http://www.coin-or.org/Couenne/couenne-user-manual.pdf

  10. Betts, J., Eldersveld, S., Huffman, W.: Sparse nonlinear programming test problems (Release 1.0). Tech. rep. BCSTECH-93-074, Boeing Computer Services (1993)

  11. Bock, H., Plitt, K.: A multiple shooting algorithm for direct solution of optimal control problems. In: Proceedings of the 9th IFAC World Congress, pp 242–247. Pergamon Press, Budapest (1984). http://www.iwr.uni-heidelberg.de/groups/agbock/FILES/Bock1984.pdf

  12. Bonami, P., Biegler, L., Conn, A., Cornuéjols, G., Grossmann, I., Laird, C., Lee, J., Lodi, A., Margot, F., Sawaya, N., Wächter, A.: An algorithmic framework for convex mixed integer nonlinear programs. Discrete Optim 5(2), 186–204 (2008). http://www.sciencedirect.com/science/article/pii/S1572528607000448

    Google Scholar 

  13. Box, G., Hunter, W., MacGregor, J., Erjavec, J.: Some problems associated with the analysis of multiresponse data. Technometrics 15, 33–51 (1973). http://www.jstor.org/stable/1266823

    Google Scholar 

  14. Bryson, A., Ho, Y.: Applied optimal control: optimization, estimation, and control. Wiley, Hoboken (1975)

    Google Scholar 

  15. Byrd, R.H., Hribar, M.E., Nocedal, J.: An interior point algorithm for large scale nonlinear programming. SIAM J. Optim. 9(4), 877–900 (1999)

    Article  MathSciNet  MATH  Google Scholar 

  16. Byrd, R.H., Gilbert, J.C., Nocedal, J.: A trust region method based on interior point techniques for nonlinear programming. Math. Program. 89, 149–185 (2000). http://www.ece.northwestern.edu/~nocedal/PSfiles/nitro.ps.gz

    Google Scholar 

  17. Byrd, R.H., Nocedal, J., Waltz, R.A.: Knitro: an integrated package for nonlinear optimization. In: di Pillo, G., Roma, M. (eds.) Large-scale nonlinear optimization, pp 35–59. Springer, Berlin (2006). http://www.ziena.com/papers/integratedpackage.pdf

  18. Cesari, L.: Optimization—theory and applications. Springer, Berlin (1983)

    MATH  Google Scholar 

  19. Conn, A.R., Gould, N.I.M., Toint, P.L.: LANCELOT: A Fortran Package for Large-Scale Nonlinear Optimization (Release A). Springer, Heidelberg (1992)

    MATH  Google Scholar 

  20. Cuthrell, J., Biegler, L.: On the optimization of differential-algebraic process systems. AIChE 33, 1257–1270 (1987). http://onlinelibrary.wiley.com/doi/10.1002/aic.690330804/abstract

  21. Diehl, M.: Real-time optimization for large scale nonlinear processes. PhD thesis, Ruprecht-Karls-Universität Heidelberg (2001). http://archiv.ub.uni-heidelberg.de/volltextserver/volltexte/2001/1659/

  22. Diehl, M., Leineweber, D., Schäfer, A.: MUSCOD-II Users’ Manual. IWR Preprint 2001–25, Interdisciplinary Center for Scientific Computing (IWR), Ruprecht-Karls-Universität Heidelberg, Im Neuenheimer Feld 368, 69120 Heidelberg, Germany (2001). http://www.iwr.uni-heidelberg.de/groups/agbock/FILES/muscod_manual.pdf

  23. Diehl, M., Bock, H., Kostina, E.: An approximation technique for robust nonlinear optimization. Math. Program. 107, 213–230 (2006). https://lirias.kuleuven.be/bitstream/123456789/70656/1/06-226.pdf

    Google Scholar 

  24. Dolan, E., Moré, J., Munson, T.: Benchmarking Optimization Software with COPS 3.0. Tech. rep. ANL/MCS-TM-273, Mathematics and Computer Science Division, Argonne National Laboratory, 9700 South Cass Avenue, Argonne, IL 60439, USA (2004). http://www.mcs.anl.gov/~more/cops/cops3.pdf

  25. Elmqvist, H., Brück, D.: Dymola–dynamic modeling language. User’s manual, Dynasim AB (2001)

  26. Fletcher, R., Leyffer, S.: User manual for filterSQP. Tech. rep., University of Dundee (1999). http://www.mcs.anl.gov/~leyffer/papers/SQP_manual.pdf

  27. Floudas, C., Pardalos, P., Adjiman, C., Esposito, W., Gumus, Z., Harding, S., Klepeis, J., Meyer, C., Schweiger, C.: Handbook of Test Problems for Local and Global Optimization. Kluwer, Dordrecht (1999)

    Book  Google Scholar 

  28. Fourer, B., Ferris, M.C., Gay, D.M.: Expressing complementarity problems and communicating them to solvers. SIAM J. Optim. 9, 991–1009 (1999). http://ftp2.cs.wisc.edu/math-prog/tech-reports/98-02.pdf

  29. Fourer, R., Gay, D., Kernighan, B.: A modeling language for mathematical programming. Manage. Sci. 36, 519–554 (1990). http://www.jstor.org/pss/2632268

    Google Scholar 

  30. Fourer, R., Gay, D.M., Kernighan, B.W.: AMPL: A Modelling Language for Mathematical Programming, 2nd edn. Books/Cole-Thomson Learning (2003)

  31. Gay, D.M.: Hooking your solver to AMPL. Tech. rep., Bell Laboratories, Murray Hill, NJ (1993; revised 1994, 1997). http://www.ampl.com/REFS/download.html#pdf

  32. Gill, P., Murray, W., Saunders, M., Wright, M.: User’s guide for NPSOL Version 5.0: a Fortran package for nonlinear programming. Report SOL 86–1, Dept. of Mathematics, University of California, San Diego (1998) http://cam.ucsd.edu/~peg/papers/npdoc.pdf

  33. Gill, P., Murray, W., Saunders, M.: SNOPT: An SQP algorithm for large-scale constrained optimization. SIAM J. Optim. 12, 979–1006 (2002). http://www.stanford.edu/group/SOL/papers/SNOPT-SIGEST.pdf

  34. Gropp, W., Moré, J.: Optimization environments and the NEOS Server. In: Buhmann M, Iserles A (eds.) Approximation theory and optimization, pp 167–182. Cambridge University Press, Cambridge (1997). ftp://ftp.mcs.anl.gov/pub/tech_reports/reports/P654.ps.Z

  35. Hatz, K.: Estimating parameters in optimal control problems. Ruprecht-Karls-Universität Heidelberg, Diploma thesis (2008)

  36. Kameswaran, S., Biegler, L.: Advantages of nonlinear-programming-based methodologies for inequality path-constrained optimal control problems - a numerical study. SIAM J. Sci. Comput. 30, 957–981 (2008). http://numero.cheme.cmu.edu/uploads/paper12.pdf

  37. Kirches, C.: Fast numerical methods for mixed-integer nonlinear model-predictive control. PhD thesis, Ruprecht-Karls-Universität Heidelberg (2010). http://www.ub.uni-heidelberg.de/archiv/11636/

  38. Kočvara, M., Stingl, M.: PENNON–a code for convex nonlinear and semidefinite programming. Optim. Methods Softw. 18(3), 317–333 (2003). http://web.mat.bham.ac.uk/kocvara/pennon/paper_OMS.pdf

  39. Kočvara, M., Stingl, M.: PENNON User’s Guide (Version 0.9). PENOPT (2008). http://www.penopt.com/doc/pennon0_9.pdf.

  40. Kühl, P., Milewska. A., Diehl, M., Molga, E., Bock, H.: NMPC for runaway-safe fed-batch reactors. In: Proc. Int. Workshop on Assessment and Future Directions of NMPC, pp. 467–474 (2005). http://www.kuleuven.be/optec/OLD/research/subgroups/fastMPC/publications/Kuehl2005.pdf

  41. Leineweber, D.: Analyse und Restrukturierung eines Verfahrens zur direkten Lösung von Optimal-Steuerungsproblemen. Ruprecht-Karls-Universität Heidelberg, Diploma thesis (1995)

  42. Leineweber, D.: Efficient reduced SQP methods for the optimization of chemical processes described by large sparse DAE models, Fortschritt-Berichte VDI Reihe 3, Verfahrenstechnik, vol. 613. VDI Verlag, Düsseldorf (1999)

    Google Scholar 

  43. Leineweber, D., Bauer, I., Schäfer, A., Bock, H., Schlöder, J.: An efficient multiple shooting based reduced SQP strategy for large-scale dynamic process optimization (Parts I and II). Comput. Chem. Eng. 27, 157–174 (2003). http://www.iwr.uni-heidelberg.de/groups/agbock/USER_PAGES/LEINEWEBER_DANIEL/WWW/mc2_part1.pdf, http://www.iwr.uni-heidelberg.de/groups/agbock/USER_PAGES/LEINEWEBER_DANIEL/WWW/mc2_part2.pdf

    Google Scholar 

  44. Leyffer, S.: User manual for MINLP. University of Dundee (1998)

  45. Logsdon, J., Biegler, L.: Decomposition strategies for large-scale dynamic optimization problems. Chem. Eng. Sci. 47(4), 851–864 (1992). http://www.sciencedirect.com/science/article/pii/000925099280272E

    Google Scholar 

  46. Maria, G.: An adaptive strategy for solving kinetic model concomitant estimation-reduction problems. Can. J. Chem. Eng. 67, 825 (1989). http://onlinelibrary.wiley.com/doi/10.1002/cjce.5450670514/abstract

    Google Scholar 

  47. Mattsson, S., Elmqvist, H., Broenink, J.: Modelica: an international effort to design the next generation modelling language. J. A Benelux Q. J. Autom. Control 38(3), 16–19 (1997), special issue on Computer Aided Control System Design, CACSD (1998). https://www.modelica.org/publications/papers/CACSD97Modelica.pdf

  48. Milewska, A.: Modelling of batch and semibatch chemical reactors—safety aspects. PhD thesis, Warsaw University of Technology (2006)

  49. Moessner-Beigel, M.: Optimale Steuerung für Industrieroboter unter Berücksichtigung der getriebebedingten Elastizität. Diploma thesis Ruprecht-Karls-Universität Heidelberg (1995)

  50. Murtagh, B., Saunders, M.: MINOS 5.4 user’s guide. Report SOL 83–20R, Department of Operations Research, Stanford University (1993)

  51. Nocedal, J., Wright, S.: Numerical Optimization, 2nd edn. Springer, Berlin (2006)

    MATH  Google Scholar 

  52. Petzold, L., Li, S., Cao, Y., Serban, R.: Sensitivity analysis of differential-algebraic equations and partial differential equations. Comput. Chem. Eng. 30, 1553–1559 (2006). http://www.sciencedirect.com/science/article/pii/S0098135406001487

  53. Plitt, K.: Ein superlinear konvergentes Mehrzielverfahren zur direkten Berechnung beschränkter optimaler Steuerungen. Diploma thesis Rheinische Friedrich-Wilhelms-Universität Bonn (1981)

  54. Potschka, A., Bock, H., Schlöder, J.: A minima tracking variant of semi-infinite programming for the treatment of path constraints within direct solution of optimal control problems. Optim. Methods Softw. 24(2), 237–252 (2009). http://www.tandfonline.com/doi/abs/10.1080/10556780902753098

  55. Rothschild, B., Sharov, A., Kearsley, A., Bondarenko, A.: Estimating growth and mortality in stage-structured populations. J. Plankton Res. 19, 1913–1928 (1997). http://plankt.oxfordjournals.org/content/19/12/1913.full.pdf

    Google Scholar 

  56. Rutquist, P., Edvall, M.: PROPT–Matlab Optimal Control Software. User’s manual, TOMLAB Optimization (2010). http://tomopt.com/docs/TOMLAB_PROPT.pdf

  57. Sager, S.: Numerical methods for mixed-integer optimal control problems. Der andere Verlag, Tönning, Lübeck, Marburg (2005). http://mathopt.uni-hd.de/PUBLICATIONS/Sager2005.pdf

  58. Sager, S.: A benchmark library of mixed-integer optimal control problems. In: Proceedings MINLP09 (2011). http://mathopt.uni-hd.de/PUBLICATIONS/Sager2011b.pdf

  59. Sager, S., Bock, H., Diehl, M.: The integer approximation error in mixed-integer optimal control. Math. Program. A (2011). doi:10.1007/s10107-010-0405-3. http://mathopt.uni-hd.de/PUBLICATIONS/Sager2011.pdf

  60. von Stryk, O.: User’s guide for DIRCOL (Version 2.1): a direct collocation method for the numerical solution of optimal control problems. Tech. rep., Technische Universität München, Germany (1999)

  61. Tjoa, I.B., Biegler, L.: Simultaneous solution and optimization strategies for parameter estimation of differential-algebraic equations systems. Ind. Eng. Chem. Res. 30, 376–385 (1991). http://pubs.acs.org/doi/abs/10.1021/ie00050a015

  62. Vanderbei, R., Shanno, D.: An interior point algorithm for nonconvex nonlinear programming. COAP 13, 231–252 (1999). http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.25.4065&rep=rep1&type=pdf

  63. Wächter, A., Biegler, L.: On the implementation of an interior-point filter line-search algorithm for Large-Scale Nonlinear Programming. Math. Program. 106(1), 25–57 (2006). http://www.springerlink.com/content/r31116mp70171220/

Download references

Acknowledgments

The research leading to these results has received funding from the European Union Seventh Framework Programme FP7/2007-2013 under grant agreement no FP7-ICT-2009-4 248940. The first author acknowledges a travel grant by Heidelberg Graduate Academy, funded by the German Excellence Initiative. We thank Hans Georg Bock, Johannes P. Schlöder, and Sebastian Sager for permission to use the optimal control software package MUSCOD-II and the mixed-integer optimal control algorithm MS-MINTOC. This work was also supported by the Office of Advanced Scientific Computing Research, Office of Science, U.S. Department of Energy, under Contract DE-AC02-06CH11357, and by the Directorate for Computer and Information Science and Engineering of the National Science Foundation under award NSF-CCF-0830035.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Christian Kirches.

Appendices

Appendices

The following sections contain supplementary material intended to guide software developers interested in using the presented TACO toolkit to interface their optimal control software packages with AMPL. Appendix A explains the most important data structures that hold information about the mapping from the optimal control point of view to the AMPL view. Appendix B lists functions available to optimal control software package developers for evaluating AMPL functions. Appendix C explains error codes emitted by the TACO toolkit, and mentions possible remedies.

Appendix A: TACO data structures exposed to optimal control problem solvers

This sections lists TACO data structures exposed to developers of software packages for solving optimal control problems. We discuss several snippets taken from the header file ocp_frontend.h, which should be consulted for additional details.

1.1 A.1: Data structures mapping from AMPL to optimal control

The optimal control frontend provides a collection of fields that hold the optimal control problem interpretation of every AMPL variable passed to the solver. They are laid out as follows:

figure a

The field vartypes gives the OCP variable type of an AMPL variable, that is, whether the variable is \(t\), \(T\), a component of vector \(p\), or a component of one of the vector trajectories \(x\), \(z\), or \(u\) and \(w\). For the case of it being a vector component, the field varindex holds the index into the OCP variable or trajectory vector. For AMPL constraints and objectives, no mapping information from AMPL to the OCP perspective is provided.

1.2 A.2: Data structures mapping from optimal control to AMPL

The AMPL optimal control frontend provides a collection of structures holding the AMPL perspective for every component of an optimal control problem according to problem class (MIOCP). Starting with information about problem dimensions, the following variables are provided and should be self-explanatory.

figure b

Information about both the independent time variable and the end-time variable is held in a structured variable named endtime of the following layout.

figure c

For a fixed-endtime scenario, endtime.index is \(-1\), the field endtime.init holds the fixed end time. For a variable end-time scenario, endtime.index is nonnegative and the field endtime.init holds the initial guess for the free end time if available, and is set to \(1.0\) otherwise.

The following structured variable xstates holds information about differential state trajectory variables, and associated right-hand side functions.

figure d

Here, the field fixed holds the AMPL index of the initial value constraint for this ODE state. It is \(-1\) if the ODE state’s initial value is free. The initializer init provides two values for linear interpolation (see suffix .interp_to).

The field ffcn_index holds the AMPL constraint index of the right-hand side function associated with a differential state. Even though we currently support explicit ODEs only, AMPL-internal rearrangement of constraint expressions may cause a negative sign on the diff() call. Hence the field rhs_factor is introduced to compensate for AMPL-internal representations of the form \(-\dot{x}(t) = f(t,x(t),\ldots )\).

Similar to differential states, the structured variable zstates holds information about algebraic state trajectories.

figure e

It is important to keep in mind that DAE constraints are not associated with algebraic state trajectory variables by a one-to-one mapping. We merely keep both in the same array for simplicity, since their numbers must match.

Information about integer and continuous control trajectories is kept in a structured variable named controls with the following layout.

figure f

The field type denotes the (solver-dependent) discretization type to be applied to this control trajectory. The field integer is set to \(1\) if the control is a binary or integer control and to \(0\) if it is a continuous control. For piecewise linear and piecewise cubic discretization types, additional information about slope limits and initial guesses is provided.

In addition, model parameters information is provided in a structured variable named params, with layout as follows. This concludes AMPL variables information.

figure g

Information about Mayer-type, Lagrange-type, and integral least-squares-type objective functions (1a) is found in structured variables named mayer, lagrange, and clsq. Their layout is presented below. In this representation, the optimal control problem objective may consist of multiple parts that are summed up, see Eq. (1a), although only one part of each objective type is allowed. Problem solvers may want to support feasibility problems that do not have an objective function at all.

figure h

dpnd is a bit field with bit \(k\) (\(k\ge 0\)) set if and only if the objective function’s AMPL expression depends on an AMPL variable with vartypes entry set to value \(k\) (see enum vartype_t). This allows for quick dependency checks that may save runtime, for example, in derivative approximation. The field maximize is set to \(1\) if the objective function is to be maximized and to \(0\) if it is to be minimized. Note that least-squares functions are recognized only if they are to be minimized. The fields nparts and parts hold information about the AMPL expression DAGs associated with the individual least-squares residual expressions of a least-squares objective.

Path constraints (1d) and coupled constraints (1e) information is held in structured variables named pathcon, cpcon_eq, and cpcon_in with the following layout.

figure i

Path constraints (1d) always are inequality constraints. For coupled constraints (1e), equality and inequality constraints are stored in separate arrays. For two-sided inequality constraints \(l\le c(x)\le u\), the field side indicates which side of the constraint should be evaluated.

Information about decoupled point constraints (1f) and point least-squares objectives (1a) is stored in a structured variable named grid. For each objective or constraint evaluation time, a grid node is introduced and holds information about the associated objective or constraint. Grid nodes are guaranteed to be unique, in other words, no two nodes share the same time point, and they are sorted in ascending order. The grid is guaranteed to contain at least two nodes: the first grid node will always be at time \(0\), and the last grid node will always be at time \(t_\text{ f }\).

For equality and inequality point constraints (1f) on a grid node, the fields n_eq and n_in hold the dimensions and the fields con_eq and con_in the constraint information, respectively. For coupled constraints (1e), we do not store pointers to constraint information structures, but rather indices into the global lists of coupled constraints cpcon_eq and cpcon_in. For solvers requiring linear separability of coupled constraints, this layout eases the setup of the coupled constraints’ block structure. The field lsq holds information about the point least-squares objective contribution in a node; again index \(-1\) indicates that no point least-squares objective is present.

Appendix B: TACO functions exposed to optimal control problem solvers

This sections lists TACO functions exposed to developers of software packages for solving optimal control problems.

Reading of the AMPL model. For reading and verifying the AMPL mode as well as creation of management of the database, the optimal control frontend provides the following functions:

void allocate_mappings()

  • allocates memory for the database to be created, prior to reading the stub.nl file provided by AMPL.

void read_mappings()

  • calls the AMPL solver library to read the stub.nl file. Afterwards, the DAGs of all AMPL objectives and constraints are examined for appearance of variables, calls to user functions, and nonsmooth operators. The role of AMPL variables, constraints, and objectives in class (MIOCP) is determined, and the database is filled with appropriate information.

void free_mappings()

  • frees memory allocated for the database after the optimal control problem has been solved.

A developer wishing to interface an optimal control problem solver with AMPL is provided with a number of functions that infer the optimal control problem’s structure from a stub.nl file, as shown in Fig. 11.

Evaluating problem functions. Once the database has been successfully filled with the optimal control problem representation of the AMPL model, an appropriate optimal control problem solver can be called. This solver will have to evaluate problem functions. For conveniently doing so, the optimal control frontend provides a set of functions that wrap around the conival and objival functions provided by AMPL’s solver library:

double evaluate_ode_rhs(i,y)

  • evaluates the ODE right-hand side \(\dot{x}_i(t)=f_i(\cdot )\), see Eq. (1b), for a differential state \(x_i(t)\), \(0 \le i < n_\text{ x }\). The vector y here is the plain vector of current AMPL variable values.

double evaluate_dae_rhs(i,y)

  • evaluates the residual of DAE constraint \(g_i(\cdot )\), \(0\le i < n_\text{ z }\), see Eq. (1c).

double evaluate_scaled_mayer(y)

  • evaluates and scales the value of the Mayer objective term, see Eq. (1a), if a Mayer term exists.

double evaluate_scaled_lagrange(y)

  • evaluates and scales the value of the Lagrange objective term’s integrand, see Eq. (1a), if a Lagrange objective exists.

void evaluate_scaled_clsq(y,res)

  • evaluates and scales the value of the Lagrange objective term’s integrand, see Eq. (1a), if the integrand has least-squares structure and if a Lagrange objective exists. Upon return the vector res holds the least-squares residuals, that is, the individual values of each squared summand.

void evaluate_scaled_node_lsq(n,y,res)

  • evaluates one summand of a point least-squares objective term, see Eq. (1a), if one exists. The integer n specified the number \(0<n<N_\text{ lsq }\) of the measurement point to be evaluated.

double evaluate_path_con(i,y)

  • evaluates and scales the residual of an inequality path constraint, see Eq. (1d),

double evaluate_coupled_eq_con(i,y)

  • evaluates and scales the residual of a coupled equality constraint, see Eq. (1e),

double evaluate_coupled_ineq_con(i,y)

  • evaluates and scales the residual of a coupled inequality constraint, see Eq. (1e),

double evaluate_point_eq_con(n,i,y)

  • evaluates and scales the residual of an equality point constraint, see Eq. (1f),

double evaluate_point_ineq_con(n,i,y)

  • evaluates and scales the residual of an inequality point constraint, see Eq. (1f),

Writing solutions from a solver. To write a solution file of the proposed format, the optimal control frontend provides three function calls to be used by a backend interfacing an optimal control problem solver with AMPL:

void alloc_solution(solution, gridlength)

  • allocates a solution structure given a discretization grid length.

void write_solution(solution, filename)

  • writes a solution file according to the new format and fills it with the solution data found in the solution structure. The solver backend should have queried the solver itself for this solution and copied it over to this solution structure.

void free_solution(solution)

  • free a previously allocated solution structure after it has been written to a solution file.

Appendix C: TACO toolkit error messages

TACO performs a range of consistency tests during the analysis and verification of the optimal control problem structure. If option solvername _auxfiles is set to contain the characters “r” and “c”, error messages will show the name of the offending variable, objective, or constraint. Codes 1 to 5 are reserved for internal errors; the remaining error messages are:

  1. 6.

    AMPL error reading stub.nl file filename” AMPL could not read the stub.nl file.

  2. 7.

    AMPL error getting solver options” AMPL could not read the solver options. Make sure your solver options string contains known keywords and valid values only.

  3. 8.

    I/O error writing solution file filename” AMPL could not write the solution file. Make sure that the current working directory is writeable and that the volume is not full.

  4. 9.

    AMPL network variables are not supported” The AMPL model contains network variables. Network modeling is currently not supported.

  5. 10.

    AMPL piecewise linear terms are not supported” The AMPL model contains piecewise linear terms. Nonsmooth models are currently not supported.

  6. 11.

    diff() must be called exactly once for each differential state variable” You called diff() more than once for the same variable. Every differential state variable is associated with exactly one right hand side function. Most likely, this is a typo in your model.

  7. 12.

    Logical operator operator not permitted” The shown constraint or objective make use of a logical operator. Nonsmooth models are currently not supported.

  8. 13.

    Relational operator operator not permitted” The shown constraint or objective make use of a relational operator. Nonsmooth models are currently not supported.

  9. 14.

    Nonsmooth operator operator not permitted” The shown constraint or objective make use of a nonsmooth operator. Nonsmooth models are currently not supported.

  10. 15.

    ODE constraints must be equality constraints” You called diff() in an inequality constraint. All ODE constraints must be equality constraints, though.

  11. 16.

    Cannot determine type of objective functions” The shown objective cannot be determined to be of Mayer, Lagrange, integral least-squares, or point least-squares type. Please refer to Section 2.3 to learn about the structure of supported objective functions.

  12. 17.

    Mayer objective function must not depend on controls” The indicated objective is of Mayer type, and hence must not depend on control trajectory variables.

  13. 18.

    The number of DAE constraints does not match the apparent number of algebraic variab- les” The number of DAE constraints found in your model does not match the number of algebraic variables you have declared by letting suffix .type to value "dae". Make sure you’ve set the suffix of all algebraic state variables, and make sure all your DAE constraints are equality constraints.

  14. 19.

    Invalid value for suffix .type” A variable, constraint, or objective has suffix .type set to an unrecognized value. This should not happen unless you’re using an incompatible OptimalControl.mod file.

  15. 20.

    Missing independent time variable or end time variable” TACO could not determine which AMPL variables represent independent time or end time. Make sure that the independent time variable appears as second argument to all diff() calls, and that the end-time variable appears as second argument to integral() in Lagrange-type objectives, or to eval() in Mayer-type objectives or end-point constraints. If your AMPL model uses a time horizon of fixed length, make sure the end-time value shows up consistently in these places.

  16. 21.

    Nesting a call to function name inside another is not allowed” You nested two calls to functions diff(), eval(), or integral(). This should never be necessary.

  17. 22.

    As of now, diff() must be explicit. Try to write your ODE as diff(var, t) = ...;” The AMPL optimal control frontend currently supported explicit ODEs only, i.e. the permitted formulation is \(\dot{x}(t)=f(t,x(t),\ldots )\) instead of the more general \(0=f(t,x(t),\dot{x}(t),\ldots )\). Try to rewrite your model to use explicit ODEs only.

  18. 23.

    First argument to eval() must not be a constant” The shown constraint or objective calls eval() with two constant arguments. This is not sensible. Either remove the calls to eval(), or make sure the expression to be evaluated references independent time or at least one state or control trajectory variable.

  19. 24.

    Second argument to eval() must be >= 0.0, or the final time variable” The shown constraint or objective calls eval() with a time point that a) evaluates to a negative value, or b) is not a simple constant and not the end-time variable.

  20. 25.

    First argument to integral() must not be a constant” An objective calls integral() with two constant arguments. This is not sensible. Either remove the call to integral(), or make sure the expression to be integrated references independent time or at least one state or control trajectory variable.

  21. 26.

    Second argument to integral() must be the final time variable” The second argument of a call to integral() must be the final time variable, or the final time itself.

  22. 27.

    Second argument to diff() must be the independent time variable” The second argument of a call to diff() must be the independent time variable.

  23. 28.

    Function diff() expects differential state variable and independent time variable as arguments” The first argument to diff must be a differential state trajectory variable, and the second argument of a call to diff() must be the independent time variable.

  24. 29.

    Calls to integral() not allowed in constraints” The function integral() was called inside a constraint expression. Calls to integral() are only allowed in a Lagrange-type or integral least-squares-type objective.

  25. 30.

    Function call to name must enclose entire expression” Calls to eval() and integral() must enclose the entire expression to be evaluated or integrated.

  26. 31.

    Only controls or parameters can be binary/integer variables” AMPL’s binary or integer restriction may be applied to control trajectory variables and model parameter variables only. Time as well as differential and algebraic state trajectory variables must be continuous.

  27. 32.

    Invalid grid node position, must be within [0,1] (tf free) or [0,tf] (tf fixed)” A call to eval() used an invalid evaluation time. Allowed times are constants \(0\) to \(1\), being relative times on the time horizon \([0,t_\text{ f }]\) if \(t_\text{ f }\) is free, absolute times \(0\) to \(t_\text{ f }\) if \(t_\text{ f }\) is fixed, or the end-time variable \(t_\text{ f }\) itself.

  28. 33.

    Duplicate objective of name -type” At most one objective of Mayer-, Lagrange-, and least-squares type is allowed per problem.

  29. 34.

    Calls to eval() not allowed in ODE constraints” The function eval() was called inside an ODE constraint expression. This is not allowed.

  30. 35.

    Calls to diff() not allowed in objective functions” The function diff() was called inside an objective function expression. This is not allowed.

Rights and permissions

Reprints and permissions

About this article

Cite this article

Kirches, C., Leyffer, S. TACO: a toolkit for AMPL control optimization. Math. Prog. Comp. 5, 227–265 (2013). https://doi.org/10.1007/s12532-013-0054-7

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s12532-013-0054-7

Keywords

Mathematics Subject Classification (2010)

Navigation