APMonitor

Last updated
APMonitor
Developer(s) APMonitor
Stable release
v1.0.1 / January 31, 2022 (2022-01-31)
Repository https://github.com/APMonitor/
Operating system Cross-platform
Type Technical computing
License Proprietary, BSD
Website APMonitor product page

Advanced process monitor (APMonitor) is a modeling language for differential algebraic (DAE) equations. [1] It is a free web-service or local server for solving representations of physical systems in the form of implicit DAE models. APMonitor is suited for large-scale problems and solves linear programming, integer programming, nonlinear programming, nonlinear mixed integer programming, dynamic simulation, [2] moving horizon estimation, [3] and nonlinear model predictive control. [4] APMonitor does not solve the problems directly, but calls nonlinear programming solvers such as APOPT, BPOPT, IPOPT, MINOS, and SNOPT. The APMonitor API provides exact first and second derivatives of continuous functions to the solvers through automatic differentiation and in sparse matrix form.

Contents

Programming language integration

Julia, MATLAB, Python are mathematical programming languages that have APMonitor integration through web-service APIs. The GEKKO Optimization Suite is a recent extension of APMonitor with complete Python integration. The interfaces are built-in optimization toolboxes or modules to both load and process solutions of optimization problems. APMonitor is an object-oriented modeling language and optimization suite that relies on programming languages to load, run, and retrieve solutions. APMonitor models and data are compiled at run-time and translated into objects that are solved by an optimization engine such as APOPT or IPOPT. The optimization engine is not specified by APMonitor, allowing several different optimization engines to be switched out. The simulation or optimization mode is also configurable to reconfigure the model for dynamic simulation, nonlinear model predictive control, moving horizon estimation or general problems in mathematical optimization.

As a first step in solving the problem, a mathematical model is expressed in terms of variables and equations such as the Hock & Schittkowski Benchmark Problem #71 [5] used to test the performance of nonlinear programming solvers. This particular optimization problem has an objective function and subject to the inequality constraint and equality constraint . The four variables must be between a lower bound of 1 and an upper bound of 5. The initial guess values are . This mathematical model is translated into the APMonitor modeling language in the following text file.

!filesavedashs71.apmVariablesx1=1,>=1,<=5x2=5,>=1,<=5x3=5,>=1,<=5x4=1,>=1,<=5EndVariablesEquationsminimizex1*x4*(x1+x2+x3)+x3x1*x2*x3*x4>25x1^2+x2^2+x3^2+x4^2=40EndEquations

The problem is then solved in Python by first installing the APMonitor package with pip install APMonitor or from the following Python code.

# Install APMonitorimportpippip.main(['install','APMonitor'])

Installing a Python is only required once for any module. Once the APMonitor package is installed, it is imported and the apm_solve function solves the optimization problem. The solution is returned to the programming language for further processing and analysis.

# Python example for solving an optimization problemfromAPMonitor.apmimport*# Solve optimization problemsol=apm_solve("hs71",3)# Access solutionx1=sol["x1"]x2=sol["x2"]

Similar interfaces are available for MATLAB and Julia with minor differences from the above syntax. Extending the capability of a modeling language is important because significant pre- or post-processing of data or solutions is often required when solving complex optimization, dynamic simulation, estimation, or control problems.

High Index DAEs

The highest order of a derivative that is necessary to return a DAE to ODE form is called the differentiation index. A standard way for dealing with high-index DAEs is to differentiate the equations to put them in index-1 DAE or ODE form (see Pantelides algorithm). However, this approach can cause a number of undesirable numerical issues such as instability. While the syntax is similar to other modeling languages such as gProms, APMonitor solves DAEs of any index without rearrangement or differentiation. [6] As an example, an index-3 DAE is shown below for the pendulum motion equations and lower index rearrangements can return this system of equations to ODE form (see Index 0 to 3 Pendulum example).

Pendulum motion (index-3 DAE form)

ModelpendulumParametersm=1g=9.81s=1End ParametersVariablesx=0y=-sv=1w=0lam=m*(1+s*g)/2*s^2End VariablesEquationsx^2+y^2=s^2$x=v$y=wm*$v=-2*x*lamm*$w=-m*g-2*y*lamEnd EquationsEnd Model

Applications in APMonitor Modeling Language

Many physical systems are naturally expressed by differential algebraic equation. Some of these include:

Models for a direct current (DC) motor and blood glucose response of an insulin dependent patient are listed below. They are representative of differential and algebraic equations encountered in many branches of science and engineering.

