Minor addition to MutateEAMixer, workaround in Population

This commit is contained in:
Marcel Kronfeld
2010-11-11 10:50:41 +00:00
parent dddbe65b3b
commit 2873df5058
3 changed files with 14 additions and 8 deletions

View File

@@ -39,7 +39,7 @@ public class MutateEAMixer implements InterfaceMutation, java.io.Serializable {
System.out.println("Illegal access exception for " +(String)mutators.get(i) );
}
}
this.m_Mutators = new PropertyMutationMixer(tmpList);
this.m_Mutators = new PropertyMutationMixer(tmpList, false);
tmpList = new InterfaceMutation[2];
tmpList[0] = new MutateGINominal();
tmpList[1] = new MutateGIOrdinal();
@@ -55,7 +55,7 @@ public class MutateEAMixer implements InterfaceMutation, java.io.Serializable {
* @param mutators
*/
public MutateEAMixer(InterfaceMutation ... mutators) {
this.m_Mutators = new PropertyMutationMixer(mutators);
this.m_Mutators = new PropertyMutationMixer(mutators, true);
this.m_UseSelfAdaption = false;
}

View File

@@ -16,11 +16,12 @@ public class PropertyMutationMixer implements java.io.Serializable {
public String m_WeightsLabel = "-";
public boolean m_NormalizationEnabled = true;
public PropertyMutationMixer(InterfaceMutation[] d) {
public PropertyMutationMixer(InterfaceMutation[] d, boolean selectAllOrNone) {
this.m_Weights = new double[d.length];
for (int i = 0; i < d.length; i++) this.m_Weights[i] = 1/((double)d.length);
this.m_AvailableTargets = d;
this.m_SelectedTargets = null;
if (selectAllOrNone) this.m_SelectedTargets = d.clone();
else this.m_SelectedTargets = null;
}
public PropertyMutationMixer(PropertyMutationMixer d) {
this.m_DescriptiveString = d.m_DescriptiveString;

View File

@@ -1725,9 +1725,14 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
for (int i = 0; i < pop.size(); i++) {
for (int j = i+1; j < pop.size(); j++) {
try {
if (metric == null) d = EuclideanMetric.euclideanDistance(AbstractEAIndividual.getDoublePositionShallow(pop.get(i)),
AbstractEAIndividual.getDoublePositionShallow(pop.get(j)));
else d = metric.distance((AbstractEAIndividual)pop.get(i), (AbstractEAIndividual)pop.get(j));
} catch (Exception e) {
EVAERROR.errorMsgOnce("Exception when calculating population measures ... possibly no double position available?");
d = 0;
}
distSum += d;
if (d < minDist) minDist = d;
if (d > maxDist) maxDist = d;