Genetic algorithm for discrete trajectory design
이전 댓글 표시
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.
답변 (1개)
Alan Weiss
2017년 3월 6일
0 개 추천
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
fe ri
2017년 3월 7일
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
카테고리
도움말 센터 및 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!