Direct current (DC) motor

Parameters! motor parameters (dc motor)v=36! input voltage to the motor (volts)rm=0.1! motor resistance (ohms)lm=0.01! motor inductance (henrys)kb=6.5e-4! back emf constant (volt·s/rad)kt=0.1! torque constant (N·m/a)jm=1.0e-4! rotor inertia (kg m²)bm=1.0e-5! mechanical damping (linear model of friction: bm * dth)! load parametersjl=1000*jm! load inertia (1000 times the rotor)bl=1.0e-3! load damping (friction)k=1.0e2! spring constant for motor shaft to loadb=0.1! spring damping for motor shaft to loadEnd ParametersVariablesi=0! motor electric current (amperes)dth_m=0! rotor angular velocity sometimes called omega (radians/sec)th_m=0! rotor angle, theta (radians)dth_l=0! wheel angular velocity (rad/s)th_l=0! wheel angle (radians)End VariablesEquationslm*$i-v=-rm*i-kb*$th_mjm*$dth_m=kt*i-(bm+b)*$th_m-k*th_m+b*$th_l+k*th_ljl*$dth_l=b*$th_m+k*th_m-(b+bl)*$th_l-k*th_ldth_m=$th_mdth_l=$th_lEnd Equations

Blood glucose response of an insulin dependent patient

! Model source:! A. Roy and R.S. Parker. “Dynamic Modeling of Free Fatty !   Acids, Glucose, and Insulin: An Extended Minimal Model,”!   Diabetes Technology and Therapeutics 8(6), 617-626, 2006.Parametersp1=0.068! 1/minp2=0.037! 1/minp3=0.000012! 1/minp4=1.3! mL/(min·µU)p5=0.000568! 1/mLp6=0.00006! 1/(min·µmol)p7=0.03! 1/minp8=4.5! mL/(min·µU)k1=0.02! 1/mink2=0.03! 1/minpF2=0.17! 1/minpF3=0.00001! 1/minn=0.142! 1/minVolG=117! dLVolF=11.7! L! basal parameters for Type-I diabeticIb=0! Insulin (µU/mL)Xb=0! Remote insulin (µU/mL)Gb=98! Blood Glucose (mg/dL)Yb=0! Insulin for Lipogenesis (µU/mL)Fb=380! Plasma Free Fatty Acid (µmol/L)Zb=380! Remote Free Fatty Acid (µmol/L)! insulin infusion rateu1=3! µU/min! glucose uptake rateu2=300! mg/min! external lipid infusionu3=0! mg/minEnd parametersIntermediatesp9=0.00021*exp(-0.0055*G)! dL/(min*mg)End IntermediatesVariablesI=IbX=XbG=GbY=YbF=FbZ=ZbEnd variablesEquations! Insulin dynamics$I=-n*I+p5*u1! Remote insulin compartment dynamics$X=-p2*X+p3*I! Glucose dynamics$G=-p1*G-p4*X*G+p6*G*Z+p1*Gb-p6*Gb*Zb+u2/VolG! Insulin dynamics for lipogenesis$Y=-pF2*Y+pF3*I! Plasma-free fatty acid (FFA) dynamics$F=-p7*(F-Fb)-p8*Y*F+p9*(F*G-Fb*Gb)+u3/VolF! Remote FFA dynamics$Z=-k2*(Z-Zb)+k1*(F-Fb)End Equations

See also

Related Research Articles

<span class="mw-page-title-main">Mathematical optimization</span> Study of mathematical algorithms for optimization problems

Mathematical optimization or mathematical programming is the selection of a best element, with regard to some criterion, from some set of available alternatives. It is generally divided into two subfields: discrete optimization and continuous optimization. Optimization problems arise in all quantitative disciplines from computer science and engineering to operations research and economics, and the development of solution methods has been of interest in mathematics for centuries.

<span class="mw-page-title-main">Partial differential equation</span> Type of differential equation

In mathematics, a partial differential equation (PDE) is an equation which computes a function between various partial derivatives of a multivariable function.

<span class="mw-page-title-main">Optimal control</span> Mathematical way of attaining a desired output from a dynamic system

Optimal control theory is a branch of control theory that deals with finding a control for a dynamical system over a period of time such that an objective function is optimized. It has numerous applications in science, engineering and operations research. For example, the dynamical system might be a spacecraft with controls corresponding to rocket thrusters, and the objective might be to reach the Moon with minimum fuel expenditure. Or the dynamical system could be a nation's economy, with the objective to minimize unemployment; the controls in this case could be fiscal and monetary policy. A dynamical system may also be introduced to embed operations research problems within the framework of optimal control theory.

