Proper set up of fmincon including ODEs

1 次查看(过去 30 天)
I am actually trying to understand how the fmincon function is used in a little more complex way(including solving ODE). So I thought of a little example for which I imagine a vehicle on a 2D object, like a table. So the vehicle can move in x and in y direction and it is supposed to "fly" through a given point(xf,yf) on the table which I defined as my equality constrained. The inequality constraints are just a region on the table where the vehicle is not allowed to fly through, so that it doesn't just fly in a straight line through xf,yf. The vehicle should not leave the table so I defined the upper and lower bounds fir the tables geometry. Also right now they include Acceleration in x and y direction and the limits of the vehicle mass(so that the mass is never negative).
My vehicle has a thruster, propellant and therefore a propellant flow.
My objective of this little example is to write a code that returns me the optimal trajectory(so the alpha is the control variable), so that the vehicle reaches xf,yf with the max. propellant(mp) possible. Obviously this is a Maximization problem, that is why I used mp=-....
The problem right now is that I don't understand how my Optimizer can return an optimal value for mp at the final time(And not just the highest possible mass, which is obviously at the beginning) .
Are the other variables I have(alpha,x,y,ax,ay) all to be defined as one control variable in form of a vector and if so how and when do I need to pass them to my Optimizer, because again I just want to output an optimal mpfinal and then plot the flight trajectory and the change of alpha in another step out of the results.
I attached my recent code
Hope someone can help
  8 个评论
Brendan Görres
Brendan Görres 2019-1-8
@Torsten
But if I leave alpha as a variable without the function
alpha=atan(y/x);
the ode45 cannot solve the equations. Or if I input alpha to fmincon as X0, how could I pass my constraints(that are only on x and y and not on alpha) to fmincon, because then the matrix for the linear inequality constraints has 2 rows and 2 columns while the X0 would just be alpha(0) and that is not solvable.
And that is exactly my problem. I do not know what Inputs I should give fmincon in this example, because I couldn't find anything similar while browsing..
Torsten
Torsten 2019-1-8
Optimal control problems contain functions as unknown objects, not single values.
So alpha = (alpha(1),alpha(2),...,alpha(n)) would be your X vector for fmincon to optimized. Here, alpha(i) corresponds to alpha at a certain time t_i between tstart and tend.
To use this vector alpha within your ODEs, you can use interpolation to the time t the integrator has reached.
Using this vector alpha, you get certain derived quantities, e.g. (x(1),...x(n)) and (y(1),...,y(n)). Constraints on these values can be set in function "nonlcon".
I strongly recommend that you consult a book on optimal control.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Nonlinear Optimization 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by