From 54d3b8e9e96bb183a4288dc4c380c6e3cf5f1d66 Mon Sep 17 00:00:00 2001 From: Debabrata Acharya Date: Thu, 7 May 2020 18:00:12 +0530 Subject: [PATCH] fix randomizedQuickSortForCrowdingDistance --- .gitignore | 7 ++++++- src/main/java/io/onclave/nsga/ii/api/Service.java | 4 ++-- .../java/io/onclave/nsga/ii/datastructure/Chromosome.java | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 85572d0..7827022 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,9 @@ /target/ .DS_Store licenseheader.txt -nb-configuration.xml \ No newline at end of file +nb-configuration.xml +.classpath +.idea/ +.project +.settings/ +NSGA-II.iml \ No newline at end of file diff --git a/src/main/java/io/onclave/nsga/ii/api/Service.java b/src/main/java/io/onclave/nsga/ii/api/Service.java index 0183f71..221b034 100644 --- a/src/main/java/io/onclave/nsga/ii/api/Service.java +++ b/src/main/java/io/onclave/nsga/ii/api/Service.java @@ -177,12 +177,12 @@ private static int partitionForCrowdingDistance(final List populace, if(populace.get(j).getCrowdingDistance() >= pivot) { - Service.swapForRank(populace, pivotIndex, j); + Service.swapForCrowdingDistance(populace, pivotIndex, j); ++pivotIndex; } } - Service.swapForRank(populace, pivotIndex, tail); + Service.swapForCrowdingDistance(populace, pivotIndex, tail); return pivotIndex; } diff --git a/src/main/java/io/onclave/nsga/ii/datastructure/Chromosome.java b/src/main/java/io/onclave/nsga/ii/datastructure/Chromosome.java index d889487..7e24fe6 100644 --- a/src/main/java/io/onclave/nsga/ii/datastructure/Chromosome.java +++ b/src/main/java/io/onclave/nsga/ii/datastructure/Chromosome.java @@ -24,7 +24,7 @@ public class Chromosome { private final Allele[] geneticCode; private int dominationCount = 0; private double fitness; - private int rank; + private int rank = 1; private Chromosome(final Chromosome chromosome) {