APMonitor Documentation

APMonitor, or "Advanced Process Monitor" is optimization software for mixed-integer and differential algebraic equations. It is coupled with large-scale solvers for linear, quadratic, nonlinear, and mixed integer programming (LP, QP, NLP, MILP, MINLP). Modes of operation include data reconciliation, moving horizon estimation, real-time optimization, dynamic simulation, and nonlinear predictive control with solution capabilities for high-index differential and algebraic (DAE) equations. It is available as a MATLAB toolbox, a Python module, a Julia package, or from a web browser interface.

The APMonitor modeling language is a high-level abstraction of mathematical optimization problems. Values in the models are defined by Constants, Parameters, and Variables. The values are related to each other by Intermediates or Equations. Objective functions are defined to maximize or minimize certain values. Objects are built-in collections of values (constants, parameters, and variables) and relationships (intermediates, equations, and objective functions). Objects can build upon other objects with object-oriented relationships.   APMonitor compiles a model to byte-code and performs model reduction based on analysis of the sparsity structure (incidence of variables in equations or objective function) of the model. For differential and algebraic equation systems, orthogonal collocation on finite elements is used to transcribe the problem into a purely algebraic system of equations.

Modes of Operation

APMonitor has several modes of operation, adjustable with the APM.IMODE parameter. The core of all modes is the model (linear or nonlinear).  Each mode interacts with the nonlinear model to receive or provide information.  The 9 modes of operation are:  

  • Steady-state simulation (SS)
  • Model parameter update (MPU)
  • Real-time optimization (RTO)
  • Dynamic simulation (SIM)
  • Moving horizon estimation (EST)
  • Nonlinear control / dynamic optimization (CTL)
  • Sequential dynamic simulation (SQS)
  • Sequential dynamic estimation (SQE)
  • Sequential dynamic optimization (SQO)

APM.IMODE 1-3 modes are steady state options with all derivatives set equal to zero.  Modes 4-6 are dynamic modes where the differential equations define how the variables change with time.  Modes 7-9 are the same as 4-6 except the solution is performed with a sequential versus a simultaneous approach. Each mode for simulation, estimation, and optimization has a steady state and dynamic option. There are many additional application configuration options and parameter and variable options that can be set or retrieved in MATLAB or Python.

Differential and Algebraic Equations

Differential and algebraic (DAE) models are a natural expression of systems that change with time. These dynamic systems may be as simple as a falling apple or as complex as biological metabolic pathways. DAE models are generally easy to write but often difficult to solve analytically. Entire university level courses are devoted to the solution of particular types of differential equations in analytic form. Solution of more complex systems is better handled through numeric approaches. There are many software packages that can solve DAE models for small and medium size problems. APMonitor is designed to solve large-scale problems. Additionally, other software packages often require the user to reformulate the equations into a restrictive form. APMonitor allows an open-equation format that is less restrictive.

Nonlinear and Mixed Integer Solvers

APMonitor uses a simultaneous or sequential solution approach to solve the differential and algebraic equations. The differential equations are converted to algebraic equations and solved with large-scale sparse solvers. There are an assortment of solvers available with various user's licenses, ranging from free and open-source to commercial. APMonitor provides Nonlinear Programming Solvers (such as APOPT, BPOPT, IPOPT, MINOS, SNOPT) are accessed by switching APM.SOLVER. It provides the required information to the solvers by compiling the model to byte code with automatic differentiation for derivatives in sparse form.

  • Variables with default values and constraints
  • Objective function
  • Equations
  • Evaluation of equation residuals
  • Sparsity structure
  • Gradients (1st derivatives)
  • Gradient of the equations
  • Gradient of the objective function
  • Hessian of the Lagrangian (2nd derivatives)
  • 2nd Derivative of the equations
  • 2nd Derivative of the objective function

Viewing Results

Once the solution is complete, APMonitor writes the results in results.csv that is available for transfer from the apm_sol(s,a) function in MATLAB or Python. It also creates several web-interface pages that are accessed with apm_web(s,a). The web-interface includes a sensitivity analysis if APM.SENSITIVITY = 1 (ON).

Advanced Diagnostics

When the system of equations does not converge, APMonitor produces a convergence report in infeasibilities.txt that can be retrieved with apm_get(s,a,'infeasibilities.txt'). There are other levels of debugging that help expose the steps that APMonitor is taking to analyze or solve the problem. Setting APM.DIAGLEVEL to higher levels (0-10) gives more output to the user. Setting APM.COLDSTART to 2 decomposes the problem into irreducible sets of variables and equations to identify infeasible equations or properly initialize a model.

Range of Usage

APMonitor is advanced process control and optimization software for industrial-scale systems. The software interfaces to live systems to provide advanced diagnostics, meet safety and environmental constraints, and drive the process to economic optimum. With rapidly changing feedstock and commodity pricing, this application enables instant and continual realignment to real operating objectives. These may include:

  • Meet regulatory reporting requirements
  • Flow assurance of oil and gas transport pipelines
  • Visualize data from remote locations
  • Reduce alarms by consolidating relevant information
  • Provide soft sensing
  • Automatic control of continuous and batch systems
  • Increase production 3-5% without equipment changes

A number of prebuilt asset models are available with the APMonitor software. The chemical processing modeling package includes reactors, distillation columns, and compressors necessary for industrial scale processes. A modeling language interface to MATLAB and Python extends the applicability for pre- and post-processing of the optimization solution results.

References to Cite

Please consider citing the following article for the APMonitor Optimization Suite.

  • Hedengren, J. D. and Asgharzadeh Shishavan, R., Powell, K.M., and Edgar, T.F., Nonlinear Modeling, Estimation and Predictive Control in APMonitor, Computers and Chemical Engineering, Volume 70, pg. 133–148, 2014, DOI: 10.1016/j.compchemeng.2014.04.013. Article - Preprint - BibTeX - RIS

Other applications of APMonitor are listed on the references page. Please send a note to if you'd like to add a reference to the list.

Discussion Group

Subscribe to APMonitor E-mail List
Visit this group

YouTube Channel