-
Notifications
You must be signed in to change notification settings - Fork 11
/
gpterminate.m
36 lines (33 loc) · 1.19 KB
/
gpterminate.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function gp = gpterminate(gp)
%GPTERMINATE Check for early termination of run.
%
% GP = GPTERMINATE(GP) checks if the GPTIPS run should be terminated at
% the end of the current generation according to a fitness criterion or
% run timeout.
%
% Copyright (c) 2009-2015 Dominic Searson
%
% GPTIPS 2
%
% See also GPFINALISE, GPTIC, GPTOC
%check if fitness termination criterion met
if gp.fitness.terminate
if gp.fitness.minimisation
if gp.results.best.fitness <= gp.fitness.terminate_value
gp.state.terminate = true;
gp.state.terminationReason = ['Fitness criterion acheived <= ' ...
num2str(gp.fitness.terminate_value)];
end
else
if gp.results.best.fitness >= gp.fitness.terminate_value;
gp.state.terminate = true;
gp.state.terminationReason = ['Fitness criterion acheived >= ' ...
num2str(gp.fitness.terminate_value)];
end
end
end
%run timeout
if ~gp.state.terminate && (gp.state.runTimeElapsed >= gp.runcontrol.timeout)
gp.state.terminate = true;
gp.state.terminationReason = ['Timeout >= ' num2str(gp.runcontrol.timeout) ' sec'];
end