Constrained dynamic optimization with fmincon
31 次查看(过去 30 天)
显示 更早的评论
Hello,
I am trying to use fmincon to solve a dynamic optimization problem:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1097705/image.png)
where u are my control variables, x are my state variables and T are terminal constraints that depend on the state variables. I know that in theory in a dynamic optimization problem there are adjoint variables that vary with time and that are defined with regards to the constraints. The optimality conditions depend on those adjoint variables (optimality conditions based on Pontryagin's principle).
In my case, I need T to be equal to 0 (within a specific tolerance). Not knowing how to solve a dynamic optimization problem with Matlab, I have taken these contraints into consideration by creating a new optimization function Jnew= w1*J+ w2 * T and I try to minimize Jnew.
For example I set w2 by keeping the tolerance I want for T in mind, e.g. if I want T to be around 1e-3 and w1*J has an order of magnitude of 1 at optimum (based on calculations run previously without the contraint), I set w2 to 1e3 to have the same order of magnitude for my two terms at the "optimum", so that fmincon doesn't just consider one term over the other. However I feel this is a somewhat arbitrary way to set the weights. And the problem is that they remain constant in all iterations.
I just don't know if this is a legitimate way to apply fmincon, if the way I have formulated my problem allows me to obtain a minimum that satisfies the optimality conditions. I know fmincon is not a dynamic solver and it doesn't consider adjoint variables, especially since I directly define the constraints myself as a sum.
Can anyone with some knowledge on the subject or has been confronted with a similar problem help me out please?
I would really appreciate it.
0 个评论
采纳的回答
Torsten
2022-8-14
J is minimized in the objective function.
The constraint T(x(t_final)) = 0 is set in the function "nonlcon" of fmincon.
u (and if there are constraints on x, also x) is/are the vector(s) of unknowns to be determined by fmincon.
Constraints on u and/or x can be set in lb, ub, A, b, Aeq,beq and nonlcon (depending on their nature).
So don't mix objective function and constraint by building O = c1*J + c2*T as objective - J is the objective and T=0 is a constraint.
9 个评论
Torsten
2022-8-14
That means saving p and y of the last calls to the "state_space_integration" function and comparing to p of the actual call ?
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!