Main

(:html:)

<iframe width="560" height="315" src="https://www.youtube.com/embed/dM8gX54jWW4" frameborder="0" allowfullscreen></iframe>

(:htmlend:)

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

(:html:)

<iframe width="560" height="315" src="https://www.youtube.com/embed/qH55ym1g-NM" frameborder="0" allowfullscreen></iframe>

(:htmlend:)
~~!!!! Exercise~~

'''Objective:''' Set up and solve several [[Attach:Dynamic_Optimization_Benchmarks.pdf|dynamic optimization benchmark problems]]'^2^'. Create a program to optimize and display the results. ''Estimated Time (each): 30 minutes''

* Example 1a - Nonlinear, unconstrained, minimize final state

->Attach:dynopt_1a.png

* Example 1b - Nonlinear, unconstrained, minimize final state with terminal constraint

->Attach:dynopt_1b.png

* Example 2 - Nonlinear, constrained, minimize final state

->Attach:dynopt_2.png

* Example 3 - Tubular reactor with parallel reaction

->Attach:dynopt_3.png

* Example 4 - Batch reactor with consecutive reactions A->B->C

->Attach:dynopt_4.png

Example 5 - Catalytic reactor with A<->B->C

->Attach:dynopt_5.png

!!!! Solution

Attach:download.png [[Attach:dynamic_optimization_benchmarks.zip|Dynamic Optimization Benchmarks in MATLAB and Python]]

(:html:)

<iframe width="560" height="315" src="https://www.youtube.com/embed/mmCFF3-6sGg" frameborder="0" allowfullscreen></iframe>

(:htmlend:)

~~# M. Čižniar, M. Fikar, M.A. Latifi: A MATLAB Package for Dynamic Optimisation of Processes, 7th International Scientific – Technical Conference – Process Control 2006, June 13 – 16, 2006, Kouty nad Desnou, Czech Republic. [[Attach:DynOpt_Benchmarks.pdf|Article]]~~

(:html:)

<iframe width="560" height="315" src="https://www.youtube.com/embed/mmCFF3-6sGg" frameborder="0" allowfullscreen></iframe>

(:htmlend:)
~~!!!! Exercise~~

'''Objective:''' Design a model predictive controller with a custom objective function that satisfies a specific problem criterion. Simulate and optimize a pendulum system with an adjustable overhead cart. ''Estimated time: 3 hours.''

A pendulum is described by the following dynamic equations:

Attach:pendulum_crane_equations.png

where ''epsilon'' is ''m'_2_'/(m'_1_'+m'_2_')'', ''y'' is the position of the overhead cart, ''v'' is the velocity of the overhead cart, ''theta'' is the angle of the pendulum relative to the cart, and ''q'' is the rate of angle change'^2^'.

Attach:pendulum_crane.png

The objective of the controller is to adjust the force on the cart to move the pendulum mass to a new final position. Ensure that initial and final velocities and angles of the pendulum are zero. The position of the pendulum mass is initially at -1 and it is desired to move it to the new position of 0 within 6.2 seconds. Demonstrate controller performance with changes in the pendulum position and that the final pendulum mass remains at the final position without oscillation.

!!!! Solution

Attach:download.png [[Attach:crane_control.zip|Crane Pendulum Solution Files in MATLAB and Python]]

~~# Bryson, A.E., Dynamic Optimization, Addison-Wesley, 1999.~~
~~Attach:download.png [[Attach:crane_control.zip|Crane Pendulum Source Files]]~~

# Bryson, A.E., Dynamic Optimization, Addison-Wesley, 1999.

## Dynamic Control Objectives

## Main.ControllerObjective History

Hide minor edits - Show changes to output

Added lines 8-11:

(:html:)

<iframe width="560" height="315" src="https://www.youtube.com/embed/dM8gX54jWW4" frameborder="0" allowfullscreen></iframe>

(:htmlend:)

Changed lines 5-9 from:

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. Two common objective functions are shown below as squared error and l'_1_'-norm forms'^1^'.

