Genetic algorithm for discrete trajectory design
4 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Alan Weiss
on 6 Mar 2017
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 Comments
Alan Weiss
on 7 Mar 2017
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
See Also
Categories
Find more on Get Started with Optimization Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!