Pro.pm

filter: Statementstmt 64.3% 251 / 390 Branchbran 49.4% 84 / 170 Conditioncond 29.8% 23 / 77 MC/DCmcdc 4.7% 2 / 42 Subroutinesub 68.5% 37 / 54 Podpod 86.3% 19 / 22 totaltotal 55.1% 416 / 755 CC 129 SCAR 38.7
CC
129
Cov
56%
chart
306.0
evolve
87.0
getFittest_as_arrayref
34.8
CRAP 48.1
« Pro/Selection/RouletteDistribution.pm ↑ Summary Pro/Mutation/Rangevector.pm »
1 package AI::Genetic::Pro;
2  
3 460 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 460 $VERSION = 1.000;
6 #---------------
7  
8 460 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 460 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 460 ▶use base qw( Class::Accessor::Fast );
Subroutine BEGIN: called CC=1 SCAR=0.0
11 #-----------------------------------------------------------------------
12 460 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 460 ▶use Clone qw( clone );
Subroutine BEGIN: called CC=1 SCAR=0.0
14 460 ▶use Struct::Compare;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 460 ▶use Digest::MD5 qw( md5_hex );
Subroutine BEGIN: called CC=1 SCAR=0.0
16 460 ▶use List::Util qw( sum );
Subroutine BEGIN: called CC=1 SCAR=0.0
17 460 ▶use List::MoreUtils qw( minmax first_index apply );
Subroutine BEGIN: called CC=1 SCAR=0.0
18 #use Data::Dumper; $Data::Dumper::Sortkeys = 1;
19 460 ▶use Tie::Array::Packed;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 460 ▶use UNIVERSAL::require;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 #-----------------------------------------------------------------------
22 460 ▶use AI::Genetic::Pro::Array::Type qw( get_package_by_element_size );
Subroutine BEGIN: called CC=1 SCAR=0.0
23 460 ▶use AI::Genetic::Pro::Chromosome;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 #-----------------------------------------------------------------------
25 460 __PACKAGE__->mk_accessors(qw(
26 mce
27 type
28 population
29 terminate
30 chromosomes
31 crossover
32 native
33 parents _parents
34 history _history
35 fitness _fitness _fitness_real
36 cache
37 mutation _mutator
38 strategy _strategist
39 selection _selector
40 _translations
41 generation
42 preserve
43 variable_length
44 _fix_range
45 _package
46 _length
47 strict _strict
48 workers
49 size
50 _init
51 ));
52 #=======================================================================
53 # Additional modules
54 460 ▶use constant STORABLE => 'Storable';
Subroutine BEGIN: called CC=1 SCAR=0.0
55 460 ▶use constant GD => 'GD::Graph::linespoints';
Subroutine BEGIN: called CC=1 SCAR=0.0
56 #=======================================================================
57 460 my $_Cache = { };
58 460 my $_temp_chromosome;
59 #=======================================================================
60 sub new {
61 876 ▶ my ( $class, %args ) = ( shift, @_ );
Subroutine new: called CC=15 SCAR=29.0
Pod documented
62
63 #-------------------------------------------------------------------
64 876 ▶ my %opts = map { if(ref $_){$_}else{ /^-?(.*)$/o; $1 }} @_;
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_) { } 3504 20190 23694
65 876 my $self = bless \%opts, $class;
66
67 #-------------------------------------------------------------------
68 876 ▶ $AI::Genetic::Pro::Array::Type::Native = 1 if $self->native;
Branch: 1 branch
BranchTrueFalseTotal
if $self->native 431 445 876
69
70 #-------------------------------------------------------------------
71 876 ▶ croak(q/Type of chromosomes cannot be "combination" if "variable length" feature is active!/)
Branch: 1 branch
BranchTrueFalseTotal
if $self->type eq "combination" and $self->variable_length 0 876 876
Condition66%2/3
$self->type eq "combination" and $self->variable_length
!ll&&!rl&&r
87510
MC/DC0%0/2
$self->type eq "combination" and $self->variable_length
$self->type eq "combination" $self->variable_length
Truth table66%2/3
A and B
A= $self->type eq "combination"B= $self->variable_length
ABresult
0X0
100
111
72 if $self->type eq q/combination/ and $self->variable_length;
73 876 ▶ croak(q/You must specify a crossover strategy with -strategy!/)
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->strategy 0 876 876
74 unless defined ($self->strategy);
75 876 ▶ croak(q/Type of chromosomes cannot be "combination" if strategy is not one of: OX, PMX!/)
Branch: 1 branch
BranchTrueFalseTotal
if $self->type eq "combination" and ($self->strategy->[0] ne "OX" and $self->strategy->[0] ne "PMX") 0 876 876
Condition50%3/6
$self->type eq "combination" and ($self->strategy->[0] ne "OX" and $self->strategy->[0] ne "PMX")
!ll&&!rl&&r
87510
$self->strategy->[0] ne "OX" and $self->strategy->[0] ne "PMX"
!ll&&!rl&&r
010
MC/DC0%0/3
$self->type eq "combination" and ($self->strategy->[0] ne "OX" and $self->strategy->[0] ne "PMX")
$self->type eq "combination" $self->strategy->[0] ne "OX" $self->strategy->[0] ne "PMX"
Truth table50%2/4
A and B and C
A= $self->type eq "combination"B= $self->strategy->[0] ne "OX"C= $self->strategy->[0] ne "PMX"
ABCresult
0XX0
10X0
1100
1111
76 if $self->type eq q/combination/ and ($self->strategy->[0] ne q/OX/ and $self->strategy->[0] ne q/PMX/);
77 876 ▶ croak(q/Strategy cannot be "/,$self->strategy->[0],q/" if "variable length" feature is active!/ )
Branch: 1 branch
BranchTrueFalseTotal
if $self->strategy->[0] eq "PMX" || $self->strategy->[0] eq "OX" and $self->variable_length 0 876 876
Condition66%4/6
$self->strategy->[0] eq "PMX" || $self->strategy->[0] eq "OX" and $self->variable_length
!ll&&!rl&&r
87510
$self->strategy->[0] eq "PMX" or $self->strategy->[0] eq "OX"
l!l&&r!l&&!r
10875
MC/DC0%0/3
$self->strategy->[0] eq "PMX" || $self->strategy->[0] eq "OX" and $self->variable_length
$self->strategy->[0] eq "PMX" $self->strategy->[0] eq "OX" $self->variable_length
Truth table40%2/5
A or B and C
A= $self->strategy->[0] eq "PMX"B= $self->strategy->[0] eq "OX"C= $self->variable_length
ABCresult
00X0
1X00
0100
1X11
0111
78 if ($self->strategy->[0] eq 'PMX' or $self->strategy->[0] eq 'OX') and $self->variable_length;
79
80 #-------------------------------------------------------------------
81 876 ▶ $self->_set_strict if $self->strict;
Branch: 1 branch
BranchTrueFalseTotal
if $self->strict 0 876 876
82  
83 #-------------------------------------------------------------------
84 876 ▶ return $self unless $self->mce;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->mce 432 444 876
85  
86 #-------------------------------------------------------------------
87 444 delete $self->{ mce };
88 444 ▶ 'AI::Genetic::Pro::MCE'->use or die q[Cannot raise multicore support: ] . $@;
Branch: 1 branch
BranchTrueFalseTotal
"AI::Genetic::Pro::MCE"->use or die 'Cannot raise multicore support: ' . $@ 0 444 444
89
90 444 return AI::Genetic::Pro::MCE->new( $self, \%args );
91 }
92 #=======================================================================
93 0 ▶sub _Cache { $_Cache; }
Subroutine _Cache: not called CC=1 SCAR=6.9
94 #=======================================================================
95 # INIT #################################################################
96 #=======================================================================
97 sub _set_strict {
98 0 ▶ my ($self) = @_;
Subroutine _set_strict: not called CC=1 SCAR=6.9
99
100 # fitness
101 0 my $fitness = $self->fitness();
102 my $replacement = sub {
103 0 ▶ my @tmp = @{$_[1]};
Subroutine __ANON__: not called CC=2 SCAR=17.9
104 0 my $ret = $fitness->(@_);
105 0 my @cmp = @{$_[1]};
106 0 ▶ die qq/Chromosome was modified in a fitness function from "@tmp" to "@{$_[1]}"!\n/ unless compare(\@tmp, \@cmp);
Branch: 1 branch
BranchTrueFalseTotal
unless compare(\@tmp, \@cmp) 0 0 0
107 0 return $ret;
108 0 };
109 0 $self->fitness($replacement);
110 }
111 #=======================================================================
112 sub _fitness_cached {
113 67954 ▶ my ($self, $chromosome) = @_;
Subroutine _fitness_cached: called CC=3 SCAR=11.0
114
115 #my $key = md5_hex(${tied(@$chromosome)});
116 67954 ▶ my $key = md5_hex( $self->_package ? md5_hex( ${ tied( @$chromosome ) } ) : join( q[:], @$chromosome ) );
Branch: 1 branch
BranchTrueFalseTotal
$self->_package ? : 59603 8351 67954
117 67954 ▶ return $_Cache->{$key} if exists $_Cache->{$key};
Branch: 1 branch
BranchTrueFalseTotal
if exists $_Cache->{$key} 53909 14045 67954
118
119 14045 $_Cache->{$key} = $self->_fitness_real->($self, $chromosome);
120 14045 return $_Cache->{$key};
121 }
122 #=======================================================================
123 sub _init_cache {
124 874 ▶ my ($self) = @_;
Subroutine _init_cache: called CC=1 SCAR=0.0
125
126 874 $self->_fitness_real($self->fitness);
127 874 $self->fitness(\&_fitness_cached);
128 874 return;
129 }
130 #=======================================================================
131 sub _check_data_ref {
132 6 ▶ my ($self, $data_org) = @_;
Subroutine _check_data_ref: called CC=3 SCAR=11.0
133 6 my $data = clone($data_org);
134 6 my $ars;
135 6 for(0..$#$data){
136 48 ▶ next if $ars->{$data->[$_]};
Branch: 1 branch
BranchTrueFalseTotal
if $$ars{$data->[$_]} 0 48 48
137 48 $ars->{$data->[$_]} = 1;
138 48 unshift @{$data->[$_]}, undef;
139 }
140 6 return $data;
141 }
142 #=======================================================================
143 # we have to find C to (in some cases) incrase value of range
144 # due to design model
145 sub _find_fix_range {
146 3 ▶ my ($self, $data) = @_;
Subroutine _find_fix_range: called CC=3 SCAR=11.3
147  
148 3 for my $idx (0..$#$data){
149 24 ▶ if($data->[$idx]->[1] < 1){
Branch: 1 branch
BranchTrueFalseTotal
if ($data->[$idx][1] < 1) { } 24 0 24
150 24 my $const = 1 - $data->[$idx]->[1];
151 24 push @{$self->_fix_range}, $const;
152 24 $data->[$idx]->[1] += $const;
153 24 $data->[$idx]->[2] += $const;
154 0 }else{ push @{$self->_fix_range}, 0; }
155 }
156  
157 3 return $data;
158 }
159 #=======================================================================
160 sub init {
161 876 ▶ my ( $self, $data ) = @_;
Subroutine init: called CC=22 SCAR=31.1
Pod documented
162
163 876 ▶ croak q/You have to pass some data to "init"!/ unless $data;
Branch: 1 branch
BranchTrueFalseTotal
unless $data 0 876 876
164 #-------------------------------------------------------------------
165 876 $self->generation(0);
166 876 $self->_init( $data );
167 876 $self->_fitness( { } );
168 876 $self->_fix_range( [ ] );
169 876 $self->_history( [ [ ], [ ], [ ] ] );
170 876 ▶ $self->_init_cache if $self->cache;
Branch: 1 branch
BranchTrueFalseTotal
if $self->cache 874 2 876
171 #-------------------------------------------------------------------
172
173 876 ▶ if($self->type eq q/listvector/){
Branch: 4 branches
BranchTrueFalseTotal
if ($self->type eq 'listvector') { } 3 873 876
elsif ($self->type eq 'bitvector') { } 869 4 873
elsif ($self->type eq 'combination') { } 1 3 4
elsif ($self->type eq 'rangevector') { } 3 0 3
174 3 ▶ croak(q/You have to pass array reference if "type" is set to "listvector"/) unless ref $data eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $data eq "ARRAY" 0 3 3
175 3 $self->_translations( $self->_check_data_ref($data) );
176 }elsif($self->type eq q/bitvector/){
177 869 ▶ croak(q/You have to pass integer if "type" is set to "bitvector"/) if $data !~ /^\d+$/o;
Branch: 1 branch
BranchTrueFalseTotal
unless $data =~ /^\d+$/o 0 869 869
178 869 $self->_translations( [ [ 0, 1 ] ] );
179 869 $self->_translations->[$_] = $self->_translations->[0] for 1..$data-1;
180 }elsif($self->type eq q/combination/){
181 1 ▶ croak(q/You have to pass array reference if "type" is set to "combination"/) unless ref $data eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $data eq "ARRAY" 0 1 1
182 1 $self->_translations( [ clone($data) ] );
183 1 $self->_translations->[$_] = $self->_translations->[0] for 1..$#$data;
184 }elsif($self->type eq q/rangevector/){
185 3 ▶ croak(q/You have to pass array reference if "type" is set to "rangevector"/) unless ref $data eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $data eq "ARRAY" 0 3 3
186 3 $self->_translations( $self->_find_fix_range( $self->_check_data_ref($data) ));
187 }else{
188 0 croak(q/You have to specify first "type" of vector!/);
189 }
190
191 876 my $size = 0;
192  
193 876 ▶ if($self->type ne q/rangevector/){ for(@{$self->_translations}){ $size = $#$_ if $#$_ > $size; } }
Branch: 2 branches
BranchTrueFalseTotal
if ($self->type ne 'rangevector') { } 873 3 876
if $_->$#* > $size 873 14877 15750
194 # else{ for(@{$self->_translations}){ $size = $_->[1] if $_->[1] > $size; } }
195 3 ▶ else{ for(@{$self->_translations}){ $size = $_->[2] if $_->[2] > $size; } } # Provisional patch for rangevector values truncated to signed 8-bit quantities. Thx to Tod Hagan
Branch: 1 branch
BranchTrueFalseTotal
if $_->[2] > $size 3 21 24
196  
197 876 my $package = get_package_by_element_size($size);
198 876 $self->_package($package);
199  
200 876 ▶ my $length = ref $data ? sub { $#$data; } : sub { $data - 1 };
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
ref $data ? : 7 869 876
201 876 ▶ if($self->variable_length){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->variable_length) 6 870 876
202 6 ▶ $length = ref $data ? sub { 1 + int( rand( $#{ $self->_init } ) ); } : sub { 1 + int( rand( $self->_init - 1) ); };
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
ref $data ? : 4 2 6
203 }
204  
205 876 $self->_length( $length );
206  
207 876 $self->chromosomes( [ ] );
208 2454 push @{$self->chromosomes},
209 AI::Genetic::Pro::Chromosome->new($self->_translations, $self->type, $package, $length->())
210 876 for 1..$self->population;
211
212 876 $self->_calculate_fitness_all();
213 }
214 #=======================================================================
215 # SAVE / LOAD ##########################################################
216 #=======================================================================
217 sub spew {
218 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
219 0 ▶ STORABLE->use( qw( store retrieve freeze thaw ) ) or croak(q/You need "/.STORABLE.q/" module to save a state of "/.__PACKAGE__.q/"!/);
Subroutine spew: not called CC=5 SCAR=34.0
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
"Storable"->use("store", "retrieve", "freeze", "thaw") or croak("You need \"Storable\" module to save a state of \"AI::Genetic::Pro\"!") 0 0 0
220 0 $Storable::Deparse = 1;
221 0 $Storable::Eval = 1;
222 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
223 0 my ( $self ) = @_;
224
225 0 my $clone = {
226 _selector => undef,
227 _strategist => undef,
228 _mutator => undef,
229 };
230
231 0 ▶ $clone->{ chromosomes } = [ map { ${ tied( @$_ ) } } @{ $self->chromosomes } ]
Branch: 1 branch
BranchTrueFalseTotal
if $self->_package 0 0 0
232 if $self->_package;
233
234 0 foreach my $key(keys %$self){
235 0 ▶ next if exists $clone->{$key};
Branch: 1 branch
BranchTrueFalseTotal
if exists $clone->{$key} 0 0 0
236 0 $clone->{$key} = $self->{$key};
237 }
238
239 0 return $clone;
240 }
241 #=======================================================================
242 sub slurp {
243 0 ▶ my ( $self, $dump ) = @_;
Subroutine slurp: not called CC=2 SCAR=17.9
Pod undocumented
244  
245 0 ▶ if( my $typ = $self->_package ){
Branch: 1 branch
BranchTrueFalseTotal
if (my $typ = $self->_package) 0 0 0
246 0 @{ $dump->{ chromosomes } } = map {
247 0 my $arr = $typ->make_with_packed( $_ );
248 0 bless $arr, q[AI::Genetic::Pro::Chromosome];
249 0 } @{ $dump->{ chromosomes } };
250 }
251
252 0 %$self = %$dump;
253
254 0 return 1;
255 }
256 #=======================================================================
257 sub save {
258 0 ▶ my ( $self, $file ) = @_;
Subroutine save: not called CC=2 SCAR=17.9
Pod documented
259
260 0 ▶ croak(q/You have to specify file!/) unless defined $file;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $file 0 0 0
261
262 0 store( $self->spew, $file );
263 }
264 #=======================================================================
265 sub load {
266 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
267 0 ▶ STORABLE->use( qw( store retrieve freeze thaw ) ) or croak(q/You need "/.STORABLE.q/" module to load a state of "/.__PACKAGE__.q/"!/);
Subroutine load: not called CC=4 SCAR=30.0
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
"Storable"->use("store", "retrieve", "freeze", "thaw") or croak("You need \"Storable\" module to load a state of \"AI::Genetic::Pro\"!") 0 0 0
268 0 $Storable::Deparse = 1;
269 0 $Storable::Eval = 1;
270 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
271 0 my ($self, $file) = @_;
272 0 ▶ croak(q/You have to specify file!/) unless defined $file;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $file 0 0 0
273  
274 0 my $clone = retrieve($file);
275 0 ▶ return carp('Incorrect file!') unless $clone;
Branch: 1 branch
BranchTrueFalseTotal
unless $clone 0 0 0
276
277 0 return $self->slurp( $clone );
278 }
279 #=======================================================================
280 # CHARTS ###############################################################
281 #=======================================================================
282 sub chart {
283 0 ▶ GD->require or croak(q/You need "/.GD.q/" module to draw chart of evolution!/);
Subroutine chart: not called CC=17 SCAR=57.2
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
"GD::Graph::linespoints"->require or croak("You need \"GD::Graph::linespoints\" module to draw chart of evolution!") 0 0 0
284 0 my ($self, %params) = (shift, @_);
285  
286 0 ▶ my $graph = GD()->new(($params{-width} || 640), ($params{-height} || 480));
Condition0%0/4
$params{'-width'} || 640
l!l
00
$params{'-height'} || 480
l!l
00
MC/DC0%0/1
$params{'-width'} || 640
$params{'-width'}
MC/DC0%0/1
$params{'-height'} || 480
$params{'-height'}
Truth table0%0/2
A
A= $params{'-width'}
Aresult
11
00
Truth table0%0/2
A
A= $params{'-height'}
Aresult
11
00
287  
288 0 my $data = $self->getHistory;
289  
290 0 ▶ if(defined $params{-font}){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params{"-font"}) 0 0 0
291 0 $graph->set_title_font ($params{-font}, 12);
292 0 $graph->set_x_label_font($params{-font}, 10);
293 0 $graph->set_y_label_font($params{-font}, 10);
294 0 $graph->set_legend_font ($params{-font}, 8);
295 }
296
297 $graph->set_legend(
298 $params{legend1} || q/Max value/,
299 $params{legend2} || q/Mean value/,
300 0 ▶ $params{legend3} || q/Min value/,
Condition0%0/6
$params{'legend1'} || 'Max value'
l!l
00
$params{'legend2'} || 'Mean value'
l!l
00
$params{'legend3'} || 'Min value'
l!l
00
MC/DC0%0/1
$params{'legend1'} || 'Max value'
$params{'legend1'}
MC/DC0%0/1
$params{'legend2'} || 'Mean value'
$params{'legend2'}
MC/DC0%0/1
$params{'legend3'} || 'Min value'
$params{'legend3'}
Truth table0%0/2
A
A= $params{'legend1'}
Aresult
11
00
Truth table0%0/2
A
A= $params{'legend2'}
Aresult
11
00
Truth table0%0/2
A
A= $params{'legend3'}
Aresult
11
00
301 );
302  
303 $graph->set(
304 x_label_skip => int(($data->[0]->[-1]*4)/100),
305 x_labels_vertical => 1,
306 x_label_position => .5,
307 y_label_position => .5,
308 y_long_ticks => 1, # poziome linie
309 x_ticks => 1, # poziome linie
310  
311 l_margin => 10,
312 b_margin => 10,
313 r_margin => 10,
314 t_margin => 10,
315  
316 show_values => (defined $params{-show_values} ? 1 : 0),
317 values_vertical => 1,
318 values_format => ($params{-format} || '%.2f'),
319  
320 zero_axis => 1,
321 #interlaced => 1,
322 logo_position => 'BR',
323 legend_placement => 'RT',
324  
325 bgclr => 'white',
326 boxclr => '#FFFFAA',
327 transparent => 0,
328  
329 title => ($params{'-title'} || q/Evolution/ ),
330 x_label => ($params{'-x_label'} || q/Generation/),
331 y_label => ($params{'-y_label'} || q/Value/ ),
332
333 0 ▶ ( $params{-logo} && -f $params{-logo} ? ( logo => $params{-logo} ) : ( ) )
Branch: 2 branches
BranchTrueFalseTotal
defined $params{'-show_values'} ? : 0 0 0
$params{'-logo'} && -f $params{'-logo'} ? : 0 0 0
Condition0%0/11
$params{'-format'} || '%.2f'
l!l
00
$params{'-title'} || 'Evolution'
l!l
00
$params{'-x_label'} || 'Generation'
l!l
00
$params{'-y_label'} || 'Value'
l!l
00
$params{"-logo"} and -f $params{"-logo"}
!ll&&!rl&&r
000
MC/DC0%0/1
$params{'-format'} || '%.2f'
$params{'-format'}
MC/DC0%0/1
$params{'-title'} || 'Evolution'
$params{'-title'}
MC/DC0%0/1
$params{'-x_label'} || 'Generation'
$params{'-x_label'}
MC/DC0%0/1
$params{'-y_label'} || 'Value'
$params{'-y_label'}
MC/DC0%0/2
$params{"-logo"} and -f $params{"-logo"}
$params{"-logo"} -f $params{"-logo"}
Truth table0%0/2
A
A= $params{'-format'}
Aresult
11
00
Truth table0%0/2
A
A= $params{'-title'}
Aresult
11
00
Truth table0%0/2
A
A= $params{'-x_label'}
Aresult
11
00
Truth table0%0/2
A
A= $params{'-y_label'}
Aresult
11
00
Truth table0%0/3
A and B
A= $params{"-logo"}B= -f $params{"-logo"}
ABresult
0X0
100
111
334 );
335
336
337 0 ▶ my $gd = $graph->plot( [ [ 0..$#{$data->[0]} ], @$data ] ) or croak($@);
Branch: 1 branch
BranchTrueFalseTotal
my $gd = $graph->plot([[0 .. $#{$$data[0];}], @$data]) or croak($@) 0 0 0
338 0 ▶ open(my $fh, '>', $params{-filename}) or croak($@);
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", $params{"-filename"} or croak($@) 0 0 0
339 0 binmode $fh;
340 0 print $fh $gd->png;
341 0 close $fh;
342
343 0 return 1;
344 }
345 #=======================================================================
346 # TRANSLATIONS #########################################################
347 #=======================================================================
348 sub as_array_def_only {
349 0 ▶ my ($self, $chromosome) = @_;
Subroutine as_array_def_only: not called CC=5 SCAR=34.0
Pod documented
350
351 0 ▶ return $self->as_array($chromosome)
Branch: 1 branch
BranchTrueFalseTotal
if not $self->variable_length or $self->variable_length < 2 0 0 0
Condition0%0/3
not $self->variable_length or $self->variable_length < 2
l!l&&r!l&&!r
000
MC/DC0%0/2
not $self->variable_length or $self->variable_length < 2
not $self->variable_length $self->variable_length < 2
Truth table0%0/3
not(A) or B
A= not $self->variable_lengthB= $self->variable_length < 2
ABresult
1X1
011
000
352 if not $self->variable_length or $self->variable_length < 2;
353
354 0 ▶ if( $self->type eq q/bitvector/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->type eq 'bitvector') { } 0 0 0
355 0 return $self->as_array($chromosome);
356 }else{
357 0 my $ar = $self->as_array($chromosome);
358 0 ▶ my $idx = first_index { $_ } @$ar;
Subroutine __ANON__: not called CC=1 SCAR=6.9
359 0 my @array = @$ar[$idx..$#$chromosome];
360 0 ▶ return @array if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
361 0 return \@array;
362 }
363 }
364 #=======================================================================
365 sub as_array {
366 24190 ▶ my ($self, $chromosome) = @_;
Subroutine as_array: called CC=7 SCAR=19.5
Pod documented
367
368 24190 ▶ if($self->type eq q/bitvector/){
Branch: 2 branches
BranchTrueFalseTotal
if ($self->type eq 'bitvector') { } 21824 2366 24190
elsif ($self->type eq 'rangevector') { } 1090 1276 2366
369 21824 ▶ return @$chromosome if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 21824 21824
370 21824 return $chromosome;
371 }elsif($self->type eq q/rangevector/){
372 1090 my $fix_range = $self->_fix_range;
373 1090 my $c = -1;
374 #my @array = map { $c++; warn "WARN: $c | ",scalar @$chromosome,"\n" if not defined $fix_range->[$c]; $_ ? $_ - $fix_range->[$c] : undef } @$chromosome;
375 1090 ▶ my @array = map { $c++; $_ ? $_ - $fix_range->[$c] : undef } @$chromosome;
Branch: 1 branch
BranchTrueFalseTotal
$_ ? : 7987 20 8007
376
377 1090 ▶ return @array if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 1090 1090
378 1090 return \@array;
379 }else{
380 1276 my $cnt = 0;
381 1276 my @array = map { $self->_translations->[$cnt++]->[$_] } @$chromosome;
382 1276 ▶ return @array if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 1276 1276
383 1276 return \@array;
384 }
385 }
386 #=======================================================================
387 sub as_string_def_only {
388 0 ▶ my ($self, $chromosome) = @_;
Subroutine as_string_def_only: not called CC=4 SCAR=30.0
Pod documented
389
390 0 ▶ return $self->as_string($chromosome)
Branch: 1 branch
BranchTrueFalseTotal
if not $self->variable_length or $self->variable_length < 2 0 0 0
Condition0%0/3
not $self->variable_length or $self->variable_length < 2
l!l&&r!l&&!r
000
MC/DC0%0/2
not $self->variable_length or $self->variable_length < 2
not $self->variable_length $self->variable_length < 2
Truth table0%0/3
not(A) or B
A= not $self->variable_lengthB= $self->variable_length < 2
ABresult
1X1
011
000
391 if not $self->variable_length or $self->variable_length < 2;
392  
393 0 my $array = $self->as_array_def_only($chromosome);
394
395 0 ▶ return join(q//, @$array) if $self->type eq q/bitvector/;
Branch: 1 branch
BranchTrueFalseTotal
if $self->type eq "bitvector" 0 0 0
396 0 return join(q/___/, @$array);
397 }
398 #=======================================================================
399 sub as_string {
400 414 ▶ return join(q//, @{$_[1]}) if $_[0]->type eq q/bitvector/;
Subroutine as_string: called CC=3 SCAR=16.5
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]->type eq "bitvector" 414 0 414
401 0 ▶ return join(q/___/, map { defined $_ ? $_ : q/ / } $_[0]->as_array($_[1]));
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 0 0 0
402 }
403 #=======================================================================
404 sub as_value {
405 23599 ▶ my ($self, $chromosome) = @_;
Subroutine as_value: called CC=8 SCAR=25.8
Pod documented
406 23599 ▶ croak(q/You MUST call 'as_value' as method of 'AI::Genetic::Pro' object./)
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_[0] and ref $_[0] and ref $_[0] eq "AI::Genetic::Pro" || ref $_[0] eq "AI::Genetic::Pro::MCE" 0 23599 23599
Condition55%5/9
defined $_[0] and ref $_[0] and ref $_[0] eq "AI::Genetic::Pro" || ref $_[0] eq "AI::Genetic::Pro::MCE"
!ll&&!rl&&r
0204453154
defined $_[0] and ref $_[0]
!ll&&!rl&&r
0023599
ref $_[0] eq "AI::Genetic::Pro" or ref $_[0] eq "AI::Genetic::Pro::MCE"
l!l&&r!l&&!r
2044531540
MC/DC0%0/4
defined $_[0] and ref $_[0] and ref $_[0] eq "AI::Genetic::Pro" || ref $_[0] eq "AI::Genetic::Pro::MCE"
defined $_[0] ref $_[0] ref $_[0] eq "AI::Genetic::Pro" ref $_[0] eq "AI::Genetic::Pro::MCE"
Truth table20%1/5
A and B and C or D
A= defined $_[0]B= ref $_[0]C= ref $_[0] eq "AI::Genetic::Pro"D= ref $_[0] eq "AI::Genetic::Pro::MCE"
ABCDresult
0XXX0
10XX0
11000
111X1
11011
407 unless defined $_[0] and ref $_[0] and ( ref $_[0] eq 'AI::Genetic::Pro' or ref $_[0] eq 'AI::Genetic::Pro::MCE');
408 23599 ▶ croak(q/You MUST pass 'AI::Genetic::Pro::Chromosome' object to 'as_value' method./)
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_[1] and ref $_[1] and ref $_[1] eq "AI::Genetic::Pro::Chromosome" 0 23599 23599
Condition33%2/6
defined $_[1] and ref $_[1] and ref $_[1] eq "AI::Genetic::Pro::Chromosome"
!ll&&!rl&&r
0023599
defined $_[1] and ref $_[1]
!ll&&!rl&&r
0023599
MC/DC0%0/3
defined $_[1] and ref $_[1] and ref $_[1] eq "AI::Genetic::Pro::Chromosome"
defined $_[1] ref $_[1] ref $_[1] eq "AI::Genetic::Pro::Chromosome"
Truth table25%1/4
A and B and C
A= defined $_[1]B= ref $_[1]C= ref $_[1] eq "AI::Genetic::Pro::Chromosome"
ABCresult
0XX0
10X0
1100
1111
409 unless defined $_[1] and ref $_[1] and ref $_[1] eq 'AI::Genetic::Pro::Chromosome';
410 23599 return $self->fitness->($self, $chromosome);
411 }
412 #=======================================================================
413 # ALGORITHM ############################################################
414 #=======================================================================
415 sub _calculate_fitness_all {
416 432 ▶ my ($self) = @_;
Subroutine _calculate_fitness_all: called CC=2 SCAR=6.9
417
418 432 $self->_fitness( { } );
419 $self->_fitness->{$_} = $self->fitness()->($self, $self->chromosomes->[$_])
420 432 for 0..$#{$self->chromosomes};
421  
422 # sorting the population is not necessary
423 # my (@chromosomes, %fitness);
424 # for my $idx (sort { $self->_fitness->{$a} <=> $self->_fitness->{$b} } keys %{$self->_fitness}){
425 # push @chromosomes, $self->chromosomes->[$idx];
426 # $fitness{$#chromosomes} = $self->_fitness->{$idx};
427 # delete $self->_fitness->{$idx};
428 # delete $self->chromosomes->[$idx];
429 # }
430 #
431 # $self->_fitness(\%fitness);
432 # $self->chromosomes(\@chromosomes);
433  
434 432 return;
435 }
436 #=======================================================================
437 sub _select_parents {
438 415 ▶ my ($self) = @_;
Subroutine _select_parents: called CC=4 SCAR=13.9
439 415 ▶ unless($self->_selector){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_selector) 401 14 415
440 401 ▶ croak "You must specify a selection strategy!"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->selection 0 401 401
441 unless defined $self->selection;
442 401 my @tmp = @{$self->selection};
443 401 my $selector = q/AI::Genetic::Pro::Selection::/ . shift @tmp;
444 401 ▶ $selector->require or die $!;
Branch: 1 branch
BranchTrueFalseTotal
$selector->require or die $! 0 401 401
445 401 $self->_selector($selector->new(@tmp));
446 }
447
448 415 $self->_parents($self->_selector->run($self));
449
450 415 return;
451 }
452 #=======================================================================
453 sub _crossover {
454 415 ▶ my ($self) = @_;
Subroutine _crossover: called CC=3 SCAR=11.0
455
456 415 ▶ unless($self->_strategist){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_strategist) 401 14 415
457 401 my @tmp = @{$self->strategy};
458 401 my $strategist = q/AI::Genetic::Pro::Crossover::/ . shift @tmp;
459 401 ▶ $strategist->require or die $!;
Branch: 1 branch
BranchTrueFalseTotal
$strategist->require or die $! 0 401 401
460 401 $self->_strategist($strategist->new(@tmp));
461 }
462  
463 415 my $a = $self->_strategist->run($self);
464 415 $self->chromosomes( $a );
465
466 415 return;
467 }
468 #=======================================================================
469 sub _mutation {
470 415 ▶ my ($self) = @_;
Subroutine _mutation: called CC=3 SCAR=11.4
471
472 415 ▶ unless($self->_mutator){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_mutator) 401 14 415
473 401 my $mutator = q/AI::Genetic::Pro::Mutation::/ . ucfirst(lc($self->type));
474 401 ▶ unless($mutator->require){
Branch: 1 branch
BranchTrueFalseTotal
unless ($mutator->require) 0 401 401
475 0 $mutator = q/AI::Genetic::Pro::Mutation::Listvector/;
476 0 $mutator->require;
477 }
478 401 $self->_mutator($mutator->new);
479 }
480
481 415 return $self->_mutator->run($self);
482 }
483 #=======================================================================
484 sub _save_history {
485 3565 ▶ my @tmp;
Subroutine _save_history: called CC=2 SCAR=7.0
486 3565 ▶ if($_[0]->history){ @tmp = $_[0]->getAvgFitness; }
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0]->history) { } 0 3565 3565
487 3565 else { @tmp = (undef, undef, undef); }
488
489 3565 push @{$_[0]->_history->[0]}, $tmp[0];
490 3565 push @{$_[0]->_history->[1]}, $tmp[1];
491 3565 push @{$_[0]->_history->[2]}, $tmp[2];
492 3565 return 1;
493 }
494 #=======================================================================
495 sub inject {
496 408 ▶ my ($self, $candidates) = @_;
Subroutine inject: called CC=2 SCAR=6.9
Pod documented
497
498 408 for(@$candidates){
499 13499 push @{$self->chromosomes},
500 AI::Genetic::Pro::Chromosome->new_from_data($self->_translations, $self->type, $self->_package, $_, $self->_fix_range);
501 13499 $self->_fitness->{$#{$self->chromosomes}} = $self->fitness()->($self, $self->chromosomes->[-1]);
502  
503 }
504 408 $self->_strict( [ ] );
505 408 $self->population( $self->population + scalar( @$candidates ) );
506  
507 408 return 1;
508 }
509 #=======================================================================
510 sub _state {
511 416 ▶ my ( $self ) = @_;
Subroutine _state: called CC=2 SCAR=6.9
512
513 416 my @res;
514
515 416 ▶ if( $self->_package ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_package) { } 208 208 416
516 @res = map {
517 208 [
518 1600 ${ tied( @{ $self->chromosomes->[ $_ ] } ) },
519 1600 $self->_fitness->{ $_ },
520 ]
521 } 0 .. $self->population - 1
522 }else{
523 @res = map {
524 208 [
525 $self->chromosomes->[ $_ ],
526 1600 $self->_fitness->{ $_ },
527 ]
528 } 0 .. $self->population - 1
529 }
530
531 416 return \@res;
532 }
533 #=======================================================================
534 sub evolve {
535 403 ▶ my ($self, $generations) = @_;
Subroutine evolve: called CC=19 SCAR=44.7
Pod documented
536  
537 # generations must be defined
538 403 ▶ $generations ||= -1;
Condition50%1/2
$generations ||= -1
l!l
4030
MC/DC0%0/1
$generations ||= -1
$generations
Truth table50%1/2
A
A= $generations
Aresult
11
00
539
540 403 ▶ if($self->strict and $self->_strict){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->strict and $self->_strict) 0 403 403
Condition33%1/3
$self->strict and $self->_strict
!ll&&!rl&&r
40300
MC/DC0%0/2
$self->strict and $self->_strict
$self->strict $self->_strict
Truth table33%1/3
A and B
A= $self->strictB= $self->_strict
ABresult
0X0
100
111
541 0 for my $idx (0..$#{$self->chromosomes}){
542 0 ▶ croak(q/Chromosomes was modified outside the 'evolve' function!/) unless $self->chromosomes->[$idx] and $self->_strict->[$idx];
Branch: 1 branch
BranchTrueFalseTotal
unless $self->chromosomes->[$idx] and $self->_strict->[$idx] 0 0 0
Condition0%0/3
$self->chromosomes->[$idx] and $self->_strict->[$idx]
!ll&&!rl&&r
000
MC/DC0%0/2
$self->chromosomes->[$idx] and $self->_strict->[$idx]
$self->chromosomes->[$idx] $self->_strict->[$idx]
Truth table0%0/3
A and B
A= $self->chromosomes->[$idx]B= $self->_strict->[$idx]
ABresult
0X0
100
111
543 0 my @tmp0 = @{$self->chromosomes->[$idx]};
544 0 my @tmp1 = @{$self->_strict->[$idx]};
545 0 ▶ croak(qq/Chromosome was modified outside the 'evolve' function from "@tmp0" to "@tmp1"!/) unless compare(\@tmp0, \@tmp1);
Branch: 1 branch
BranchTrueFalseTotal
unless compare(\@tmp0, \@tmp1) 0 0 0
546 }
547 }
548
549 # split into two loops just for speed
550 403 ▶ unless($self->preserve){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->preserve) { } 2 401 403
551 401 ▶ for(my $i = 0; $i != $generations; $i++){
Branch: 1 branch
BranchTrueFalseTotal
if ($i != $generations) 426 390 816
552 # terminate ----------------------------------------------------
553 426 ▶ last if $self->terminate and $self->terminate->($self);
Branch: 1 branch
BranchTrueFalseTotal
if $self->terminate and $self->terminate->($self) 11 415 426
Condition66%2/3
$self->terminate and $self->terminate->($self)
!ll&&!rl&&r
041511
MC/DC50%1/2
$self->terminate and $self->terminate->($self)
$self->terminate $self->terminate->($self)
Truth table66%2/3
A and B
A= $self->terminateB= $self->terminate->($self)
ABresult
0X0
100
111
554 # update generation --------------------------------------------
555 415 $self->generation($self->generation + 1);
556 # update history -----------------------------------------------
557 415 $self->_save_history;
558 # selection ----------------------------------------------------
559 415 $self->_select_parents();
560 # crossover ----------------------------------------------------
561 415 $self->_crossover();
562 # mutation -----------------------------------------------------
563 415 $self->_mutation();
564 }
565 }else{
566 2 ▶ croak('You cannot preserve more chromosomes than is in population!') if $self->preserve > $self->population;
Branch: 1 branch
BranchTrueFalseTotal
if $self->preserve > $self->population 0 2 2
567 2 my @preserved;
568 2 ▶ for(my $i = 0; $i != $generations; $i++){
Branch: 1 branch
BranchTrueFalseTotal
if ($i != $generations) 2 0 2
569 # terminate ----------------------------------------------------
570 2 ▶ last if $self->terminate and $self->terminate->($self);
Branch: 1 branch
BranchTrueFalseTotal
if $self->terminate and $self->terminate->($self) 2 0 2
Condition33%1/3
$self->terminate and $self->terminate->($self)
!ll&&!rl&&r
002
MC/DC0%0/2
$self->terminate and $self->terminate->($self)
$self->terminate $self->terminate->($self)
Truth table33%1/3
A and B
A= $self->terminateB= $self->terminate->($self)
ABresult
0X0
100
111
571 # update generation --------------------------------------------
572 0 $self->generation($self->generation + 1);
573 # update history -----------------------------------------------
574 0 $self->_save_history;
575 #---------------------------------------------------------------
576 # preservation of N unique chromosomes
577 0 @preserved = map { clone($_) } @{ $self->getFittest_as_arrayref($self->preserve - 1, 1) };
578 # selection ----------------------------------------------------
579 0 $self->_select_parents();
580 # crossover ----------------------------------------------------
581 0 $self->_crossover();
582 # mutation -----------------------------------------------------
583 0 $self->_mutation();
584 #---------------------------------------------------------------
585 0 for(@preserved){
586 0 my $idx = int rand @{$self->chromosomes};
587 0 $self->chromosomes->[$idx] = $_;
588 0 $self->_fitness->{$idx} = $self->fitness()->($self, $_);
589 }
590 }
591 }
592
593 403 ▶ if($self->strict){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->strict) 0 403 403
594 0 $self->_strict( [ ] );
595 0 push @{$self->_strict}, clone($_) for @{$self->chromosomes};
596 }
597 }
598 #=======================================================================
599 # ALIASES ##############################################################
600 #=======================================================================
601 0 ▶sub people { $_[0]->chromosomes() }
Subroutine people: not called CC=1 SCAR=6.9
Pod documented
602 #=======================================================================
603 0 ▶sub getHistory { $_[0]->_history() }
Subroutine getHistory: not called CC=1 SCAR=6.9
Pod documented
604 #=======================================================================
605 0 ▶sub mutProb { shift->mutation(@_) }
Subroutine mutProb: not called CC=1 SCAR=6.9
Pod documented
606 #=======================================================================
607 0 ▶sub crossProb { shift->crossover(@_) }
Subroutine crossProb: not called CC=1 SCAR=6.9
Pod documented
608 #=======================================================================
609 0 ▶sub intType { shift->type() }
Subroutine intType: not called CC=1 SCAR=6.9
Pod undocumented
610 #=======================================================================
611 # STATS ################################################################
612 #=======================================================================
613 sub getFittest_as_arrayref {
614 3594 ▶ my ($self, $n, $uniq) = @_;
Subroutine getFittest_as_arrayref: called CC=10 SCAR=35.5
Pod documented
615 3594 ▶ $n ||= 1;
Condition100%2/2
$n ||= 1
l!l
13593
MC/DC100%1/1
$n ||= 1
$n
Truth table100%2/2
A
A= $n
Aresult
11
00
616
617 3594 ▶ $self->_calculate_fitness_all() unless scalar %{ $self->_fitness };
Branch: 1 branch
BranchTrueFalseTotal
unless scalar %{$self->_fitness;} 0 3594 3594
618 3594 my @keys = sort { $self->_fitness->{$a} <=> $self->_fitness->{$b} } 0..$#{$self->chromosomes};
619
620 3594 ▶ if($uniq){
Branch: 1 branch
BranchTrueFalseTotal
if ($uniq) 0 3594 3594
621 0 my %grep;
622 0 my $chromosomes = $self->chromosomes;
623 0 ▶ if( my $pkg = $self->_package ){
Branch: 1 branch
BranchTrueFalseTotal
if (my $pkg = $self->_package) { } 0 0 0
624 0 my %tmp;
625 @keys = grep {
626 0 my $key = ${ tied( @{ $chromosomes->[ $_ ] } ) };
627 #my $key = md5_hex( ${ tied( @{ $chromosomes->[ $_ ] } ) } ); # ?
628 0 ▶ $tmp{ $key } && 0 or $tmp{ $key } = 1;
Branch: 1 branch
BranchTrueFalseTotal
$tmp{$key} and 0 or $tmp{$key} = 1 0 0 0
Condition0%0/2
$tmp{$key} and 0
!ll
00
MC/DC0%0/1
$tmp{$key} and 0
$tmp{$key}
Truth table0%0/2
A
A= $tmp{$key}
Aresult
00
11
629 } @keys;
630 #@keys = grep {
631 # my $add_to_list = 0;
632 # my $key = md5_hex(${tied(@{$chromosomes->[$_]})});
633 # unless($grep{$key}) {
634 # $grep{$key} = 1;
635 # $add_to_list = 1;
636 # }
637 # $add_to_list;
638 # } @keys;
639 }else{
640 0 my %tmp;
641 @keys = grep {
642 0 my $key = md5_hex( join( q[:], @{ $chromosomes->[ $_ ] } ) );
643 0 ▶ $tmp{ $key } && 0 or $tmp{ $key } = 1;
Branch: 1 branch
BranchTrueFalseTotal
$tmp{$key} and 0 or $tmp{$key} = 1 0 0 0
Condition0%0/2
$tmp{$key} and 0
!ll
00
MC/DC0%0/1
$tmp{$key} and 0
$tmp{$key}
Truth table0%0/2
A
A= $tmp{$key}
Aresult
00
11
644 } @keys;
645 }
646 }
647
648 3594 ▶ $n = scalar @keys if $n > scalar @keys;
Branch: 1 branch
BranchTrueFalseTotal
if $n > scalar @keys 0 3594 3594
649 3594 return [ reverse @{$self->chromosomes}[ splice @keys, $#keys - $n + 1, $n ] ];
650 }
651 #=======================================================================
652 3594 ▶sub getFittest { return wantarray ? @{ shift->getFittest_as_arrayref(@_) } : shift @{ shift->getFittest_as_arrayref(@_) }; }
Subroutine getFittest: called CC=2 SCAR=8.1
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 3594 0 3594
653 #=======================================================================
654 sub getAvgFitness {
655 0 ▶ my ($self) = @_;
Subroutine getAvgFitness: not called CC=1 SCAR=6.9
Pod documented
656
657 0 my @minmax = minmax values %{$self->_fitness};
658 0 my $mean = sum(values %{$self->_fitness}) / scalar values %{$self->_fitness};
659 0 return $minmax[1], int($mean), $minmax[0];
660 }
661 #=======================================================================
662 460 1;
663  
664  
665 __END__
« Pro/Selection/RouletteDistribution.pm ↑ Summary Pro/Mutation/Rangevector.pm »