to:

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.

Attach:download.png [[Attach:mpc_objectives.zip|MPC Objective Exercise (Python and MATLAB)]]

Two common objective functions are shown below as squared error and l'_1_'-norm forms'^1^'.

Attach:download.png [[Attach:mpc_objectives.zip|MPC Objective Exercise (Python and MATLAB)]]

Two common objective functions are shown below as squared error and l'_1_'-norm forms'^1^'.

Changed line 21 from:

%width=~~300px~~%Attach:obj_ctrl_nomenclature.png

to:

%width=400px%Attach:obj_ctrl_nomenclature.png

Changed lines 11-12 from:

%width=~~200px~~%Attach:obj_ctrl_sq_error.png

to:

%width=300px%Attach:obj_ctrl_sq_error.png

Changed lines 17-18 from:

%width=~~200px~~%Attach:obj_ctrl_l1_norm.png

to:

%width=300px%Attach:obj_ctrl_l1_norm.png

Changed line 21 from:

Attach:obj_ctrl_nomenclature.png

to:

%width=300px%Attach:obj_ctrl_nomenclature.png

Changed lines 11-12 from:

Attach:obj_ctrl_sq_error.png

to:

%width=200px%Attach:obj_ctrl_sq_error.png

Changed lines 15-17 from:

The l'_1_'-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 ~~is ~~

Attach:obj_ctrl_l1_norm.png

Attach

to:

