Vanish, thou evil typo!
This commit is contained in:
parent
a2fba4d958
commit
fc8fc15fc3
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
134
src/eva2/server/go/operators/selection/SelectBestSingle.java
Normal file
134
src/eva2/server/go/operators/selection/SelectBestSingle.java
Normal file
@ -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.";
|
||||
}
|
||||
}
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user