You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by sh...@apache.org on 2018/03/21 05:52:31 UTC

[kylin] branch 2.3.x updated: APACHE-KYLIN-3306: Fix the rarely happened unit test exception of generic algorithm

This is an automated email from the ASF dual-hosted git repository.

shaofengshi pushed a commit to branch 2.3.x
in repository https://gitbox.apache.org/repos/asf/kylin.git


The following commit(s) were added to refs/heads/2.3.x by this push:
     new aa4cf28  APACHE-KYLIN-3306: Fix the rarely happened unit test exception of generic algorithm
aa4cf28 is described below

commit aa4cf286f440273bad04ae30a3842d9143ef918d
Author: Zhong <nj...@apache.org>
AuthorDate: Wed Mar 21 13:42:13 2018 +0800

    APACHE-KYLIN-3306: Fix the rarely happened unit test exception of generic algorithm
    
    Signed-off-by: shaofengshi <sh...@apache.org>
---
 .../cube/cuboid/algorithm/generic/RouletteWheelSelection.java    | 9 ++++-----
 .../kylin/cube/cuboid/algorithm/ITGeneticAlgorithmTest.java      | 2 +-
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/generic/RouletteWheelSelection.java b/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/generic/RouletteWheelSelection.java
index db84171..b93ed31 100755
--- a/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/generic/RouletteWheelSelection.java
+++ b/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/generic/RouletteWheelSelection.java
@@ -18,15 +18,14 @@
 
 package org.apache.kylin.cube.cuboid.algorithm.generic;
 
-import java.util.List;
-
+import com.google.common.collect.Lists;
 import org.apache.kylin.cube.cuboid.algorithm.generic.lib.Chromosome;
 import org.apache.kylin.cube.cuboid.algorithm.generic.lib.ChromosomePair;
 import org.apache.kylin.cube.cuboid.algorithm.generic.lib.ListPopulation;
 import org.apache.kylin.cube.cuboid.algorithm.generic.lib.Population;
 import org.apache.kylin.cube.cuboid.algorithm.generic.lib.SelectionPolicy;
 
-import com.google.common.collect.Lists;
+import java.util.List;
 
 public class RouletteWheelSelection implements SelectionPolicy {
 
@@ -48,8 +47,8 @@ public class RouletteWheelSelection implements SelectionPolicy {
     }
 
     private Chromosome rouletteWheel(final List<Chromosome> chromosomes, final double totalFitness) {
-        float rnd = (float) (GeneticAlgorithm.RANDGEN.get().nextDouble() * totalFitness);
-        float runningScore = 0;
+        double rnd = (GeneticAlgorithm.RANDGEN.get().nextDouble() * totalFitness);
+        double runningScore = 0;
         for (Chromosome o : chromosomes) {
             if (rnd >= runningScore && rnd <= runningScore + o.getFitness()) {
                 return o;
diff --git a/kylin-it/src/test/java/org/apache/kylin/cube/cuboid/algorithm/ITGeneticAlgorithmTest.java b/kylin-it/src/test/java/org/apache/kylin/cube/cuboid/algorithm/ITGeneticAlgorithmTest.java
index f227789..34dfb00 100755
--- a/kylin-it/src/test/java/org/apache/kylin/cube/cuboid/algorithm/ITGeneticAlgorithmTest.java
+++ b/kylin-it/src/test/java/org/apache/kylin/cube/cuboid/algorithm/ITGeneticAlgorithmTest.java
@@ -24,7 +24,7 @@ import org.apache.kylin.cube.cuboid.algorithm.generic.GeneticAlgorithm;
 import org.junit.Ignore;
 import org.junit.Test;
 
-@Ignore("testBPUSCalculator() is unsable; whole test takes too long")
+//@Ignore("testBPUSCalculator() is unsable; whole test takes too long")
 public class ITGeneticAlgorithmTest extends ITAlgorithmTestBase {
 
     @Test

-- 
To stop receiving notification emails like this one, please contact
shaofengshi@apache.org.