IGNITE-8242: Remove method GAGridUtils.getGenesForChromosome() as problematic when Chromosome contains duplicate genes. GAGridUtils.getGenesInOrderForChromosome() will be used instead.
this closes #3813 Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/baaef276 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/baaef276 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/baaef276 Branch: refs/heads/ignite-7708 Commit: baaef27661971ff093d861d699e43167602e11cf Parents: 9e21cec Author: Turik Campbell <ad...@techbysample.com> Authored: Mon Apr 16 20:43:49 2018 +0300 Committer: Yury Babak <yba...@gridgain.com> Committed: Mon Apr 16 20:43:49 2018 +0300 ---------------------------------------------------------------------- .../OptimizeMakeChangeTerminateCriteria.java | 2 +- .../genetic/movie/MovieTerminateCriteria.java | 2 +- .../ignite/ml/genetic/utils/GAGridUtils.java | 27 -------------------- 3 files changed, 2 insertions(+), 29 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/baaef276/examples/src/main/java/org/apache/ignite/examples/ml/genetic/change/OptimizeMakeChangeTerminateCriteria.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/genetic/change/OptimizeMakeChangeTerminateCriteria.java b/examples/src/main/java/org/apache/ignite/examples/ml/genetic/change/OptimizeMakeChangeTerminateCriteria.java index a4ea263..ab3f462 100644 --- a/examples/src/main/java/org/apache/ignite/examples/ml/genetic/change/OptimizeMakeChangeTerminateCriteria.java +++ b/examples/src/main/java/org/apache/ignite/examples/ml/genetic/change/OptimizeMakeChangeTerminateCriteria.java @@ -58,7 +58,7 @@ public class OptimizeMakeChangeTerminateCriteria implements ITerminateCriteria { igniteLogger.info("Generation: " + currentGeneration); igniteLogger.info("Fittest is Chromosome Key: " + fittestChromosome); igniteLogger.info("Chromsome: " + fittestChromosome); - printCoins(GAGridUtils.getGenesForChromosome(ignite, fittestChromosome)); + printCoins(GAGridUtils.getGenesInOrderForChromosome(ignite, fittestChromosome)); igniteLogger.info("Avg Chromsome Fitness: " + averageFitnessScore); igniteLogger.info("##########################################################################################"); http://git-wip-us.apache.org/repos/asf/ignite/blob/baaef276/examples/src/main/java/org/apache/ignite/examples/ml/genetic/movie/MovieTerminateCriteria.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/ml/genetic/movie/MovieTerminateCriteria.java b/examples/src/main/java/org/apache/ignite/examples/ml/genetic/movie/MovieTerminateCriteria.java index 747d514..34a7331 100644 --- a/examples/src/main/java/org/apache/ignite/examples/ml/genetic/movie/MovieTerminateCriteria.java +++ b/examples/src/main/java/org/apache/ignite/examples/ml/genetic/movie/MovieTerminateCriteria.java @@ -61,7 +61,7 @@ public class MovieTerminateCriteria implements ITerminateCriteria { igniteLogger.info("Generation: " + currentGeneration); igniteLogger.info("Fittest is Chromosome Key: " + fittestChromosome); igniteLogger.info("Chromsome: " + fittestChromosome); - printMovies(GAGridUtils.getGenesForChromosome(ignite, fittestChromosome)); + printMovies(GAGridUtils.getGenesInOrderForChromosome(ignite, fittestChromosome)); igniteLogger.info("##########################################################################################"); if (!(fittestChromosome.getFitnessScore() > 32)) { http://git-wip-us.apache.org/repos/asf/ignite/blob/baaef276/modules/ml/src/main/java/org/apache/ignite/ml/genetic/utils/GAGridUtils.java ---------------------------------------------------------------------- diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/genetic/utils/GAGridUtils.java b/modules/ml/src/main/java/org/apache/ignite/ml/genetic/utils/GAGridUtils.java index 326cdda..e27ddac 100644 --- a/modules/ml/src/main/java/org/apache/ignite/ml/genetic/utils/GAGridUtils.java +++ b/modules/ml/src/main/java/org/apache/ignite/ml/genetic/utils/GAGridUtils.java @@ -60,33 +60,6 @@ public class GAGridUtils { } /** - * @param ignite Ignite - * @param chromosome Chromosome - * @return List of Genes - */ - public static List<Gene> getGenesForChromosome(Ignite ignite, Chromosome chromosome) { - List<Gene> genes = new ArrayList<Gene>(); - IgniteCache<Long, Gene> cache = ignite.cache(GAGridConstants.GENE_CACHE); - StringBuffer sbSqlClause = new StringBuffer(); - sbSqlClause.append("_key IN "); - String sqlInClause = Arrays.toString(chromosome.getGenes()); - - sqlInClause = sqlInClause.replace("[", "("); - sqlInClause = sqlInClause.replace("]", ")"); - - sbSqlClause.append(sqlInClause); - - SqlQuery sql = new SqlQuery(Gene.class, sbSqlClause.toString()); - - try (QueryCursor<Entry<Long, Gene>> cursor = cache.query(sql)) { - for (Entry<Long, Gene> e : cursor) - genes.add(e.getValue()); - } - - return genes; - } - - /** * Retrieve genes in order * * @param ignite Ignite