Dynamic Optimization: Cost Function is Unstable

45 Views Asked by At

I am solving an optimal control problem by applying Pontryagin's Maximum Principle in MATLAB. My ODEs are stiff so I have to use the function ode15s to solve the ODEs. On every iteration, I calculated the cost function. The cost function value did not converged but oscillating. I would like to have some guidance or suggestions to resolve this issue.

img1 shows the optimal control problem. The control is linear so a bang-bang control is expected. img2 and img3 show the equations obtained by applying Pontryagin's Maximum Principle. img4, img5, and img6 show how do I solve the problem. The steps in img4 to img6 is considered one iteration. After an iteration is done, the cost function is calculated.

img1: The Optimal Control Problem

img2: Hamiltonian

img3: Costate ODE, Siwtching Function, and Costate Final Conditions

img4: step1

img5: step2

img6: step3

P.S. I am newbie in dynamic optimization. Any help here is much appreciated. Sorry for my poor language too.