Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

SYSC5807X_final_2023w is the assignment

1 answer below »
Carleton University Final Exam Winter 2023
Course Number: SYSC5897X Instructor: Chao Shen
Take-Home Exam Due: April 27, 2023
1. [5pts] Solve the following linear programming (LP) problem analytically
min f(x) = c1x1 + c2x2 + ·+ cnxn
s.t. ai ≤ xi ≤ bi for i = 1, 2, ..., n
where ci 6= 0.
2. [8pts] Consider the minimization problem
min f(x) = cTx
s.t. Ax = 0, ‖x‖ ≤ 1
where ‖x‖ denotes the Euclidean norm of x.
(a) Derive the KKT conditions for the solution points of the problem.
(b) Show that if c−ATλ 6= 0 where λ satisfies
AATλ = Ac
then the minimizer is given by
x∗ = − c−A

‖c−ATλ‖
3. [9pts] Formulate the following problems as linear programming (LP) prob-
lems in standard (primal or dual) form
(a) Minimize ‖Ax− b‖∞.
(b) Minimize ‖Ax− b‖1 subject to ‖x‖∞ ≤ 1.
(c) Minimize ‖Ax− b‖1 + ‖x‖∞.
4. [8pts] Find the Lagrange dual function of the following convex problems
(a) A quadratic program (QP) subject to linear constraints
min f(x) = xTx
s.t. Ax =
(b) A quadratic program (QP) subject to quadratic constraints
min f(x) =
1
2
xTHx+ pTx+ c
s.t.
1
2
xTP ix+ p
T
i x+ ci ≤ 0 for i = 1, 2, ..., q
1
5. [14pts] Consider the system with the following continuous-time state equation
ẋ(t) =
 1 1 −20 1 1
0 0 1
x(t) +
 10