<span class="mw-page-title-main">Inverse kinematics</span> Computing joint values of a kinematic chain from a known end position

In computer animation and robotics, inverse kinematics is the mathematical process of calculating the variable joint parameters needed to place the end of a kinematic chain, such as a robot manipulator or animation character's skeleton, in a given position and orientation relative to the start of the chain. Given joint parameters, the position and orientation of the chain's end, e.g. the hand of the character or robot, can typically be calculated directly using multiple applications of trigonometric formulas, a process known as forward kinematics. However, the reverse operation is, in general, much more challenging.

In mathematics, nonlinear programming (NLP) is the process of solving an optimization problem where some of the constraints or the objective function are nonlinear. An optimization problem is one of calculation of the extrema of an objective function over a set of unknown real variables and conditional to the satisfaction of a system of equalities and inequalities, collectively termed constraints. It is the sub-field of mathematical optimization that deals with problems that are not linear.

Model predictive control (MPC) is an advanced method of process control that is used to control a process while satisfying a set of constraints. It has been in use in the process industries in chemical plants and oil refineries since the 1980s. In recent years it has also been used in power system balancing models and in power electronics. Model predictive controllers rely on dynamic models of the process, most often linear empirical models obtained by system identification. The main advantage of MPC is the fact that it allows the current timeslot to be optimized, while keeping future timeslots in account. This is achieved by optimizing a finite time-horizon, but only implementing the current timeslot and then optimizing again, repeatedly, thus differing from a linear–quadratic regulator (LQR). Also MPC has the ability to anticipate future events and can take control actions accordingly. PID controllers do not have this predictive ability. MPC is nearly universally implemented as a digital control, although there is research into achieving faster response times with specially designed analog circuitry.

<span class="mw-page-title-main">Differential equation</span> Type of functional equation (mathematics)

In mathematics, a differential equation is an equation that relates one or more unknown functions and their derivatives. In applications, the functions generally represent physical quantities, the derivatives represent their rates of change, and the differential equation defines a relationship between the two. Such relations are common; therefore, differential equations play a prominent role in many disciplines including engineering, physics, economics, and biology.

In mathematics, a differential-algebraic system of equations (DAE) is a system of equations that either contains differential equations and algebraic equations, or is equivalent to such a system.

Sequential quadratic programming (SQP) is an iterative method for constrained nonlinear optimization which may be considered a quasi-Newton method. SQP methods are used on mathematical problems for which the objective function and the constraints are twice continuously differentiable, but not necessarily convex.

<span class="mw-page-title-main">EcosimPro</span> Simulation software

EcosimPro is a simulation tool developed by Empresarios Agrupados A.I.E for modelling simple and complex physical processes that can be expressed in terms of Differential algebraic equations or Ordinary differential equations and Discrete event simulation.

The PROPT MATLAB Optimal Control Software is a new generation platform for solving applied optimal control and parameters estimation problems.

The TomSym MATLAB symbolic modeling engine is a platform for modeling applied optimization and optimal control problems.

Industrial process data validation and reconciliation, or more briefly, process data reconciliation (PDR), is a technology that uses process information and mathematical methods in order to automatically ensure data validation and reconciliation by correcting measurements in industrial processes. The use of PDR allows for extracting accurate and reliable information about the state of industry processes from raw measurement data and produces a single consistent set of data representing the most likely process operation.

Augmented Lagrangian methods are a certain class of algorithms for solving constrained optimization problems. They have similarities to penalty methods in that they replace a constrained optimization problem by a series of unconstrained problems and add a penalty term to the objective, but the augmented Lagrangian method adds yet another term designed to mimic a Lagrange multiplier. The augmented Lagrangian is related to, but not identical with, the method of Lagrange multipliers.

Moving horizon estimation (MHE) is an optimization approach that uses a series of measurements observed over time, containing noise and other inaccuracies, and produces estimates of unknown variables or parameters. Unlike deterministic approaches, MHE requires an iterative approach that relies on linear programming or nonlinear programming solvers to find a solution.

APOPT is a software package for solving large-scale optimization problems of any of these forms:

The proper generalized decomposition (PGD) is an iterative numerical method for solving boundary value problems (BVPs), that is, partial differential equations constrained by a set of boundary conditions, such as the Poisson's equation or the Laplace's equation.

