6. 数值稳定性和正则化
发布时间:2025-06-24 19:55:01 作者:北方职教升学中心 阅读量:699
二次形式:
其中,P 是对称正定矩阵。
自适应动态规划的逐步推进#xff08;ADP)离散时间线性二次调节器(LQR)问题中的应用。 将导数设置为零,获得最佳控制输入:
5. 值函数迭代。3. 动态规划原理。2. 定义成本函数。% ADP Optimal Controlclear;clc;% Define system parametersA = [1 1; 0 1];B = [0.5; 1];Q = eye(2);R = 1;% ADP parametersnum_iterations = 100;gamma = 0.95; % Discount factorlearning_rate = 0.01;% Initialize value function weights (assuming quadratic form)P = eye(2);% Simulation parametersx = [10; 0]; % Initial statenum_steps = 100;trajectory = zeros(2, num_steps);% ADP algorithmfor iter = 1:num_iterations % Initialize state x = x0; for k = 1:num_steps % Compute control input using current policy u = -inv(R + B' * P * B) * B' * P * A * x; % Store state trajectory(:, k) = x; % Compute next state x_next = A * x + B * u; % Compute cost-to-go cost_to_go = x' * Q * x + u' * R * u + gamma * x_next' * P * x_next; % Update value function weights P = P + learning_rate * (cost_to_go - x' * P * x) * (x * x'); % Update state x = x_next; endend% Plot resultsfigure;plot(trajectory(1, :), 'r', 'LineWidth', 2);hold on;plot(trajectory(2, :), 'b', 'LineWidth', 2);xlabel('Time step');ylabel('State');legend('x1', 'x2');title('State Trajectory using ADP Optimal Control');grid on;
2. 定义成本函数。% ADP Optimal Controlclear;clc;% Define system parametersA = [1 1; 0 1];B = [0.5; 1];Q = eye(2);R = 1;% ADP parametersnum_iterations = 100;gamma = 0.95; % Discount factorlearning_rate = 0.01;% Initialize value function weights (assuming quadratic form)P = eye(2);% Simulation parametersx = [10; 0]; % Initial statenum_steps = 100;trajectory = zeros(2, num_steps);% ADP algorithmfor iter = 1:num_iterations % Initialize state x = x0; for k = 1:num_steps % Compute control input using current policy u = -inv(R + B' * P * B) * B' * P * A * x; % Store state trajectory(:, k) = x; % Compute next state x_next = A * x + B * u; % Compute cost-to-go cost_to_go = x' * Q * x + u' * R * u + gamma * x_next' * P * x_next; % Update value function weights P = P + learning_rate * (cost_to_go - x' * P * x) * (x * x'); % Update state x = x_next; endend% Plot resultsfigure;plot(trajectory(1, :), 'r', 'LineWidth', 2);hold on;plot(trajectory(2, :), 'b', 'LineWidth', 2);xlabel('Time step');ylabel('State');legend('x1', 'x2');title('State Trajectory using ADP Optimal Control');grid on;
% ADP Optimal Controlclear;clc;% Define system parametersA = [1 1; 0 1];B = [0.5; 1];Q = eye(2);R = 1;% ADP parametersnum_iterations = 100;gamma = 0.95; % Discount factorlearning_rate = 0.01;% Initialize value function weights (assuming quadratic form)P = eye(2);% Simulation parametersx = [10; 0]; % Initial statenum_steps = 100;trajectory = zeros(2, num_steps);% ADP algorithmfor iter = 1:num_iterations % Initialize state x = x0; for k = 1:num_steps % Compute control input using current policy u = -inv(R + B' * P * B) * B' * P * A * x; % Store state trajectory(:, k) = x; % Compute next state x_next = A * x + B * u; % Compute cost-to-go cost_to_go = x' * Q * x + u' * R * u + gamma * x_next' * P * x_next; % Update value function weights P = P + learning_rate * (cost_to_go - x' * P * x) * (x * x'); % Update state x = x_next; endend% Plot resultsfigure;plot(trajectory(1, :), 'r', 'LineWidth', 2);hold on;plot(trajectory(2, :), 'b', 'LineWidth', 2);xlabel('Time step');ylabel('State');legend('x1', 'x2');title('State Trajectory using ADP Optimal Control');grid on;
致读者:我的小白也是在学习过程中,加强学习优化控制的相关内容将陆续更新#xff0c;总结后与大家分享,与您讨论学习!如果出现错误请指出我会更正!!!感谢!!!!
并且在更新值函数矩阵。
1. 问题定义。具体,每次迭代,根据当前战略计算状态和成本,然后更新 P:
其中,是学习率。贝尔曼方程:
其中,是从状态。
自适应动态规划(Adaptive Dynamic Programming,ADP)#xff00是一种优化控制方法c;解决动态系统中的最佳控制问题。
其中,系统状态,
控制输入,A 和 B 分别是系统状态矩阵和控制矩阵。
1. 定义系统模型。
考虑离散时间线性系统:
其中,
是系统状态向量,
控制输入向量,
和。
6. 数值稳定性和正则化。如果发现负特征值将其设置为一个小的正值。
以下是一个简单的自适应动态规划优化控制 MATLAB 程序示例。
。
分别是系统状态矩阵和控制矩阵。
以离散时间线性系统为例a;
。
在这个假设下,贝尔曼方程变成:
控制输入。
假设值函数。matlab程序仿真。
保持正定。
动态规划(DP)该方法通过解决贝尔曼方程来找到最佳策略。
我们的目标是最小化以下二次成本函数:
其中,Q 和 R 权重矩阵,确保系统状态与控制输入之间的平衡。
4. 最佳控制策略。通过近似动态规划(Approximate Dynamic Programming)接近系统的最佳控制策略。
后,通过监测其特征值来保证。
为了迭代更新值函数矩阵 P,梯度下降法可以使用。
二、
3. ADP 优化控制程序。
以下是完整的 MATLAB 程序。
2. 成本函数。
目标是在无限时间内最小化二次成本函数:
其中,
是正定状态权重矩阵,
正定控制权重矩阵,
是折扣因素。原则推导-废话少说。
一、
确保矩阵。