1
u
y(t) = [2 0 0] x(t)
We are designing a controller u(t) = pr(t)−Kx(t) so that the closed-loop system
has eigenvalues −2 and −1± j1 and will track any step input signal r(t). Since
the controller will be implemented using a digital computer, we can also design
the system in discrete-time domain.
(a) Using forward Euler method with sampling rate 10 [Hz], find the discrete-
time model of the system. Show how you calculate the discretized system ma-
trices Ad, Bd by hand. Is it open-loop stable?
(b) Design the controller for the discrete-time system and find the feedforward
gain p and feedback gain K. Implement this discrete-time system in MATLAB
and verify your design by plotting the output y(k) for r(k) = −5, 2, and 20.
(Hint: You need to compute the co
esponding discrete-time poles (eigenvalues)
first, and then design the controller.)
6. [20pts] A cart-pendulum system is shown in Figure 1. The objective is to
alance the inverted pendulum by applying a force to the motorized cart (i.e.,
control both the position of the motorized cart x and the angular position of
the pendulum θ using the control force F ). A real-world example that relates
directly is the attitude control of a rocket at takeoff.
Figure 1: A cart-pendulum system.
(a) Denote the mass of the cart by M , the mass of the pendulum by m, the
friction coefficient by b, the length to pendulum center of mass by l, and the
2
mass moment of inertia of the pendulum by I. Perform force analysis and find
the dynamic equations.
(b) Establish a (linear) state-space model for the system assuming that the
angle θ is small. The input is u = F , and the output is y = [x, θ]T. Suppose
M = 0.5 [kg], m = 0.2 [kg], b = 0.1 [N/m/s], l = 0.3 [m], I = 0.006 [kg ·m2] and
the gravitational acceleration g = 9.8 [m/s2], then check the controllability and
observability of the system.
(c) Discretize the system using exact sampling method with sampling period
T = 0.1 [s]. Then design a LQ-optimal controller to regulate the system from
initial condition x(0) = 1 [m], ẋ(0) = 0 [m/s], θ(0) = 0.3491 [rad] and θ̇(0) = 0
[rad/s] to the origin. The design requirements are
R1) The settling time for x and θ is less than 5 seconds and
R2) The angle never deviate more than 0.35 radians, i.e., |θ| ≤ 0.35.
Implement the control system in MATLAB and plot u(k) and y(k) to verify
your design.
(d) We now have an additional requirement on the control:
R3) The control force is bounded by 2.6 [N] in magnitude, i.e., |u| ≤ 2.6.
Check if the requirements can still be met by LQ-optimal control? If not, can
you design a MPC controller to meet all the requirements? Implement the
control system in MATLAB and plot u(k) and y(k) to verify your design.
7. [16pts] The vertical position y of a machine tool positioning platform is
controlled by a motor which applies a vertical force F to the platform (Figure
2). The platform has mass M and ca
ies a variable load of mass m; the
unloaded weight of the platform is balanced by a counter-weight. The force F
is proportional to the voltage V applied to the motor, so F = KV V where KV
is a fixed gain. Assuming m is small such that M +m ≈M , the unknown load
Figure 2: Machine tool and positioning platform.
constitutes a (constant) distu
ance in the discrete-time model of the system:
x(k + 1) = Ax(k) +Bu(k) +Dw, e(k) = Cx(k)
3
A =
[
1 T
0 1
]
, B =
KV
2M
[
T 2/2
T
]
, D = − g
2M
[
T 2/2
T
]
, C = [1 0]
where T is the sampling period, and e is the e
or in y relative to a desired
steady-state height y0. The system state, input, and distu
ance are defined as
x =
[
y − y0

]
, u = V, w = m.
(a) For the model parameters M = 10 [kg], KV = 7 [N/Vol] , T = 0.1 [s],
g = 9.8 [m/s2], the LQ-optimal control law with respect to
J(k) =
∞∑
i=0
(e2(k + i|k) + λu2(k + i|k)), λ = 10−4
is u(k) = Kx(k), K = [−66.0,−19.4]. Determine the maximum steady-state
e
or y − y0 with this controller if the mass of the load is limited to the range
m ≤ 0.5
(b) Explain how to modify the cost and model dynamics in order to obtain
a stabilizing LQ-optimal controller giving zero steady-state e
or. Verify you
answer by implement the system in MATLAB and plot the output.
(c) The motor input voltage is subject to the constraints
−1 ≤ V ≤ 1
A predictive controller is to be designed based on the predicted cost:
J(k) =
∞∑
i=0
(e2(k + i|k) + v2(k + i|k) + λu2(k + i|k)), λ = 10−4
where v(i+ 1|k) = v(i|k) + e(i|k) is the prediction of the integrated e
or. Show
that the cost function can be re-written as
J(k) =
N−1∑
i=0
(e2(k + i|k) + v2(k + i|k) + λu2(k + i|k)) + ‖ξT(k +N |k)‖2P
and define ξ and P . What is the implied mode 2 feedback control law?
(d) Explain how the constraints on V can be incorporated in a robust MPC
strategy for this system (i.e. for all values of m in the range m ≤ 0.5 [kg]).
8. (Bonus Question [10pts]) For the MPC problem in Question 6 part (d),
solve it as an explicit MPC problem (i.e, formulate it as an mp-QP and solve it
with the MPT toolbox).
Note: Please also submit the MATLAB code (m-files) for Q5, Q6 (and Q8 if
you choose to answer it).
4

����
����� ����� ���������� ��
���� ������

� �����
��������� ���� ���
��
���� ��


��
��
��
    
���������

    �     ��� ���������� ����
� ��� � � � � � � � � � � � � � � � � � � � � �
    �
���� ��� �
���� � � � � � � � � � � � � � � � � � � � � � � � � � �
    �� ����� ��
��� �� �������� � � � � � � � � � � � � � � � � � � � �
    �� ���������
���� ��������� ��
���� � � � � � � � � � � � � � � � � �     �
    ���     ��������� ��
���� � � � � � � � � � � � � � � � � � � � � � � �     �
    ���
��� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �     �
    �
������ ������������ ����������
� � � � � � � � � � � � � � � � �         
    �� ������
� ����� �� ��� � � � � � � � � � � � � � � � � � � � � � � �     
    ���     ��������� ��� � � � � � � � � � � � � � � � � � � � � � � � �     
    ���
�������� ��� � � � � � � � � � � � � � � � � � � � � � � � � �     
    ���� ������ ��� � � � � � � � � � � � � � � � � � � � � � � � � �     
    ���� ���������� ��� � � � � � � � � � � � � � � � � � � � � � � �     

���������
�� �����������
    �
�     ��
�����
�� �����������
�������� � � � � � � � � � � � � � � � �     �

������������
�� ��
�����
�� �����������
�������� � � � � � � �     
��
����
�� ���������� �
� ����������
����
�� ��
�����
� � � � �     �
���    
����
�� ����������� � � � � � � � � � � � � � � � � � � � � �     �
���
�������� ��
�����
�� � � � � � � � � � � � � � � � � � � � � �     �
����
�������� ��
�����
�� � � � � � � � � � � � � � � � � � � � �

���� ����������
����
�� ����� ��
�����
� � � � � � � � � � �
�� ����
������� ��
�����
� � � � � � � � � � � � � � � � � � � � � � �

���     ����
������� ��������� ��
�����
� � � � � � � � � � � � �

���
����
������� ������
� ��
�����
� � � � � � � � � � � � � �


��
������ � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �


�     ��
��� ���� �
� ��
��� ��
����
� � � � � � � � � � � � � �



���������� �� ��
��� ��
����
� � � � � � � � � � � � � � � � �    
�� ������� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � ��
���     ����� ���� �� � ��
��� ���������
� ������� � � � � � � ��
���
���
����
�� ���� � � � � � � � � � � � � � � � � � � � � � � ��
    
�� ���
� ��� �� ����� ��
��� ���������
� � � � � � � � � � � � � � ��
� ��
���� ��

��� �������

��    
���������
� � � � � � � � � � � � � � � � � � � � � � � � � � � � � �

��
��
��
���������

��� ������� � � � � � � � � � � � � � � � � � �

��
�     ������ ����� � � � � � � � � � � � � � � � � � � � � � � � � �

��

��������� � � � � � � � � � � � � � � � � � � � � � � � � � � � �

��
��
����
�� ��������� � � � � � � � � � � � � � � � � � � � � � �

��� ������������� ������� � � � � � � � � � � � � � � � � � � � � � � � � �
��� �������
��� ��
���� � � � � � � � � � � � � � � � � � � � � � � � � � �    
��
�������������
��
���� � � � � � � � � � � � � � � � � � � � � � � � �
��
�     ������������ � � � � � � � � � � � � � � � � � � � � � � � � � � �
��

��
������
���� ��
���� � � � � � � � � � � � � � � � � � � ��
��
�� ��
������������ � � � � � � � � � � � � � � � � � � � � � � � � ��
��
�� ������������
�� ����� �������
� � � � � � � � � � � � � � � �
��� ������������� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � ��
���

��� ��������� ���������

��� �
Answered 7 days After Apr 13, 2023

Solution

