diff --git a/src/eva2/server/go/operators/selection/InterfaceSelection.java b/src/eva2/server/go/operators/selection/InterfaceSelection.java index 6c524160..4a690a6e 100644 --- a/src/eva2/server/go/operators/selection/InterfaceSelection.java +++ b/src/eva2/server/go/operators/selection/InterfaceSelection.java @@ -33,7 +33,7 @@ public interface InterfaceSelection { */ public void prepareSelection(Population population); - /** This method will select >size< indiviudals from the given + /** This method will select >size< individuals from the given * Population. * @param population The source population where to select from * @param size The number of Individuals to select diff --git a/src/eva2/server/go/operators/selection/SelectAll.java b/src/eva2/server/go/operators/selection/SelectAll.java index 674ad99a..8d6bf679 100644 --- a/src/eva2/server/go/operators/selection/SelectAll.java +++ b/src/eva2/server/go/operators/selection/SelectAll.java @@ -38,7 +38,7 @@ public class SelectAll implements InterfaceSelection, java.io.Serializable { // nothing to prepare here } - /** This method will select one Indiviudal from the given + /** This method will select one Individual from the given * Population in respect to the selection propability of the * individual. * @param population The source population where to select from diff --git a/src/eva2/server/go/operators/selection/SelectBestIndividuals.java b/src/eva2/server/go/operators/selection/SelectBestIndividuals.java index 1bbc7ea0..719dca61 100644 --- a/src/eva2/server/go/operators/selection/SelectBestIndividuals.java +++ b/src/eva2/server/go/operators/selection/SelectBestIndividuals.java @@ -41,7 +41,7 @@ public class SelectBestIndividuals implements InterfaceSelection, java.io.Serial // nothing to prepare here } - /** This method will select one Indiviudal from the given + /** This method will select one Individual from the given * Population. * @param population The source population where to select from * @param size The number of Individuals to select diff --git a/src/eva2/server/go/operators/selection/SelectBestSingle.java b/src/eva2/server/go/operators/selection/SelectBestSingle.java new file mode 100644 index 00000000..89528409 --- /dev/null +++ b/src/eva2/server/go/operators/selection/SelectBestSingle.java @@ -0,0 +1,134 @@ +package eva2.server.go.operators.selection; + +import eva2.server.go.individuals.AbstractEAIndividual; +import eva2.server.go.populations.Population; +import wsi.ra.math.RNG; + + +/** Select best individual multiple times if necessary. + * In case of multiple fitness values the selection + * critria is selected randomly for each selection event. + * Created by IntelliJ IDEA. + * User: streiche + * Date: 18.03.2003 + * Time: 16:17:10 + * To change this template use Options | File Templates. + */ +public class SelectBestSingle implements InterfaceSelection, java.io.Serializable { + + private boolean m_ObeyDebsConstViolationPrinciple = true; + + public SelectBestSingle() { + } + + public SelectBestSingle(SelectBestSingle a) { + this.m_ObeyDebsConstViolationPrinciple = a.m_ObeyDebsConstViolationPrinciple; + } + + public Object clone() { + return (Object) new SelectBestSingle(this); + } + + /** This method allows an selection method to do some preliminary + * calculations on the population before selection is performed. + * For example: Homologeuos mate could compute all the distances + * before hand... + * @param population The population that is to be processed. + */ + public void prepareSelection(Population population) { + // nothing to prepare here + } + + /** This method will select >size< individuals from the given + * Population. + * @param population The source population where to select from + * @param size The number of Individuals to select + * @return The selected population. + */ + public Population selectFrom(Population population, int size) { + Population result = new Population(); + AbstractEAIndividual tmpIndy = null; + int currentCriteria = 0, critSize; + double currentBestValue; + + critSize = ((AbstractEAIndividual)population.get(0)).getFitness().length; + result.setPopulationSize(size); + if (this.m_ObeyDebsConstViolationPrinciple) { + for (int i = 0; i < size; i++) { + currentCriteria = RNG.randomInt(0, critSize-1); + currentBestValue = Double.POSITIVE_INFINITY; + tmpIndy = null; + for (int j = 0; j < population.size(); j++) { + if ((!((AbstractEAIndividual)population.get(j)).violatesConstraint()) && (((AbstractEAIndividual)population.get(j)).getFitness(currentCriteria) < currentBestValue)) { + currentBestValue = ((AbstractEAIndividual)population.get(j)).getFitness(currentCriteria); + tmpIndy = (AbstractEAIndividual)population.get(j); + } + } + if (tmpIndy == null) { + // darn all individuals violate the constraints + // so select the guy with the least worst constraint violation + for (int j = 0; j < population.size(); j++) { + if (((AbstractEAIndividual)population.get(j)).getConstraintViolation() < currentBestValue) { + currentBestValue = ((AbstractEAIndividual)population.get(j)).getConstraintViolation(); + tmpIndy = (AbstractEAIndividual)population.get(j); + } + } + } + result.add(tmpIndy); + } + } else { + for (int i = 0; i < size; i++) { + currentCriteria = RNG.randomInt(0, critSize-1); + currentBestValue = Double.POSITIVE_INFINITY; + for (int j = 0; j < population.size(); j++) { + if (((AbstractEAIndividual)population.get(j)).getFitness(currentCriteria) < currentBestValue) { + currentBestValue = ((AbstractEAIndividual)population.get(j)).getFitness(currentCriteria); + tmpIndy = (AbstractEAIndividual)population.get(j); + } + } + result.add(tmpIndy); + } + } + return result; + } + + /** This method allows you to select >size< partners for a given Individual + * @param dad The already seleceted parent + * @param avaiablePartners The mating pool. + * @param size The number of partners needed. + * @return The selected partners. + */ + public Population findPartnerFor(AbstractEAIndividual dad, Population avaiablePartners, int size) { + return this.selectFrom(avaiablePartners, size); + } +/********************************************************************************************************************** + * These are for GUI + */ + /** This method returns a global info string + * @return description + */ + public String globalInfo() { + return "This selection method will select the single Best individual (n-times if necessary)." + + "This is a single objective selecting method, it will select in respect to a random criterion."; + } + /** This method will return a naming String + * @return The name of the algorithm + */ + public String getName() { + return "Totalitarian Selection"; + } + + /** Toggel the use of obeying the constraint violation principle + * of Deb + * @param b The new state + */ + public void setObeyDebsConstViolationPrinciple(boolean b) { + this.m_ObeyDebsConstViolationPrinciple = b; + } + public boolean getObeyDebsConstViolationPrinciple() { + return this.m_ObeyDebsConstViolationPrinciple; + } + public String obeyDebsConstViolationPrincipleToolTip() { + return "Toggle the use of Deb's coonstraint violation principle."; + } +} diff --git a/src/eva2/server/go/operators/selection/SelectEPTournaments.java b/src/eva2/server/go/operators/selection/SelectEPTournaments.java index 198d761e..9e0615c7 100644 --- a/src/eva2/server/go/operators/selection/SelectEPTournaments.java +++ b/src/eva2/server/go/operators/selection/SelectEPTournaments.java @@ -78,7 +78,7 @@ public class SelectEPTournaments implements InterfaceSelection, java.io.Serializ } } - /** This method will select one Indiviudal from the given + /** This method will select one Individual from the given * Population in respect to the selection propability of the * individual. * @param population The source population where to select from diff --git a/src/eva2/server/go/operators/selection/SelectMOMAIIDominanceCounter.java b/src/eva2/server/go/operators/selection/SelectMOMAIIDominanceCounter.java index 0d507405..b859b6a1 100644 --- a/src/eva2/server/go/operators/selection/SelectMOMAIIDominanceCounter.java +++ b/src/eva2/server/go/operators/selection/SelectMOMAIIDominanceCounter.java @@ -86,7 +86,7 @@ public class SelectMOMAIIDominanceCounter implements InterfaceSelection, java.io } } - /** This method will select one Indiviudal from the given + /** This method will select one Individual from the given * Population in respect to the selection propability of the * individual. * @param population The source population where to select from diff --git a/src/eva2/server/go/operators/selection/SelectMOMaxiMin.java b/src/eva2/server/go/operators/selection/SelectMOMaxiMin.java index d3e26ad0..54b4926d 100644 --- a/src/eva2/server/go/operators/selection/SelectMOMaxiMin.java +++ b/src/eva2/server/go/operators/selection/SelectMOMaxiMin.java @@ -42,7 +42,7 @@ public class SelectMOMaxiMin implements InterfaceSelection, java.io.Serializable // nothing to prepare here } - /** This method will select one Indiviudal from the given + /** This method will select one Individual from the given * Population in respect to the selection propability of the * individual. * @param population The source population where to select from diff --git a/src/eva2/server/go/operators/selection/SelectMONSGAIICrowedTournament.java b/src/eva2/server/go/operators/selection/SelectMONSGAIICrowedTournament.java index 0481fd52..dd374865 100644 --- a/src/eva2/server/go/operators/selection/SelectMONSGAIICrowedTournament.java +++ b/src/eva2/server/go/operators/selection/SelectMONSGAIICrowedTournament.java @@ -45,7 +45,7 @@ public class SelectMONSGAIICrowedTournament implements InterfaceSelection, java. this.m_NSGAII.calculateCrowdingDistance(this.m_Fronts); } - /** This method will select one Indiviudal from the given + /** This method will select one Individual from the given * Population in respect to the selection propability of the * individual. * @param population The source population where to select from diff --git a/src/eva2/server/go/operators/selection/SelectMONonDominated.java b/src/eva2/server/go/operators/selection/SelectMONonDominated.java index 16327995..73e89c71 100644 --- a/src/eva2/server/go/operators/selection/SelectMONonDominated.java +++ b/src/eva2/server/go/operators/selection/SelectMONonDominated.java @@ -38,7 +38,7 @@ public class SelectMONonDominated implements InterfaceSelection, java.io.Seriali // nothing to prepare here } - /** This method will select one Indiviudal from the given + /** This method will select one Individual from the given * Population in respect to the selection propability of the * individual. * @param population The source population where to select from diff --git a/src/eva2/server/go/operators/selection/SelectMOPESA.java b/src/eva2/server/go/operators/selection/SelectMOPESA.java index 9166cfcf..862d58f7 100644 --- a/src/eva2/server/go/operators/selection/SelectMOPESA.java +++ b/src/eva2/server/go/operators/selection/SelectMOPESA.java @@ -43,7 +43,7 @@ public class SelectMOPESA implements InterfaceSelection, java.io.Serializable { this.m_Squeeze = this.m_PESAII.calculateSqueezeFactor(population); } - /** This method will select one Indiviudal from the given + /** This method will select one Individual from the given * Population in respect to the selection propability of the * individual. * @param population The source population where to select from diff --git a/src/eva2/server/go/operators/selection/SelectMOPESAII.java b/src/eva2/server/go/operators/selection/SelectMOPESAII.java index d40a33f3..e7b2ee5b 100644 --- a/src/eva2/server/go/operators/selection/SelectMOPESAII.java +++ b/src/eva2/server/go/operators/selection/SelectMOPESAII.java @@ -77,7 +77,7 @@ public class SelectMOPESAII implements InterfaceSelection, java.io.Serializable } } - /** This method will select one Indiviudal from the given + /** This method will select one Individual from the given * Population in respect to the selection propability of the * individual. * @param population The source population where to select from diff --git a/src/eva2/server/go/operators/selection/SelectMOSPEAII.java b/src/eva2/server/go/operators/selection/SelectMOSPEAII.java index cc95f354..1440ddc2 100644 --- a/src/eva2/server/go/operators/selection/SelectMOSPEAII.java +++ b/src/eva2/server/go/operators/selection/SelectMOSPEAII.java @@ -49,7 +49,7 @@ public class SelectMOSPEAII implements InterfaceSelection, java.io.Serializable m_SPEAFitness = this.m_SPEAII.calculateSPEA(population); } - /** This method will select one Indiviudal from the given + /** This method will select one Individual from the given * Population in respect to the selection propability of the * individual. * @param population The source population where to select from diff --git a/src/eva2/server/go/operators/selection/SelectRandom.java b/src/eva2/server/go/operators/selection/SelectRandom.java index c709a5f5..531a206b 100644 --- a/src/eva2/server/go/operators/selection/SelectRandom.java +++ b/src/eva2/server/go/operators/selection/SelectRandom.java @@ -39,7 +39,7 @@ public class SelectRandom implements InterfaceSelection, java.io.Serializable { // nothing to prepare here } - /** This method will select one Indiviudal from the given + /** This method will select one Individual from the given * Population in respect to the selection propability of the * individual. * @param population The source population where to select from diff --git a/src/eva2/server/go/operators/selection/SelectTournament.java b/src/eva2/server/go/operators/selection/SelectTournament.java index 42ef839a..4250209c 100644 --- a/src/eva2/server/go/operators/selection/SelectTournament.java +++ b/src/eva2/server/go/operators/selection/SelectTournament.java @@ -41,7 +41,7 @@ public class SelectTournament implements InterfaceSelection, java.io.Serializabl // nothing to prepare here } - /** This method will select one Indiviudal from the given + /** This method will select one Individual from the given * Population in respect to the selection propability of the * individual. * @param population The source population where to select from diff --git a/src/eva2/server/go/operators/selection/SelectXProbRouletteWheel.java b/src/eva2/server/go/operators/selection/SelectXProbRouletteWheel.java index b45c6d7c..e9f31845 100644 --- a/src/eva2/server/go/operators/selection/SelectXProbRouletteWheel.java +++ b/src/eva2/server/go/operators/selection/SelectXProbRouletteWheel.java @@ -86,7 +86,7 @@ public class SelectXProbRouletteWheel implements InterfaceSelection, java.io.Ser this.m_TreeRoot = this.buildSelectionTree(population); } - /** This method will select a pool of indiviudals from the given + /** This method will select a pool of individuals from the given * Population in respect to the selection propability of the * individuals. * @param population The source population where to select from