Catching nulls in defaultInit(Problem)

This commit is contained in:
Marcel Kronfeld 2010-02-24 10:47:12 +00:00
parent 5cda401398
commit f08cd297ab
5 changed files with 5 additions and 5 deletions

View File

@ -253,7 +253,7 @@ public class ESIndividualBinaryData extends AbstractEAIndividual implements Inte
} }
public void defaultInit(InterfaceOptimizationProblem prob) { public void defaultInit(InterfaceOptimizationProblem prob) {
if (prob instanceof InterfaceHasInitRange && (((InterfaceHasInitRange)prob).getInitRange()!=null)) ESIndividualDoubleData.defaultInit(m_Genotype, (double[][])((InterfaceHasInitRange)prob).getInitRange()); if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange)prob).getInitRange()!=null)) ESIndividualDoubleData.defaultInit(m_Genotype, (double[][])((InterfaceHasInitRange)prob).getInitRange());
else ESIndividualDoubleData.defaultInit(m_Genotype, m_Range); else ESIndividualDoubleData.defaultInit(m_Genotype, m_Range);
} }
/********************************************************************************************************************** /**********************************************************************************************************************

View File

@ -300,7 +300,7 @@ public class ESIndividualDoubleData extends AbstractEAIndividual implements Inte
} }
public void defaultInit(InterfaceOptimizationProblem prob) { public void defaultInit(InterfaceOptimizationProblem prob) {
if (prob instanceof InterfaceHasInitRange && (((InterfaceHasInitRange)prob).getInitRange()!=null)) ESIndividualDoubleData.defaultInit(m_Genotype, (double[][])((InterfaceHasInitRange)prob).getInitRange()); if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange)prob).getInitRange()!=null)) ESIndividualDoubleData.defaultInit(m_Genotype, (double[][])((InterfaceHasInitRange)prob).getInitRange());
else ESIndividualDoubleData.defaultInit(m_Genotype, m_Range); else ESIndividualDoubleData.defaultInit(m_Genotype, m_Range);
} }

View File

@ -267,7 +267,7 @@ public class ESIndividualIntegerData extends AbstractEAIndividual implements Int
public void defaultInit(InterfaceOptimizationProblem prob) { public void defaultInit(InterfaceOptimizationProblem prob) {
int[][] range = m_Range; int[][] range = m_Range;
if (prob instanceof InterfaceHasInitRange && (((InterfaceHasInitRange)prob).getInitRange()!=null)) range = (int[][])((InterfaceHasInitRange)prob).getInitRange(); if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange)prob).getInitRange()!=null)) range = (int[][])((InterfaceHasInitRange)prob).getInitRange();
for (int i = 0; i < this.m_Genotype.length; i++) { for (int i = 0; i < this.m_Genotype.length; i++) {
this.m_Genotype[i] = RNG.randomInt(range[i][0], range[i][1]); this.m_Genotype[i] = RNG.randomInt(range[i][0], range[i][1]);
} }

View File

@ -319,7 +319,7 @@ public class ESIndividualPermutationData extends AbstractEAIndividual implements
public void defaultInit(InterfaceOptimizationProblem prob) { public void defaultInit(InterfaceOptimizationProblem prob) {
double[][][] range = m_Range; double[][][] range = m_Range;
if (prob instanceof InterfaceHasInitRange && (((InterfaceHasInitRange)prob).getInitRange()!=null)) range = (double[][][])((InterfaceHasInitRange)prob).getInitRange(); if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange)prob).getInitRange()!=null)) range = (double[][][])((InterfaceHasInitRange)prob).getInitRange();
for (int i = 0; i < this.m_Genotype.length; i++) { for (int i = 0; i < this.m_Genotype.length; i++) {
ESIndividualDoubleData.defaultInit(m_Genotype[i], range[i]); ESIndividualDoubleData.defaultInit(m_Genotype[i], range[i]);

View File

@ -273,7 +273,7 @@ public class GIIndividualIntegerData extends AbstractEAIndividual implements Int
public void defaultInit(InterfaceOptimizationProblem prob) { public void defaultInit(InterfaceOptimizationProblem prob) {
int[][] range = m_Range; int[][] range = m_Range;
if (prob instanceof InterfaceHasInitRange && (((InterfaceHasInitRange)prob).getInitRange()!=null)) range = (int[][])((InterfaceHasInitRange)prob).getInitRange(); if ((prob != null) && (prob instanceof InterfaceHasInitRange) && (((InterfaceHasInitRange)prob).getInitRange()!=null)) range = (int[][])((InterfaceHasInitRange)prob).getInitRange();
for (int i = 0; i < this.m_Genotype.length; i++) { for (int i = 0; i < this.m_Genotype.length; i++) {
this.m_Genotype[i] = RNG.randomInt(range[i][0], range[i][1]); this.m_Genotype[i] = RNG.randomInt(range[i][0], range[i][1]);