Last active
August 29, 2015 13:57
-
-
Save JJ/9788502 to your computer and use it in GitHub Desktop.
Applying Wilcoxon-comparison based partial order to an evolutionary algorithm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for my $p ( @pop ) { | |
push(@{$p->{'_fitness_memory'}}, $noisy->apply( $p )); | |
$p->Fitness($comparisons); | |
} | |
for my $i (1..$comparisons) { | |
my @copy_of_population = @pop; | |
while( @copy_of_population ) { | |
my $first = splice( @copy_of_population, rand( @copy_of_population ), 1 ); | |
my $second = splice( @copy_of_population, rand( @copy_of_population ), 1 ); | |
my $aov = Statistics::ANOVA->new(); | |
$aov->load_data( { 1 => $first->{'_fitness_memory'}, 2 => $second->{'_fitness_memory'} }); | |
my $test_value = $aov->compare(independent => 1, parametric => 0, flag => 1, alpha => .05, dump => 0); # Wilcoxon (between-groups) sum-of-ranks (Dwass Procedure) | |
if ( $test_value->{'1,2'}{'p_value'} < 0.05 ) { | |
if ( $test_value->{'1,2'}{'z_value'} < 0 ) { | |
$first->Fitness( $first->Fitness( ) + 1); | |
$second->Fitness( $second->Fitness( ) - 1); | |
} else { | |
$first->Fitness( $first->Fitness( ) - 1); | |
$second->Fitness( $second->Fitness( ) + 1); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment