The dynamic control objective function is a mathematical statement that is minimized or maximized to find a best solution among all possible feasible solutions for a controller. The form of this objective function is critical to give desirable solutions for driving a system to a desirable state or along a desired trajectory. Common objective statements relate to economic, safety, operability, environmental, or related objectives.
# MV tuning
p.STATUS=1#allow optimizer to change
p.DCOST=0.1#smooth out MV
p.DMAX=20#slow down change of MV
# CV tuning
v.STATUS=1#add the CV to the objective
m.options.CV_TYPE=1#Dead-band
v.SPHI=42#set point
v.SPLO=38#set point
v.TR_INIT=1#setpoint trajectory
v.TAU=5#time constant of setpoint trajectory
# Solve
m.solve()
# get additional solution information import json withopen(m.path+'//results.json')as f:
results = json.load(f)
Two common objective functions are shown below as squared error and l1-norm forms1.
Squared Error Objective
The squared error objective is the most common form used in the literature. It penalizes deviation of the current measured value of the controlled variable from the desired target value.
The l1-norm objective is the absolute value of the difference between the current measured value of the controlled variable and the desired target value. The absolute value operator (abs(x)) does not have a continuous first and second derivative at x=0 (see absolute value function alternatives). Slack variables give the same absolute value function but with continuous first and second derivatives.
In formulating an objective function and model equations follow the following tips for improved convergence.
Rearrange to equation in residual form to:
Avoid divide by zero
Minimize use of functions like sqrt, log, exp, etc.
Have continuous first and second derivatives
Fit the equation into a linear or quadratic form
Bounds
Include variable bounds to exclude infeasible solutions
Variable bounds to avoid regions of strong nonlinearity
Caution: watch for infeasible solutions
Scaling:
Scale absolute value of variables to 1e-3 to 1e3
Scale absolute value of equation residuals to 1e-3 to 1e3
Better that 1st derivative values are closer to 1.0
Good initial conditions:
Starting near a solution can improve convergence
Try multiple initial conditions to verify global solution (non-convex problems)
Explicitly calculate intermediate values
Check iteration summary for improved convergence
Custom Reference Trajectory
Some applications require a custom reference trajectory that does not fit a standard form. A custom reference trajectory is specified by creating a new error (e) variable that is the difference between the specified trajectory (sinusoidal, sawtooth, random, etc) and the model output. This error is specified as a controlled variable (CV) with an upper and lower dead-band denoted as SPHI and SPLO. The CV can also be a value of zero with a squared error objective (e.SP=0, m.options.CV_TYPE=2) to drive to a target instead of a dead-band range.
# MV tuning
p.STATUS=1#allow optimizer to change
p.DCOST=0.1#smooth out MV
p.DMAX=50#slow down change of MV
# CV tuning
e.STATUS=1#add the CV to the objective
m.options.CV_TYPE=1#Dead-band
db =2
e.SPHI= db #set point
e.SPLO= -db #set point
e.TR_INIT=0#setpoint trajectory
e.TAU=5#time constant of setpoint trajectory
# Solve
m.solve()
# get additional solution information import json withopen(m.path+'//results.json')as f:
results = json.load(f)
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. Article