Genetic algorithm for discrete trajectory design
4 次查看(过去 30 天)
显示 更早的评论
Hi, I have to optimize an interplanetary trajectory. I thought to follow this procedure: 1- divide the trajectory in N step 2- define the control vector u = [T1,alpha1,...,TN,alphaN] 3- define the objective function J = -mf +w1Dr+w2Dv (where Dr and Dv are the errors on position and velocity respectively) 4- integrate the motion equations (considering the thrust constant for each segment)
The control vector has an upper bound and a lower bound for T and alpha.
How can I implement this problem using the "ga" of Matlab? In particular, can I pass to "ga" a population given by discrete set of values? And how can I define the bounds on the control vector?
Thank you.
0 个评论
回答(1 个)
Alan Weiss
2017-3-6
You can set bound for your control vector u in the lb and ub arguments; see the ga function reference page.
You should probably sum the absolute values or the squares of the errors, not just sum the errors, in your objective function.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
3 个评论
Alan Weiss
2017-3-7
As the function reference page states, nvars is the number of design variables, also called control variables, which are the variables that ga passes to your fitness function. In your case nvars might be 2N, because you seem to have alpha_i and T_i for i ranging from 1 to N.
Generally your fitness function accepts a row vector x of length nvars and returns the value of the fitness function. If you need to call ode45 inside your fitness function, just do so. For example, (this just solves a simple ODE starting from y(0) = x(1) then adds the squares of the solution minus a fixed function):
function fval = myobj(x)
odefun = @(t,y)(2*y-t);
tspan = 0:0.2:5;
y0 = x(1);
[t,y] = ode45(@(t,y) 2*t, tspan, y0);
fval = sum((2*y-t).^2);
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with Optimization Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!