The l'_1_'-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 [[http://apmonitor.com/me575/index.php/Main/LogicalConditions|absolute value function alternatives]]). [[http://apmonitor.com/wiki/index.php/Main/SlackVariables|Slack variables]] give the same absolute value function but with continuous first and second derivatives.

%width=200px%Attach:obj_ctrl_l1_norm.png

%width=200px%Attach:obj_ctrl_l1_norm.png

Added lines 9-10:

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.

Added lines 15-16:

The l'_1_'-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 is

Added lines 22-42:

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

Added lines 18-21:

(:html:)

<iframe width="560" height="315" src="https://www.youtube.com/embed/qH55ym1g-NM" frameborder="0" allowfullscreen></iframe>

(:htmlend:)

Deleted lines 18-42:

'''Objective:''' Set up and solve several [[Attach:Dynamic_Optimization_Benchmarks.pdf|dynamic optimization benchmark problems]]'^2^'. Create a program to optimize and display the results. ''Estimated Time (each): 30 minutes''

* Example 1a - Nonlinear, unconstrained, minimize final state

->Attach:dynopt_1a.png

* Example 1b - Nonlinear, unconstrained, minimize final state with terminal constraint

->Attach:dynopt_1b.png

* Example 2 - Nonlinear, constrained, minimize final state

->Attach:dynopt_2.png

* Example 3 - Tubular reactor with parallel reaction

->Attach:dynopt_3.png

* Example 4 - Batch reactor with consecutive reactions A->B->C

->Attach:dynopt_4.png

Example 5 - Catalytic reactor with A<->B->C

->Attach:dynopt_5.png

!!!! Solution

Attach:download.png [[Attach:dynamic_optimization_benchmarks.zip|Dynamic Optimization Benchmarks in MATLAB and Python]]

(:html:)

<iframe width="560" height="315" src="https://www.youtube.com/embed/mmCFF3-6sGg" frameborder="0" allowfullscreen></iframe>

(:htmlend:)

Deleted line 22:

Added lines 39-42:

(:html:)

<iframe width="560" height="315" src="https://www.youtube.com/embed/mmCFF3-6sGg" frameborder="0" allowfullscreen></iframe>

(:htmlend:)

Changed line 33 from:

Example 5 - Catalytic ~~plug flow reactor with ~~A->B->C

to:

Example 5 - Catalytic reactor with A<->B->C

Added lines 19-39:

!!!! Exercise

'''Objective:''' Set up and solve several [[Attach:Dynamic_Optimization_Benchmarks.pdf|dynamic optimization benchmark problems]]'^2^'. Create a program to optimize and display the results. ''Estimated Time (each): 30 minutes''

* Example 1a - Nonlinear, unconstrained, minimize final state

->Attach:dynopt_1a.png

* Example 1b - Nonlinear, unconstrained, minimize final state with terminal constraint

->Attach:dynopt_1b.png

* Example 2 - Nonlinear, constrained, minimize final state

->Attach:dynopt_2.png

* Example 3 - Tubular reactor with parallel reaction

->Attach:dynopt_3.png

* Example 4 - Batch reactor with consecutive reactions A->B->C

->Attach:dynopt_4.png

Example 5 - Catalytic plug flow reactor with A->B->C

->Attach:dynopt_5.png

!!!! Solution

Attach:download.png [[Attach:dynamic_optimization_benchmarks.zip|Dynamic Optimization Benchmarks in MATLAB and Python]]

'''Objective:''' Set up and solve several [[Attach:Dynamic_Optimization_Benchmarks.pdf|dynamic optimization benchmark problems]]'^2^'. Create a program to optimize and display the results. ''Estimated Time (each): 30 minutes''

* Example 1a - Nonlinear, unconstrained, minimize final state

->Attach:dynopt_1a.png

* Example 1b - Nonlinear, unconstrained, minimize final state with terminal constraint

->Attach:dynopt_1b.png

* Example 2 - Nonlinear, constrained, minimize final state

->Attach:dynopt_2.png

* Example 3 - Tubular reactor with parallel reaction

->Attach:dynopt_3.png

* Example 4 - Batch reactor with consecutive reactions A->B->C

->Attach:dynopt_4.png

Example 5 - Catalytic plug flow reactor with A->B->C

->Attach:dynopt_5.png

!!!! Solution

Attach:download.png [[Attach:dynamic_optimization_benchmarks.zip|Dynamic Optimization Benchmarks in MATLAB and Python]]

Changed line 44 from:

to:

# M. Čižniar, M. Fikar, M.A. Latifi: A MATLAB Package for Dynamic Optimisation of Processes, 7th International Scientific – Technical Conference – Process Control 2006, June 13 – 16, 2006, Kouty nad Desnou, Czech Republic. [[Attach:DynOpt_Benchmarks.pdf|Article]]

Deleted lines 18-35:

'''Objective:''' Design a model predictive controller with a custom objective function that satisfies a specific problem criterion. Simulate and optimize a pendulum system with an adjustable overhead cart. ''Estimated time: 3 hours.''

A pendulum is described by the following dynamic equations:

Attach:pendulum_crane_equations.png

where ''epsilon'' is ''m'_2_'/(m'_1_'+m'_2_')'', ''y'' is the position of the overhead cart, ''v'' is the velocity of the overhead cart, ''theta'' is the angle of the pendulum relative to the cart, and ''q'' is the rate of angle change'^2^'.

Attach:pendulum_crane.png

The objective of the controller is to adjust the force on the cart to move the pendulum mass to a new final position. Ensure that initial and final velocities and angles of the pendulum are zero. The position of the pendulum mass is initially at -1 and it is desired to move it to the new position of 0 within 6.2 seconds. Demonstrate controller performance with changes in the pendulum position and that the final pendulum mass remains at the final position without oscillation.

!!!! Solution

Attach:download.png [[Attach:crane_control.zip|Crane Pendulum Solution Files in MATLAB and Python]]

Deleted line 22:

Changed lines 27-28 from:

where ''epsilon'' is ''m'_2_'/(m'_1_'+m'_2_')'', ''y'' is the position of the overhead cart, ''v'' is the velocity of the overhead cart, ''theta'' is the angle of the pendulum relative to the cart, and ''q'' is the rate of angle change.

to:

where ''epsilon'' is ''m'_2_'/(m'_1_'+m'_2_')'', ''y'' is the position of the overhead cart, ''v'' is the velocity of the overhead cart, ''theta'' is the angle of the pendulum relative to the cart, and ''q'' is the rate of angle change'^2^'.

Deleted lines 30-31:

Added lines 35-36:

Attach:download.png [[Attach:crane_control.zip|Crane Pendulum Solution Files in MATLAB and Python]]

Added lines 40-41:

# Bryson, A.E., Dynamic Optimization, Addison-Wesley, 1999.

Added lines 19-36:

!!!! Exercise

'''Objective:''' Design a model predictive controller with a custom objective function that satisfies a specific problem criterion. Simulate and optimize a pendulum system with an adjustable overhead cart. ''Estimated time: 3 hours.''

A pendulum is described by the following dynamic equations:

Attach:pendulum_crane_equations.png

where ''epsilon'' is ''m'_2_'/(m'_1_'+m'_2_')'', ''y'' is the position of the overhead cart, ''v'' is the velocity of the overhead cart, ''theta'' is the angle of the pendulum relative to the cart, and ''q'' is the rate of angle change.

Attach:pendulum_crane.png

Attach:download.png [[Attach:crane_control.zip|Crane Pendulum Source Files]]

The objective of the controller is to adjust the force on the cart to move the pendulum mass to a new final position. Ensure that initial and final velocities and angles of the pendulum are zero. The position of the pendulum mass is initially at -1 and it is desired to move it to the new position of 0 within 6.2 seconds. Demonstrate controller performance with changes in the pendulum position and that the final pendulum mass remains at the final position without oscillation.

!!!! Solution

'''Objective:''' Design a model predictive controller with a custom objective function that satisfies a specific problem criterion. Simulate and optimize a pendulum system with an adjustable overhead cart. ''Estimated time: 3 hours.''

A pendulum is described by the following dynamic equations:

Attach:pendulum_crane_equations.png

where ''epsilon'' is ''m'_2_'/(m'_1_'+m'_2_')'', ''y'' is the position of the overhead cart, ''v'' is the velocity of the overhead cart, ''theta'' is the angle of the pendulum relative to the cart, and ''q'' is the rate of angle change.

Attach:pendulum_crane.png

Attach:download.png [[Attach:crane_control.zip|Crane Pendulum Source Files]]

The objective of the controller is to adjust the force on the cart to move the pendulum mass to a new final position. Ensure that initial and final velocities and angles of the pendulum are zero. The position of the pendulum mass is initially at -1 and it is desired to move it to the new position of 0 within 6.2 seconds. Demonstrate controller performance with changes in the pendulum position and that the final pendulum mass remains at the final position without oscillation.

!!!! Solution

Added line 40:

Changed line 21 from:

# 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|~~http://dx.doi.org/10.1016/j.compchemeng.2014.04.013]]

to:

# 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. [[http://dx.doi.org/10.1016/j.compchemeng.2014.04.013|Article]]

Changed lines 5-21 from:

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.

to:

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. Two common objective functions are shown below as squared error and l'_1_'-norm forms'^1^'.

!!!! Squared Error Objective

Attach:obj_ctrl_sq_error.png

!!!! l'_1_'-norm Objective

Attach:obj_ctrl_l1_norm.png

!!!! Nomenclature

Attach:obj_ctrl_nomenclature.png

!!!! References

# 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|http://dx.doi.org/10.1016/j.compchemeng.2014.04.013]]

!!!! Squared Error Objective

Attach:obj_ctrl_sq_error.png

!!!! l'_1_'-norm Objective

Attach:obj_ctrl_l1_norm.png

!!!! Nomenclature

Attach:obj_ctrl_nomenclature.png

!!!! References

# 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|http://dx.doi.org/10.1016/j.compchemeng.2014.04.013]]

Added lines 1-5:

(:title Dynamic Control Objectives:)

(:keywords objective function, MATLAB, Simulink, predictive control, time horizon, tutorial:)

(:description Objective function forms for improved control performance with nonlinear models:)

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.

(:keywords objective function, MATLAB, Simulink, predictive control, time horizon, tutorial:)

(:description Objective function forms for improved control performance with nonlinear models:)

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.