Practice Final Exam
Main.FinalExam History
Hide minor edits - Show changes to output
Changed lines 8-9 from:
%width=30px%Attach:download.png [[Attach:final_exam_files.zip|Final Exam Files]]
to:
%width=20px%Attach:download.png [[Attach:final_exam_files.zip|Final Exam Files]]
Changed lines 85-86 from:
Attach:download.png [[Attach:final_solution1_files.zip|KKT Conditions for Dynamic Optimization: Solution Files]]
to:
%width=20px%Attach:download.png [[Attach:final_solution1_files.zip|KKT Conditions for Dynamic Optimization: Solution Files]]
Changed lines 95-96 from:
Attach:download.png See [[Main/InvertedPendulum|Inverted Pendulum Solution]]
to:
%width=20px%Attach:download.png See [[Main/InvertedPendulum|Inverted Pendulum Solution]]
Changed line 101 from:
Attach:download.png See [[Main/LevelControl|Level Control]]
to:
%width=20px%Attach:download.png See [[Main/LevelControl|Level Control]]
Changed line 8 from:
Attach:download.png [[Attach:final_exam_files.zip|Final Exam Files]]
to:
%width=30px%Attach:download.png [[Attach:final_exam_files.zip|Final Exam Files]]
Changed line 7 from:
Attach:download.png [[Attach:final_exam.pdf|Final Exam]]
to:
%width=30px%Attach:pdf.png [[Attach:final_exam.pdf|Final Exam]]
Added lines 13-83:
(:toggle hide gekko button show="Show GEKKO (Python) Code":)
(:div id=gekko:)
(:source lang=python:)
import numpy as np
from gekko import GEKKO
# Check solution with GEKKO
m = GEKKO()
m.time=[0,1]
u = m.Var(value=1)
x = m.Var(value=0)
m.Obj((x-3)**2)
m.Equation(5*x.dt()==-x+2*u)
m.options.IMODE = 6
m.options.NODES = 3
m.solve()
# Matrix solution for Orthogonal Collocation on Finite Elements
#
# min (x-3)^2
# s.t. 5 * dx/dt = -x + 2 * u
#
# Equations 1-2 (subject to equations at each node)
# 5 * xdot1 = -x1 + 2*u1
# 5 * xdot2 = -x2 + 2*u2
# Equations 3-4 (collocation equations)
# t2 * 0.75 * xdot1 - t2 * 0.25 * xdot2 = x1 - x0
# t2 * 1.00 * xdot1 = x2 - x0
# Equations 5-6 (derivative of objective = 0)
# 2 * (x1-3) = 0
# 2 * (x2-3) = 0
#
# Rearrange to put all variables on left-hand side
# Equations 1-2 (subject to equations at each node)
# 5 * xdot1 + x1 - 2*u1 = 0
# 5 * xdot2 + x2 - 2*u2 = 0
# Equations 3-4 (collocation equations)
# t2 * 0.75 * xdot1 - t2 * 0.25 * xdot2 - x1 = -x0
# t2 * 1.00 * xdot1 - x2 = -x0
# Equations 5-6 (derivative of objective = 0)
# 2 * x1 = 6
# 2 * x2 = 6
#
# Set-up and solve A y = b
# y = [xdot1 xdot2 x1 x2 u1 u2]
# Matrix A
A = np.array([[5,0,1,0,-2,0],\
[0,5,0,1,0,-2],\
[0.75,-0.25,-1,0,0,0],\
[1,0,0,-1,0,0],\
[0,0,2,0,0,0],\
[0,0,0,2,0,0]])
# Column vector b
b = np.array([0,0,0,0,6,6])
# Solve A y = b as y = A^-1 * b
ymat = np.linalg.solve(A,b)
print('Variables with Orthogonal Collocation')
print(['u1 = ' + str(ymat[4])])
print(['u2 = ' + str(ymat[5]) + \
' (Matrix) vs ' + str(u.value[-1]) + ' (GEKKO)'])
print(['x1 = ' + str(ymat[2])])
print(['x2 = ' + str(ymat[3]) + \
' (Matrix) vs ' + str(x.value[-1]) + ' (GEKKO)'])
print(' ')
print('Derivatives with Orthogonal Collocation')
print(['d(x11)/dt = ' + str(ymat[0])])
print(['d(x21)/dt = ' + str(ymat[1])])
(:sourceend:)
(:divend:)
Changed lines 30-41 from:
Attach:download.png
Attach:download.png [[Attach:final_solution3_steps_python.zip|Dual Tank: Step Test for Model Identification (Python/Excel)]]
(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/U7uyj9BaNKg" frameborder="0" allowfullscreen></iframe>
(:htmlend:)
Attach:download.png [[Attach:final_solution3_linear_mpc.zip|Dual Tank: Linear MPC Solution (MATLAB/Simulink)]]
Attach:download.png [[Attach:final_solution3_python_mpc.zip|Dual Tank: Linear MPC Solution (Python)
to:
Attach:download.png See [[Main/LevelControl|Level Control]]
Deleted lines 33-34:
(:htmlend:)
Changed line 1 from:
(:title 2015 Final Exam for Dynamic Optimization:)
to:
(:title Practice Final Exam:)
Changed line 26 from:
Attach:inverted_pendulum2.gif
to:
Attach:inverted_pendulum_wgts.gif
Changed line 26 from:
Attach:inverted_pendulum.gif
to:
Attach:inverted_pendulum2.gif
Changed lines 10-11 from:
!!!! Solution
to:
!!!! Solution 1
Changed lines 20-21 from:
See [[Main/InvertedPendulum|Inverted Pendulum Solution]]
to:
!!!! Solution 2
Attach:download.png See [[Main/InvertedPendulum|Inverted Pendulum Solution]]
Attach:download.png See [[Main/InvertedPendulum|Inverted Pendulum Solution]]
Added lines 25-26:
!!!! Solution 3
Changed lines 20-24 from:
(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/iW52CoG33pk" frameborder="0" allowfullscreen></iframe>
(:htmlend:)
to:
See [[Main/InvertedPendulum|Inverted Pendulum Solution]]
Changed line 29 from:
Attach:download.png [[Attach:final_solution3_steps_python.zip|Dual Tank: Step Test for Model Identification (Python)]]
to:
Attach:download.png [[Attach:final_solution3_steps_python.zip|Dual Tank: Step Test for Model Identification (Python/Excel)]]
Changed line 28 from:
Attach:download.png [[Attach:final_solution3_steps_simulink.zip|Dual Tank: Step Test for Model Identification (MATLAB/Simulink/Excel)]]
to:
Attach:download.png [[Attach:final_solution3_steps_simulink.zip|Dual Tank: Step Test for Model Identification (Simulink/Excel)]]
Changed lines 28-29 from:
Attach:download.png [[Attach:final_solution3_step_test.zip|Dual Tank: Step Test for Model Identification]]
to:
Attach:download.png [[Attach:final_solution3_steps_simulink.zip|Dual Tank: Step Test for Model Identification (MATLAB/Simulink/Excel)]]
Attach:download.png [[Attach:final_solution3_steps_python.zip|Dual Tank: Step Test for Model Identification (Python)]]
Attach:download.png [[Attach:final_solution3_steps_python.zip|Dual Tank: Step Test for Model Identification (Python)]]
Changed lines 35-36 from:
Attach:download.png [[Attach:final_solution3_linear_mpc.zip|Dual Tank: Linear MPC Solution]]
to:
Attach:download.png [[Attach:final_solution3_linear_mpc.zip|Dual Tank: Linear MPC Solution (MATLAB/Simulink)]]
Attach:download.png [[Attach:final_solution3_python_mpc.zip|Dual Tank: Linear MPC Solution (Python)]]
Attach:download.png [[Attach:final_solution3_python_mpc.zip|Dual Tank: Linear MPC Solution (Python)]]
Added lines 27-32:
Attach:download.png [[Attach:final_solution3_step_test.zip|Dual Tank: Step Test for Model Identification]]
(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/U7uyj9BaNKg" frameborder="0" allowfullscreen></iframe>
(:htmlend:)
Changed line 28 from:
Attach:download.png [[Attach:final_solution3_files.zip|Dual Tank MPC: Solution Files]]
to:
Attach:download.png [[Attach:final_solution3_linear_mpc.zip|Dual Tank: Linear MPC Solution]]
Changed line 1 from:
(:title Final Exam for Dynamic Optimization:)
to:
(:title 2015 Final Exam for Dynamic Optimization:)
Changed line 3 from:
(:description Final exam for the graduate level course on dynamic estimation and optimization.:)
to:
(:description Final exam for the graduate level course on dynamic estimation and optimization in 2015.:)
Changed lines 12-13 from:
Attach:download.png [[Attach:final_solution_key.pdf|Final Exam Solution Key (PDF)]]
to:
Attach:download.png [[Attach:final_solution1_files.zip|KKT Conditions for Dynamic Optimization: Solution Files]]
(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/n4OzENKziR4" frameborder="0" allowfullscreen></iframe>
(:htmlend:)
(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/n4OzENKziR4" frameborder="0" allowfullscreen></iframe>
(:htmlend:)
Changed lines 20-21 from:
Attach:download.png [[Attach:final_solution1_files.zip|KKT Conditions for Dynamic Optimization Solution Files]]
to:
Attach:download.png [[Attach:final_solution2_files.zip|Inverted Pendulum: Solution Files]]
Changed line 23 from:
<iframe width="560" height="315" src="https://www.youtube.com/embed/n4OzENKziR4" frameborder="0" allowfullscreen></iframe>
to:
<iframe width="560" height="315" src="https://www.youtube.com/embed/iW52CoG33pk" frameborder="0" allowfullscreen></iframe>
Changed lines 28-36 from:
Attach:download.png [[Attach:final_solution2_files.zip|Inverted Pendulum Solution Files]]
(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/iW52CoG33pk" frameborder="0" allowfullscreen></iframe>
(:htmlend:)
----
Attach:download.png [[Attach:final_solution3_files.zip|Dual Tank MPC Solution Files]]
(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/iW52CoG33pk" frameborder="0" allowfullscreen></iframe>
(:htmlend:)
----
Attach:download.png [[Attach:final_solution3_files.zip|Dual Tank MPC Solution Files]]
to:
Attach:download.png [[Attach:final_solution3_files.zip|Dual Tank MPC: Solution Files]]
Added lines 9-35:
!!!! Solution
Attach:download.png [[Attach:final_solution_key.pdf|Final Exam Solution Key (PDF)]]
----
Attach:download.png [[Attach:final_solution1_files.zip|KKT Conditions for Dynamic Optimization Solution Files]]
(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/n4OzENKziR4" frameborder="0" allowfullscreen></iframe>
(:htmlend:)
----
Attach:download.png [[Attach:final_solution2_files.zip|Inverted Pendulum Solution Files]]
(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/iW52CoG33pk" frameborder="0" allowfullscreen></iframe>
(:htmlend:)
----
Attach:download.png [[Attach:final_solution3_files.zip|Dual Tank MPC Solution Files]]
(:html:)
(:htmlend:)
Changed lines 1-3 from:
(:title Midterm Exam for Dynamic Optimization:)
(:keywords Python, MATLAB, Simulink, nonlinear control, model predictive control, exam,midterm:)
(:descriptionMid-term exam for dynamic estimation and optimization as a graduate-level course.:)
(:keywords Python, MATLAB, Simulink, nonlinear control, model predictive control, exam,
(:description
to:
(:title Final Exam for Dynamic Optimization:)
(:keywords Python, MATLAB, Simulink, nonlinear control, model predictive control, exam, final:)
(:description Final exam for the graduate level course on dynamic estimation and optimization.:)
(:keywords Python, MATLAB, Simulink, nonlinear control, model predictive control, exam, final:)
(:description Final exam for the graduate level course on dynamic estimation and optimization.:)
Changed lines 7-8 from:
Attach:download.png [[Attach:final_exam1.pdf|Final Exam]]
Attach:download.png [[Attach:final_exam_files1.zip|Final Exam Files]]
Attach:download.png [[Attach:final_exam_
to:
Attach:download.png [[Attach:final_exam.pdf|Final Exam]]
Attach:download.png [[Attach:final_exam_files.zip|Final Exam Files]]
Attach:download.png [[Attach:final_exam_files.zip|Final Exam Files]]
Changed lines 7-8 from:
Attach:download.png [[Attach:final_exam.pdf|Final Exam]]
Attach:download.png [[Attach:final_exam_files.zip|Final Exam Files]]
Attach:download.png [[Attach:final_exam_
to:
Attach:download.png [[Attach:final_exam1.pdf|Final Exam]]
Attach:download.png [[Attach:final_exam_files1.zip|Final Exam Files]]
Attach:download.png [[Attach:final_exam_files1.zip|Final Exam Files]]
Added lines 1-8:
(:title Midterm Exam for Dynamic Optimization:)
(:keywords Python, MATLAB, Simulink, nonlinear control, model predictive control, exam, midterm:)
(:description Mid-term exam for dynamic estimation and optimization as a graduate-level course.:)
!!!! Final Exam
Attach:download.png [[Attach:final_exam.pdf|Final Exam]]
Attach:download.png [[Attach:final_exam_files.zip|Final Exam Files]]
(:keywords Python, MATLAB, Simulink, nonlinear control, model predictive control, exam, midterm:)
(:description Mid-term exam for dynamic estimation and optimization as a graduate-level course.:)
!!!! Final Exam
Attach:download.png [[Attach:final_exam.pdf|Final Exam]]
Attach:download.png [[Attach:final_exam_files.zip|Final Exam Files]]