Genetic Algorithm: Failure in initial user-supplied fitness function evaluation. GA cannot continue.
5 views (last 30 days)
Show older comments
Hello, I am recieving this king of error from genetic algorithm
Error in
interplanetaryTrajectory>@(x)FunctionGA(x,PLANETDEP,PLANETGA,PLANETARR,mu_sun,dv_dep)
(line 28)
Fun = @(x) FunctionGA(x, PLANETDEP, PLANETGA, PLANETARR, mu_sun, dv_dep);
Error in createAnonymousFcn>@(x)fcn(x,FcnArgs{:}) (line 11)
fcn_handle = @(x) fcn(x,FcnArgs{:});
Error in fcnvectorizer (line 13)
y(i,:) = feval(fun,(pop(i,:)));
Error in makeState (line 58)
Score =
fcnvectorizer(state.Population(initScoreProvided+2:end,:),FitnessFcn,1,options.SerialUserFcn);
Error in galincon (line 17)
state = makeState(GenomeLength,FitnessFcn,Iterate,output.problemtype,options);
Error in ga (line 374)
[x,fval,exitFlag,output,population,scores] =
galincon(FitnessFcn,nvars, ...
Error in interplanetaryTrajectory (line 42)
[t,dv_min] = ga(Fun,nvars,A,b,[],[],LB,UB,[],[],options);
Error in FlybyMission_group_11 (line 20)
interplanetaryTrajectory (PLANETDEP, PLANETGA, PLANETARR);
Caused by:
Failure in user-supplied fitness function evaluation. GA cannot continue.
My code is:
% % Function to minimize
Fun = @(x) FunctionGA(x, PLANETDEP, PLANETGA, PLANETARR, mu_sun, dv_dep);
nvars = 3; % Number of variables
LB = [T1(1) T2(1) T3(1)]; % Lower Boundaries for the variables
UB = [T1(end) T2(end) T3(end)]; % Upper Boundaries for the variables
% Linear Inequalities ( t1-t2<0 ; t2-t3<0 )
A = [ 1 -1 0; 0 1 -1];
b = [ 0; 0];
% Option set
options = optimoptions('ga','Display','off');
% Genetic Algorithm Solution
[t,dv_min] = ga(Fun,nvars,A,b,[],[],LB,UB,[],options);
I have two linear inequalities, but if I create a Constraints function that gives the exact same inequalities of the A*x < b, the code works. What am I missing?
1 Comment
SARA OUANES
on 25 Sep 2019
Hello,
Did you find a solution to your problem? I'm encountering the same issue.
Answers (0)
See Also
Categories
Find more on Genetic Algorithm 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!