Skip Menu |

This queue is for tickets about the AI-Genetic CPAN distribution.

Report information
The Basics
Id: 13548
Status: resolved
Priority: 0/
Queue: AI-Genetic

People
Owner: Nobody in particular
Requestors: crenz [...] web42.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.03
Fixed in: (no value)



Subject: Fencepost error in RangeVector individuals
When using individuals of type RangeVector, their genes can never read the specified maximum of the range. This is because of a bug in IndRangeVector.pm. Line 21 should be changed from my $rand = $r->[0] + int rand($r->[1] - $r->[0]); to my $rand = $r->[0] + int rand($r->[1] - $r->[0] + 1); Explanation: rand(5) will generate numbers between 0 and 5, ie. numbers from 0 up to 4.999999... . int() will cut off these numbers, _not_round them.
A similar fix is needed for OpMutation.PM, line 46: $g = $ranges->[$i][0] + int rand($abs); becomes $g = $ranges->[$i][0] + int rand($abs + 1);
From: Ala Qumsieh
[CRENZ - Wed Jul 6 09:29:10 2005]: Show quoted text
> When using individuals of type RangeVector, their genes can never read > the specified maximum of the range. This is because of a bug in > IndRangeVector.pm. Line 21 should be changed from > > my $rand = $r->[0] + int rand($r->[1] - $r->[0]); > > to > > my $rand = $r->[0] + int rand($r->[1] - $r->[0] + 1);
Fixed in v0.04. Thanks for the report.