kylin-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF subversion and git services (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (KYLIN-3306) Fix the rarely happened unit test exception of generic algorithm
Date Wed, 21 Mar 2018 05:53:00 GMT

    [ https://issues.apache.org/jira/browse/KYLIN-3306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16407492#comment-16407492
] 

ASF subversion and git services commented on KYLIN-3306:
--------------------------------------------------------

Commit aa4cf286f440273bad04ae30a3842d9143ef918d in kylin's branch refs/heads/2.3.x from Zhong
[ https://gitbox.apache.org/repos/asf?p=kylin.git;h=aa4cf28 ]

APACHE-KYLIN-3306: Fix the rarely happened unit test exception of generic algorithm

Signed-off-by: shaofengshi <shaofengshi@apache.org>


> Fix the rarely happened unit test exception of generic algorithm
> ----------------------------------------------------------------
>
>                 Key: KYLIN-3306
>                 URL: https://issues.apache.org/jira/browse/KYLIN-3306
>             Project: Kylin
>          Issue Type: Bug
>            Reporter: Zhong Yanghong
>            Assignee: Zhong Yanghong
>            Priority: Major
>             Fix For: v2.3.1
>
>         Attachments: APACHE-KYLIN-3306.patch
>
>
> There's a bug in the following code:
> {code}
> private Chromosome rouletteWheel(final List<Chromosome> chromosomes, final double
totalFitness) {
>         float rnd = (float) (GeneticAlgorithm.getRandomGenerator().nextDouble() * totalFitness);
>         float runningScore = 0;
>         for (Chromosome o : chromosomes) {
>             if (rnd >= runningScore && rnd <= runningScore + o.getFitness())
{
>                 return o;
>             }
>             runningScore += o.getFitness();
>         }
>         return null;
>     }
> {code}
> We should use double instead of float.
> For example, (float) (0.9999999988948809 * 40.510999999999996) = 40.511 > 40.510999999999996



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message