Solving minimum time problem with final time free using numerical optimisation techniques

25 views (last 30 days)
To whomsoever reading this.
I am trying formulate a code for minimum time optimal control problem with final time free. The following is the system,
x1dot = x2
x2dot = u
|u| <= 1
Performance index J is same as that of a minimum time problem.
initial state = x(0) = [1 2] Final state = x(tf) = [0 0]
Below attached is a half done code. Please help me how to proceed after this
clear all
% State equations
syms x1 x2 p1 p2 u;
Dx1 = x2;
Dx2 = u;
% Cost function inside the integral
syms g;
g = 1;
% Hamiltonian
syms p1 p2 H;
H = g + p1*Dx1 + p2*Dx2
% Costate equations
Dp1 = -diff(H,x1)
Dp2 = -diff(H,x2)
% solve for control u
sol_u = -sign(p2)
% Substitute u to state equations
Dx2 = subs(Dx2,u,sol_u)
% convert symbolic objects to strings for using 'dsolve'
eq1 = strcat('Dx1=',char(Dx1));
eq2 = strcat('Dx2=',char(Dx2));
eq3 = strcat('Dp1=',char(Dp1));
eq4 = strcat('Dp2=',char(Dp2));
sol_h = dsolve(eq1,eq2,eq3,eq4);

Answers (1)

Hari
Hari on 27 Dec 2023
Edited: Hari on 27 Dec 2023
Hi SERENE SIBY,
I understand that you are trying to solve a minimum time optimal control problem with free final time for a given system. You have the system dynamics, control constraints, performance index, initial and final states and want to proceed with the problem using symbolic computation and numerical solving in MATLAB.
I am assuming that your half-done code correctly represents the Hamiltonian system and the costate equations, the next steps involve solving the differential equations with the given boundary conditions. Since the final time `tf` is free and the final state is specified, you need to solve the two-point boundary value problem (TPBVP).
To proceed, you would:
1. Define the boundary conditions for "x1", "x2", "p1", and "p2".
2. Use MATLAB's numerical solvers for boundary value problems, such as "bvp4c" or "bvp5c", to solve the TPBVP.
Here's how you might extend your code to include these steps:
1. Defining the boundary conditions
% Define boundary conditions
initialState = [1; 2]; % x(0) = [1 2]
finalState = [0; 0]; % x(tf) = [0 0]
% Boundary condition function for bvp4c or bvp5c
%....
2. Providing an initial guess for the solution
% Guess for the solution (modify as needed)
solinit = bvpinit(linspace(0, 1, 10), [1 2 0 0]);
3. Solving the boundary value problem
% Solve the BVP
sol = bvp4c(@state_costate_eqns, @boundary_conditions, solinit);
4. Defining the system of differential equations
% Function to return state and costate equations
function dydt = state_costate_eqns(t, y)
dydt = [y(2); % Dx1
sign(y(4)); % Dx2 with control u substituted
0; % Dp1
-y(3)]; % Dp2
end
Please note that you will need to adjust the boundary condition function and the guess for the solution according to your specific problem. The example provided here is a template for setting up the numerical solver.
For more information on solving boundary value problems, refer to the documentation of
Hope this helps!

Categories

Find more on Quadratic Programming and Cone Programming in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!