Solving a system of nonlinear equation using steepest descent for optimal control

16 views (last 30 days)
Hello, anyone has an example on how I should use the steepest descent algorithm to solve for optimal controls with free final time and states? I have read papers about how they change the unknown final time tf to 1 by diving tf/tf but how do I write them into the code to represent the division of tf throughout all the other equations?

Answers (1)

Hari
Hari on 4 Feb 2024
Hi Rachel Ong,
I understand that you are looking for an example of how to implement the steepest descent algorithm to solve for optimal controls in a system with free final time, and you want to know about the technique of normalizing the final time to 1 by dividing by 'tf' in the code.
Assuming you have a set of nonlinear equations representing your system dynamics and cost function. The normalization of final time is a common technique to simplify the problem.
To represent the division of 'tf' throughout your equations in MATLAB, you would define 'tf' as a variable and then use it to scale your time-dependent variables and equations accordingly. Here's an example:
% Define the final time variable, initially guessed
tf = 1; % or another initial guess
% Define other parameters and initial conditions
% ...
% Steepest descent algorithm loop
for iter = 1:max_iterations
% Calculate gradients with respect to control and final time
gradient_control = ...; % Compute gradient w.r.t. control
gradient_tf = ...; % Compute gradient w.r.t. final time
% Update control and final time using steepest descent
control = control - learning_rate * gradient_control;
tf = tf - learning_rate * gradient_tf;
% Normalize time-dependent variables and equations by tf
normalized_time = actual_time / tf;
% Use normalized_time in your system equations
% ...
% Check for convergence or continue iterating
% ...
end
This is an example code normalizes the time by dividing it by 'tf' within the loop, ensuring that all time-dependent variables and equations are properly scaled. You may have to change it according to your problem parameters and initial conditions.
For more information on implementing optimization algorithms in MATLAB, refer the documentation of "fminunc" https://www.mathworks.com/help/optim/ug/fminunc.html
To understand how to work with nonlinear equations in MATLAB, refer to "fsolve" documentation https://www.mathworks.com/help/optim/ug/fsolve.html
Hope this helps!

Categories

Find more on Simulink Design Optimization in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!