The generation of random alleles for genes represented by real numbers is:
public void setToRandomValue (randomGenerator a_numberGenerator) (
setAllele (new Double ((m_upperBound - m_lowerBound) *
a_numberGenerator.nextDouble () + m_lowerBound));
)
If the bounds which we want are [0, Double.MAX_VALUE], where Double.MAX_VALUE = 1.7976931348623157E308 occurs:
setAllele (new Double ((Double.MAX_VALUE - 0) *
a_numberGenerator.nextDouble () + 0));
The values generated by a_numberGenerator.nextDouble () are between 0 and 1 following a uniform distribution.
Conclusion:
To generate coherent real numbers, the numbers generated by a_numberGenerator.nextDouble () should be of order E-308, and that never happens.
Easy solution:
private Double valueIn(Double v1, Double v2, RandomGenerator rnd) {
Double max=Math.max(v1, v2);
Double min=Math.min(v1, v2);
int den=Math.abs(rnd.nextInt());
if(den==0) den=2;
Double shift=(max-min)/den;
Double v=min+shift;
return v;
}
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
The generation of random alleles for genes represented by real numbers is:
public void setToRandomValue (randomGenerator a_numberGenerator) (
setAllele (new Double ((m_upperBound - m_lowerBound) *
a_numberGenerator.nextDouble () + m_lowerBound));
)
If the bounds which we want are [0, Double.MAX_VALUE], where
Double.MAX_VALUE = 1.7976931348623157E308 occurs:
setAllele (new Double ((Double.MAX_VALUE - 0) *
a_numberGenerator.nextDouble () + 0));
The values generated by a_numberGenerator.nextDouble () are between 0 and 1
following a uniform distribution.
Conclusion:
To generate coherent real numbers, the numbers generated by
a_numberGenerator.nextDouble () should be of order E-308, and that never
happens.
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
Sorry, but the proposed solution doesn't work correctly. Ignore the last lines please. Thanks
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
A possible solution?
private Double valueIn(Double v1, Double v2, RandomGenerator rnd) {
Double max=Math.max(v1, v2);
Double min=Math.min(v1, v2);
Double v=0d;
do{
Double v01=rnd.nextDouble(); //generates a value between 0 and 1
double pow=Math.log10(max);
double powBetween=rnd.nextInt((int)pow);
double block=Math.pow(10d, powBetween); //generates 10^1, 10^2,...
v=v01*block; //places the value in a block
}while(v<min);
return v;
}
I cannot fully follow the problem described. After adding some test cases to the DoubleGeneTest class, I do not see the problem. Could you kindly send me a test case where the problem occurs?
PS: Sorry for the late reply, you haven't been forgotten