Constrained dynamic optimization with fmincon

19 views (last 30 days)
I am trying to use fmincon to solve a dynamic optimization problem:
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.

Accepted Answer

Torsten on 14 Aug 2022
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.
AM on 14 Aug 2022
I found this when I looked for a way to solve my problem : Objective and Nonlinear Constraints in the Same Function. I've implemented it and it does the job perfectly.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!