a few cosmetics
This commit is contained in:
parent
6ecc695886
commit
e3f2768a29
@ -196,14 +196,16 @@ public class GAIndividualIntegerData extends AbstractEAIndividual implements Int
|
|||||||
*/
|
*/
|
||||||
public void SetIntegerDataLamarkian(int[] doubleData) {
|
public void SetIntegerDataLamarkian(int[] doubleData) {
|
||||||
this.SetIntegerData(doubleData);
|
this.SetIntegerData(doubleData);
|
||||||
int[] locus = new int[2];
|
if (doubleData != null) {
|
||||||
locus[0] = 0;
|
int[] locus = new int[2];
|
||||||
locus[1] = 0;
|
locus[0] = 0;
|
||||||
for (int i = 0; i < doubleData.length; i++) {
|
locus[1] = 0;
|
||||||
locus[0] += locus[1];
|
for (int i = 0; i < doubleData.length; i++) {
|
||||||
locus[1] = this.m_CodingLenghts[i];
|
locus[0] += locus[1];
|
||||||
this.m_IntegerCoding.codeValue(doubleData[i], this.m_Range[i], this.m_Genotype, locus);
|
locus[1] = this.m_CodingLenghts[i];
|
||||||
}
|
this.m_IntegerCoding.codeValue(doubleData[i], this.m_Range[i], this.m_Genotype, locus);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
|
@ -25,11 +25,12 @@ public class MutateESGlobal implements InterfaceMutation, java.io.Serializable {
|
|||||||
protected SelectedTag m_CrossoverType;
|
protected SelectedTag m_CrossoverType;
|
||||||
|
|
||||||
public MutateESGlobal() {
|
public MutateESGlobal() {
|
||||||
Tag[] tag = new Tag[3];
|
initTags();
|
||||||
tag[0] = new Tag(0, "None");
|
}
|
||||||
tag[1] = new Tag(1, "Intermediate");
|
|
||||||
tag[2] = new Tag(2, "Discrete");
|
public MutateESGlobal(double mutationStepSize) {
|
||||||
this.m_CrossoverType = new SelectedTag(0, tag);
|
initTags();
|
||||||
|
setMutationStepSize(mutationStepSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutateESGlobal(MutateESGlobal mutator) {
|
public MutateESGlobal(MutateESGlobal mutator) {
|
||||||
@ -39,6 +40,14 @@ public class MutateESGlobal implements InterfaceMutation, java.io.Serializable {
|
|||||||
this.m_CrossoverType = (SelectedTag)mutator.m_CrossoverType.clone();
|
this.m_CrossoverType = (SelectedTag)mutator.m_CrossoverType.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void initTags() {
|
||||||
|
Tag[] tag = new Tag[3];
|
||||||
|
tag[0] = new Tag(0, "None");
|
||||||
|
tag[1] = new Tag(1, "Intermediate");
|
||||||
|
tag[2] = new Tag(2, "Discrete");
|
||||||
|
this.m_CrossoverType = new SelectedTag(0, tag);
|
||||||
|
}
|
||||||
|
|
||||||
/** This method will enable you to clone a given mutation operator
|
/** This method will enable you to clone a given mutation operator
|
||||||
* @return The clone
|
* @return The clone
|
||||||
*/
|
*/
|
||||||
|
@ -21,8 +21,7 @@ public class FM0Problem extends F1Problem implements Interface2DBorderProblem, I
|
|||||||
protected InterfaceDistanceMetric m_Metric = new PhenotypeMetricDoubleData();
|
protected InterfaceDistanceMetric m_Metric = new PhenotypeMetricDoubleData();
|
||||||
protected double m_GlobalOpt = 0;
|
protected double m_GlobalOpt = 0;
|
||||||
protected Population m_Optima;
|
protected Population m_Optima;
|
||||||
protected double m_XEpsilon = 0.05;
|
protected double m_Epsilon = 0.05;
|
||||||
protected double m_YEpsilon = 0.05;
|
|
||||||
protected boolean m_UseXCrit = true;
|
protected boolean m_UseXCrit = true;
|
||||||
protected boolean m_UseYCrit = true;
|
protected boolean m_UseYCrit = true;
|
||||||
protected double[][] m_Range;
|
protected double[][] m_Range;
|
||||||
@ -64,12 +63,9 @@ public class FM0Problem extends F1Problem implements Interface2DBorderProblem, I
|
|||||||
this.m_UseTestConstraint = b.m_UseTestConstraint;
|
this.m_UseTestConstraint = b.m_UseTestConstraint;
|
||||||
//FM0Problem
|
//FM0Problem
|
||||||
this.m_GlobalOpt = b.m_GlobalOpt;
|
this.m_GlobalOpt = b.m_GlobalOpt;
|
||||||
this.m_XEpsilon = b.m_XEpsilon;
|
this.m_Epsilon = b.m_Epsilon;
|
||||||
this.m_YEpsilon = b.m_YEpsilon;
|
|
||||||
this.m_UseXCrit = b.m_UseXCrit;
|
this.m_UseXCrit = b.m_UseXCrit;
|
||||||
this.m_UseYCrit = b.m_UseYCrit;
|
this.m_UseYCrit = b.m_UseYCrit;
|
||||||
this.m_XEpsilon = b.m_XEpsilon;
|
|
||||||
this.m_YEpsilon = b.m_YEpsilon;
|
|
||||||
this.m_UseXCrit = b.m_UseXCrit;
|
this.m_UseXCrit = b.m_UseXCrit;
|
||||||
if (b.m_Metric != null)
|
if (b.m_Metric != null)
|
||||||
this.m_Metric = (InterfaceDistanceMetric)((InterfaceDistanceMetric)b.m_Metric).clone();
|
this.m_Metric = (InterfaceDistanceMetric)((InterfaceDistanceMetric)b.m_Metric).clone();
|
||||||
@ -187,15 +183,21 @@ public class FM0Problem extends F1Problem implements Interface2DBorderProblem, I
|
|||||||
* @param y
|
* @param y
|
||||||
*/
|
*/
|
||||||
protected void add2DOptimum(double x, double y) {
|
protected void add2DOptimum(double x, double y) {
|
||||||
InterfaceDataTypeDouble tmpIndy;
|
double[] point = new double[2];
|
||||||
double[] point;
|
|
||||||
|
|
||||||
tmpIndy = (InterfaceDataTypeDouble)((AbstractEAIndividual)this.m_Template).clone();
|
|
||||||
point = new double[2];
|
|
||||||
point[0] = x;
|
point[0] = x;
|
||||||
point[1] = y;
|
point[1] = y;
|
||||||
|
addOptimum(point);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** This method allows you to add a 2d optima to the list of optima
|
||||||
|
* @param x
|
||||||
|
* @param y
|
||||||
|
*/
|
||||||
|
protected void addOptimum(double[] point) {
|
||||||
|
InterfaceDataTypeDouble tmpIndy;
|
||||||
|
tmpIndy = (InterfaceDataTypeDouble)((AbstractEAIndividual)this.m_Template).clone();
|
||||||
tmpIndy.SetDoubleDataLamarkian(point);
|
tmpIndy.SetDoubleDataLamarkian(point);
|
||||||
((AbstractEAIndividual)tmpIndy).SetFitness(0, this.doEvaluationUnNormalized(point)[0]);
|
((AbstractEAIndividual)tmpIndy).SetFitness(this.doEvaluationUnNormalized(point));
|
||||||
this.m_GlobalOpt = Math.max(this.m_GlobalOpt, ((AbstractEAIndividual)tmpIndy).getFitness(0));
|
this.m_GlobalOpt = Math.max(this.m_GlobalOpt, ((AbstractEAIndividual)tmpIndy).getFitness(0));
|
||||||
this.m_Optima.add(tmpIndy);
|
this.m_Optima.add(tmpIndy);
|
||||||
}
|
}
|
||||||
@ -244,7 +246,7 @@ public class FM0Problem extends F1Problem implements Interface2DBorderProblem, I
|
|||||||
for (int j = 0; j < this.m_Optima.size(); j++) {
|
for (int j = 0; j < this.m_Optima.size(); j++) {
|
||||||
opt = (AbstractEAIndividual) this.m_Optima.get(j);
|
opt = (AbstractEAIndividual) this.m_Optima.get(j);
|
||||||
if (!found[j]) {
|
if (!found[j]) {
|
||||||
if (this.m_Metric.distance(posOpt, opt) < this.m_XEpsilon) found[j] = true;
|
if (this.m_Metric.distance(posOpt, opt) < this.m_Epsilon) found[j] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -271,7 +273,7 @@ public class FM0Problem extends F1Problem implements Interface2DBorderProblem, I
|
|||||||
for (int j = 0; j < this.m_Optima.size(); j++) {
|
for (int j = 0; j < this.m_Optima.size(); j++) {
|
||||||
if (!found[j]) {
|
if (!found[j]) {
|
||||||
opt = (AbstractEAIndividual) this.m_Optima.get(j);
|
opt = (AbstractEAIndividual) this.m_Optima.get(j);
|
||||||
if (this.m_Metric.distance(posOpt, opt) < this.m_XEpsilon) {
|
if (this.m_Metric.distance(posOpt, opt) < this.m_Epsilon) {
|
||||||
found[j] = true;
|
found[j] = true;
|
||||||
result += this.m_GlobalOpt - posOpt.getFitness(0);
|
result += this.m_GlobalOpt - posOpt.getFitness(0);
|
||||||
//System.out.println("Found Optimum " + j + ".: " + (this.m_GlobalOpt - posOpt.getFitness(0)));
|
//System.out.println("Found Optimum " + j + ".: " + (this.m_GlobalOpt - posOpt.getFitness(0)));
|
||||||
@ -324,4 +326,22 @@ public class FM0Problem extends F1Problem implements Interface2DBorderProblem, I
|
|||||||
range[1] = 5;
|
range[1] = 5;
|
||||||
return range;
|
return range;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the m_Epsilon
|
||||||
|
*/
|
||||||
|
public double getEpsilon() {
|
||||||
|
return m_Epsilon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param epsilon the m_Epsilon to set
|
||||||
|
*/
|
||||||
|
public void setEpsilon(double epsilon) {
|
||||||
|
m_Epsilon = epsilon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String epsilonTipText() {
|
||||||
|
return "Epsilon criterion indicating whether an optimum was found";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,9 +58,10 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
|||||||
private int m_PopulationSize = 50;
|
private int m_PopulationSize = 50;
|
||||||
|
|
||||||
private boolean m_Debug = true;
|
private boolean m_Debug = true;
|
||||||
private int m_ShowCycle = 2;
|
private int m_ShowCycle = 10;
|
||||||
private TopoPlot m_Topology;
|
transient private TopoPlot m_Topology;
|
||||||
private int haltingWindow = 15;
|
private int haltingWindow = 15;
|
||||||
|
private double muLambdaRatio = 0.5;
|
||||||
|
|
||||||
|
|
||||||
public ClusterBasedNichingEA() {
|
public ClusterBasedNichingEA() {
|
||||||
@ -284,6 +285,23 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Population optimizeSpecies(Population species) {
|
||||||
|
m_Optimizer.setPopulation(species);
|
||||||
|
if (m_Optimizer instanceof EvolutionStrategies) {
|
||||||
|
EvolutionStrategies es = (EvolutionStrategies)m_Optimizer;
|
||||||
|
int mu = (int)(muLambdaRatio*species.size());
|
||||||
|
if (mu < 1) mu = 1;
|
||||||
|
else if (mu >= species.size()) {
|
||||||
|
if (m_Debug) System.err.println("warning, muLambdaRatio produced mu >= lambda.. reducing to mu=lambda-1");
|
||||||
|
mu = species.size() - 1;
|
||||||
|
}
|
||||||
|
es.setMyu(mu);
|
||||||
|
es.setLambda(species.size());
|
||||||
|
}
|
||||||
|
this.m_Optimizer.optimize();
|
||||||
|
return m_Optimizer.getPopulation();
|
||||||
|
}
|
||||||
|
|
||||||
public void optimize() {
|
public void optimize() {
|
||||||
// plot the populations
|
// plot the populations
|
||||||
if (this.m_ShowCycle > 0) {
|
if (this.m_ShowCycle > 0) {
|
||||||
@ -304,9 +322,7 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
|||||||
this.m_Undifferentiated.setPopulationSize(this.m_Undifferentiated.size());
|
this.m_Undifferentiated.setPopulationSize(this.m_Undifferentiated.size());
|
||||||
if (isActive(m_Undifferentiated)) {
|
if (isActive(m_Undifferentiated)) {
|
||||||
this.capMutationRate(this.m_Undifferentiated, 0); // MK TODO this sets mutation rate to 0! why?
|
this.capMutationRate(this.m_Undifferentiated, 0); // MK TODO this sets mutation rate to 0! why?
|
||||||
this.m_Optimizer.setPopulation(this.m_Undifferentiated);
|
m_Undifferentiated = optimizeSpecies(m_Undifferentiated);
|
||||||
this.m_Optimizer.optimize();
|
|
||||||
this.m_Undifferentiated = this.m_Optimizer.getPopulation();
|
|
||||||
} else {
|
} else {
|
||||||
this.m_Undifferentiated.incrGeneration();
|
this.m_Undifferentiated.incrGeneration();
|
||||||
}
|
}
|
||||||
@ -352,13 +368,15 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
|||||||
} else {
|
} else {
|
||||||
// actually optimize D_i
|
// actually optimize D_i
|
||||||
this.capMutationRate(curSpecies, 0.05);
|
this.capMutationRate(curSpecies, 0.05);
|
||||||
this.m_Optimizer.setPopulation(curSpecies);
|
//this.m_Optimizer.setPopulation(curSpecies);
|
||||||
this.m_Optimizer.optimize();
|
//this.m_Optimizer.optimize();
|
||||||
this.m_Species.set(i, this.m_Optimizer.getPopulation());
|
//this.m_Species.set(i, this.m_Optimizer.getPopulation());
|
||||||
|
this.m_Species.set(i, optimizeSpecies(curSpecies));
|
||||||
curSpecies = ((Population)this.m_Species.get(i)); // reset to expected population, just to be sure
|
curSpecies = ((Population)this.m_Species.get(i)); // reset to expected population, just to be sure
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// a single individual species, this element is inactive
|
// a single individual species, this element is inactive
|
||||||
|
if (m_Debug) System.out.println("inactive species not optimized");
|
||||||
}
|
}
|
||||||
// This is necessary to keep track to the function calls needed
|
// This is necessary to keep track to the function calls needed
|
||||||
this.m_Undifferentiated.SetFunctionCalls(this.m_Undifferentiated.getFunctionCalls() + curSpecies.getFunctionCalls());
|
this.m_Undifferentiated.SetFunctionCalls(this.m_Undifferentiated.getFunctionCalls() + curSpecies.getFunctionCalls());
|
||||||
@ -492,9 +510,8 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
|||||||
}
|
}
|
||||||
// output the result
|
// output the result
|
||||||
if (this.m_Debug) System.out.println("-Number of species: " + this.m_Species.size());
|
if (this.m_Debug) System.out.println("-Number of species: " + this.m_Species.size());
|
||||||
this.m_Population = new Population();
|
|
||||||
m_Population.setUseHistory(true);
|
|
||||||
this.m_Population = (Population)this.m_Undifferentiated.clone();
|
this.m_Population = (Population)this.m_Undifferentiated.clone();
|
||||||
|
m_Population.setUseHistory(true);
|
||||||
if (this.m_Debug) System.out.println("initing with " + this.m_Undifferentiated.size());
|
if (this.m_Debug) System.out.println("initing with " + this.m_Undifferentiated.size());
|
||||||
for (int i = 0; i < this.m_Species.size(); i++) {
|
for (int i = 0; i < this.m_Species.size(); i++) {
|
||||||
if (this.m_Debug) System.out.println("Adding deme " + i + " with size " + ((Population)this.m_Species.get(i)).size());
|
if (this.m_Debug) System.out.println("Adding deme " + i + " with size " + ((Population)this.m_Species.get(i)).size());
|
||||||
@ -596,7 +613,8 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
|||||||
* @return The population of current solutions to a given problem.
|
* @return The population of current solutions to a given problem.
|
||||||
*/
|
*/
|
||||||
public Population getPopulation() {
|
public Population getPopulation() {
|
||||||
this.m_Population = (Population)this.m_Undifferentiated.clone();
|
this.m_Population = (Population)m_Undifferentiated.clone();
|
||||||
|
// m_Population.addPopulation(this.m_Undifferentiated);
|
||||||
for (int i = 0; i < this.m_Species.size(); i++) this.m_Population.addPopulation((Population)this.m_Species.get(i));
|
for (int i = 0; i < this.m_Species.size(); i++) this.m_Population.addPopulation((Population)this.m_Species.get(i));
|
||||||
return this.m_Population;
|
return this.m_Population;
|
||||||
}
|
}
|
||||||
@ -669,12 +687,16 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
|||||||
}
|
}
|
||||||
public void setOptimizer(InterfaceOptimizer b){
|
public void setOptimizer(InterfaceOptimizer b){
|
||||||
this.m_Optimizer = b;
|
this.m_Optimizer = b;
|
||||||
|
if (b instanceof EvolutionStrategies) {
|
||||||
|
EvolutionStrategies es = (EvolutionStrategies)b;
|
||||||
|
setMuLambdaRatio(es.getMyu()/(double)es.getLambda());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public String optimizerTipText() {
|
public String optimizerTipText() {
|
||||||
return "Choose a population based optimizing technique to use.";
|
return "Choose a population based optimizing technique to use.";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The cluster algorithm on which the species differentation is based
|
/** The cluster algorithm on which the species differentiation is based
|
||||||
* @return The current clustering method
|
* @return The current clustering method
|
||||||
*/
|
*/
|
||||||
public InterfaceClustering getDifferentationCA() {
|
public InterfaceClustering getDifferentationCA() {
|
||||||
@ -737,4 +759,23 @@ public class ClusterBasedNichingEA implements InterfacePopulationChangedEventLis
|
|||||||
public String populationSizeTipText() {
|
public String populationSizeTipText() {
|
||||||
return "Determines the size of the initial population.";
|
return "Determines the size of the initial population.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * @return the muLambdaRatio
|
||||||
|
// */
|
||||||
|
// public double getMuLambdaRatio() {
|
||||||
|
// return muLambdaRatio;
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is now set if an ES is set as optimizer.
|
||||||
|
* @param muLambdaRatio the muLambdaRatio to set
|
||||||
|
*/
|
||||||
|
public void setMuLambdaRatio(double muLambdaRatio) {
|
||||||
|
this.muLambdaRatio = muLambdaRatio;
|
||||||
|
}
|
||||||
|
|
||||||
|
// public String muLambdaRatioTipText() {
|
||||||
|
// return "ratio between mu and lambda for a CBN-ES";
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ public class HillClimbing implements InterfaceOptimizer, java.io.Serializable {
|
|||||||
if (((AbstractEAIndividual)original.get(i)).isDominatingDebConstraints(((AbstractEAIndividual)this.m_Population.get(i)))) {
|
if (((AbstractEAIndividual)original.get(i)).isDominatingDebConstraints(((AbstractEAIndividual)this.m_Population.get(i)))) {
|
||||||
this.m_Population.remove(i);
|
this.m_Population.remove(i);
|
||||||
this.m_Population.add(i, original.get(i));
|
this.m_Population.add(i, original.get(i));
|
||||||
}
|
} // else: mutation improved the individual
|
||||||
}
|
}
|
||||||
this.m_Population.incrGeneration();
|
this.m_Population.incrGeneration();
|
||||||
// for (int i = 0; i < this.m_Population.size(); i++) {
|
// for (int i = 0; i < this.m_Population.size(); i++) {
|
||||||
|
@ -16,6 +16,7 @@ import javaeva.server.go.PopulationInterface;
|
|||||||
import javaeva.server.go.individuals.AbstractEAIndividual;
|
import javaeva.server.go.individuals.AbstractEAIndividual;
|
||||||
import javaeva.server.go.operators.terminators.EvaluationTerminator;
|
import javaeva.server.go.operators.terminators.EvaluationTerminator;
|
||||||
import javaeva.server.go.populations.Population;
|
import javaeva.server.go.populations.Population;
|
||||||
|
import javaeva.server.go.problems.InterfaceMultimodalProblem;
|
||||||
import javaeva.server.go.strategies.InterfaceOptimizer;
|
import javaeva.server.go.strategies.InterfaceOptimizer;
|
||||||
import javaeva.server.go.tools.RandomNumberGenerator;
|
import javaeva.server.go.tools.RandomNumberGenerator;
|
||||||
import javaeva.server.stat.Statistics;
|
import javaeva.server.stat.Statistics;
|
||||||
@ -208,7 +209,11 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo
|
|||||||
// m_Statistics.createNextGenerationPerformed((PopulationInterface)this.m_ModulParameter.getOptimizer().getPopulation());
|
// m_Statistics.createNextGenerationPerformed((PopulationInterface)this.m_ModulParameter.getOptimizer().getPopulation());
|
||||||
// m_ListenerModule.updateProgress(getStatusPercent(m_ModulParameter.getOptimizer().getPopulation(), runCounter, m_Statistics.getStatisticsParameter().getMultiRuns()));
|
// m_ListenerModule.updateProgress(getStatusPercent(m_ModulParameter.getOptimizer().getPopulation(), runCounter, m_Statistics.getStatisticsParameter().getMultiRuns()));
|
||||||
// } // end of while (m_doOpt==true)
|
// } // end of while (m_doOpt==true)
|
||||||
|
if (m_ModulParameter.getProblem() instanceof InterfaceMultimodalProblem) {
|
||||||
|
// TODO improve this?
|
||||||
|
InterfaceMultimodalProblem mmProb = (InterfaceMultimodalProblem)m_ModulParameter.getProblem();
|
||||||
|
System.out.println("no optima found: " + mmProb.getNumberOfFoundOptima(m_ModulParameter.getOptimizer().getPopulation()));
|
||||||
|
}
|
||||||
m_Statistics.stopOptPerformed(isOptRunning()); // stop is "normal" if opt wasnt set false by the user
|
m_Statistics.stopOptPerformed(isOptRunning()); // stop is "normal" if opt wasnt set false by the user
|
||||||
}
|
}
|
||||||
setOptRunning(false); // normal finish
|
setOptRunning(false); // normal finish
|
||||||
|
@ -16,7 +16,7 @@ import java.util.jar.JarInputStream;
|
|||||||
/**
|
/**
|
||||||
* Allow for java to list Classes that exist in one package and can be instantiated from
|
* Allow for java to list Classes that exist in one package and can be instantiated from
|
||||||
* the classpath, either directly or through a jar on the classpath.
|
* the classpath, either directly or through a jar on the classpath.
|
||||||
* So far, jars which are located <i>whithin</i> another jar will not be searched.
|
* So far, jars which are located <i>within</i> another jar will not be searched.
|
||||||
*
|
*
|
||||||
* @author mkron
|
* @author mkron
|
||||||
*
|
*
|
||||||
@ -44,26 +44,30 @@ public class ReflectPackage {
|
|||||||
try {
|
try {
|
||||||
// Get a File object for the package
|
// Get a File object for the package
|
||||||
File directory = null;
|
File directory = null;
|
||||||
|
String dir = null;
|
||||||
try {
|
try {
|
||||||
ClassLoader cld = ClassLoader.getSystemClassLoader();
|
ClassLoader cld = ClassLoader.getSystemClassLoader();
|
||||||
if (cld == null) {
|
if (cld == null) {
|
||||||
throw new ClassNotFoundException("Can't get class loader.");
|
throw new ClassNotFoundException("Can't get class loader.");
|
||||||
}
|
}
|
||||||
String dir = path + "/" + pckgname.replace(".","/");
|
dir = path + "/" + pckgname.replace(".","/");
|
||||||
|
|
||||||
if (TRACE) System.out.println(path);
|
if (TRACE) System.out.println(".. opening " + path);
|
||||||
|
|
||||||
directory = new File(dir);
|
directory = new File(dir);
|
||||||
|
|
||||||
} catch (NullPointerException x) {
|
} catch (NullPointerException x) {
|
||||||
if (TRACE) System.err.println(directory.getPath()+ " not found in " + path);
|
if (TRACE) {
|
||||||
|
System.err.println(directory.getPath()+ " not found in " + path);
|
||||||
|
System.err.println("directory " + (directory.exists() ? "exists" : "doesnt exist"));
|
||||||
|
}
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
if (directory.exists()) {
|
if (directory.exists()) {
|
||||||
// Get the list of the files contained in the package
|
// Get the list of the files contained in the package
|
||||||
getClassesFromDirFltr(set, directory, pckgname, includeSubs, reqSuperCls);
|
getClassesFromDirFltr(set, directory, pckgname, includeSubs, reqSuperCls);
|
||||||
} else {
|
} else {
|
||||||
if (TRACE) System.err.println(directory.getPath()+ " not found in " + path);
|
if (TRACE) System.err.println(directory.getPath() + " doesnt exist in " + path + ", dir was " + dir);
|
||||||
}
|
}
|
||||||
} catch(ClassNotFoundException e) {
|
} catch(ClassNotFoundException e) {
|
||||||
System.err.println(e.getMessage());
|
System.err.println(e.getMessage());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user