Aditi answered on Apr 17 2023
27 Votes
Advance Mathematics
1.
% Define the problem parameters
c = [c1, c2, ..., cn]; % coefficient vector
A = eye(n); % identity matrix
= [b1, b2, ..., bn]; % upper bound vector
lb = [a1, a2, ..., an]; % lower bound vecto
% Solve the linear programming problem using linprog function
[x, fval] = linprog(c, A, b, [], [], lb);
% Display the optimal solution and objective function value
fprintf('Optimal solution: x* = [%s]\n', num2str(x));
fprintf('Objective function value: f(x*) = %f\n', fval);
2.
syms x1 x2 x3 lambda mu
% Define the objective function and constraints
f = [c1; c2; c3]' * [x1; x2; x3];
g = [a1 <= x1 <= b1, a2 <= x2 <= b2, a3 <= x3 <= b3, norm([x1;x2;x3]) <= 1];
% Write the Lagrangian function
L = f + lambda' * g;
% Find the gradient of the Lagrangian w.r.t. x and lambda
gradL_x = gradient(L, [x1, x2, x3]);
gradL_lambda = gradient(L, lambda);
% Write the KKT conditions
KKT_conditions = [gradL_x(1) == 0, gradL_x(2) == 0, gradL_x(3) == 0, gradL_lambda'*g
== 0, lambda >= 0, g >= 0, lambda'*g == 0];
Matlab code for (b) showing that if c - ATλ ≠ 0 where λ satisfies AATλ = Ac, then the
minimizer is given by x∗ = - (c - ATλ) / ||c - ATλ||:
% Check if c - AT*lambda != 0 where A*A' * lambda = A*c
if norm(c - A'*lambda) ~= 0
% Compute the minimizer
x_star = - (c - A'*lambda) / norm(c - A'*lambda);
else
disp('No minimizer exists since c - AT*lambda = 0')
end
3.
a.
Minimize ||Ax - b||∞:
% primal LP
cvx_begin
variable x(n)
variable t
minimize t
subject to
A*x - b <= t*ones(m,1)
A*x - b >= -t*ones(m,1)
cvx_end
.
Minimize ||Ax - b||1 subject to ||x||∞ <= 1:
% primal LP
cvx_begin
variable x(n)
variable t
minimize ones(1,n)*abs(x-A\b)
subject to
max(abs(x)) <= t
cvx_end
c.
Minimize ||Ax - b||1 + ||x||∞:
% primal LP
cvx_begin
variable x(n)
variable t
minimize ones(1,n)*abs(x-A\b) + t
subject to
max(abs(x)) <= t
cvx_end
4.
a.
% Define problem data A = [1, 2; 3, 4]; % constraint matrix b = [5; 6]; % constraint
vector
% Define Lagrange dual function g = @(lambda) -1/4 * lambda' * A * A' * lambda +
lambda' * b;
% Test the dual function with some random values of lambda lambda = rand(2, 1); %
andom vector of Lagrange multipliers g_lambda = g(lambda);
disp(['The value of the Lagrange dual function is ', num2str(g_lambda)])
.
% Define problem data H = [2, -1; -1, 2]; % quadratic coefficient matrix p = [1; 2]; %
linear coefficient vector c = 3; % constant term P = [1, 0; 0, 1]; % quadratic constraint
matrix
% Define Lagrange dual function g = @(lambda) c - 1/4 * lambda' * (P * (H + lambda' *
P)^(-1) * P' + eye(2)) * lambda;
% Test the dual function with some random values of lambda lambda = rand(2, 1); %
andom vector of Lagrange multipliers g_lambda = g(lambda);
disp(['The value of the Lagrange dual function is ', num2str(g_lambda)]);
5.
(a) Using forward Euler method with sampling rate 10 [Hz], we can discretize the
continuous-time state equation as:
x(k+1) = x(k) + dt * Ax(k) y(k) = Cx(k)
where dt = 1/10 is the time step, A = [1 1 -2; 2 0 0; 0 0 0] is the state matrix, and C = [1
0 0] is the output matrix.
To calculate the discretized system matrices Ad and Bd, we can use the following
formulas:
Ad = I + dt * A Bd = dt * B
where B = [0; p; 0] is the input matrix.
So, using the forward Euler method, we have:
Ad = eye(3) + dt * A Bd = dt * B
where B = [0; p; 0] is the input matrix.
To determine whether the discretized system is open-loop stable, we can check the
eigenvalues of Ad. If all the eigenvalues are inside the unit circle, then the system is
stable. We can use the MATLAB function eig(Ad) to find the eigenvalues.
(b) To design the controller for the discrete-time system, we first need to find the
discrete-time poles (eigenvalues) of the closed-loop system. We want the poles to be
at 2 and 1 +/- j1 to satisfy the design specifications. We can use the MATLAB function
c2d to discretize the controller design in the continuous-time domain to the discrete-
time domain.
Assuming a controller of the form u(k) = p * r(k) - K * x(k), we can use the MATLAB
function place to design the feedback gain K to place the desired poles. Then, we can
use the MATLAB function dcgain to find the feedforward gain p that ensures zero
steady-state e
or for a step input.
Here is the MATLAB code to implement the design and simulation of the discrete-time
system:
% Define problem data A = [1, 1, -2; 2, 0, 0; 0, 0, 0]; % state matrix B = [0; 1; 0]; %
input matrix C = [1, 0, 0]; % output matrix dt = 1/10; % sampling time
% Discretize the system using forward Euler method Ad = eye(3) + dt * A; Bd = dt * B;
% Check if the discretized system is open-loop stable eig_Ad = eig(Ad); if
all(abs(eig_Ad) < 1) disp('The discretized system is open-loop stable.'); else disp('The
discretized system is open-loop unstable.'); end
% Design the controller for the discrete-time system desired_poles = [2, 1+1j, 1-1j]; K
= place(Ad, Bd, desired_poles); p = -dcgain(Ad - BdK, BdC);
% Simulation of the closed-loop system with step inputs T = 0:dt:2; % simulation time
= [5ones(1, length(T)/2), 2ones(1, length(T)/2+1)]; % step inputs x0 = [0; 0; 0]; %
initial state x = zeros(3, length(T)); % state trajectory y = zeros(1, length(T)); % output
trajectory u = zeros(1, length(T)); % input trajectory for k = 1:length(T) % Compute
control input u(k) = pr(k) - Kx(:,k);
% Simulate the system forward one step x(:,k+1) = Adx(:,k) + Bdu(k); y(k) = C*x(:,k);
end
% Plot the results subplot(2,1,1); plot(T, y); xlabel('Time (s)'); ylabel('Output y');
title('Step response of the closed-loop system');
subplot(2,1,2); plot(T, u); xlabel('Time (s)'); ylabel('Input u'); title('Control input of the
closed-loop system');
% Display the feedforward and feedback gains disp('The feedforward gain p is:');
disp(p); disp('The feedback gain K is:'); disp(K);
6.
(a) Force analysis:
The forces acting on the cart-pendulum system are the control force F, the
gravitational force mg, and the friction force bẋ. By applying Newton's second law and
torque balance to the cart and the pendulum, we get the following dynamic
equations:
Cart:
Mẍ = F - bẋ - mlsin(θ)θ̇²
Pendulum:
(I + ml²)θ̈ + bθ̇ + mgl sin(θ) = -m l cos(θ)ẍ
where M is the mass of the cart, m is the mass of the pendulum, b is the friction
coefficient, l is the length to the center of mass of the pendulum, I is the mass
moment of inertia of the pendulum, x is the position of the cart, θ is the angle of the
pendulum, F is the control force, g is the gravitational acceleration.
(b) State-space model:
Let x1 = x, x2 = ẋ, x3 = θ, and x4 = θ̇. Then we have the following state-space model:
ẋ = f(x, u) = Ax + Bu y = h(x) = Cx
where
A = [0 1 0 0; 0 -
M -mg/M 0; 0 0 0 1; 0 -
(Ml) -(M+m)g/(Ml) 0]
B = [0; 1/M; 0; 1/(M*l)]
C = [1 0 0 0; 0 0 1 0]
The matrices A and B are:
A = [0.0000 1.0000 0.0000 0.0000; 0.0000 -0.2000 -98.0000 0.0000; 0.0000 0.0000
0.0000 1.0000; 0.0000 -3.3333 -326.6667 0.0000]
B = [0.0000; 2.0000; 0.0000; 6.6667]
The system is controllable and observable since its controllability and observability
matrices have full rank:
ank([B AB A^2B A^3B]) = 4 rank([C; CA; CA^2; CA^3]) = 4
c.
Discretization and LQ-optimal control design:
The given continuous-time state-space model can be discretized using the exact
sampling method with sampling period T=0.1s. This can be done using the c2d
function in MATLAB. Then, a LQ-optimal controller can be designed using the dlqr
function.
Here is the complete MATLAB code for this part:
% Cart-pendulum system parameters
M = 0.5; m = 0.2; b = 0.1; l = 0.3; I = 0.006; g = 9.8;
% Continuous-time state-space model
Ac = [0 1 0 0; 0 -
M g*m/M 0; 0 0 0 1; 0
(M*l) g*(M+m)/(M*l) 0];
Bc = [0; 1/M; 0; -1/(M*l)];
Cc = [1 0 0 0; 0 0 1 0];
Dc = [0; 0];
sysc = ss(Ac, Bc, Cc, Dc);
% Discrete-time state-space model
T = 0.1;
[Ad, Bd, Cd, Dd] = c2dm(Ac, Bc, Cc, Dc, T, 'zoh');
sysd = ss(Ad, Bd, Cd, Dd, T);
% LQ-optimal control design
Q = diag([10 1 100 1]);
R = 0.01;
[Klq, ~, ~] = dlqr(Ad, Bd, Q, R);
% Simulation time and initial conditions
t_sim = 5;
x0 = [1; 0; 0.3491; 0];
% State-feedback controller
K = Klq;
% Simulation with LQ-optimal controller
sim('cart_pendulum_simulink_LQ', t_sim);
% Plot results
figure;
subplot(2,1,1);
plot(tout, y(:,1), 'b-', 'LineWidth', 1.5);
hold on;...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here