Minor addition to MutateEAMixer, workaround in Population
This commit is contained in:
@@ -39,7 +39,7 @@ public class MutateEAMixer implements InterfaceMutation, java.io.Serializable {
|
|||||||
System.out.println("Illegal access exception for " +(String)mutators.get(i) );
|
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 = new InterfaceMutation[2];
|
||||||
tmpList[0] = new MutateGINominal();
|
tmpList[0] = new MutateGINominal();
|
||||||
tmpList[1] = new MutateGIOrdinal();
|
tmpList[1] = new MutateGIOrdinal();
|
||||||
@@ -55,7 +55,7 @@ public class MutateEAMixer implements InterfaceMutation, java.io.Serializable {
|
|||||||
* @param mutators
|
* @param mutators
|
||||||
*/
|
*/
|
||||||
public MutateEAMixer(InterfaceMutation ... mutators) {
|
public MutateEAMixer(InterfaceMutation ... mutators) {
|
||||||
this.m_Mutators = new PropertyMutationMixer(mutators);
|
this.m_Mutators = new PropertyMutationMixer(mutators, true);
|
||||||
this.m_UseSelfAdaption = false;
|
this.m_UseSelfAdaption = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,11 +16,12 @@ public class PropertyMutationMixer implements java.io.Serializable {
|
|||||||
public String m_WeightsLabel = "-";
|
public String m_WeightsLabel = "-";
|
||||||
public boolean m_NormalizationEnabled = true;
|
public boolean m_NormalizationEnabled = true;
|
||||||
|
|
||||||
public PropertyMutationMixer(InterfaceMutation[] d) {
|
public PropertyMutationMixer(InterfaceMutation[] d, boolean selectAllOrNone) {
|
||||||
this.m_Weights = new double[d.length];
|
this.m_Weights = new double[d.length];
|
||||||
for (int i = 0; i < d.length; i++) this.m_Weights[i] = 1/((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_AvailableTargets = d;
|
||||||
this.m_SelectedTargets = null;
|
if (selectAllOrNone) this.m_SelectedTargets = d.clone();
|
||||||
|
else this.m_SelectedTargets = null;
|
||||||
}
|
}
|
||||||
public PropertyMutationMixer(PropertyMutationMixer d) {
|
public PropertyMutationMixer(PropertyMutationMixer d) {
|
||||||
this.m_DescriptiveString = d.m_DescriptiveString;
|
this.m_DescriptiveString = d.m_DescriptiveString;
|
||||||
|
@@ -1725,10 +1725,15 @@ public class Population extends ArrayList implements PopulationInterface, Clonea
|
|||||||
|
|
||||||
for (int i = 0; i < pop.size(); i++) {
|
for (int i = 0; i < pop.size(); i++) {
|
||||||
for (int j = i+1; j < pop.size(); j++) {
|
for (int j = i+1; j < pop.size(); j++) {
|
||||||
if (metric == null) d = EuclideanMetric.euclideanDistance(AbstractEAIndividual.getDoublePositionShallow(pop.get(i)),
|
try {
|
||||||
AbstractEAIndividual.getDoublePositionShallow(pop.get(j)));
|
if (metric == null) d = EuclideanMetric.euclideanDistance(AbstractEAIndividual.getDoublePositionShallow(pop.get(i)),
|
||||||
else d = metric.distance((AbstractEAIndividual)pop.get(i), (AbstractEAIndividual)pop.get(j));
|
AbstractEAIndividual.getDoublePositionShallow(pop.get(j)));
|
||||||
distSum += d;
|
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 < minDist) minDist = d;
|
||||||
if (d > maxDist) maxDist = d;
|
if (d > maxDist) maxDist = d;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user