The GEKKO Python package solves large-scale mixed-integer and differential algebraic equations with nonlinear programming solvers. Modes of operation include machine learning, data reconciliation, real-time optimization, dynamic simulation, and nonlinear model predictive control. In addition, the package solves Linear programming (LP), Quadratic programming (QP), Quadratically constrained quadratic program (QCQP), Nonlinear programming (NLP), Mixed integer programming (MIP), and Mixed integer linear programming (MILP). GEKKO is available in Python and installed with pip from PyPI of the Python Software Foundation.

PDE-constrained optimization is a subset of mathematical optimization where at least one of the constraints may be expressed as a partial differential equation. Typical domains where these problems arise include aerodynamics, computational fluid dynamics, image segmentation, and inverse problems. A standard formulation of PDE-constrained optimization encountered in a number of disciplines is given by:

References

  1. J.D. Hedengren; R. Asgharzadeh Shishavan; K.M. Powell; T.F. Edgar (2014). "Nonlinear modeling, estimation and predictive control in APMonitor". Computers & Chemical Engineering. 70 (5): 133–148. doi:10.1016/j.compchemeng.2014.04.013.
  2. Hedengren, J. (2008). "A Nonlinear Model Library for Dynamics and Control" (PDF). CACHE (Computer Aids for Chemical Engineering) News.
  3. Spivey, B. (2009). "Monitoring of Process Fouling Using First-Principles Modeling and Moving Horizon Estimation". Proc. Applications of Computer Algebra (ACA) Conference.
  4. Ramlal, J. (2007). "Moving Horizon Estimation for an Industrial Gas Phase Polymerization Reactor" (PDF). IFAC Symposium on Nonlinear Control Systems Design (NOLCOS). Archived from the original (PDF) on 2009-09-20. Retrieved 2010-03-29.
  5. W. Hock and K. Schittkowski, Test Examples for Nonlinear Programming Codes, Lecture Notes in Economics and Mathematical Systems, Vol. 187, Springer 1981.
  6. Harney, D. (2013). "Numerical evaluation of the stability of stationary points of index-2 differential-algebraic equations: Applications to reactive flash and reactive distillation systems". Computers & Chemical Engineering. 49: 61–69. doi:10.1016/j.compchemeng.2012.09.021.
  7. Mojica, J. (2017). "Optimal combined long-term facility design and short-term operational strategy for CHP capacity investments". Energy. 118: 97–115. doi:10.1016/j.energy.2016.12.009.
  8. Eaton, A. (2017). "Real time model identification using multi-fidelity models in managed pressure drilling". Computers & Chemical Engineering. 97: 76–84. doi:10.1016/j.compchemeng.2016.11.008.
  9. Valderrama, F. (2018). "An optimal control approach to steam distillation of essential oils from aromatic plants". Computers & Chemical Engineering. 117: 25–31. doi:10.1016/j.compchemeng.2018.05.009.
  10. Nielsen, Isak (2012). Modeling and Control of Friction Stir Welding in 5 cm thick Copper Canisters (M.Sc. thesis). Linköping University.
  11. Brower, D. (2012). "Fiber Optic Monitoring of Subsea Equipment" (PDF). OMAE 2012 Proceedings, Rio de Janeiro, Brazil.
  12. Eaton, A. (2015). "Post-installed fiber optic pressure sensors on subsea production risers for severe slugging control" (PDF). OMAE 2015 Proceedings, St. John's, Canada.
  13. Powell, K. (2014). "Dynamic Optimization of a Hybrid Solar Thermal and Fossil Fuel System". Solar Energy. 108: 210–218. Bibcode:2014SoEn..108..210P. doi:10.1016/j.solener.2014.07.004.
  14. Spivey, B. (2010). "Dynamic Modeling of Reliability Constraints in Solid Oxide Fuel Cells and Implications for Advanced Control" (PDF). AIChE Annual Meeting Proceedings, Salt Lake City, Utah.
  15. Spivey, B. (2012). "Dynamic modeling, simulation, and MIMO predictive control of a tubular solid oxide fuel cell". Journal of Process Control. 22 (8): 1502–1520. doi:10.1016/j.jprocont.2012.01.015.
  16. Sun, L. (2013). "Optimal Trajectory Generation using Model Predictive Control for Aerially Towed Cable Systems" (PDF). Journal of Guidance, Control, and Dynamics. 37 (2): 525–539. Bibcode:2014JGCD...37..525S. doi:10.2514/1.60820.