From cb5c709f4bf8299f10ce272758a68dae6b0ad7ba Mon Sep 17 00:00:00 2001 From: Fabian Becker Date: Wed, 22 Oct 2014 21:19:57 +0200 Subject: [PATCH] More general cleanup. refs #2 --- .../individuals/AbstractEAIndividual.java | 35 -- .../individuals/InterfaceDataTypeDouble.java | 5 - .../OBGAIndividualPermutationData.java | 8 +- .../strategies/DifferentialEvolution.java | 47 +- .../problems/AbstractDynTransProblem.java | 6 - .../AbstractDynamicOptimizationProblem.java | 23 - .../AbstractMultiModalProblemKnown.java | 2 +- ...ractMultiObjectiveOptimizationProblem.java | 58 +-- .../problems/AbstractOptimizationProblem.java | 31 +- .../AbstractParallelOptimizationProblem.java | 3 +- src/eva2/problems/AbstractProblemBinary.java | 18 +- src/eva2/problems/AbstractProblemDouble.java | 2 +- src/eva2/problems/AbstractProblemInteger.java | 5 - ...bstractSynchronousOptimizationProblem.java | 21 +- src/eva2/problems/BKnapsackProblem.java | 1 - src/eva2/problems/DynJumpProblem.java | 5 - src/eva2/problems/ExternalRuntimeProblem.java | 4 - src/eva2/problems/F13Problem.java | 6 +- src/eva2/problems/F15Problem.java | 2 +- src/eva2/problems/F6Problem.java | 2 +- src/eva2/problems/GPFunctionProblem.java | 10 +- src/eva2/problems/MatlabEvalMediator.java | 29 -- src/eva2/problems/MatlabProblem.java | 26 -- src/eva2/problems/PSymbolicRegression.java | 32 +- src/eva2/problems/TF1Problem.java | 34 -- .../InterfaceRegressionFunction.java | 5 - .../problems/regression/RFKoza_GPI_10_1.java | 8 - .../problems/regression/RFKoza_GPI_10_2.java | 8 - .../problems/regression/RFKoza_GPI_7_3.java | 8 - .../regression/RFKoza_GPI_7_3_extended.java | 8 - src/eva2/problems/regression/RFRaidl_F1.java | 8 - src/eva2/problems/regression/RFRaidl_F2.java | 9 +- src/eva2/problems/regression/RFRaidl_F3.java | 9 +- src/eva2/tools/Serializer.java | 4 - .../Chart2DDPointContentSelectable.java | 4 - .../chart2d/Chart2DDPointIconCircle.java | 1 - .../chart2d/Chart2DDPointIconContent.java | 8 - .../tools/chart2d/Chart2DDPointIconCross.java | 2 - .../tools/chart2d/Chart2DDPointIconPoint.java | 6 +- src/eva2/tools/chart2d/DArea.java | 222 ++++------ src/eva2/tools/chart2d/DArray.java | 92 ++-- src/eva2/tools/chart2d/DBorder.java | 11 - src/eva2/tools/chart2d/DComponent.java | 27 +- src/eva2/tools/chart2d/DContainer.java | 34 +- src/eva2/tools/chart2d/DElement.java | 26 +- src/eva2/tools/chart2d/DFunction.java | 4 +- src/eva2/tools/chart2d/DGrid.java | 76 +--- src/eva2/tools/chart2d/DIntDoubleMap.java | 9 - src/eva2/tools/chart2d/DLine.java | 26 +- src/eva2/tools/chart2d/DMeasures.java | 162 ++----- src/eva2/tools/chart2d/DParent.java | 23 +- src/eva2/tools/chart2d/DPoint.java | 26 +- src/eva2/tools/chart2d/DPointIcon.java | 10 - src/eva2/tools/chart2d/DPointSet.java | 32 +- src/eva2/tools/chart2d/DRectangle.java | 26 +- src/eva2/tools/chart2d/ScaledBorder.java | 316 +++++++------- src/eva2/tools/chart2d/SlimRect.java | 2 - .../math/Jama/CholeskyDecomposition.java | 8 - .../math/Jama/EigenvalueDecomposition.java | 21 +- src/eva2/tools/math/Jama/LUDecomposition.java | 79 ---- src/eva2/tools/math/Jama/Matrix.java | 1 - src/eva2/tools/math/Jama/QRDecomposition.java | 19 - .../math/Jama/SingularValueDecomposition.java | 22 +- src/eva2/tools/math/Mathematics.java | 3 - src/eva2/tools/math/StatisticUtils.java | 44 +- .../interpolation/AbstractDataModifier.java | 32 +- .../math/interpolation/AbstractDataSet.java | 36 -- .../math/interpolation/BasicDataSet.java | 14 - .../interpolation/InterpolationException.java | 30 +- .../interpolation/LinearInterpolation.java | 6 - .../math/interpolation/PolyInterpolation.java | 405 ------------------ .../interpolation/SplineInterpolation.java | 40 +- 72 files changed, 409 insertions(+), 1978 deletions(-) delete mode 100644 src/eva2/tools/math/interpolation/PolyInterpolation.java diff --git a/src/eva2/optimization/individuals/AbstractEAIndividual.java b/src/eva2/optimization/individuals/AbstractEAIndividual.java index ebb6a8e1..5a494533 100644 --- a/src/eva2/optimization/individuals/AbstractEAIndividual.java +++ b/src/eva2/optimization/individuals/AbstractEAIndividual.java @@ -185,9 +185,6 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. return false; } - // Age will not be used - //if (this.age != indy.age) return false; - // checking on mutation/crossover probabilities if (this.mutationProbability != indy.mutationProbability) { return false; @@ -203,7 +200,6 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. if (!this.crossoverOperator.equals(indy.crossoverOperator)) { return false; } -// System.err.println("Check whether this is semantically meant by equality!!! (AbstractEAIndividual.equals())"); return true; } else { return false; @@ -235,10 +231,6 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. return "AbstractEAIndividual"; } -// public String getIndividualName() { -// return this.name; -// } - /** * This method is used when a new offspring is created the increment the * name. @@ -276,28 +268,6 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. */ public abstract boolean equalGenotypes(AbstractEAIndividual individual); -// /** Every object should have it's equals method, but who to programm it. -// * Currently i will limit myself to check the class and the fitness -// * values. -// * @param obj -// * @return True if the objects are equal. -// */ -// public boolean equals(Object obj) { -// if (obj instanceof AbstractEAIndividual) { -// AbstractEAIndividual indy = (AbstractEAIndividual)obj; -// if (this.fitness.length != indy.fitness.length) return false; -//// for (int i = 0; i < this.fitness.length; i++) if (this.fitness[i] != indy.fitness[i]) return false; -//// for (int i = 0; i < this.fitness.length; i++) -//// if (new Double(this.fitness[i]).compareTo(new Double(indy.fitness[i])) != 0) return false; -// for (int i = 0; i < this.fitness.length; i++) { -// if (Math.abs(this.fitness[i]- indy.fitness[i]) > 0.00000001) return false; -// } -// return true; -// } else { -// return false; -// } -// } - /** * This method will allow a default initialisation of the individual * @@ -305,7 +275,6 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. */ public void init(InterfaceOptimizationProblem opt) { initializationOperator.initialize(this, opt); -// this.defaultInit(opt); this.mutationOperator.init(this, opt); this.crossoverOperator.init(this, opt); } @@ -411,7 +380,6 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. sb.append("[ "); for (int i = 0; i < parentTree.length; i++) { sb.append(parentTree[i].getHeritageTree(depth - 1)); -// if ((i+1) < parentTree.length) sb.append(", "); } sb.append("] "); } @@ -779,7 +747,6 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. } else { return (constrViolComp > 0); } -// return isDominatingFitnessNotEqual(getFitness(), indy.getFitness()); } /** @@ -1087,8 +1054,6 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java. } else if (individual instanceof InterfaceDataTypeDouble) { double[] d = ((InterfaceDataTypeDouble) individual).getDoubleData(); for (int i = 0; i < d.length; i++) { -// sb.append(d[i]); -// if ((i+1) < d.length) sb.append(separator); fm.format("% .3f", d[i]); if ((i + 1) < d.length) { sb.append(separator); diff --git a/src/eva2/optimization/individuals/InterfaceDataTypeDouble.java b/src/eva2/optimization/individuals/InterfaceDataTypeDouble.java index 5d7ce57f..fe7df601 100644 --- a/src/eva2/optimization/individuals/InterfaceDataTypeDouble.java +++ b/src/eva2/optimization/individuals/InterfaceDataTypeDouble.java @@ -4,11 +4,6 @@ package eva2.optimization.individuals; * This interface gives access to a double phenotype and except * for problemspecific operators should only be used by the * optimization problem. - * Created by IntelliJ IDEA. - * User: streiche - * Date: 24.03.2003 - * Time: 10:57:39 - * To change this template use Options | File Templates. */ public interface InterfaceDataTypeDouble { diff --git a/src/eva2/optimization/individuals/OBGAIndividualPermutationData.java b/src/eva2/optimization/individuals/OBGAIndividualPermutationData.java index b3e0d0ed..49726161 100644 --- a/src/eva2/optimization/individuals/OBGAIndividualPermutationData.java +++ b/src/eva2/optimization/individuals/OBGAIndividualPermutationData.java @@ -90,10 +90,6 @@ public class OBGAIndividualPermutationData extends AbstractEAIndividual implemen } } - /************************************************************************************ - * AbstractEAIndividual methods - */ - /** * This method will initialize the individual with a given value for the * phenotype. @@ -203,11 +199,11 @@ public class OBGAIndividualPermutationData extends AbstractEAIndividual implemen perm[p] = new int[this.genotype[p].length]; ArrayList pot = new ArrayList(); for (int i = 0; i < this.sizePermutation()[p]; i++) { - pot.add(new Integer(firstindex[p] + i)); + pot.add(firstindex[p] + i); } int i = 0; while (!pot.isEmpty()) { - perm[p][i] = ((Integer) (pot.remove(RNG.randomInt(0, pot.size() - 1)))).intValue(); + perm[p][i] = (Integer) (pot.remove(RNG.randomInt(0, pot.size() - 1))); i++; } } diff --git a/src/eva2/optimization/strategies/DifferentialEvolution.java b/src/eva2/optimization/strategies/DifferentialEvolution.java index 0c331af8..582c95dc 100644 --- a/src/eva2/optimization/strategies/DifferentialEvolution.java +++ b/src/eva2/optimization/strategies/DifferentialEvolution.java @@ -296,10 +296,11 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial /** * This method will generate one new individual from the given population * - * @param pop The current population + * @param population The current population + * @param parentIndex * @return AbstractEAIndividual */ - public AbstractEAIndividual generateNewIndividual(Population pop, int parentIndex) { + public AbstractEAIndividual generateNewIndividual(Population population, int parentIndex) { AbstractEAIndividual indy; InterfaceDataTypeDouble esIndy; @@ -309,11 +310,11 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial parents = null; } try { - // select one random indy as starting individual. its a parent in any case. + // select one random indy as starting individual. It's a parent in any case. if (parentIndex < 0) { - parentIndex = RNG.randomInt(0, pop.size() - 1); + parentIndex = RNG.randomInt(0, population.size() - 1); } - indy = (AbstractEAIndividual) (pop.getEAIndividual(parentIndex)).getClone(); + indy = (AbstractEAIndividual) (population.getEAIndividual(parentIndex)).getClone(); esIndy = (InterfaceDataTypeDouble) indy; } catch (java.lang.ClassCastException e) { throw new RuntimeException("Differential Evolution currently requires InterfaceESIndividual as basic data type!"); @@ -325,9 +326,9 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial switch (this.DEType) { case DE1_Rand_1: { // this is DE1 or DE/rand/1 - double[] delta = this.fetchDeltaRandom(pop); + double[] delta = this.fetchDeltaRandom(population); if (parents != null) { - parents.add(pop.getEAIndividual(parentIndex)); + parents.add(population.getEAIndividual(parentIndex)); } // Add wherever oX is used directly for (int i = 0; i < oX.length; i++) { vX[i] = oX[i] + this.getCurrentF() * delta[i]; @@ -336,10 +337,10 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial } case DE_CurrentToRand: { // this is DE/current-to-rand/1 - double[] rndDelta = this.fetchDeltaRandom(pop); - double[] bestDelta = this.fetchDeltaCurrentRandom(pop, esIndy); + double[] rndDelta = this.fetchDeltaRandom(population); + double[] bestDelta = this.fetchDeltaCurrentRandom(population, esIndy); if (parents != null) { - parents.add(pop.getEAIndividual(parentIndex)); + parents.add(population.getEAIndividual(parentIndex)); } // Add wherever oX is used directly for (int i = 0; i < oX.length; i++) { vX[i] = oX[i] + this.getCurrentLambda() * bestDelta[i] + this.getCurrentF() * rndDelta[i]; @@ -348,10 +349,10 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial } case DE2_CurrentToBest: { // this is DE2 or DE/current-to-best/1 - double[] rndDelta = this.fetchDeltaRandom(pop); - double[] bestDelta = this.fetchDeltaBest(pop, esIndy); + double[] rndDelta = this.fetchDeltaRandom(population); + double[] bestDelta = this.fetchDeltaBest(population, esIndy); if (parents != null) { - parents.add(pop.getEAIndividual(parentIndex)); + parents.add(population.getEAIndividual(parentIndex)); } // Add wherever oX is used directly for (int i = 0; i < oX.length; i++) { vX[i] = oX[i] + this.getCurrentLambda() * bestDelta[i] + this.getCurrentF() * rndDelta[i]; @@ -360,12 +361,12 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial } case DE_Best_1: { // DE/best/1 - AbstractEAIndividual bestIndy = getBestIndy(pop); + AbstractEAIndividual bestIndy = getBestIndy(population); oX = getGenotype(bestIndy); if (parents != null) { parents.add(bestIndy); } // Add best instead of preselected - double[] delta1 = this.fetchDeltaRandom(pop); + double[] delta1 = this.fetchDeltaRandom(population); for (int i = 0; i < oX.length; i++) { vX[i] = oX[i] + this.getCurrentF() * delta1[i]; } @@ -373,13 +374,13 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial } case DE_Best_2: { // DE/best/2 - AbstractEAIndividual bestIndy = getBestIndy(pop); + AbstractEAIndividual bestIndy = getBestIndy(population); oX = getGenotype(bestIndy); if (parents != null) { parents.add(bestIndy); } // Add best instead of preselected - double[] delta1 = this.fetchDeltaRandom(pop); - double[] delta2 = this.fetchDeltaRandom(pop); + double[] delta1 = this.fetchDeltaRandom(population); + double[] delta2 = this.fetchDeltaRandom(population); for (int i = 0; i < oX.length; i++) { vX[i] = oX[i] + this.getCurrentF() * delta1[i] + this.getCurrentF() * delta2[i]; } @@ -388,7 +389,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial case TrigonometricDE: { // this is trigonometric mutation if (parents != null) { - parents.add(pop.getEAIndividual(parentIndex)); + parents.add(population.getEAIndividual(parentIndex)); } // Add wherever oX is used directly if (RNG.flipCoin(this.mt)) { double[] xk, xl; @@ -396,8 +397,8 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial InterfaceDataTypeDouble indy1 = null, indy2 = null; try { // and i got indy! - indy1 = (InterfaceDataTypeDouble) pop.get(RNG.randomInt(0, pop.size() - 1)); - indy2 = (InterfaceDataTypeDouble) pop.get(RNG.randomInt(0, pop.size() - 1)); + indy1 = (InterfaceDataTypeDouble) population.get(RNG.randomInt(0, population.size() - 1)); + indy2 = (InterfaceDataTypeDouble) population.get(RNG.randomInt(0, population.size() - 1)); if (parents != null) { parents.add((AbstractEAIndividual) indy1); parents.add((AbstractEAIndividual) indy2); @@ -416,9 +417,9 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial } } else { // this is DE1 - double[] delta = this.fetchDeltaRandom(pop); + double[] delta = this.fetchDeltaRandom(population); if (parents != null) { - parents.add(pop.getEAIndividual(parentIndex)); + parents.add(population.getEAIndividual(parentIndex)); } // Add wherever oX is used directly for (int i = 0; i < oX.length; i++) { vX[i] = oX[i] + this.getCurrentF() * delta[i]; diff --git a/src/eva2/problems/AbstractDynTransProblem.java b/src/eva2/problems/AbstractDynTransProblem.java index a275739a..d561a11d 100644 --- a/src/eva2/problems/AbstractDynTransProblem.java +++ b/src/eva2/problems/AbstractDynTransProblem.java @@ -61,7 +61,6 @@ public abstract class AbstractDynTransProblem extends AbstractSynchronousOptimiz double delta = transLength(getCurrentProblemTime()); if (isExtraPlot()) { if (myplot != null) { - // myplot.addGraph(0, 1); myplot.jump(); } else { double[] tmpD = new double[2]; @@ -71,7 +70,6 @@ public abstract class AbstractDynTransProblem extends AbstractSynchronousOptimiz this.myplot = new Plot("population measures", "x1", "x2", tmpD, tmpD); } myplot.setConnectedPoint(population.getFunctionCalls(), delta, 0); - //myplot.setUnconnectedPoint(population.getFunctionCalls(), population.getPopulationMeasures()[2], 2); } else { myplot = null; } @@ -142,10 +140,6 @@ public abstract class AbstractDynTransProblem extends AbstractSynchronousOptimiz return problemDimension; } - /** - * *************************************************************************** - * These are for the GUI - */ @Override public String getStringRepresentationForProblem(InterfaceOptimizer opt) { return "DynTransProblem"; diff --git a/src/eva2/problems/AbstractDynamicOptimizationProblem.java b/src/eva2/problems/AbstractDynamicOptimizationProblem.java index 2d9c7b4d..84d3b69a 100644 --- a/src/eva2/problems/AbstractDynamicOptimizationProblem.java +++ b/src/eva2/problems/AbstractDynamicOptimizationProblem.java @@ -52,11 +52,9 @@ public abstract class AbstractDynamicOptimizationProblem extends AbstractOptimiz * A constructor. */ public AbstractDynamicOptimizationProblem() { - //System.out.println("AbstractDynamicOptimizationProblem()"); bExtraPlot = false; myplot = null; idealInd = null; -// initialize(0, 1., 0.1); } /** @@ -103,7 +101,6 @@ public abstract class AbstractDynamicOptimizationProblem extends AbstractOptimiz */ @Override public void initializePopulation(Population population) { - //initializeProblem(); // this shouldnt be necessary this.initPopulationAt(population, getCurrentProblemTime()); } @@ -225,7 +222,6 @@ public abstract class AbstractDynamicOptimizationProblem extends AbstractOptimiz */ public abstract AbstractEAIndividual getCurrentOptimum(); - /******************** The most important methods ****************************************/ /** * This method evaluates a single individual and sets the fitness value at default time stamp 0. @@ -279,9 +275,6 @@ public abstract class AbstractDynamicOptimizationProblem extends AbstractOptimiz evaluateAt(individual, getCurrentProblemTime()); } -/********************************************************************************************************************** - * These are for GUI - */ /** * Override population evaluation to do some data output. * @@ -289,26 +282,10 @@ public abstract class AbstractDynamicOptimizationProblem extends AbstractOptimiz */ @Override public void evaluatePopulationEnd(Population population) { - //System.out.println(">> mean distance at " + population.getFunctionCalls() + " / " + getProblemTime() + " is " + population.getMeanDistance()); - //System.out.println("> current best is " + population.getBestFitness()[0]); - //double[] meanMinMax = population.getPopulationMeasures(); - - //myplot.setConnectedPoint(population.getFunctionCalls(), population.getPopulationMeasures()[0], 0); - AbstractEAIndividual popBest = (AbstractEAIndividual) (population.getBestIndividual()); if (idealInd == null) { idealInd = (AbstractEAIndividual) popBest.clone(); } - -// getCurrentOptimum((InterfaceDataTypeDouble)idealInd); - -// double d = new PhenotypeMetric().distance(popBest, idealInd); -// double d = distanceBetween(popBest, idealInd); - - //System.out.println("tracking dist is " + d); - - //if (myplot!=null) myplot.setConnectedPoint(population.getFunctionCalls(), d, 0); - //myplot.setUnconnectedPoint(population.getFunctionCalls(), population.getPopulationMeasures()[2], 2); } protected void setExtraPlot(boolean doPlot) { diff --git a/src/eva2/problems/AbstractMultiModalProblemKnown.java b/src/eva2/problems/AbstractMultiModalProblemKnown.java index d5b3b4f0..8996c959 100644 --- a/src/eva2/problems/AbstractMultiModalProblemKnown.java +++ b/src/eva2/problems/AbstractMultiModalProblemKnown.java @@ -377,7 +377,7 @@ public abstract class AbstractMultiModalProblemKnown extends AbstractProblemDoub */ @Override public void setDefaultAccuracy(double epsilon) { - super.SetDefaultAccuracy(epsilon); + super.setDefaultAccuracy(epsilon); } @Override diff --git a/src/eva2/problems/AbstractMultiObjectiveOptimizationProblem.java b/src/eva2/problems/AbstractMultiObjectiveOptimizationProblem.java index 326f6467..17665b60 100644 --- a/src/eva2/problems/AbstractMultiObjectiveOptimizationProblem.java +++ b/src/eva2/problems/AbstractMultiObjectiveOptimizationProblem.java @@ -65,16 +65,9 @@ public abstract class AbstractMultiObjectiveOptimizationProblem extends Abstract if (border == null) { prob.border = new double[fitness.length][2]; } else if (fitness.length != prob.border.length) { - //System.out.println("AbstractMOOptimizationProblem: Warning fitness.length("+fitness.length+") doesn't fit border.length("+this.border.length+")"); - //System.out.println("Resetting the border!"); prob.border = new double[fitness.length][2]; } for (int j = 0; j < fitness.length; j++) { -// if ((this.border[j][0] > fitness[j]) || (this.border[j][1] < fitness[j])) { -// System.out.println("border... " + j); -// System.out.println(this.border[j][0]+" > "+fitness[j]); -// System.out.println(this.border[j][1]+" < "+fitness[j]); -// } prob.border[j][0] = Math.min(prob.border[j][0], fitness[j]); prob.border[j][1] = Math.max(prob.border[j][1], fitness[j]); } @@ -192,11 +185,9 @@ public abstract class AbstractMultiObjectiveOptimizationProblem extends Abstract for (int i = 0; i < pop.size(); i++) { tmpFitLen = ((AbstractEAIndividual) pop.get(i)).getFitness().length; if (tmpFitLen <= 1) { - //System.out.println("There is a single objective individual in the population!"); return false; } if (tmpFitLen != bestFitLen) { - //System.out.println("Not all individual have equal length fitness!"); return false; } } @@ -232,16 +223,9 @@ public abstract class AbstractMultiObjectiveOptimizationProblem extends Abstract if (border == null) { this.border = new double[fitness.length][2]; } else if (fitness.length != this.border.length) { - //System.out.println("AbstractMOOptimizationProblem: Warning fitness.length("+fitness.length+") doesn't fit border.length("+this.border.length+")"); - //System.out.println("Resetting the border!"); this.border = new double[fitness.length][2]; } for (int j = 0; j < fitness.length; j++) { -// if ((this.border[j][0] > fitness[j]) || (this.border[j][1] < fitness[j])) { -// System.out.println("border... " + j); -// System.out.println(this.border[j][0]+" > "+fitness[j]); -// System.out.println(this.border[j][1]+" < "+fitness[j]); -// } this.border[j][0] = Math.min(this.border[j][0], fitness[j]); this.border[j][1] = Math.max(this.border[j][1], fitness[j]); } @@ -330,7 +314,6 @@ public abstract class AbstractMultiObjectiveOptimizationProblem extends Abstract */ public static void drawProblem(Population pFront, Population archive, Plot plot) { ArchivingAllDominating tmpArch = new ArchivingAllDominating(); -// Population tmpPop = null; // i want to plot the pareto front for MOEA and other strategies // but i have to differentiate between the case where @@ -377,7 +360,6 @@ public abstract class AbstractMultiObjectiveOptimizationProblem extends Abstract Population tmpPop = null; if (p.getGeneration() > 2) { -// plot = new eva2.gui.plot.Plot("Multiobjective Optimization", "Y1", "Y2"); // i want to plot the pareto front for MOEA and other strategies // but i have to differentiate between the case where // there is a true MOEA at work and where the @@ -519,13 +501,13 @@ public abstract class AbstractMultiObjectiveOptimizationProblem extends Abstract @Override public Double getDoublePlotValue(Population pop) { if (AbstractMultiObjectiveOptimizationProblem.isPopulationMultiObjective(pop)) { - return new Double(this.calculateMetric(pop)); + return this.calculateMetric(pop); } else { // in this case the local Pareto-Front could be multi-objective if (AbstractMultiObjectiveOptimizationProblem.isPopulationMultiObjective(this.paretoFront)) { - return new Double(this.calculateMetric(this.paretoFront)); + return this.calculateMetric(this.paretoFront); } else { - return new Double(pop.getBestEAIndividual().getFitness(0)); + return pop.getBestEAIndividual().getFitness(0); } } } @@ -558,10 +540,6 @@ public abstract class AbstractMultiObjectiveOptimizationProblem extends Abstract return ToolBox.appendArrays(result, super.getAdditionalDataValue(pop)); } - /* - * (non-Javadoc) - * @see eva2.problems.AbstractOptimizationProblem#getAdditionalDataInfo(eva2.optimization.PopulationInterface) - */ @Override public String[] getAdditionalDataInfo() { String[] superInfo = super.getAdditionalDataInfo(); @@ -569,10 +547,6 @@ public abstract class AbstractMultiObjectiveOptimizationProblem extends Abstract "Pareto metric on the collected pareto front"}, superInfo); } - /* - * (non-Javadoc) - * @see eva2.problems.InterfaceOptimizationProblem#getStringRepresentationForProblem(eva2.optimization.strategies.InterfaceOptimizer) - */ @Override public String getStringRepresentationForProblem(InterfaceOptimizer opt) { // TODO Auto-generated method stub @@ -608,32 +582,6 @@ public abstract class AbstractMultiObjectiveOptimizationProblem extends Abstract return this.outputDimension; } -// /** This method will calculate the s-Metric if an archive population is present. -// * @param population The population. -// * @return s-metric -// */ -// public double tcalculateSMetric(Population population) { -// double result = 0; -// -// ((SMetric)this.distanceMetric).setObjectiveSpaceRange(this.border); -// result = this.distanceMetric.calculateMetricOn(population); -// -// return result; -// } -// -// /** This method will calculate the s-Metric if an archive population is present. -// * @param population The population. -// * @return s-metric -// */ -// public double calculateRelativeSMetric(Population population, double[][] ref) { -// double result = 0; -// SMetricWithReference tmpMetric = new SMetricWithReference(); -// tmpMetric.setObjectiveSpaceRange(this.border); -// tmpMetric.setReferenceFront(ref); -// result = tmpMetric.calculateMetricOn(population); -// return result; -// } - /** * This method allows you to set a Multiobjective to * Singleobjective converter if you choose to. diff --git a/src/eva2/problems/AbstractOptimizationProblem.java b/src/eva2/problems/AbstractOptimizationProblem.java index 9b095bde..a1a1ff72 100644 --- a/src/eva2/problems/AbstractOptimizationProblem.java +++ b/src/eva2/problems/AbstractOptimizationProblem.java @@ -71,7 +71,6 @@ public abstract class AbstractOptimizationProblem implements InterfaceOptimizati private int parallelthreads = 1; protected AbstractEAIndividual template = null; -// private transient ArrayList changeListeners = null; private double defaultAccuracy = 0.001; // default accuracy for identifying optima. @@ -102,8 +101,6 @@ public abstract class AbstractOptimizationProblem implements InterfaceOptimizati @Override public abstract void initializeProblem(); - /******************** The most important methods ****************************************/ - /** * This method inits a given population * @@ -205,8 +202,6 @@ public abstract class AbstractOptimizationProblem implements InterfaceOptimizati population.init(); } - /******************** Some output methods *******************************************/ - /** * This method allows you to output a string that describes a found solution * in a way that is most suitable for a given problem. @@ -430,15 +425,12 @@ public abstract class AbstractOptimizationProblem implements InterfaceOptimizati * @param clusterSigma minimum cluster distance * @param maxEvalsPerIndy maximum number of evaluations or -1 to take the maximum * @return - * @see #isPotentialOptimumNMS(AbstractEAIndividual, double, double, int) */ public static Population extractPotentialOptima(AbstractOptimizationProblem prob, Population pop, double epsilonPhenoSpace, double epsilonFitConv, double clusterSigma, int maxEvalsPerIndy) { Population potOptima = new Population(); for (int i = 0; i < pop.size(); ++i) { - //System.out.println("Refining " + i + " of " + population.size()); AbstractEAIndividual indy = pop.getEAIndividual(i); -// System.out.println("bef: " + indy.toString()); boolean isConverged = AbstractOptimizationProblem.isPotentialOptimumNMS(prob, indy, epsilonPhenoSpace, epsilonFitConv, maxEvalsPerIndy); if (isConverged) { potOptima.addIndividual(indy); @@ -514,11 +506,7 @@ public abstract class AbstractOptimizationProblem implements InterfaceOptimizati return false; // dont waste any more evaluations on this candidate } } - if (overallDist < epsilon) { - return true; - } else { - return false; - } + return overallDist < epsilon; } /** @@ -565,21 +553,8 @@ public abstract class AbstractOptimizationProblem implements InterfaceOptimizati } int evalsPerf = PostProcess.processSingleCandidatesNMCMA(PostProcessMethod.nelderMead, pop, term, initRelPerturb, prob); overallDist = metric.distance(indy, pop.getBestEAIndividual()); - //System.out.println(System.currentTimeMillis() + " in " + evalsPerf + " evals moved by "+ overallDist); -// System.out.println("aft: " + population.getBestEAIndividual().toString() + ", evals performed: " + evalsPerf + ", opt moved by " + overallDist); -// System.out.println("terminated because: " + term.lastTerminationMessage()); orig.putData(PostProcess.movedDistanceKey, overallDist); orig.putData(PostProcess.movedToPositionKey, pop.getBestEAIndividual().getDoublePosition()); -// if (overallDist==0) { -// PostProcess.processSingleCandidatesNMCMA(PostProcessMethod.nelderMead, population, term, initPerturb, this); -// } - -// System.out.println("Checked "+ indy.getStringRepresentation()); -// String msg = "----discarding "; -// if (overallDist <= epsilonPhenoSpace) msg= "++++keeping "; -// System.out.println(msg + BeanInspector.toString(indy.getDoublePosition())); -// System.out.println("which moved to " + BeanInspector.toString(population.getBestEAIndividual().getDoublePosition())); -// System.out.println(" by " + overallDist + " > " + epsilonPhenoSpace); return (overallDist < epsilonPhenoSpace); } @@ -588,10 +563,6 @@ public abstract class AbstractOptimizationProblem implements InterfaceOptimizati return defaultAccuracy; } - public void SetDefaultAccuracy(double defAcc) { - defaultAccuracy = defAcc; - } - public void setDefaultAccuracy(double defAcc) { defaultAccuracy = defAcc; } diff --git a/src/eva2/problems/AbstractParallelOptimizationProblem.java b/src/eva2/problems/AbstractParallelOptimizationProblem.java index 28f22262..037c8697 100644 --- a/src/eva2/problems/AbstractParallelOptimizationProblem.java +++ b/src/eva2/problems/AbstractParallelOptimizationProblem.java @@ -8,8 +8,7 @@ public abstract class AbstractParallelOptimizationProblem extends AbstractOptimi private boolean parallelize = false; @Override - public void initializeProblem() { - } + public void initializeProblem() { } /** * This method returns a global info string diff --git a/src/eva2/problems/AbstractProblemBinary.java b/src/eva2/problems/AbstractProblemBinary.java index 9ad14a15..b6c3c9d9 100644 --- a/src/eva2/problems/AbstractProblemBinary.java +++ b/src/eva2/problems/AbstractProblemBinary.java @@ -11,8 +11,6 @@ import java.util.BitSet; /** * An abstract problem based on binary data. - * - * @author mkron */ public abstract class AbstractProblemBinary extends AbstractOptimizationProblem { @@ -63,16 +61,6 @@ public abstract class AbstractProblemBinary extends AbstractOptimizationProblem */ public abstract int getProblemDimension(); -// /** -// * Initialize a single individual with index k in the -// * initializePopulation cycle. -// * @param k -// * @param indy -// */ -// protected void initIndy(int k, AbstractEAIndividual indy) { -// indy.initialize(this); -// } - @Override public void initializePopulation(Population population) { ((InterfaceDataTypeBinary) this.template).setBinaryDataLength(this.getProblemDimension()); @@ -84,9 +72,6 @@ public abstract class AbstractProblemBinary extends AbstractOptimizationProblem initTemplate(); } - /********************************************************************************************************************** - * These are for GUI - */ /** * This method allows the CommonJavaObjectEditorPanel to read the * name to the current object. @@ -122,5 +107,4 @@ public abstract class AbstractProblemBinary extends AbstractOptimizationProblem sb.append(this.getProblemDimension()); return sb.toString(); } -} - +} \ No newline at end of file diff --git a/src/eva2/problems/AbstractProblemDouble.java b/src/eva2/problems/AbstractProblemDouble.java index a5c85975..100da6a6 100644 --- a/src/eva2/problems/AbstractProblemDouble.java +++ b/src/eva2/problems/AbstractProblemDouble.java @@ -86,7 +86,7 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem protected void cloneObjects(AbstractProblemDouble o) { this.defaultRange = o.defaultRange; this.noise = o.noise; - this.SetDefaultAccuracy(o.getDefaultAccuracy()); + this.setDefaultAccuracy(o.getDefaultAccuracy()); if (o.template != null) { this.template = (AbstractEAIndividual) o.template.clone(); } diff --git a/src/eva2/problems/AbstractProblemInteger.java b/src/eva2/problems/AbstractProblemInteger.java index 564813b1..3fc7ec02 100644 --- a/src/eva2/problems/AbstractProblemInteger.java +++ b/src/eva2/problems/AbstractProblemInteger.java @@ -77,11 +77,6 @@ public abstract class AbstractProblemInteger extends AbstractOptimizationProblem */ public abstract double[] evaluate(int[] x); - /** - * ******************************************************************************************************************* - * These are for GUI - */ - @Override public String getName() { return "AbstractProblemInteger"; diff --git a/src/eva2/problems/AbstractSynchronousOptimizationProblem.java b/src/eva2/problems/AbstractSynchronousOptimizationProblem.java index 1e0ef2a6..125d18e3 100644 --- a/src/eva2/problems/AbstractSynchronousOptimizationProblem.java +++ b/src/eva2/problems/AbstractSynchronousOptimizationProblem.java @@ -11,10 +11,6 @@ import eva2.optimization.population.Population; * so that the problem changes after every evaluation. This of course under the simplification * that an evaluation takes no time, or from a different POV, changes within an evaluation * can not be taken into account (or just discretely approximated). - * - * @author M.Kronfeld - *

- * Jan 4, 2007 */ public abstract class AbstractSynchronousOptimizationProblem extends AbstractDynamicOptimizationProblem { @@ -31,7 +27,6 @@ public abstract class AbstractSynchronousOptimizationProblem extends * measures the "distance" which the problem shifts when it changes */ protected double shiftPerChange; - //protected double timeIntPerEval = 1.; // better assume this to be constant /** * @@ -51,18 +46,12 @@ public abstract class AbstractSynchronousOptimizationProblem extends } - /* (non-Javadoc) - * @see eva2.server.oa.go.OptimizationProblems.AbstractDynamicOptimizationProblem#changeProblemAt(double) - */ @Override protected void changeProblemAt(double problemTime) { incProblemTime(shiftPerChange); evalsSinceChange = 0.; } - /* (non-Javadoc) - * @see eva2.server.oa.go.OptimizationProblems.AbstractDynamicOptimizationProblem#problemToChangeAt(double) - */ @Override protected boolean problemToChangeAt(double problemTime) { return (evalsSinceChange >= constantProblemEvals); @@ -78,9 +67,6 @@ public abstract class AbstractSynchronousOptimizationProblem extends constantProblemEvals = constEvals; } - /* (non-Javadoc) - * @see eva2.server.oa.go.OptimizationProblems.AbstractDynamicOptimizationProblem#countEvaluation() - */ @Override protected void countEvaluation() { evalsSinceChange += 1.; @@ -99,7 +85,6 @@ public abstract class AbstractSynchronousOptimizationProblem extends @Override public void setFrequency(double frequency) { super.setFrequency(frequency); - //if (frequency > 1.) System.out.println("warning, frequency should be <= 1 (setFrequency)"); if (isFrequencyRelative()) { // bogus. this must be reset right before population evaluation setConstantProblemEvals(9999999); @@ -109,10 +94,6 @@ public abstract class AbstractSynchronousOptimizationProblem extends } } - - /* (non-Javadoc) - * @see eva2.server.oa.go.OptimizationProblems.AbstractDynamicOptimizationProblem#setFrequencyRelative(boolean) - */ @Override public void setFrequencyRelative(boolean frequencyRelative) { super.setFrequencyRelative(frequencyRelative); @@ -127,4 +108,4 @@ public abstract class AbstractSynchronousOptimizationProblem extends setConstantProblemEvals(population.size() / getFrequency()); } } -} +} \ No newline at end of file diff --git a/src/eva2/problems/BKnapsackProblem.java b/src/eva2/problems/BKnapsackProblem.java index 3ded8659..b3d3597f 100644 --- a/src/eva2/problems/BKnapsackProblem.java +++ b/src/eva2/problems/BKnapsackProblem.java @@ -347,7 +347,6 @@ public class BKnapsackProblem extends AbstractProblemBinary implements java.io.S result.append(this.punish); result.append("\n"); result.append("Solution representation:\n"); - //result += this.template.getSolutionRepresentationFor(); return result.toString(); } diff --git a/src/eva2/problems/DynJumpProblem.java b/src/eva2/problems/DynJumpProblem.java index 0047870e..3ef738dd 100644 --- a/src/eva2/problems/DynJumpProblem.java +++ b/src/eva2/problems/DynJumpProblem.java @@ -154,11 +154,6 @@ public class DynJumpProblem extends eva2.problems.AbstractDynTransProblem { return null; } - /** - * *********************************************************************** - * These are for the GUI - */ - @Override public String getStringRepresentationForProblem(InterfaceOptimizer opt) { return "DynJumpProblem"; diff --git a/src/eva2/problems/ExternalRuntimeProblem.java b/src/eva2/problems/ExternalRuntimeProblem.java index 13661263..f346ab75 100644 --- a/src/eva2/problems/ExternalRuntimeProblem.java +++ b/src/eva2/problems/ExternalRuntimeProblem.java @@ -53,7 +53,6 @@ public class ExternalRuntimeProblem extends AbstractOptimizationProblem writer.write(c); writer.flush(); } -// System.out.println("monitor-thread finished!"); } catch (IOException ioe) { System.err.println("IOException in MonitorInputStreamThread/ExternalRuntimeProblem: " + ioe.getMessage()); ioe.printStackTrace(System.err); @@ -208,7 +207,6 @@ public class ExternalRuntimeProblem extends AbstractOptimizationProblem @Override public void evaluate(AbstractEAIndividual individual) { double[] x; -// double[] fitness; x = getXVector(individual); @@ -266,7 +264,6 @@ public class ExternalRuntimeProblem extends AbstractOptimizationProblem line = line.trim(); String[] parts = line.split(colSepRegExp); Collections.addAll(results, parts); -// results.add(line); } br.close(); } catch (IOException e) { @@ -463,7 +460,6 @@ public class ExternalRuntimeProblem extends AbstractOptimizationProblem this.additionalArg = additionalArg; } - // @Override @Override public Object getInitializationRange() { if (initializationRange == null) { diff --git a/src/eva2/problems/F13Problem.java b/src/eva2/problems/F13Problem.java index 5b7a3ef4..999cae6b 100644 --- a/src/eva2/problems/F13Problem.java +++ b/src/eva2/problems/F13Problem.java @@ -69,7 +69,6 @@ public class F13Problem extends AbstractProblemDoubleOffset implements Interface result[0] -= xi * Math.sin(Math.sqrt(Math.abs(xi))); } result[0] += (418.9829 * problemDimension); - // res = cn-sum_i(xi*sin(sqrt(abs(xi)))) return result; } @@ -86,19 +85,16 @@ public class F13Problem extends AbstractProblemDoubleOffset implements Interface result += "Dimension : " + this.problemDimension + "\n"; result += "Noise level : " + this.getNoise() + "\n"; result += "Solution representation:\n"; - //result += this.template.getSolutionRepresentationFor(); return result; } @Override public SolutionHistogram getHistogram() { -// EVAERROR.errorMsgOnce("Warning: Restore line in getHistogram for evaluation on F13Problem ???"); if (getProblemDimension() < 15) { return new SolutionHistogram(0, 800, 16); } else if (getProblemDimension() < 25) { return new SolutionHistogram(0, 1600, 16); } -// else if (getProblemDimension() < 35) return new SolutionHistogram(0, 1600, 16); else { return new SolutionHistogram(0, 3200, 12); } @@ -117,6 +113,6 @@ public class F13Problem extends AbstractProblemDoubleOffset implements Interface @Override public void setDefaultAccuracy(double v) { - super.SetDefaultAccuracy(v); + super.setDefaultAccuracy(v); } } \ No newline at end of file diff --git a/src/eva2/problems/F15Problem.java b/src/eva2/problems/F15Problem.java index 1df168e1..38869aa1 100644 --- a/src/eva2/problems/F15Problem.java +++ b/src/eva2/problems/F15Problem.java @@ -15,7 +15,7 @@ public class F15Problem extends AbstractProblemDouble implements Serializable, I public F15Problem() { super(); - super.SetDefaultAccuracy(0.00001); + super.setDefaultAccuracy(0.00001); setDefaultRange(10); } diff --git a/src/eva2/problems/F6Problem.java b/src/eva2/problems/F6Problem.java index a3cb68a7..962bc4a2 100644 --- a/src/eva2/problems/F6Problem.java +++ b/src/eva2/problems/F6Problem.java @@ -137,7 +137,7 @@ public class F6Problem extends AbstractProblemDoubleOffset @Override public void setDefaultAccuracy(double acc) { - super.SetDefaultAccuracy(acc); + super.setDefaultAccuracy(acc); } @Override diff --git a/src/eva2/problems/GPFunctionProblem.java b/src/eva2/problems/GPFunctionProblem.java index 9463f835..cf369741 100644 --- a/src/eva2/problems/GPFunctionProblem.java +++ b/src/eva2/problems/GPFunctionProblem.java @@ -12,8 +12,6 @@ import eva2.tools.EVAERROR; * function by scaling it logarithmically. This avoids ugly functions in GP. To activate scaling, * set the scStart and scLimit parameters to positive values. Function values y with |y|>scStart * will be rescaled to values below scLimit. - * - * @author mkron */ public class GPFunctionProblem extends AbstractProblemDouble implements InterfaceProgramProblem { InterfaceProgram gpProblem = null; @@ -109,7 +107,7 @@ public class GPFunctionProblem extends AbstractProblemDouble implements Interfac /** * Scale the allover fitness value. * - * @param doubleValue + * @param v * @return */ public double scaleFit(double v) { @@ -127,12 +125,6 @@ public class GPFunctionProblem extends AbstractProblemDouble implements Interfac } } -// public static void main(String[] args) { -// for (double x=1.; x<100000000; x*=10.) { -// System.out.println("x: " + -x + " sc: " + scaleFit(-x)); -// } -// } - @Override public int getProblemDimension() { return dim; diff --git a/src/eva2/problems/MatlabEvalMediator.java b/src/eva2/problems/MatlabEvalMediator.java index c9eec40c..38ce1539 100644 --- a/src/eva2/problems/MatlabEvalMediator.java +++ b/src/eva2/problems/MatlabEvalMediator.java @@ -21,8 +21,6 @@ import java.util.concurrent.Semaphore; * Adding sleep time reduces CPU load a lot but reduces efficiency badly at the same time, probably because * there's so much going on. For cases where the evaluation function is very time-consuming, adding sleep time * might be an option. - * - * @author mkron */ public class MatlabEvalMediator { volatile Boolean requesting = false; @@ -71,13 +69,7 @@ public class MatlabEvalMediator { double[] requestEval(MatlabProblem mp, Object x) { this.mp = mp; question = x; -// System.err.println("IN REQUESTEVAL, x is " + BeanInspector.toString(x)); if (question.getClass().isArray()) { -// System.err.println("array of type ** " + Array.get(question, 0).getClass().toString()); -// } else if (question instanceof BitSet){ -// BitSet b = (BitSet)x; -// Integer.decode() -// if (question == null) { System.err.println("Error: requesting evaluation for null array!"); } @@ -86,35 +78,15 @@ public class MatlabEvalMediator { System.err.println("Error, requesting evaluation for invalid data type! " + question.getClass()); } } -// logMPAndSysOut("Synch requesting A requestEval " + getState()); synchronized (requesting) { //MdP -// logMPAndSysOut(" in synch requesting A requestEval " + getState()); if (requesting) { String msg = "Warning: already in requesting state when request arrived!"; System.err.println(msg); logMP(msg); } requesting = true; -// logMPAndSysOut("-- Requesting evaluate for " + BeanInspector.toString(x) + ", req state is " + requesting + "\n"); } - -// logMPAndSysOut("Synch requesting A done " + getState()); - /*int k=0; int mod=25; - while (requesting && !quit) { - // wait for matlab to answer the question - if (sleepTime > 0) try { Thread.sleep(sleepTime); } catch(Exception e) { - System.err.println("Exception in sleep (MatlabEvalMediator)"); - }; - k++; - if ((k%mod)==0) { -// System.out.println("waiting for matlab to answer..."); - logMP("waiting for matlab to answer... (" + mod + ") " + getState() + "\n"); - mod*=2; - if (mod <=0) mod=Integer.MAX_VALUE; - - } - }*/ try { requests.acquire(); } catch (InterruptedException e) { @@ -123,7 +95,6 @@ public class MatlabEvalMediator { } logMP("-- Requesting done\n"); // matlab is finished, answer is here - //return null; return getAnswer(); // return to JE with answer } diff --git a/src/eva2/problems/MatlabProblem.java b/src/eva2/problems/MatlabProblem.java index b9de5ef6..db20dce0 100644 --- a/src/eva2/problems/MatlabProblem.java +++ b/src/eva2/problems/MatlabProblem.java @@ -53,15 +53,10 @@ public class MatlabProblem extends AbstractOptimizationProblem implements Interf this.handler = o.handler; this.runnable = o.runnable; this.allowSingleRunnable = o.allowSingleRunnable; -// this.jmInterface = new String(o.jmInterface); this.problemDimension = o.problemDimension; -// this.res = new ResultArr(); -// if (o.res != null) if (o.res.get() != null) res.set(o.res.get()); this.range = o.range; this.dataType = o.dataType; this.initialRange = o.initialRange; -// this.mtCmd = o.mtCmd; -// currArray = null; } @Override @@ -69,15 +64,6 @@ public class MatlabProblem extends AbstractOptimizationProblem implements Interf return new MatlabProblem(this); } - /** - * Constructor of a real valued problem. - * @param dim - * @param range - */ -// public MatlabProblem(int dim, double[][] range) { -// initialize(dim, ProblemDataTypeEnum.typeDouble, range, null, defTestOut); -// } - /** * Constructor of a binary problem with given bit length. * @@ -87,16 +73,6 @@ public class MatlabProblem extends AbstractOptimizationProblem implements Interf init(dim, MatlabProblemDataTypeEnum.typeBinary, null, null, defTestOut); } - /** - * Constructor of a real valued problem with initialization range. - * @param dim - * @param range - * @param initRange - */ -// public MatlabProblem(int dim, double[][] range, double[][] initRange) { -// initialize(dim, ProblemDataTypeEnum.typeDouble, range, initRange, defTestOut); -// } - /** * Constructor of real or integer valued problem, the range will be converted * to integer in the latter case. @@ -187,7 +163,6 @@ public class MatlabProblem extends AbstractOptimizationProblem implements Interf */ private void init(int dim, MatlabProblemDataTypeEnum datType, double[][] globalRange, double[][] initRange, String outFile) { this.problemDimension = dim; -// if ((rng != null) && (dim != rng.length)) throw new ArrayIndexOutOfBoundsException("Mismatching dimension and range!"); if (globalRange != null) { // these may be Matlab objects, so I do it by foot, just to be sure not to clone them within Matlab instead of here this.range = new double[globalRange.length][globalRange[0].length]; for (int i = 0; i < this.range.length; i++) { @@ -344,7 +319,6 @@ public class MatlabProblem extends AbstractOptimizationProblem implements Interf * @param outputFilePrefix * @param specParams * @param specValues - * @see OptimizerFactory.getOptRunnable */ public void optimize(final int optType, String outputFilePrefix, Object[] specParams, Object[] specValues) { if (allowSingleRunnable && (runnable != null) && (!runnable.isFinished())) { diff --git a/src/eva2/problems/PSymbolicRegression.java b/src/eva2/problems/PSymbolicRegression.java index f9a0dd3a..657d5ebb 100644 --- a/src/eva2/problems/PSymbolicRegression.java +++ b/src/eva2/problems/PSymbolicRegression.java @@ -150,7 +150,10 @@ public class PSymbolicRegression extends AbstractOptimizationProblem implements /** * This method inits a given population * - * @param population The populations that is to be inited + * @param pop The populations that is to be inited + * @param prob + * @param useInnerConsts + * @param numConsts */ public static void initPopulation(Population pop, InterfaceProgramProblem prob, boolean useInnerConsts, int numConsts) { AbstractEAIndividual template; @@ -240,8 +243,8 @@ public class PSymbolicRegression extends AbstractOptimizationProblem implements for (int j = 0; j < this.numberOfCheckPoints; j++) { setCheckPoint(x, j); - tmpValue = ((Double) program.evaluate(this)).doubleValue(); - fitness += Math.pow((this.targetFunction.evaluateFunction(this.x) - ((Double) program.evaluate(this)).doubleValue()), 2); + tmpValue = (Double) program.evaluate(this); + fitness += Math.pow((this.targetFunction.evaluateFunction(this.x) - (Double) program.evaluate(this)), 2); } fitness /= (double) this.numberOfCheckPoints; @@ -262,7 +265,7 @@ public class PSymbolicRegression extends AbstractOptimizationProblem implements program = ((InterfaceDataTypeProgram) this.overallBestIndividuum).getProgramData()[0]; for (int i = 0; i < this.numberOfCheckPoints; i++) { setCheckPoint(x, i); - tmpValue = ((Double) program.evaluate(this)).doubleValue(); + tmpValue = (Double) program.evaluate(this); this.plot.setConnectedPoint(this.x[0], tmpValue, 0); tmpValue = this.targetFunction.evaluateFunction(this.x); this.plot.setConnectedPoint(this.x[0], tmpValue, 1); @@ -309,9 +312,6 @@ public class PSymbolicRegression extends AbstractOptimizationProblem implements @Override public Object getSensorValue(String sensor) { return PSymbolicRegression.getSensorValue(sensor, x, constants); -// for (int i = 0; i < this.x.length; i++) if (sensor.equalsIgnoreCase("X"+i)) return new Double(this.x[i]); -// for (int i = 0; i < this.c.length; i++) if (sensor.equalsIgnoreCase("C"+i)) return new Double(this.c[i]); -// return new Double(0); } /** @@ -333,22 +333,19 @@ public class PSymbolicRegression extends AbstractOptimizationProblem implements return vars; } int index = Integer.parseInt(sensor.substring(1)); - return new Double(vars[index]); + return vars[index]; } catch (Exception e) { System.err.println("Warning, unable to access " + sensor); return vars; } } else if (sensor.charAt(0) == 'C') { int index = Integer.parseInt(sensor.substring(1)); - return new Double(consts[index]); + return consts[index]; } else if (sensor.charAt(0) == 'N') { return (double) vars.length; } else { - return new Double(0); + return (double) 0; } -// for (int i = 0; i < this.x.length; i++) if (sensor.equalsIgnoreCase("X"+i)) return new Double(this.x[i]); -// for (int i = 0; i < this.c.length; i++) if (sensor.equalsIgnoreCase("C"+i)) return new Double(this.c[i]); -// return new Double(0); } /** @@ -362,9 +359,6 @@ public class PSymbolicRegression extends AbstractOptimizationProblem implements // no actuators in this problem } -/********************************************************************************************************************** - * These are for GUI - */ /** * This method allows the CommonJavaObjectEditorPanel to read the * name to the current object. @@ -702,10 +696,4 @@ public class PSymbolicRegression extends AbstractOptimizationProblem implements System.out.println("Evaluated individual: " + indy); return indy.getFitness(); } - -// public static void main(String[] args) { -// String bestStudentSol = "-(abs(abs(-(-(X0, -(-(X0, X0), X0)), sin(abs(-(-(X0, X0), X0)))))), -(-(sin(-(abs(X0), -(-(-(X0, X0), X0), abs(abs(X0))))), -(-(abs(abs(abs(X0))), -(-(-(X0, X0), X0), abs(-(X0,X0)))), sin(-(abs(X0), sin(sin(X0)))))), X0))"; -//// String bestStudentSol = "-(abs(-(sqrt(-(-(abs(1.0), X0), X0)), -(sqrt(-(sqrt(1.0), sqrt(pi))), X0))),-(-(sin(sqrt(-(-(sqrt(1.0), X0), pi))), abs(X0)), -(sqrt(pi), -(sqrt(sqrt(-(abs(1.0), X0))),X0))))"; -// evalNodeString(bestStudentSol); -// } } diff --git a/src/eva2/problems/TF1Problem.java b/src/eva2/problems/TF1Problem.java index 970ed57d..11833bc7 100644 --- a/src/eva2/problems/TF1Problem.java +++ b/src/eva2/problems/TF1Problem.java @@ -257,9 +257,6 @@ public class TF1Problem extends AbstractMultiObjectiveOptimizationProblem implem } } -/********************************************************************************************************************** - * These are for GUI - */ /** * This method allows the CommonJavaObjectEditorPanel to read the * name to the current object. @@ -344,24 +341,6 @@ public class TF1Problem extends AbstractMultiObjectiveOptimizationProblem implem return "Length of the x vector at is to be optimized."; } -// /** This method allows you to set the number of objective variables -// * @param a The number of objective variables -// */ -// public void setOutputDimension(int a) { -// this.outputDimension = a; -// this.border = new double[this.outputDimension][2]; -// for (int i = 0; i < this.border.length; i++) { -// this.border[i][0] = 0; -// this.border[i][1] = 5; -// } -// } -// public int getOutputDimension() { -// return this.outputDimension; -// } -// public String outputDimensionTipText() { -// return "Number of objective variables."; -// } - /** * This method allows you to choose the EA individual * @@ -397,19 +376,6 @@ public class TF1Problem extends AbstractMultiObjectiveOptimizationProblem implem return "Choose a Multiobjective to Singleobjective converter."; } -// /** This method allows you to toggel the application of constraints on the problem -// * @param b state. -// */ -// public void setApplyConstraints(boolean b) { -// this.applyConstraints = b; -// } -// public boolean getApplyConstraints() { -// return this.applyConstraints; -// } -// public String applyConstraintsTipText() { -// return "Toggle application of constraint (works only for T1)."; -// } - /** * Since you can apply single objective optimization algorithms on * multi-objective problems, the problem needs a way to log the pareto- diff --git a/src/eva2/problems/regression/InterfaceRegressionFunction.java b/src/eva2/problems/regression/InterfaceRegressionFunction.java index 2089a8a7..81f33f40 100644 --- a/src/eva2/problems/regression/InterfaceRegressionFunction.java +++ b/src/eva2/problems/regression/InterfaceRegressionFunction.java @@ -1,11 +1,6 @@ package eva2.problems.regression; /** - * Created by IntelliJ IDEA. - * User: streiche - * Date: 27.06.2003 - * Time: 15:51:48 - * To change this template use Options | File Templates. */ public interface InterfaceRegressionFunction { diff --git a/src/eva2/problems/regression/RFKoza_GPI_10_1.java b/src/eva2/problems/regression/RFKoza_GPI_10_1.java index 956b37d6..db112874 100644 --- a/src/eva2/problems/regression/RFKoza_GPI_10_1.java +++ b/src/eva2/problems/regression/RFKoza_GPI_10_1.java @@ -1,11 +1,6 @@ package eva2.problems.regression; /** - * Created by IntelliJ IDEA. - * User: streiche - * Date: 27.06.2003 - * Time: 15:55:28 - * To change this template use Options | File Templates. */ public class RFKoza_GPI_10_1 implements InterfaceRegressionFunction, java.io.Serializable { @@ -37,9 +32,6 @@ public class RFKoza_GPI_10_1 implements InterfaceRegressionFunction, java.io.Ser return result; } -/********************************************************************************************************************** - * These are for GUI - */ /** * This method allows the CommonJavaObjectEditorPanel to read the * name to the current object. diff --git a/src/eva2/problems/regression/RFKoza_GPI_10_2.java b/src/eva2/problems/regression/RFKoza_GPI_10_2.java index 9698a5c2..3b46d6a3 100644 --- a/src/eva2/problems/regression/RFKoza_GPI_10_2.java +++ b/src/eva2/problems/regression/RFKoza_GPI_10_2.java @@ -1,11 +1,6 @@ package eva2.problems.regression; /** - * Created by IntelliJ IDEA. - * User: streiche - * Date: 27.06.2003 - * Time: 15:58:06 - * To change this template use Options | File Templates. */ public class RFKoza_GPI_10_2 implements InterfaceRegressionFunction, java.io.Serializable { @@ -37,9 +32,6 @@ public class RFKoza_GPI_10_2 implements InterfaceRegressionFunction, java.io.Ser return result; } -/********************************************************************************************************************** - * These are for GUI - */ /** * This method allows the CommonJavaObjectEditorPanel to read the * name to the current object. diff --git a/src/eva2/problems/regression/RFKoza_GPI_7_3.java b/src/eva2/problems/regression/RFKoza_GPI_7_3.java index 29e7b1bb..0477c8ea 100644 --- a/src/eva2/problems/regression/RFKoza_GPI_7_3.java +++ b/src/eva2/problems/regression/RFKoza_GPI_7_3.java @@ -1,11 +1,6 @@ package eva2.problems.regression; /** - * Created by IntelliJ IDEA. - * User: streiche - * Date: 09.10.2003 - * Time: 11:36:54 - * To change this template use Options | File Templates. */ public class RFKoza_GPI_7_3 implements InterfaceRegressionFunction, java.io.Serializable { @@ -37,9 +32,6 @@ public class RFKoza_GPI_7_3 implements InterfaceRegressionFunction, java.io.Seri return result; } -/********************************************************************************************************************** - * These are for GUI - */ /** * This method allows the CommonJavaObjectEditorPanel to read the * name to the current object. diff --git a/src/eva2/problems/regression/RFKoza_GPI_7_3_extended.java b/src/eva2/problems/regression/RFKoza_GPI_7_3_extended.java index 547f1f16..fb2a4c87 100644 --- a/src/eva2/problems/regression/RFKoza_GPI_7_3_extended.java +++ b/src/eva2/problems/regression/RFKoza_GPI_7_3_extended.java @@ -1,11 +1,6 @@ package eva2.problems.regression; /** - * Created by IntelliJ IDEA. - * User: streiche - * Date: 09.10.2003 - * Time: 11:38:20 - * To change this template use Options | File Templates. */ public class RFKoza_GPI_7_3_extended implements InterfaceRegressionFunction, java.io.Serializable { @@ -37,9 +32,6 @@ public class RFKoza_GPI_7_3_extended implements InterfaceRegressionFunction, jav return result; } -/********************************************************************************************************************** - * These are for GUI - */ /** * This method allows the CommonJavaObjectEditorPanel to read the * name to the current object. diff --git a/src/eva2/problems/regression/RFRaidl_F1.java b/src/eva2/problems/regression/RFRaidl_F1.java index 48244e53..53e858de 100644 --- a/src/eva2/problems/regression/RFRaidl_F1.java +++ b/src/eva2/problems/regression/RFRaidl_F1.java @@ -1,11 +1,6 @@ package eva2.problems.regression; /** - * Created by IntelliJ IDEA. - * User: streiche - * Date: 30.09.2003 - * Time: 14:02:41 - * To change this template use Options | File Templates. */ public class RFRaidl_F1 implements InterfaceRegressionFunction, java.io.Serializable { @@ -37,9 +32,6 @@ public class RFRaidl_F1 implements InterfaceRegressionFunction, java.io.Serializ return result; } -/********************************************************************************************************************** - * These are for GUI - */ /** * This method allows the CommonJavaObjectEditorPanel to read the * name to the current object. diff --git a/src/eva2/problems/regression/RFRaidl_F2.java b/src/eva2/problems/regression/RFRaidl_F2.java index b366c015..0806aed1 100644 --- a/src/eva2/problems/regression/RFRaidl_F2.java +++ b/src/eva2/problems/regression/RFRaidl_F2.java @@ -1,11 +1,7 @@ package eva2.problems.regression; /** - * Created by IntelliJ IDEA. - * User: streiche - * Date: 30.09.2003 - * Time: 14:02:50 - * To change this template use Options | File Templates. + * */ public class RFRaidl_F2 implements InterfaceRegressionFunction, java.io.Serializable { @@ -37,9 +33,6 @@ public class RFRaidl_F2 implements InterfaceRegressionFunction, java.io.Serializ return result; } -/********************************************************************************************************************** - * These are for GUI - */ /** * This method allows the CommonJavaObjectEditorPanel to read the * name to the current object. diff --git a/src/eva2/problems/regression/RFRaidl_F3.java b/src/eva2/problems/regression/RFRaidl_F3.java index 69b8a7d2..8c7952b9 100644 --- a/src/eva2/problems/regression/RFRaidl_F3.java +++ b/src/eva2/problems/regression/RFRaidl_F3.java @@ -1,11 +1,7 @@ package eva2.problems.regression; /** - * Created by IntelliJ IDEA. - * User: streiche - * Date: 30.09.2003 - * Time: 14:02:59 - * To change this template use Options | File Templates. + * */ public class RFRaidl_F3 implements InterfaceRegressionFunction, java.io.Serializable { @@ -37,9 +33,6 @@ public class RFRaidl_F3 implements InterfaceRegressionFunction, java.io.Serializ return result; } -/********************************************************************************************************************** - * These are for GUI - */ /** * This method allows the CommonJavaObjectEditorPanel to read the * name to the current object. diff --git a/src/eva2/tools/Serializer.java b/src/eva2/tools/Serializer.java index 9f81ea7c..e64e5d5b 100644 --- a/src/eva2/tools/Serializer.java +++ b/src/eva2/tools/Serializer.java @@ -48,10 +48,6 @@ public class Serializer { objectStream.writeObject(objToStore); objectStream.flush(); objectStream.close(); - String output; - Gson gson = new Gson(); - output = gson.toJson(objToStore); - System.out.println(output); } catch (java.io.NotSerializableException ex) { LOGGER.log(Level.SEVERE, "Object is not serializable!", ex); } diff --git a/src/eva2/tools/chart2d/Chart2DDPointContentSelectable.java b/src/eva2/tools/chart2d/Chart2DDPointContentSelectable.java index d4540932..db8fc754 100644 --- a/src/eva2/tools/chart2d/Chart2DDPointContentSelectable.java +++ b/src/eva2/tools/chart2d/Chart2DDPointContentSelectable.java @@ -68,10 +68,6 @@ public class Chart2DDPointContentSelectable implements InterfaceDPointWithConten this.size = d; } - /********************************************************************************************* - * The InterfaceSelectablePointIcon - */ - /** * This method allows to add a selection listner to the PointIcon * it should need more than one listener to this abstruse event diff --git a/src/eva2/tools/chart2d/Chart2DDPointIconCircle.java b/src/eva2/tools/chart2d/Chart2DDPointIconCircle.java index 22050f2b..6b9efc0a 100644 --- a/src/eva2/tools/chart2d/Chart2DDPointIconCircle.java +++ b/src/eva2/tools/chart2d/Chart2DDPointIconCircle.java @@ -2,7 +2,6 @@ package eva2.tools.chart2d; import java.awt.*; - /** * */ diff --git a/src/eva2/tools/chart2d/Chart2DDPointIconContent.java b/src/eva2/tools/chart2d/Chart2DDPointIconContent.java index 737b182a..824817d6 100644 --- a/src/eva2/tools/chart2d/Chart2DDPointIconContent.java +++ b/src/eva2/tools/chart2d/Chart2DDPointIconContent.java @@ -1,6 +1,5 @@ package eva2.tools.chart2d; - import eva2.gui.plot.InterfaceDPointWithContent; import eva2.optimization.individuals.AbstractEAIndividual; import eva2.problems.InterfaceOptimizationProblem; @@ -10,13 +9,6 @@ import java.awt.*; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; -/** - * Created by IntelliJ IDEA. - * User: streiche - * Date: 13.04.2004 - * Time: 13:31:48 - * To change this template use File | Settings | File Templates. - */ public class Chart2DDPointIconContent implements InterfaceDPointWithContent, DPointIcon { AbstractEAIndividual individual; diff --git a/src/eva2/tools/chart2d/Chart2DDPointIconCross.java b/src/eva2/tools/chart2d/Chart2DDPointIconCross.java index d112c913..34f64976 100644 --- a/src/eva2/tools/chart2d/Chart2DDPointIconCross.java +++ b/src/eva2/tools/chart2d/Chart2DDPointIconCross.java @@ -1,9 +1,7 @@ package eva2.tools.chart2d; - import java.awt.*; - /** * */ diff --git a/src/eva2/tools/chart2d/Chart2DDPointIconPoint.java b/src/eva2/tools/chart2d/Chart2DDPointIconPoint.java index 519af6c2..a4326b9c 100644 --- a/src/eva2/tools/chart2d/Chart2DDPointIconPoint.java +++ b/src/eva2/tools/chart2d/Chart2DDPointIconPoint.java @@ -5,11 +5,7 @@ import java.awt.*; /** - * Created by IntelliJ IDEA. - * User: streiche - * Date: 17.08.2005 - * Time: 16:52:34 - * To change this template use File | Settings | File Templates. + * */ public class Chart2DDPointIconPoint implements DPointIcon { diff --git a/src/eva2/tools/chart2d/DArea.java b/src/eva2/tools/chart2d/DArea.java index b54daaa7..ac622657 100644 --- a/src/eva2/tools/chart2d/DArea.java +++ b/src/eva2/tools/chart2d/DArea.java @@ -36,8 +36,7 @@ public class DArea extends JComponent implements DParent, Printable { */ private static final long serialVersionUID = 1461387400381365146L; - private boolean auto_focus = false, auto_grid = false, - grid_to_front = false; + private boolean autoFocus = false, autoGrid = false, gridToFront = false; /** * the container in which all DElements of the area are contained except the @@ -55,7 +54,7 @@ public class DArea extends JComponent implements DParent, Printable { /** * maximal number of grid lines */ - private int max_grid = 10; + private int maxGrid = 10; /** * the measures of the area it calculates the coordinates @@ -64,12 +63,12 @@ public class DArea extends JComponent implements DParent, Printable { /** * min_rectangle is set, when all elements are removed the intersection of - * visible_rect and max_rectangle is the currently visible rectangle + * visibleRect and max_rectangle is the currently visible rectangle */ - protected DRectangle min_rect = DEFAULT_MIN_RECT, - visible_rect = DEFAULT_MIN_RECT; + protected DRectangle minRect = DEFAULT_MIN_RECT, + visibleRect = DEFAULT_MIN_RECT; - protected Double min_x, min_y, max_x, max_y; + protected Double minX, minY, maxX, maxY; /** * initializes the DArea with the initial capacity of 10 components @@ -82,12 +81,12 @@ public class DArea extends JComponent implements DParent, Printable { * initializes the DArea with the specialized initial capacity of components * (@see java.util.Vector) * - * @param the initial capacity + * @param initialCapacity the initial capacity */ - public DArea(int initial_capacity) { + public DArea(int initialCapacity) { container = new DContainer(); container.setDParent(this); - grid = new DGrid(visible_rect, 1, 1); + grid = new DGrid(visibleRect, 1, 1); grid.setVisible(false); grid.setDParent(this); measures = new DMeasures(this); @@ -162,17 +161,17 @@ public class DArea extends JComponent implements DParent, Printable { * @return DRectangle the size and position of the visible area */ public DRectangle getDRectangle() { - DRectangle rect = (DRectangle) visible_rect.clone(); - if (min_x != null) { + DRectangle rect = (DRectangle) visibleRect.clone(); + if (minX != null) { rect.setX(Math.max(rect.getX(), getMinX())); } - if (min_y != null) { + if (minY != null) { rect.setY(Math.max(rect.getY(), getMinY())); } - if (max_x != null) { + if (maxX != null) { rect.setWidth(Math.min(rect.getWidth(), getMaxX() - getMinX())); } - if (max_y != null) { + if (maxY != null) { rect.setHeight(Math.min(rect.getHeight(), getMaxY() - getMinY())); } return rect; @@ -185,10 +184,7 @@ public class DArea extends JComponent implements DParent, Printable { * @deprecated see getMaxX, getMaxY, getMinX, getMinY */ public DRectangle getMaxRectangle() { - return new DRectangle(min_x.doubleValue(), min_y.doubleValue(), max_x - .doubleValue() - - min_x.doubleValue(), max_y.doubleValue() - - min_y.doubleValue()); + return new DRectangle(minX, minY, maxX - minX, maxY - minY); } /** @@ -197,8 +193,8 @@ public class DArea extends JComponent implements DParent, Printable { * @return the maxmal x-value */ public double getMaxX() { - if (max_x != null) { - return max_x.doubleValue(); + if (maxX != null) { + return maxX; } return 0; } @@ -209,46 +205,12 @@ public class DArea extends JComponent implements DParent, Printable { * @return the maximal y-value */ public double getMaxY() { - if (max_y != null) { - return max_y.doubleValue(); + if (maxY != null) { + return maxY; } return 0; } - // /** - // * method sets the maximal rectangle whioch can be viewed with the - // * DArea. This method can be used if the area is used with scale functions - // * which are not invertible on all reals - // * - // * @param x the minmal x value - // * @param y the minmal y value - // * @param width of the maximal rectangle - // * @param height of the maximal rectangle - // */ - // public void setMaxRectangle( double x, double y, double width, double - // height ){ - // setMaxRectangle( new DRectangle( x, y, width, height ) ); - // } - - // /** - // * method sets the maximal rectangle whioch can be viewed with the - // * DArea. This method can be used if the area is used with scale functions - // * which are not invertible on all reals - // * - // * @param the rect maximal rectangle of the DArea - // * @deprecated see setMinX, setMinY, setMaxX, setMaxY - // */ - // public void setMaxRectangle( DRectangle rect ){ - // if( !rect.contains( min_rect ) ) throw - // new - // IllegalArgumentException("Maximal rectangle does not contain minmal rectangle"); - // - // setMinX( rect.x ); - // setMinY( rect.y ); - // setMaxX( rect.x + rect.width ); - // setMaxY( rect.y + rect.height ); - // } - /** * method returns the minimal rectangle which is set as the visible when all * elements are removed and the area is on auto focus @@ -256,7 +218,7 @@ public class DArea extends JComponent implements DParent, Printable { * @return the minmal rectangle */ public DRectangle getMinRectangle() { - return (DRectangle) min_rect.clone(); + return (DRectangle) minRect.clone(); } /** @@ -265,8 +227,8 @@ public class DArea extends JComponent implements DParent, Printable { * @return the minmal x-value */ public double getMinX() { - if (min_x != null) { - return min_x.doubleValue(); + if (minX != null) { + return minX; } return 0; } @@ -277,8 +239,8 @@ public class DArea extends JComponent implements DParent, Printable { * @return the minmal y-value */ public double getMinY() { - if (min_y != null) { - return min_y.doubleValue(); + if (minY != null) { + return minY; } return 0; } @@ -289,25 +251,25 @@ public class DArea extends JComponent implements DParent, Printable { * @return DRectangle the size and position of the visible area */ public SlimRect getSlimRectangle() { - SlimRect srect = new SlimRect(visible_rect.getX(), visible_rect.getY(), - visible_rect.getWidth(), visible_rect.getHeight()); - if (min_x != null) { + SlimRect srect = new SlimRect(visibleRect.getX(), visibleRect.getY(), + visibleRect.getWidth(), visibleRect.getHeight()); + if (minX != null) { srect.x = Math.max(srect.x, getMinX()); } - if (min_y != null) { + if (minY != null) { srect.y = Math.max(srect.y, getMinY()); } - if (max_x != null) { + if (maxX != null) { srect.width = Math.min(srect.width, getMaxX() - getMinX()); } - if (max_y != null) { + if (maxY != null) { srect.height = Math.min(srect.height, getMaxY() - getMinY()); } return srect; } public DFunction getYScale() { - return measures.y_scale; + return measures.yScale; } /** @@ -316,7 +278,7 @@ public class DArea extends JComponent implements DParent, Printable { * @return true if the grid is on, else false */ public boolean hasAutoGrid() { - return auto_grid; + return autoGrid; } /** @@ -335,7 +297,7 @@ public class DArea extends JComponent implements DParent, Printable { * @return true or false */ public boolean isOnAutoFocus() { - return auto_focus; + return autoFocus; } /** @@ -355,23 +317,23 @@ public class DArea extends JComponent implements DParent, Printable { */ @Override public void paint(Graphics g) { - if (auto_focus) { + if (autoFocus) { container.restore(); - visible_rect = (DRectangle) container.getRectangle().clone(); - // grid.updateDistByRect(visible_rect); + visibleRect = (DRectangle) container.getRectangle().clone(); + // grid.updateDistByRect(visibleRect); } - if (visible_rect.isEmpty()) { - visible_rect = (DRectangle) min_rect.clone(); - // grid.updateDistByRect(visible_rect); + if (visibleRect.isEmpty()) { + visibleRect = (DRectangle) minRect.clone(); + // grid.updateDistByRect(visibleRect); } super.paint(g); measures.setGraphics(g); - if (grid.isVisible() && !grid_to_front) { + if (grid.isVisible() && !gridToFront) { paintGrid(measures); } container.paint(measures); - if (grid.isVisible() && grid_to_front) { + if (grid.isVisible() && gridToFront) { paintGrid(measures); } } @@ -379,11 +341,11 @@ public class DArea extends JComponent implements DParent, Printable { /** * method paints the grid how the method paints the grid depends on whether * the area is wrapped in a ScaledBorder or not and on the - * auto_grid option + * autoGrid option */ private void paintGrid(DMeasures m) { grid.rectangle = getDRectangle(); - if (auto_grid) { + if (autoGrid) { Border b = getBorder(); if (b instanceof ScaledBorder) { ScaledBorder sb = (ScaledBorder) b; @@ -392,16 +354,16 @@ public class DArea extends JComponent implements DParent, Printable { } else { grid.setDistances(ScaledBorder.aBitBigger(grid.rectangle .getWidth() - / max_grid), ScaledBorder.aBitBigger(grid.rectangle + / maxGrid), ScaledBorder.aBitBigger(grid.rectangle .getHeight() - / max_grid)); + / maxGrid)); } } grid.paint(m); } /** - * paints the grid when auto_grid is selected and the area is surrounded by + * paints the grid when autoGrid is selected and the area is surrounded by * an instance of ScaledBorder * * @param sb the ScaledBorder around the area @@ -412,9 +374,9 @@ public class DArea extends JComponent implements DParent, Printable { FontMetrics fm = m.getGraphics().getFontMetrics(); grid.setDistances(sb.getSrcdX(fm, d), sb.getSrcdY(fm, d)); - if (m.x_scale == null && m.y_scale == null) { + if (m.xScale == null && m.yScale == null) { grid.paint(m); - } else {// selber malen + } else { Graphics g = m.g; g.setColor(grid.getColor()); @@ -438,16 +400,16 @@ public class DArea extends JComponent implements DParent, Printable { double pos; for (; (pos = x * grid.getHorDist()) < src_rect.x + src_rect.width; x++) { - if (m.x_scale != null) { - pos = m.x_scale.getImageOf(pos); + if (m.xScale != null) { + pos = m.xScale.getImageOf(pos); } Point p1 = m.getPoint(pos, miny), p2 = m.getPoint(pos, maxy); g.drawLine(p1.x, p1.y, p2.x, p2.y); } for (; (pos = y * grid.getVerDist()) < src_rect.y + src_rect.height; y++) { - if (m.y_scale != null) { - pos = m.y_scale.getImageOf(pos); + if (m.yScale != null) { + pos = m.yScale.getImageOf(pos); } Point p1 = m.getPoint(minx, pos), p2 = m.getPoint(maxx, pos); g.drawLine(p1.x, p1.y, p2.x, p2.y); @@ -475,12 +437,12 @@ public class DArea extends JComponent implements DParent, Printable { if (!(sb instanceof ScaledBorder)) { sb = null; } else { - ((ScaledBorder) sb).show_outer_border = false; + ((ScaledBorder) sb).showOuterBorder = false; } PagePrinter printer = new PagePrinter(this, g, pf); int ret = printer.print(); if (sb != null) { - ((ScaledBorder) sb).show_outer_border = true; + ((ScaledBorder) sb).showOuterBorder = true; } return ret; } @@ -489,35 +451,35 @@ public class DArea extends JComponent implements DParent, Printable { * method resets the maximal x-value */ public void releaseMaxX() { - max_x = null; + maxX = null; } /** * method resets the maximal y-value */ public void releaseMaxY() { - max_y = null; + maxY = null; } /** * method resets the minimal x-value */ public void releaseMinX() { - min_x = null; + minX = null; } /** * method resets the minimal y-value */ public void releaseMinY() { - min_y = null; + minY = null; } /** * removes all elements from the area */ public void removeAllDElements() { - visible_rect = (DRectangle) min_rect.clone(); + visibleRect = (DRectangle) minRect.clone(); container.removeAllDElements(); } @@ -542,13 +504,11 @@ public class DArea extends JComponent implements DParent, Printable { throw new IllegalArgumentException( "Cannot repaint a null DRectangle"); } - if (r.isAll() || auto_focus) { + if (r.isAll() || autoFocus) { repaint(); } else { Point p1 = measures.getPoint(r.getX(), r.getY()), p2 = measures .getPoint(r.getX() + r.getWidth(), r.getY() + r.getHeight()); - // Point p1 = measures.getPoint( r.x, r.y ), - // p2 = measures.getPoint( r.x + r.width, r.y + r.height); if (p1 == null || p2 == null) { repaint(); } else { @@ -570,8 +530,8 @@ public class DArea extends JComponent implements DParent, Printable { * @param b on or off */ public void setAutoFocus(boolean b) { - boolean old = auto_focus; - auto_focus = b; + boolean old = autoFocus; + autoFocus = b; if (old != b) { repaint(); } @@ -588,10 +548,10 @@ public class DArea extends JComponent implements DParent, Printable { grid.rectangle = getDRectangle(); grid.setVisible(true); } - if (b == auto_grid) { + if (b == autoGrid) { return; } - auto_grid = b; + autoGrid = b; repaint(); } @@ -603,16 +563,16 @@ public class DArea extends JComponent implements DParent, Printable { * @param ver_dist the vertical distance */ public void setGrid(double hor_dist, double ver_dist) { - grid = new DGrid(visible_rect, hor_dist, ver_dist); + grid = new DGrid(visibleRect, hor_dist, ver_dist); grid.setDParent(this); - auto_grid = false; + autoGrid = false; repaint(); } /** * sets the color of the grid * - * @param java .awt.Color + * @param color The new grid color */ public void setGridColor(Color color) { grid.setColor(color); @@ -625,8 +585,8 @@ public class DArea extends JComponent implements DParent, Printable { * @param aFlag grid t front or not */ public void setGridToFront(boolean aFlag) { - boolean old = grid_to_front; - grid_to_front = aFlag; + boolean old = gridToFront; + gridToFront = aFlag; if (old != aFlag && grid.isVisible()) { repaint(); } @@ -652,8 +612,8 @@ public class DArea extends JComponent implements DParent, Printable { if (no < 1) { return; } - int old = max_grid; - max_grid = no; + int old = maxGrid; + maxGrid = no; if (old != no) { repaint(); } @@ -666,11 +626,11 @@ public class DArea extends JComponent implements DParent, Printable { * @param max the maximal x-value */ public void setMaxX(double max) { - if (max < min_rect.getX() + min_rect.getWidth()) { + if (max < minRect.getX() + minRect.getWidth()) { throw new IllegalArgumentException( "Maximal x-value axes intersects minmal rectangle."); } - max_x = new Double(max); + maxX = max; } /** @@ -681,11 +641,11 @@ public class DArea extends JComponent implements DParent, Printable { * @param may the maximal y-value */ public void setMaxY(double may) { - if (may < min_rect.getY() + min_rect.getHeight()) { + if (may < minRect.getY() + minRect.getHeight()) { throw new IllegalArgumentException( "Maximal y-value axes intersects minmal rectangle."); } - max_y = new Double(may); + maxY = may; } /** @@ -707,9 +667,9 @@ public class DArea extends JComponent implements DParent, Printable { */ public void setMinRectangle(DRectangle rect) { if (rect.isEmpty()) { - min_rect = DEFAULT_MIN_RECT; + minRect = DEFAULT_MIN_RECT; } else { - min_rect = (DRectangle) rect.clone(); + minRect = (DRectangle) rect.clone(); } } @@ -720,11 +680,11 @@ public class DArea extends JComponent implements DParent, Printable { * @param mix the minimal x-value */ public void setMinX(double mix) { - if (mix > min_rect.getX()) { + if (mix > minRect.getX()) { throw new IllegalArgumentException( "Mimimal y-value axes intersects minmal rectangle."); } - min_x = new Double(mix); + minX = mix; } /** @@ -734,11 +694,11 @@ public class DArea extends JComponent implements DParent, Printable { * @param miy the minimal y-value */ public void setMinY(double miy) { - if (miy > min_rect.getY()) { + if (miy > minRect.getY()) { throw new IllegalArgumentException( "Mimimal y-value axes intersects minmal rectangle."); } - min_y = new Double(miy); + minY = miy; } /** @@ -767,10 +727,10 @@ public class DArea extends JComponent implements DParent, Printable { + "as the visible rectangle of an DArea"); } - if (!rect.equals(visible_rect) && rect.getWidth() > 0 + if (!rect.equals(visibleRect) && rect.getWidth() > 0 && rect.getHeight() > 0) { - auto_focus = false; - visible_rect = (DRectangle) rect.clone(); + autoFocus = false; + visibleRect = (DRectangle) rect.clone(); repaint(); } } @@ -783,10 +743,10 @@ public class DArea extends JComponent implements DParent, Printable { * @param x_s the scale function for the x-axis */ public void setXScale(DFunction x_s) { - if (x_s == null && measures.x_scale == null) { + if (x_s == null && measures.xScale == null) { return; } - measures.x_scale = x_s; + measures.xScale = x_s; repaint(); } @@ -798,14 +758,10 @@ public class DArea extends JComponent implements DParent, Printable { * @param y_s the scale function for the y-axis */ public void setYScale(DFunction y_s) { - if (y_s == null && measures.y_scale == null) { + if (y_s == null && measures.yScale == null) { return; } - measures.y_scale = y_s; + measures.yScale = y_s; repaint(); } -} - -/**************************************************************************** - * END OF FILE - ****************************************************************************/ +} \ No newline at end of file diff --git a/src/eva2/tools/chart2d/DArray.java b/src/eva2/tools/chart2d/DArray.java index b0c6afa6..1445e93e 100644 --- a/src/eva2/tools/chart2d/DArray.java +++ b/src/eva2/tools/chart2d/DArray.java @@ -1,14 +1,5 @@ package eva2.tools.chart2d; -/** - * Title: - * Description: - * Copyright: Copyright (c) 2001 - * Company: - * @author - * @version 1.0 - */ - /** * This class stores an array of double values. * It can be used as data stack for an DPointSet object. @@ -16,8 +7,8 @@ package eva2.tools.chart2d; * been modified. */ public class DArray implements DIntDoubleMap { - private int initial_capacity, size; - private double capacity_multiplier = 2, max, min, minPositive = -1; + private int initialCapacity, size; + private double capacityMultiplier = 2, max, min, minPositive = -1; private double[] value; /** @@ -32,30 +23,28 @@ public class DArray implements DIntDoubleMap { * Constructor for an DArray object with default value for the capacity * multiplier (2). * - * @param initial_capacity the initial capacity of the array + * @param initialCapacity the initial capacity of the array */ - public DArray(int initial_capacity) { - this(initial_capacity, 2); + public DArray(int initialCapacity) { + this(initialCapacity, 2); } /** * Constructor for an DArray object * - * @param initial_capacity the initial capacity of the array - * @param capacity_multiplier the capacity multiplier when the array overflows + * @param initialCapacity the initial capacity of the array + * @param capacityMultiplier the capacity multiplier when the array overflows */ - public DArray(int initial_capacity, double capacity_multiplier) { - if (initial_capacity < 1) { - throw - new IllegalArgumentException("The initial capacity has to be at least 1"); + public DArray(int initialCapacity, double capacityMultiplier) { + if (initialCapacity < 1) { + throw new IllegalArgumentException("The initial capacity has to be at least 1"); } - if (capacity_multiplier <= 1) { - throw - new IllegalArgumentException("The capacity multiplier has to be bigger than 1"); + if (capacityMultiplier <= 1) { + throw new IllegalArgumentException("The capacity multiplier has to be bigger than 1"); } - this.initial_capacity = initial_capacity; - value = new double[initial_capacity]; - this.capacity_multiplier = capacity_multiplier; + this.initialCapacity = initialCapacity; + value = new double[initialCapacity]; + this.capacityMultiplier = capacityMultiplier; } /** @@ -67,25 +56,24 @@ public class DArray implements DIntDoubleMap { @Override public boolean setImage(int source, double image) { if (source < 0 || source >= size) { - throw - new ArrayIndexOutOfBoundsException(source); + throw new ArrayIndexOutOfBoundsException(source); } - boolean min_max_changed = false, restore = false; + boolean minMaxChanged = false, restore = false; if (image < min) { min = image; - min_max_changed = true; + minMaxChanged = true; } else if (image > max) { max = image; - min_max_changed = true; + minMaxChanged = true; } if (value[source] == min || value[source] == max || (value[source] == minPositive)) { restore = true; } value[source] = image; if (restore) { - min_max_changed = restore() || min_max_changed; + minMaxChanged = restore() || minMaxChanged; } - return min_max_changed; + return minMaxChanged; } /** @@ -94,15 +82,10 @@ public class DArray implements DIntDoubleMap { * @param source the source value * @return the image value */ -// public double getImage(int source){ -// if(source<0 || source>=size) throw -// new ArrayIndexOutOfBoundsException(source); -// return value[source]; -// } @Override public double getImage(int source) { if (source < 0) { - new ArrayIndexOutOfBoundsException(source); + throw new ArrayIndexOutOfBoundsException(source); } if (source >= size && size > 1) { return value[size - 1]; @@ -121,37 +104,37 @@ public class DArray implements DIntDoubleMap { @Override public boolean addImage(double image) { if (size >= value.length) { - int new_length = (int) (value.length * capacity_multiplier); - if (!(new_length > value.length)) { - new_length++; + int newLength = (int) (value.length * capacityMultiplier); + if (!(newLength > value.length)) { + newLength++; } - double[] new_val = new double[new_length]; + double[] new_val = new double[newLength]; System.arraycopy(value, 0, new_val, 0, value.length); value = new_val; } - boolean min_max_changed = false; + boolean minMaxChanged = false; if (size == 0) { min = image; max = image; - min_max_changed = true; + minMaxChanged = true; if (image > 0) { minPositive = image; } } else { if ((image > 0) && ((image < minPositive) || (minPositive < 0))) { minPositive = image; - min_max_changed = true; + minMaxChanged = true; } if (image > max) { max = image; - min_max_changed = true; + minMaxChanged = true; } else if (image < min) { min = image; - min_max_changed = true; + minMaxChanged = true; } } value[size++] = image; - return min_max_changed; + return minMaxChanged; } /** @@ -200,7 +183,7 @@ public class DArray implements DIntDoubleMap { @Override public void reset() { size = 0; - value = new double[initial_capacity]; + value = new double[initialCapacity]; } /** @@ -211,8 +194,7 @@ public class DArray implements DIntDoubleMap { @Override public double getMinImageValue() { if (size == 0) { - throw - new IllegalArgumentException("DArray is empty. No minimal value exists"); + throw new IllegalArgumentException("DArray is empty. No minimal value exists"); } return min; } @@ -225,8 +207,7 @@ public class DArray implements DIntDoubleMap { @Override public double getMinPositiveImageValue() { if (size == 0) { - throw - new IllegalArgumentException("DArray is empty. No minimal value exists"); + throw new IllegalArgumentException("DArray is empty. No minimal value exists"); } return (minPositive < 0) ? max : minPositive; } @@ -239,8 +220,7 @@ public class DArray implements DIntDoubleMap { @Override public double getMaxImageValue() { if (size == 0) { - throw - new IllegalArgumentException("DArray is empty. No maximal value exists"); + throw new IllegalArgumentException("DArray is empty. No maximal value exists"); } return max; } diff --git a/src/eva2/tools/chart2d/DBorder.java b/src/eva2/tools/chart2d/DBorder.java index 31b427ea..885e7937 100644 --- a/src/eva2/tools/chart2d/DBorder.java +++ b/src/eva2/tools/chart2d/DBorder.java @@ -1,14 +1,3 @@ -/** - * Filename: $RCSfile: DBorder.java,v $ - * Purpose: - * Language: Java - * Compiler: JDK 1.3 - * Authors: Fabian Hennecke - * Version: $Revision: 1.1.1.1 $ - * $Date: 2003/07/03 14:59:41 $ - * $Author: ulmerh $ - * Copyright (c) Dept. Computer Architecture, University of Tuebingen, Germany - */ package eva2.tools.chart2d; import java.awt.*; diff --git a/src/eva2/tools/chart2d/DComponent.java b/src/eva2/tools/chart2d/DComponent.java index 2c763a14..19bbc74b 100644 --- a/src/eva2/tools/chart2d/DComponent.java +++ b/src/eva2/tools/chart2d/DComponent.java @@ -1,27 +1,7 @@ -/** - * Filename: $RCSfile: DComponent.java,v $ - * Purpose: - * Language: Java - * Compiler: JDK 1.3 - * Authors: Fabian Hennecke - * Version: $Revision: 1.1.1.1 $ - * $Date: 2003/07/03 14:59:41 $ - * $Author: ulmerh $ - * Copyright (c) Dept. Computer Architecture, University of Tuebingen, Germany - */ - package eva2.tools.chart2d; -/*==========================================================================* - * IMPORTS - *==========================================================================*/ - import java.awt.*; -/*==========================================================================* - * CLASS DECLARATION - *==========================================================================*/ - /** * DComponent is the mother of all objects which can be displayed * by a DArea object, even when it would be also enough to @@ -133,7 +113,6 @@ public abstract class DComponent implements DElement { */ @Override public void repaint() { - //System.out.println("DComponent.repaint()"); if (parent != null) { parent.repaint(getRectangle()); } @@ -179,8 +158,4 @@ public abstract class DComponent implements DElement { return visible; } -} - -/**************************************************************************** - * END OF FILE - ****************************************************************************/ +} \ No newline at end of file diff --git a/src/eva2/tools/chart2d/DContainer.java b/src/eva2/tools/chart2d/DContainer.java index 8d965d3d..601bcc70 100644 --- a/src/eva2/tools/chart2d/DContainer.java +++ b/src/eva2/tools/chart2d/DContainer.java @@ -1,28 +1,8 @@ -/** - * Filename: $RCSfile: DContainer.java,v $ - * Purpose: - * Language: Java - * Compiler: JDK 1.3 - * Authors: Fabian Hennecke - * Version: $Revision: 1.1.1.1 $ - * $Date: 2003/07/03 14:59:41 $ - * $Author: ulmerh $ - * Copyright (c) Dept. Computer Architecture, University of Tuebingen, Germany - */ - package eva2.tools.chart2d; -/*==========================================================================* - * IMPORTS - *==========================================================================*/ - import java.awt.*; import java.util.Vector; -/*==========================================================================* - * CLASS DECLARATION - *==========================================================================*/ - public class DContainer extends DComponent implements DParent { /** * the elements of the container and their keys ( Strings ) @@ -78,14 +58,12 @@ public class DContainer extends DComponent implements DParent { if (e instanceof DParent) { DParent he = (DParent) e, me = this; if (he == me) { - throw new - IllegalArgumentException("Adding DParent to itself"); + throw new IllegalArgumentException("Adding DParent to itself"); } me = getDParent(); while (me != null) { if (he == me) { - throw new - IllegalArgumentException("Adding DContainer's parent to itself"); + throw new IllegalArgumentException("Adding DContainer's parent to itself"); } if (me instanceof DElement) { me = ((DElement) me).getDParent(); @@ -164,8 +142,6 @@ public class DContainer extends DComponent implements DParent { return (index < keys.size()) ? elements.get(index) : null; } -// implementing DComponent: - /** * method calls all currently visible DElements of the container to paint * themselves by the given DMeasures object @@ -247,8 +223,4 @@ public class DContainer extends DComponent implements DParent { } return !old.equals(rectangle); } -} - -/**************************************************************************** - * END OF FILE - ****************************************************************************/ +} \ No newline at end of file diff --git a/src/eva2/tools/chart2d/DElement.java b/src/eva2/tools/chart2d/DElement.java index 70fb2302..749f98dc 100644 --- a/src/eva2/tools/chart2d/DElement.java +++ b/src/eva2/tools/chart2d/DElement.java @@ -1,27 +1,7 @@ -/** - * Filename: $RCSfile: DElement.java,v $ - * Purpose: - * Language: Java - * Compiler: JDK 1.3 - * Authors: Fabian Hennecke - * Version: $Revision: 1.1.1.1 $ - * $Date: 2003/07/03 14:59:41 $ - * $Author: ulmerh $ - * Copyright (c) Dept. Computer Architecture, University of Tuebingen, Germany - */ - package eva2.tools.chart2d; -/*==========================================================================* - * IMPORTS - *==========================================================================*/ - import java.awt.*; -/*==========================================================================* - * INTERFACE DECLARATION - *==========================================================================*/ - /** * some useful methods for objects which should be paintable in a scaled area */ @@ -49,8 +29,4 @@ public interface DElement { void setDBorder(DBorder b); DBorder getDBorder(); -} - -/**************************************************************************** - * END OF FILE - ****************************************************************************/ +} \ No newline at end of file diff --git a/src/eva2/tools/chart2d/DFunction.java b/src/eva2/tools/chart2d/DFunction.java index 3e86e7a5..87f057c2 100644 --- a/src/eva2/tools/chart2d/DFunction.java +++ b/src/eva2/tools/chart2d/DFunction.java @@ -50,8 +50,8 @@ public abstract class DFunction extends DComponent { Point last = null, next; for (int i = 0; i < int_w; i++) { double x_val = src_rect.x + i / (double) int_w * src_rect.width; - if (m.x_scale != null) { - x_val = m.x_scale.getImageOf(x_val); + if (m.xScale != null) { + x_val = m.xScale.getImageOf(x_val); } if (isDefinedAt(x_val)) { next = m.getPoint(x_val, getImageOf(x_val)); diff --git a/src/eva2/tools/chart2d/DGrid.java b/src/eva2/tools/chart2d/DGrid.java index fd318705..3906a0a3 100644 --- a/src/eva2/tools/chart2d/DGrid.java +++ b/src/eva2/tools/chart2d/DGrid.java @@ -1,29 +1,9 @@ -/** - * Filename: $RCSfile: DGrid.java,v $ - * Purpose: - * Language: Java - * Compiler: JDK 1.3 - * Authors: Fabian Hennecke - * Version: $Revision: 1.1.1.1 $ - * $Date: 2003/07/03 14:59:41 $ - * $Author: ulmerh $ - * Copyright (c) Dept. Computer Architecture, University of Tuebingen, Germany - */ - package eva2.tools.chart2d; -/*==========================================================================* - * IMPORTS - *==========================================================================*/ - import eva2.tools.math.Mathematics; import java.awt.*; -/*==========================================================================* - * CLASS DECLARATION - *==========================================================================*/ - /** * this class paints a grid with certain line distances on a DParent */ @@ -31,7 +11,7 @@ public class DGrid extends DComponent { /** * the distances between the lines */ - private double hor_dist, ver_dist; + private double horDist, verDist; private Color DEFAULT_COLOR = Color.lightGray; @@ -39,15 +19,15 @@ public class DGrid extends DComponent { * constructor with the size and position of the grid and the line distances * * @param rectangle the rectangle around the grid - * @param hor_dist the horizontal distance between the lines in D-coordinates, + * @param horDist the horizontal distance between the lines in D-coordinates, * not in pixel coordinates! - * @param ver_dist vertical distance between the lines in D-coordinates, + * @param verDist vertical distance between the lines in D-coordinates, * not in pixel coordinates! */ - public DGrid(DRectangle rectangle, double hor_dist, double ver_dist) { + public DGrid(DRectangle rectangle, double horDist, double verDist) { this.rectangle = rectangle; - this.hor_dist = hor_dist; - this.ver_dist = ver_dist; + this.horDist = horDist; + this.verDist = verDist; color = DEFAULT_COLOR; } @@ -55,32 +35,31 @@ public class DGrid extends DComponent { * constructor with the size and position of the grid and the line distances * * @param rectangle the rectangle around the grid - * @param hor_dist the horizontal distance between the lines in D-coordinates, + * @param horDist the horizontal distance between the lines in D-coordinates, * not in pixel coordinates! - * @param ver_dist the vertical distance between the lines in D-coordinates, + * @param verDist the vertical distance between the lines in D-coordinates, * not in pixel coordinates! * @param color the color of the grid * ( can also be set by setColor( java.awt.Color ) ) */ - public DGrid(DRectangle rectangle, double hor_dist, double ver_dist, Color color) { + public DGrid(DRectangle rectangle, double horDist, double verDist, Color color) { this.rectangle = rectangle; - this.hor_dist = hor_dist; - this.ver_dist = ver_dist; + this.horDist = horDist; + this.verDist = verDist; this.color = color; } public void setDistances(double hor, double ver) { - hor_dist = hor; - ver_dist = ver; -// System.out.println("set new Grid distances " + this.toString()); + horDist = hor; + verDist = ver; } public double getHorDist() { - return hor_dist; + return horDist; } public double getVerDist() { - return ver_dist; + return verDist; } /** @@ -98,18 +77,12 @@ public class DGrid extends DComponent { DPoint p1, p2; DLine l; - minX = Mathematics.firstMultipleAbove(rectangle.getX(), hor_dist); - minY = Mathematics.firstMultipleAbove(rectangle.getY(), ver_dist); -// minX = (int)( rectangle.x / hor_dist ); -// if( minX * hor_dist <= rectangle.x ) minX++; -// minX *= hor_dist; -// minY = (int)( rectangle.y / ver_dist ); -// if( minY * ver_dist <= rectangle.y ) minY++; -// minY *= ver_dist; + minX = Mathematics.firstMultipleAbove(rectangle.getX(), horDist); + minY = Mathematics.firstMultipleAbove(rectangle.getY(), verDist); p1 = new DPoint(0, rectangle.getY()); p2 = new DPoint(0, rectangle.getY() + rectangle.getHeight()); - for (pos = minX; pos <= rectangle.getX() + rectangle.getWidth(); pos += hor_dist) { + for (pos = minX; pos <= rectangle.getX() + rectangle.getWidth(); pos += horDist) { p1.x = p2.x = pos; l = new DLine(p1, p2, color); l.paint(m); @@ -122,22 +95,17 @@ public class DGrid extends DComponent { p1.y = p2.y = pos; l = new DLine(p1, p2, color); l.paint(m); - if (pos + ver_dist <= pos) { + if (pos + verDist <= pos) { System.err.println("Overflow error in DGrid!"); pos *= 1.01; } else { - pos += ver_dist; + pos += verDist; } -// System.out.println("pos is " + pos + ", loop until " + rectangle.y + rectangle.height); } } @Override public String toString() { - return "chart2d.DGrid[ hor: " + hor_dist + ", ver: " + ver_dist + " ]"; + return "chart2d.DGrid[ hor: " + horDist + ", ver: " + verDist + " ]"; } -} - -/**************************************************************************** - * END OF FILE - ****************************************************************************/ +} \ No newline at end of file diff --git a/src/eva2/tools/chart2d/DIntDoubleMap.java b/src/eva2/tools/chart2d/DIntDoubleMap.java index d162c05e..f6218cb5 100644 --- a/src/eva2/tools/chart2d/DIntDoubleMap.java +++ b/src/eva2/tools/chart2d/DIntDoubleMap.java @@ -1,14 +1,5 @@ package eva2.tools.chart2d; -/** - * Title: - * Description: - * Copyright: Copyright (c) 2001 - * Company: - * @author - * @version 1.0 - */ - /** * This interface is used by DPointSet to store values as images of integer * values which can be displayed in a DArea. All modifications of the values can diff --git a/src/eva2/tools/chart2d/DLine.java b/src/eva2/tools/chart2d/DLine.java index 8b59c306..18471c1c 100644 --- a/src/eva2/tools/chart2d/DLine.java +++ b/src/eva2/tools/chart2d/DLine.java @@ -1,27 +1,7 @@ -/** - * Filename: $RCSfile: DLine.java,v $ - * Purpose: - * Language: Java - * Compiler: JDK 1.3 - * Authors: Fabian Hennecke - * Version: $Revision: 1.1.1.1 $ - * $Date: 2003/07/03 14:59:41 $ - * $Author: ulmerh $ - * Copyright (c) Dept. Computer Architecture, University of Tuebingen, Germany - */ - package eva2.tools.chart2d; -/*==========================================================================* - * IMPORTS - *==========================================================================*/ - import java.awt.*; -/*==========================================================================* - * CLASS DECLARATION - *==========================================================================*/ - public class DLine extends DComponent { DPoint start, end; @@ -78,8 +58,4 @@ public class DLine extends DComponent { public String toString() { return "DLine[(" + start.x + "," + start.y + ") --> (" + end.x + "," + end.y + ", color: " + color + "]"; } -} - -/**************************************************************************** - * END OF FILE - ****************************************************************************/ +} \ No newline at end of file diff --git a/src/eva2/tools/chart2d/DMeasures.java b/src/eva2/tools/chart2d/DMeasures.java index 9f0b95a0..6eee286f 100644 --- a/src/eva2/tools/chart2d/DMeasures.java +++ b/src/eva2/tools/chart2d/DMeasures.java @@ -14,13 +14,12 @@ public class DMeasures implements Serializable { * */ private static final long serialVersionUID = 243092480517044848L; - private boolean under_construction = false; // when in use for a DArea: Graphics g; // when in use for a ScaledBorder: ScaledBorder sb; // for both: - DFunction x_scale, y_scale; + DFunction xScale, yScale; Component comp; Insets insets; @@ -55,11 +54,11 @@ public class DMeasures implements Serializable { return null; } try { - if (x_scale != null) { - x = x_scale.getSourceOf(x); + if (xScale != null) { + x = xScale.getSourceOf(x); } - if (y_scale != null) { - y = y_scale.getSourceOf(y); + if (yScale != null) { + y = yScale.getSourceOf(y); } } catch (IllegalArgumentException e) { return null; @@ -93,11 +92,11 @@ public class DMeasures implements Serializable { dx = rect.x + rect.width * x / (double) dim.width; dy = rect.y + rect.height * (1 - y / (double) dim.height); try { - if (x_scale != null) { - dx = x_scale.getImageOf(dx); + if (xScale != null) { + dx = xScale.getImageOf(dx); } - if (y_scale != null) { - dy = y_scale.getImageOf(dy); + if (yScale != null) { + dy = yScale.getImageOf(dy); } } catch (IllegalArgumentException nde) { return null; @@ -105,16 +104,6 @@ public class DMeasures implements Serializable { return new DPoint(dx, dy); } -// /** -// * returns the visible rectangle in D-coordinates of the shown component -// * -// * @return the visible rectangle -// */ -// public DRectangle getDRectangle(){ -// if( under_construction ) System.out.println("DMeasures.getDRectangle"); -// if( sb != null ) return getImageOf( sb.src_rect ); -// return ((DArea)comp).getDRectangle(); -// } /** * Returns the visible rectangle in D-coordinates of the shown component as slim structure. @@ -122,9 +111,8 @@ public class DMeasures implements Serializable { * @return the visible rectangle */ public SlimRect getSlimRectangle() { -// if( under_construction ) System.out.println("DMeasures.getDRectangle"); if (sb != null) { - return getImageOf(sb.src_rect.x, sb.src_rect.y, sb.src_rect.width, sb.src_rect.height); + return getImageOf(sb.srcRect.x, sb.srcRect.y, sb.srcRect.width, sb.srcRect.height); } return ((DArea) comp).getSlimRectangle(); } @@ -138,9 +126,6 @@ public class DMeasures implements Serializable { * @return the Graphics object ( or null if no object was set ) */ public Graphics getGraphics() { - if (under_construction) { - System.out.println("DMeasures.getGraphics"); - } if (g != null) { Dimension d = comp.getSize(); Insets insets = getInsets(); @@ -156,9 +141,6 @@ public class DMeasures implements Serializable { * used by DArea to set a new Graphics object */ void setGraphics(Graphics g) { - if (under_construction) { - System.out.println("DMeasures.setGraphics"); - } this.g = g; } @@ -170,8 +152,8 @@ public class DMeasures implements Serializable { void update(Component c, Insets insets) { this.comp = c; this.insets = insets; - x_scale = sb.x_scale; - y_scale = sb.y_scale; + xScale = sb.xScale; + yScale = sb.yScale; } private Dimension getInner() { @@ -182,60 +164,28 @@ public class DMeasures implements Serializable { return d; } -// /** -// * method returns the image rectangle of the given rectangle -// * they differ if there are scale functions selected which are not the identity -// * if the given rectangle does not belong to the defintion area of the scale -// * functions, the method returns null -// * -// * @param rect the source rectangle -// * @return the source of it -// */ -// DRectangle getImageOf( DRectangle rect ){ -// if( under_construction ) System.out.println("DMeasures.getImageOf: "+rect); -// if( x_scale == null && y_scale == null ) return rect; -// if( rect.isEmpty() ) return (DRectangle)rect.clone(); -// DPoint p1 = new DPoint( rect.x, rect.y ), -// p2 = new DPoint( rect.x + rect.width, rect.y + rect.height ); -// try{ -// if( x_scale != null ){ -// p1.x = x_scale.getImageOf( p1.x ); -// p2.x = x_scale.getImageOf( p2.x ); -// } -// if( y_scale != null ){ -// p1.y = y_scale.getImageOf( p1.y ); -// p2.y = y_scale.getImageOf( p2.y ); -// } -// } -// catch( IllegalArgumentException nde ){ return null; } -// return new DRectangle( p1.x, p1.y, p2.x - p1.x, p2.y - p1.y ); -// } - /** * method returns the image rectangle of the given rectangle * they differ if there are scale functions selected which are not the identity * if the given rectangle does not belong to the definition area of the scale * functions, the method returns null * - * @param rect the source rectangle * @return the source of it */ SlimRect getImageOf(double xpos, double ypos, double width, double height) { -// if( under_construction ) System.out.println("DMeasures.getImageOf: "+rect); - - if (x_scale == null && y_scale == null) { + if (xScale == null && yScale == null) { return new SlimRect(xpos, ypos, width, height); } double x1 = xpos, y1 = ypos, x2 = xpos + width, y2 = ypos + height; try { - if (x_scale != null) { - x1 = x_scale.getImageOf(x1); - x2 = x_scale.getImageOf(x2); + if (xScale != null) { + x1 = xScale.getImageOf(x1); + x2 = xScale.getImageOf(x2); } - if (y_scale != null) { - y1 = y_scale.getImageOf(y1); - y2 = y_scale.getImageOf(y2); + if (yScale != null) { + y1 = yScale.getImageOf(y1); + y2 = yScale.getImageOf(y2); } } catch (IllegalArgumentException nde) { return null; @@ -247,47 +197,6 @@ public class DMeasures implements Serializable { return getImageOf(srect.x, srect.y, srect.width, srect.height); } -// /** -// * method returns the source rectangle of the given rectangle -// * they differ if there are scale functions selected which are not the identity -// * if the given rectangle does not belong to the image area of the scale -// * functions, the method returns null -// * -// * @param rect the image rectangle -// * @return the source of it -// */ -// DRectangle getSourceOf( DRectangle rect ){ -// if( under_construction ) System.out.println("DMeasures.getSourceOf: "+rect); -// if( !getDRectangle().contains( rect ) ) { -//// System.out.println("case not contains"); -// return null; -// //throw new IllegalArgumentException("The rectangle lies not in the currently painted rectangle"); -// } -// -// if( x_scale == null && y_scale == null ) { -//// System.out.println("Case scale null"); -// return rect; -// } -// if( rect.isEmpty() ) { -//// System.out.println("Case isEmpty"); -// return (DRectangle)rect.clone(); -// } -// DPoint p1 = new DPoint( rect.x, rect.y ), -// p2 = new DPoint( rect.x + rect.width, rect.y + rect.height ); -// try{ -// if( x_scale != null ){ -// p1.x = x_scale.getSourceOf( p1.x ); -// p2.x = x_scale.getSourceOf( p2.x ); -// } -// if( y_scale != null ){ -// p1.y = y_scale.getSourceOf( p1.y ); -// p2.y = y_scale.getSourceOf( p2.y ); -// } -// } -// catch( IllegalArgumentException nde ){ return null; } -// return new DRectangle( p1.x, p1.y, p2.x - p1.x, p2.y - p1.y ); -// } - /** * method returns the source rectangle of the given rectangle * they differ if there are scale functions selected which are not the identity @@ -300,27 +209,23 @@ public class DMeasures implements Serializable { * @return the source of it */ SlimRect getSourceOf(double x, double y, double width, double height) { -// if( under_construction ) System.out.println("DMeasures.getSourceOf: "+rect); if (!getSlimRectangle().contains(x, y, width, height)) { -// System.out.println("case not contains"); return null; - //throw new IllegalArgumentException("The rectangle lies not in the currently painted rectangle"); } - if (x_scale == null && y_scale == null) { -// System.out.println("Case scale null"); + if (xScale == null && yScale == null) { return new SlimRect(x, y, width, height); } double x1 = x, y1 = y, x2 = x + width, y2 = y + height; try { - if (x_scale != null) { - x1 = x_scale.getSourceOf(x1); - x2 = x_scale.getSourceOf(x2); + if (xScale != null) { + x1 = xScale.getSourceOf(x1); + x2 = xScale.getSourceOf(x2); } - if (y_scale != null) { - y1 = y_scale.getSourceOf(y1); - y2 = y_scale.getSourceOf(y2); + if (yScale != null) { + y1 = yScale.getSourceOf(y1); + y2 = yScale.getSourceOf(y2); } } catch (IllegalArgumentException nde) { return null; @@ -329,15 +234,6 @@ public class DMeasures implements Serializable { } return new SlimRect(x1, y1, x2 - x1, y2 - y1); } -// SlimRect getSourceOf( double xpos, double ypos, double width, double height){ -// if( !getSlimRectangle().contains( xpos, ypos, width, height ) ) { -// System.err.println("The rectangle lies not in the currently painted rectangle"); -// return null; -// //throw new IllegalArgumentException("The rectangle lies not in the currently painted rectangle"); -// } -// // MK: this now strangely does the same as getImageOf -// return getImageOf(xpos, ypos, width, height); -// } SlimRect getSourceOf(SlimRect srect) { return getSourceOf(srect.x, srect.y, srect.width, srect.height); @@ -349,8 +245,4 @@ public class DMeasures implements Serializable { } return ((DArea) comp).getInsets(); } -} - -/**************************************************************************** - * END OF FILE - ****************************************************************************/ +} \ No newline at end of file diff --git a/src/eva2/tools/chart2d/DParent.java b/src/eva2/tools/chart2d/DParent.java index e3a9cf79..0eef8752 100644 --- a/src/eva2/tools/chart2d/DParent.java +++ b/src/eva2/tools/chart2d/DParent.java @@ -1,22 +1,5 @@ -/** - * Filename: $RCSfile: DParent.java,v $ - * Purpose: - * Language: Java - * Compiler: JDK 1.3 - * Authors: Fabian Hennecke - * Version: $Revision: 1.1.1.1 $ - * $Date: 2003/07/03 14:59:41 $ - * $Author: ulmerh $ - * Copyright (c) Dept. Computer Architecture, University of Tuebingen, Germany - */ - package eva2.tools.chart2d; - -/*==========================================================================* - * INTERFACE DECLARATION - *==========================================================================*/ - public interface DParent { void addDElement(DElement e); @@ -31,8 +14,4 @@ public interface DParent { void addDBorder(DBorder b); void restoreBorder(); -} - -/**************************************************************************** - * END OF FILE - ****************************************************************************/ +} \ No newline at end of file diff --git a/src/eva2/tools/chart2d/DPoint.java b/src/eva2/tools/chart2d/DPoint.java index 06ba3ba3..3dd77d5c 100644 --- a/src/eva2/tools/chart2d/DPoint.java +++ b/src/eva2/tools/chart2d/DPoint.java @@ -1,27 +1,7 @@ -/** - * Filename: $RCSfile: DPoint.java,v $ - * Purpose: - * Language: Java - * Compiler: JDK 1.3 - * Authors: Fabian Hennecke - * Version: $Revision: 1.1.1.1 $ - * $Date: 2003/07/03 14:59:42 $ - * $Author: ulmerh $ - * Copyright (c) Dept. Computer Architecture, University of Tuebingen, Germany - */ - package eva2.tools.chart2d; -/*==========================================================================* - * IMPORTS - *==========================================================================*/ - import java.awt.*; -/*==========================================================================* - * CLASS DECLARATION - *==========================================================================*/ - public class DPoint extends DComponent { public double x, y; public String label; @@ -104,8 +84,4 @@ public class DPoint extends DComponent { text += "x: " + x + ", y: " + y + ", color: " + color + "]"; return text; } -} - -/**************************************************************************** - * END OF FILE - ****************************************************************************/ +} \ No newline at end of file diff --git a/src/eva2/tools/chart2d/DPointIcon.java b/src/eva2/tools/chart2d/DPointIcon.java index e66e6932..b8dcb1de 100644 --- a/src/eva2/tools/chart2d/DPointIcon.java +++ b/src/eva2/tools/chart2d/DPointIcon.java @@ -1,15 +1,5 @@ package eva2.tools.chart2d; -/** - * Filename: $RCSfile: DPointIcon.java,v $ - * Purpose: - * Language: Java - * Compiler: JDK 1.3 - * Authors: Fabian Hennecke - * Version: - * Copyright (c) Dept. Computer Architecture, University of Tuebingen, Germany - */ - import java.awt.*; /** diff --git a/src/eva2/tools/chart2d/DPointSet.java b/src/eva2/tools/chart2d/DPointSet.java index 5fb210d2..c91aa6a0 100644 --- a/src/eva2/tools/chart2d/DPointSet.java +++ b/src/eva2/tools/chart2d/DPointSet.java @@ -1,15 +1,5 @@ -/** - * Filename: $RCSfile: DPointSet.java,v $ Purpose: Language: Java Compiler: JDK 1.3 Authors: Fabian - * Hennecke Version: $Revision: 1.1.1.1 $ $Date: 2003/07/03 14:59:42 $ $Author: ulmerh $ Copyright - * (c) Dept. Computer Architecture, University of Tuebingen, Germany - */ package eva2.tools.chart2d; -/* - * ==========================================================================* IMPORTS - *========================================================================== - */ - import eva2.tools.math.Mathematics; import java.awt.*; @@ -19,11 +9,6 @@ public class DPointSet extends DComponent { protected DPointIcon icon = null; - /* - * -------------------------------------------------------------------------* private member - * variables - *------------------------------------------------------------------------- - */ protected DIntDoubleMap x, y; protected boolean connected; protected Stroke stroke = new BasicStroke(); @@ -48,8 +33,7 @@ public class DPointSet extends DComponent { public DPointSet(DIntDoubleMap x_values, DIntDoubleMap y_values) { if (x_values.getSize() != y_values.getSize()) { - throw new IllegalArgumentException( - "The number of x-values has to be the same than the number of y-values"); + throw new IllegalArgumentException("The number of x-values has to be the same than the number of y-values"); } x = x_values; y = y_values; @@ -57,10 +41,6 @@ public class DPointSet extends DComponent { setDBorder(new DBorder(1, 1, 1, 1)); } - /* - * -------------------------------------------------------------------------* public methods - *------------------------------------------------------------------------- - */ @Override public void paint(DMeasures m) { Graphics2D g = (Graphics2D) m.getGraphics(); @@ -298,16 +278,6 @@ public class DPointSet extends DComponent { } } -// public int getSize(){ -// int size = x.getSize(); -// if( size != y.getSize() ) throw -// new ArrayStoreException( -// "The number of x-values is not equal to the number of y-values.\n" -// +"The size of the DPointSet isn�t clear." -// ); -// return size; -// } - /** * */ diff --git a/src/eva2/tools/chart2d/DRectangle.java b/src/eva2/tools/chart2d/DRectangle.java index 67035fff..dd738e2f 100644 --- a/src/eva2/tools/chart2d/DRectangle.java +++ b/src/eva2/tools/chart2d/DRectangle.java @@ -1,29 +1,9 @@ -/** - * Filename: $RCSfile: DRectangle.java,v $ - * Purpose: - * Language: Java - * Compiler: JDK 1.3 - * Authors: Fabian Hennecke - * Version: $Revision: 1.1.1.1 $ - * $Date: 2003/07/03 14:59:42 $ - * $Author: ulmerh $ - * Copyright (c) Dept. Computer Architecture, University of Tuebingen, Germany - */ - package eva2.tools.chart2d; -/*==========================================================================* - * IMPORTS - *==========================================================================*/ - import eva2.tools.EVAERROR; import java.awt.*; -/*==========================================================================* - * CLASS DECLARATION - *==========================================================================*/ - public class DRectangle extends DComponent { private double x, y; private double width, height; @@ -356,8 +336,4 @@ public class DRectangle extends DComponent { public boolean isEmpty() { return status == EMPTY; } -} - -/**************************************************************************** - * END OF FILE - ****************************************************************************/ +} \ No newline at end of file diff --git a/src/eva2/tools/chart2d/ScaledBorder.java b/src/eva2/tools/chart2d/ScaledBorder.java index ee07037b..cdab04e9 100644 --- a/src/eva2/tools/chart2d/ScaledBorder.java +++ b/src/eva2/tools/chart2d/ScaledBorder.java @@ -33,23 +33,23 @@ public class ScaledBorder implements Border { /** * distance between the x-values in digits */ - int x_value2value = 2; + int xValue2value = 2; /** * distance between y-label and y-values in digit width */ - int y_label2values = 1; + int yLabel2values = 1; /** * distance between y-values and y-axis markers in parts of the digit width */ - int y_values2marker = 2; + int yValues2marker = 2; /** * distance between values and arrows in pixels */ - int x_values2arrow = 10, - y_values2arrow = 10; + int xValues2arrow = 10, + yValues2arrow = 10; /** * distance between arrows and outer border @@ -59,19 +59,19 @@ public class ScaledBorder implements Border { /** * distance between labels and the border in pixels */ - public int x_label2border = 6, - y_label2border = 6; + public int xLabel2border = 6, + yLabel2border = 6; /** * the size of the source rectangle * that means before the values are mdified by scale functions */ - SlimRect src_rect = null; + SlimRect srcRect = null; /** * the minimal increment of the scales */ - public double minimal_increment; + public double minimalIncrement; /** * the displayed labels @@ -86,26 +86,26 @@ public class ScaledBorder implements Border { /** * the border which is shown around the scaled border */ - Border outer_border; + Border outerBorder; /** * flag if the outer border should be displayed */ - boolean show_outer_border = true; + boolean showOuterBorder = true; /** * scale functions if, for example, an logarithmic function is needed instead * of a linear. */ - public DFunction x_scale, y_scale; + public DFunction xScale, yScale; /** * formatters of the x- and y-axis numbers * * @see java.text.NumberFormat */ - private NumberFormat format_x = new DecimalFormat(), - format_y = new DecimalFormat(); + private NumberFormat formatX = new DecimalFormat(), + formatY = new DecimalFormat(); /** * Possible patterns for the number formats used by a border. @@ -118,13 +118,13 @@ public class ScaledBorder implements Border { private int nextYPattern = 1; private int nextXPattern = 1; - private double src_dX = -1, src_dY = -1; + private double srcDX = -1, srcDY = -1; - private boolean do_refresh, - auto_scale_x = true, - auto_scale_y = true; + private boolean doRefresh, + autoScaleX = true, + autoScaleY = true; - private Insets old_insets; + private Insets oldInsets; private DMeasures m; @@ -148,7 +148,7 @@ public class ScaledBorder implements Border { * surrounded by the specified Border */ public ScaledBorder(Border outer) { - outer_border = outer; + outerBorder = outer; m = new DMeasures(this); } @@ -157,7 +157,7 @@ public class ScaledBorder implements Border { * x-values by itself */ public void setAutoScaleX() { - auto_scale_x = true; + autoScaleX = true; } /** @@ -165,7 +165,7 @@ public class ScaledBorder implements Border { * y-values by itself */ public void setAutoScaleY() { - auto_scale_y = true; + autoScaleY = true; } /** @@ -176,8 +176,8 @@ public class ScaledBorder implements Border { * and the source values */ public void setSrcdX(double dX) { - auto_scale_x = false; - src_dX = dX; + autoScaleX = false; + srcDX = dX; } /** @@ -188,8 +188,8 @@ public class ScaledBorder implements Border { * and the source values */ public void setSrcdY(double dY) { - auto_scale_y = false; - src_dY = dY; + autoScaleY = false; + srcDY = dY; } /** @@ -217,61 +217,61 @@ public class ScaledBorder implements Border { if (background == null) { background = c.getBackground(); } - Color old_color = g.getColor(); + Color oldColor = g.getColor(); g.setColor(background); g.fillRect(x, y, width, height); - g.setColor(old_color); + g.setColor(oldColor); - Insets outer_insets = new Insets(0, 0, 0, 0);// insets of the outer border - if (show_outer_border) { - outer_border.paintBorder(c, g, x, y, width, height); - outer_insets = outer_border.getBorderInsets(c); + Insets outerInsets = new Insets(0, 0, 0, 0);// insets of the outer border + if (showOuterBorder) { + outerBorder.paintBorder(c, g, x, y, width, height); + outerInsets = outerBorder.getBorderInsets(c); } - do_refresh = true; - Insets inner_insets = getBorderInsets(c); + doRefresh = true; + Insets innerInsets = getBorderInsets(c); Dimension d = c.getSize(), - cd = new Dimension(d.width - inner_insets.left - inner_insets.right, - d.height - inner_insets.top - inner_insets.bottom); + cd = new Dimension(d.width - innerInsets.left - innerInsets.right, + d.height - innerInsets.top - innerInsets.bottom); FontMetrics fm = g.getFontMetrics(); int fontAsc = fm.getAscent(); - do_refresh = false; + doRefresh = false; - m.update(c, inner_insets); + m.update(c, innerInsets); // axes g.setColor(foreground); - g.drawLine(inner_insets.left, inner_insets.top, - inner_insets.left, inner_insets.top + cd.height); - g.drawLine(inner_insets.left, inner_insets.top + cd.height, - inner_insets.left + cd.width, inner_insets.top + cd.height); + g.drawLine(innerInsets.left, innerInsets.top, + innerInsets.left, innerInsets.top + cd.height); + g.drawLine(innerInsets.left, innerInsets.top + cd.height, + innerInsets.left + cd.width, innerInsets.top + cd.height); if (showArrows) { - g.drawLine(inner_insets.left, inner_insets.top, - inner_insets.left, inner_insets.top - y_values2arrow); - g.drawLine(inner_insets.left - markerLength, inner_insets.top - y_values2arrow, - inner_insets.left, inner_insets.top - y_values2arrow - arrowLength); - g.drawLine(inner_insets.left + markerLength, inner_insets.top - y_values2arrow, - inner_insets.left, inner_insets.top - y_values2arrow - arrowLength); - g.drawLine(inner_insets.left - markerLength, inner_insets.top - y_values2arrow, - inner_insets.left + markerLength, inner_insets.top - y_values2arrow); + g.drawLine(innerInsets.left, innerInsets.top, + innerInsets.left, innerInsets.top - yValues2arrow); + g.drawLine(innerInsets.left - markerLength, innerInsets.top - yValues2arrow, + innerInsets.left, innerInsets.top - yValues2arrow - arrowLength); + g.drawLine(innerInsets.left + markerLength, innerInsets.top - yValues2arrow, + innerInsets.left, innerInsets.top - yValues2arrow - arrowLength); + g.drawLine(innerInsets.left - markerLength, innerInsets.top - yValues2arrow, + innerInsets.left + markerLength, innerInsets.top - yValues2arrow); - g.drawLine(inner_insets.left + cd.width, inner_insets.top + cd.height, - inner_insets.left + cd.width + x_values2arrow, inner_insets.top + cd.height); - g.drawLine(inner_insets.left + cd.width + x_values2arrow, - inner_insets.top + cd.height - markerLength, - inner_insets.left + cd.width + x_values2arrow + arrowLength, - inner_insets.top + cd.height); - g.drawLine(inner_insets.left + cd.width + x_values2arrow, - inner_insets.top + cd.height + markerLength, - inner_insets.left + cd.width + x_values2arrow + arrowLength, - inner_insets.top + cd.height); - g.drawLine(inner_insets.left + cd.width + x_values2arrow, - inner_insets.top + cd.height - markerLength, - inner_insets.left + cd.width + x_values2arrow, - inner_insets.top + cd.height + markerLength); + g.drawLine(innerInsets.left + cd.width, innerInsets.top + cd.height, + innerInsets.left + cd.width + xValues2arrow, innerInsets.top + cd.height); + g.drawLine(innerInsets.left + cd.width + xValues2arrow, + innerInsets.top + cd.height - markerLength, + innerInsets.left + cd.width + xValues2arrow + arrowLength, + innerInsets.top + cd.height); + g.drawLine(innerInsets.left + cd.width + xValues2arrow, + innerInsets.top + cd.height + markerLength, + innerInsets.left + cd.width + xValues2arrow + arrowLength, + innerInsets.top + cd.height); + g.drawLine(innerInsets.left + cd.width + xValues2arrow, + innerInsets.top + cd.height - markerLength, + innerInsets.left + cd.width + xValues2arrow, + innerInsets.top + cd.height + markerLength); } if (yLabel != null) { @@ -279,31 +279,31 @@ public class ScaledBorder implements Border { AffineTransform T = new AffineTransform(0, 1, 1, 0, 0, 0); Font old = g.getFont(), f = old.deriveFont(T); g.setFont(f); - g.drawString(yLabel, y_label2border + fm.getAscent(), inner_insets.top + (cd.height + yld.height) / 2); + g.drawString(yLabel, yLabel2border + fm.getAscent(), innerInsets.top + (cd.height + yld.height) / 2); g.setFont(old); } if (xLabel != null) { g.drawString( - xLabel, inner_insets.left + (cd.width - fm.stringWidth(xLabel)) / 2, - d.height - outer_insets.bottom - x_label2border - fm.getDescent()); + xLabel, innerInsets.left + (cd.width - fm.stringWidth(xLabel)) / 2, + d.height - outerInsets.bottom - xLabel2border - fm.getDescent()); } - if (src_rect.x == 0 && src_rect.y == 0) { - int v2m = fm.stringWidth("0") / y_values2marker; - g.drawString("0", inner_insets.left - fm.stringWidth("0") - v2m - markerLength, - inner_insets.top + cd.height + fontAsc); - g.drawLine(inner_insets.left, inner_insets.top + cd.height + fm.getAscent(), - inner_insets.left, inner_insets.top + cd.height); - g.drawLine(inner_insets.left, inner_insets.top + cd.height, - inner_insets.left - fm.stringWidth("0") - v2m - markerLength, - inner_insets.top + cd.height); + if (srcRect.x == 0 && srcRect.y == 0) { + int v2m = fm.stringWidth("0") / yValues2marker; + g.drawString("0", innerInsets.left - fm.stringWidth("0") - v2m - markerLength, + innerInsets.top + cd.height + fontAsc); + g.drawLine(innerInsets.left, innerInsets.top + cd.height + fm.getAscent(), + innerInsets.left, innerInsets.top + cd.height); + g.drawLine(innerInsets.left, innerInsets.top + cd.height, + innerInsets.left - fm.stringWidth("0") - v2m - markerLength, + innerInsets.top + cd.height); } - drawYValues(g, inner_insets); - drawXValues(g, inner_insets, cd); + drawYValues(g, innerInsets); + drawXValues(g, innerInsets, cd); - g.setColor(old_color); + g.setColor(oldColor); } /** @@ -314,24 +314,24 @@ public class ScaledBorder implements Border { */ private void drawYValues(Graphics g, Insets insets) { FontMetrics fm = g.getFontMetrics(); - int fontAsc = fm.getAscent(), v2m = fm.stringWidth("0") / y_values2marker; + int fontAsc = fm.getAscent(), v2m = fm.stringWidth("0") / yValues2marker; - double startVal = Mathematics.firstMultipleAbove(src_rect.y, src_dY); + double startVal = Mathematics.firstMultipleAbove(srcRect.y, srcDY); - double v, scaledV, minx = src_rect.x; - if (x_scale != null) { - minx = x_scale.getImageOf(minx); + double v, scaledV, minx = srcRect.x; + if (xScale != null) { + minx = xScale.getImageOf(minx); } v = startVal; - while (v <= src_rect.y + src_rect.height) { - if (y_scale != null) { - scaledV = y_scale.getImageOf(v); + while (v <= srcRect.y + srcRect.height) { + if (yScale != null) { + scaledV = yScale.getImageOf(v); } else { scaledV = v; } - String text = format_y.format(scaledV); + String text = formatY.format(scaledV); try { - scaledV = format_y.parse(text).doubleValue(); + scaledV = formatY.parse(text).doubleValue(); } catch (java.text.ParseException ex) { } Point p = m.getPoint(minx, scaledV); @@ -341,11 +341,10 @@ public class ScaledBorder implements Border { p.y + fontAsc / 2); g.drawLine(insets.left - markerLength, p.y, insets.left, p.y); } - if (v + src_dY <= v) { -// System.err.println("Overflow error B in ScaledBorder! v,src_dY:" + v + ", " + src_dY); + if (v + srcDY <= v) { v *= 1.01; } - v += src_dY; + v += srcDY; } } @@ -354,82 +353,82 @@ public class ScaledBorder implements Border { } public double getSrcdY(int fontMetricsHeight, int componentHeight) { - if ((!do_refresh && src_dY != -1) || !auto_scale_y) { - return src_dY; + if ((!doRefresh && srcDY != -1) || !autoScaleY) { + return srcDY; } int max = componentHeight / fontMetricsHeight; - if (Double.isInfinite(src_rect.height) || Double.isInfinite(src_rect.width)) { + if (Double.isInfinite(srcRect.height) || Double.isInfinite(srcRect.width)) { System.err.println("Error, infinite value in ScaledBorder:getSrcdY !!"); } - double minsrc_dY = 2 * src_rect.height / (double) max; // die 2 einfach mal so eingesetzt <-------------------------- - src_dY = aBitBigger(minsrc_dY); - if (src_dY < minimal_increment) { - src_dY = minimal_increment; + double minsrc_dY = 2 * srcRect.height / (double) max; // die 2 einfach mal so eingesetzt <-------------------------- + srcDY = aBitBigger(minsrc_dY); + if (srcDY < minimalIncrement) { + srcDY = minimalIncrement; } - return src_dY; + return srcDY; } private void drawXValues(Graphics g, Insets insets, Dimension cd) { FontMetrics fm = g.getFontMetrics(); - double mx = cd.width / src_rect.width; + double mx = cd.width / srcRect.width; int n, labelX, - xnull = insets.left + (int) (-src_rect.x * mx); + xnull = insets.left + (int) (-srcRect.x * mx); - n = (int) (src_rect.x / src_dX); - if (n * src_dX < src_rect.x || (src_rect.x == 0 && src_rect.y == 0)) { + n = (int) (srcRect.x / srcDX); + if (n * srcDX < srcRect.x || (srcRect.x == 0 && srcRect.y == 0)) { n++; } int fontAsc = fm.getAscent(), xLineY = insets.top + cd.height; - labelX = xnull + (int) (n * src_dX * mx); - while (n * src_dX <= src_rect.x + src_rect.width) { - double v = n * src_dX; - if (x_scale != null) { - v = x_scale.getImageOf(v); + labelX = xnull + (int) (n * srcDX * mx); + while (n * srcDX <= srcRect.x + srcRect.width) { + double v = n * srcDX; + if (xScale != null) { + v = xScale.getImageOf(v); } - String text = format_x.format(v); + String text = formatX.format(v); try { - v = format_x.parse(text).doubleValue(); + v = formatX.parse(text).doubleValue(); } catch (java.text.ParseException ex) { } int strW = fm.stringWidth(text); g.drawString(text, labelX - strW / 2, xLineY + fontAsc); g.drawLine(labelX, xLineY, labelX, xLineY + markerLength); n++; - labelX = xnull + (int) (n * src_dX * mx); + labelX = xnull + (int) (n * srcDX * mx); } } public double getSrcdX(FontMetrics fm, Dimension cd) { - if ((!do_refresh && src_dX != -1) || !auto_scale_x) { - return src_dX; + if ((!doRefresh && srcDX != -1) || !autoScaleX) { + return srcDX; } int digit_width = fm.stringWidth("0"), - max = cd.width / (digit_width * (x_value2value + 1)); - src_dX = src_rect.width / (double) max; + max = cd.width / (digit_width * (xValue2value + 1)); + srcDX = srcRect.width / (double) max; int n, labelX, olsrc_dX; boolean ok = false; while (!ok) { - src_dX = aBitBigger(src_dX); + srcDX = aBitBigger(srcDX); - n = (int) (src_rect.x / src_dX); - if (n * src_dX < src_rect.x) { + n = (int) (srcRect.x / srcDX); + if (n * srcDX < srcRect.x) { n++; } olsrc_dX = 0; boolean suits = true, first = true; - while (suits && n * src_dX <= src_rect.x + src_rect.width) { - double v = n * src_dX; - if (x_scale != null) { - v = x_scale.getImageOf(v); + while (suits && n * srcDX <= srcRect.x + srcRect.width) { + double v = n * srcDX; + if (xScale != null) { + v = xScale.getImageOf(v); } - String text = format_x.format(v); + String text = formatX.format(v); int strW = fm.stringWidth(text); - labelX = (int) (((n * src_dX - src_rect.x) / src_rect.width) * cd.width) - strW / 2; - if (!first && labelX <= olsrc_dX + digit_width * x_value2value) { + labelX = (int) (((n * srcDX - srcRect.x) / srcRect.width) * cd.width) - strW / 2; + if (!first && labelX <= olsrc_dX + digit_width * xValue2value) { suits = false; } else { olsrc_dX = labelX + strW; @@ -439,10 +438,10 @@ public class ScaledBorder implements Border { } ok = suits; } - if (src_dX < minimal_increment) { - src_dX = minimal_increment; + if (srcDX < minimalIncrement) { + srcDX = minimalIncrement; } - return src_dX; + return srcDX; } /** @@ -484,7 +483,7 @@ public class ScaledBorder implements Border { @Override public boolean isBorderOpaque() { - return outer_border.isBorderOpaque(); + return outerBorder.isBorderOpaque(); } /** @@ -545,13 +544,12 @@ public class ScaledBorder implements Border { * * @param bXorY * @param pattern - * @see #java.text.DecimalFormat.applyPattern */ public void applyPattern(boolean bXorY, String pattern) { if (bXorY) { - ((java.text.DecimalFormat) format_x).applyPattern(pattern); + ((java.text.DecimalFormat) formatX).applyPattern(pattern); } else { - ((java.text.DecimalFormat) format_y).applyPattern(pattern); + ((java.text.DecimalFormat) formatY).applyPattern(pattern); } } @@ -562,15 +560,15 @@ public class ScaledBorder implements Border { */ @Override public Insets getBorderInsets(Component c) { - if (!do_refresh && old_insets != null) { - return old_insets; + if (!doRefresh && oldInsets != null) { + return oldInsets; } Graphics g = c.getGraphics(); Insets insets = new Insets(0, 0, 0, 0); - if (show_outer_border) { - insets = outer_border.getBorderInsets(c); + if (showOuterBorder) { + insets = outerBorder.getBorderInsets(c); } if (g == null) { @@ -584,76 +582,76 @@ public class ScaledBorder implements Border { if (c instanceof DArea) { DArea area = (DArea) c; DMeasures m = area.getDMeasures(); - src_rect = m.getSourceOf(area.getSlimRectangle()); - x_scale = area.getDMeasures().x_scale; - y_scale = area.getDMeasures().y_scale; + srcRect = m.getSourceOf(area.getSlimRectangle()); + xScale = area.getDMeasures().xScale; + yScale = area.getDMeasures().yScale; } // left: if (yLabel != null) { insets.left += fm.getAscent() + fm.getDescent(); } - insets.left += y_label2values * digit_width; + insets.left += yLabel2values * digit_width; getSrcdY(fm, c.getSize()); double start, n, inc; int maxWidth = 0; - start = src_dY * (int) (src_rect.y / src_dY); + start = srcDY * (int) (srcRect.y / srcDY); n = start; - if (n < src_rect.y) { - n += src_dY; + if (n < srcRect.y) { + n += srcDY; } - if (((src_rect.y + src_rect.height) - start) / src_dY > 20) { - inc = ((src_rect.y + src_rect.height) - start) / 20.; + if (((srcRect.y + srcRect.height) - start) / srcDY > 20) { + inc = ((srcRect.y + srcRect.height) - start) / 20.; } else { - inc = src_dY; + inc = srcDY; } if ((n + inc) == n) { System.err.println("Warning, too small increase step size!"); } - for (; n <= src_rect.y + src_rect.height; n += inc) { + for (; n <= srcRect.y + srcRect.height; n += inc) { // TODO here might be a bug for mean values double v = n; - if (y_scale != null) { - v = y_scale.getImageOf(v); + if (yScale != null) { + v = yScale.getImageOf(v); } - int w = fm.stringWidth(format_y.format(v)); + int w = fm.stringWidth(formatY.format(v)); if (w > maxWidth) { maxWidth = w; } - // avoid nearly endless loop for large src_rect.y value and small src_dY + // avoid nearly endless loop for large srcRect.y value and small srcDY } - insets.left += 1 + y_label2border + maxWidth + digit_width / y_values2marker + markerLength; + insets.left += 1 + yLabel2border + maxWidth + digit_width / yValues2marker + markerLength; // bottom: - insets.bottom += 1 + fontHeight + x_label2border; + insets.bottom += 1 + fontHeight + xLabel2border; if (xLabel != null) { insets.bottom += fontHeight; } // top: if (showArrows) { - insets.top += y_values2arrow + arrowLength; + insets.top += yValues2arrow + arrowLength; } insets.top += axis2border; // right: if (showArrows) { - insets.right += x_values2arrow + arrowLength; + insets.right += xValues2arrow + arrowLength; } insets.right += axis2border; getSrcdX(fm, c.getSize()); - int k = (int) (src_rect.x + src_rect.width / src_dX); + int k = (int) (srcRect.x + srcRect.width / srcDX); if (k < 0) { k++; } - int w = fm.stringWidth(format_x.format(k * src_dX)); + int w = fm.stringWidth(formatX.format(k * srcDX)); if (w / 2 > insets.right) { insets.right = w / 2; } - old_insets = insets; + oldInsets = insets; return insets; } } diff --git a/src/eva2/tools/chart2d/SlimRect.java b/src/eva2/tools/chart2d/SlimRect.java index 62b0983c..9b466ff2 100644 --- a/src/eva2/tools/chart2d/SlimRect.java +++ b/src/eva2/tools/chart2d/SlimRect.java @@ -3,8 +3,6 @@ package eva2.tools.chart2d; /** * Encapsulates a slim rectangle structure with x, y, width and height and * nothing else. Makes some painting calculations quite a bit faster. - * - * @author mkron */ public class SlimRect { double x, y, width, height; diff --git a/src/eva2/tools/math/Jama/CholeskyDecomposition.java b/src/eva2/tools/math/Jama/CholeskyDecomposition.java index fd0b2db6..8b6c2b63 100644 --- a/src/eva2/tools/math/Jama/CholeskyDecomposition.java +++ b/src/eva2/tools/math/Jama/CholeskyDecomposition.java @@ -13,10 +13,6 @@ package eva2.tools.math.Jama; public class CholeskyDecomposition implements java.io.Serializable { -/* ------------------------ - Class variables - * ------------------------ */ - /** * Array for internal storage of decomposition. * @@ -38,10 +34,6 @@ public class CholeskyDecomposition implements java.io.Serializable { */ private boolean isspd; -/* ------------------------ - Constructor - * ------------------------ */ - /** * Cholesky algorithm for symmetric and positive definite matrix. * diff --git a/src/eva2/tools/math/Jama/EigenvalueDecomposition.java b/src/eva2/tools/math/Jama/EigenvalueDecomposition.java index dde52f96..b1834352 100644 --- a/src/eva2/tools/math/Jama/EigenvalueDecomposition.java +++ b/src/eva2/tools/math/Jama/EigenvalueDecomposition.java @@ -64,10 +64,6 @@ public class EigenvalueDecomposition implements java.io.Serializable { */ private double[] ort; -/* ------------------------ - Private Methods - * ------------------------ */ - // Symmetric Householder reduction to tridiagonal form. private void tred2() { @@ -855,21 +851,16 @@ public class EigenvalueDecomposition implements java.io.Serializable { } } - -/* ------------------------ - Constructor - * ------------------------ */ - /** * Check for symmetry, then construct the eigenvalue decomposition * - * @param A Square matrix + * @param arg A Square matrix * @return Structure to access D and V. */ - public EigenvalueDecomposition(Matrix Arg) { - double[][] A = Arg.getArray(); - n = Arg.getColumnDimension(); + public EigenvalueDecomposition(Matrix matrix) { + double[][] A = matrix.getArray(); + n = matrix.getColumnDimension(); V = new double[n][n]; d = new double[n]; e = new double[n]; @@ -910,10 +901,6 @@ public class EigenvalueDecomposition implements java.io.Serializable { } } -/* ------------------------ - Public Methods - * ------------------------ */ - /** * Return the eigenvector matrix * diff --git a/src/eva2/tools/math/Jama/LUDecomposition.java b/src/eva2/tools/math/Jama/LUDecomposition.java index aae41ae8..2dfdaf10 100644 --- a/src/eva2/tools/math/Jama/LUDecomposition.java +++ b/src/eva2/tools/math/Jama/LUDecomposition.java @@ -40,10 +40,6 @@ public class LUDecomposition implements java.io.Serializable { */ private int[] piv; -/* ------------------------ - Constructor - * ------------------------ */ - /** * LU Decomposition * @@ -52,11 +48,6 @@ public class LUDecomposition implements java.io.Serializable { */ public LUDecomposition(Matrix A) { - - // Use a "left-looking", dot-product, Crout/Doolittle algorithm. -// System.out.println("A="); -// A.print(A.getRowDimension(),A.getColumnDimension()); - LU = A.getArrayCopy(); m = A.getRowDimension(); n = A.getColumnDimension(); @@ -124,69 +115,6 @@ public class LUDecomposition implements java.io.Serializable { } } -/* ------------------------ - Temporary, experimental code. - ------------------------ *\ - - \** LU Decomposition, computed by Gaussian elimination. -

- This constructor computes L and U with the "daxpy"-based elimination - algorithm used in LINPACK and MATLAB. In Java, we suspect the dot-product, - Crout algorithm will be faster. We have temporarily included this - constructor until timing experiments confirm this suspicion. -

- @param A Rectangular matrix - @param linpackflag Use Gaussian elimination. Actual value ignored. - @return Structure to access L, U and piv. - *\ - - public LUDecomposition (Matrix A, int linpackflag) { - // Initialize. - LU = A.getArrayCopy(); - m = A.getRowDimension(); - n = A.getColumnDimension(); - piv = new int[m]; - for (int i = 0; i < m; i++) { - piv[i] = i; - } - pivsign = 1; - // Main loop. - for (int k = 0; k < n; k++) { - // Find pivot. - int p = k; - for (int i = k+1; i < m; i++) { - if (Math.abs(LU[i][k]) > Math.abs(LU[p][k])) { - p = i; - } - } - // Exchange if necessary. - if (p != k) { - for (int j = 0; j < n; j++) { - double t = LU[p][j]; LU[p][j] = LU[k][j]; LU[k][j] = t; - } - int t = piv[p]; piv[p] = piv[k]; piv[k] = t; - pivsign = -pivsign; - } - // Compute multipliers and eliminate k-th column. - if (LU[k][k] != 0.0) { - for (int i = k+1; i < m; i++) { - LU[i][k] /= LU[k][k]; - for (int j = k+1; j < n; j++) { - LU[i][j] -= LU[i][k]*LU[k][j]; - } - } - } - } - } - -\* ------------------------ - End of temporary code. - * ------------------------ */ - -/* ------------------------ - Public Methods - * ------------------------ */ - /** * Is the matrix nonsingular? * @@ -195,7 +123,6 @@ public class LUDecomposition implements java.io.Serializable { public boolean isNonsingular() { for (int j = 0; j < n; j++) { - //System.out.println("LU[j][j]"+LU[j][j]); if (LU[j][j] == 0) { return false; } @@ -253,7 +180,6 @@ public class LUDecomposition implements java.io.Serializable { * * @return piv */ - public int[] getPivot() { int[] p = new int[m]; System.arraycopy(piv, 0, p, 0, m); @@ -265,7 +191,6 @@ public class LUDecomposition implements java.io.Serializable { * * @return (double) piv */ - public double[] getDoublePivot() { double[] vals = new double[m]; for (int i = 0; i < m; i++) { @@ -280,7 +205,6 @@ public class LUDecomposition implements java.io.Serializable { * @return det(A) * @throws IllegalArgumentException Matrix must be square */ - public double det() { if (m != n) { throw new IllegalArgumentException("Matrix must be square."); @@ -300,14 +224,11 @@ public class LUDecomposition implements java.io.Serializable { * @throws IllegalArgumentException Matrix row dimensions must agree. * @throws RuntimeException Matrix is singular. */ - public Matrix solve(Matrix B) { if (B.getRowDimension() != m) { throw new IllegalArgumentException("Matrix row dimensions must agree."); } if (!this.isNonsingular()) { - //System.out.println("B="); - //B.print(B.getRowDimension(),B.getColumnDimension()); throw new RuntimeException("Matrix is singular."); } diff --git a/src/eva2/tools/math/Jama/Matrix.java b/src/eva2/tools/math/Jama/Matrix.java index aa2c4e92..2d6e3801 100644 --- a/src/eva2/tools/math/Jama/Matrix.java +++ b/src/eva2/tools/math/Jama/Matrix.java @@ -17,7 +17,6 @@ import java.util.Arrays; import java.util.Locale; import java.util.Vector; - /** * Jama = Java Matrix class. *

diff --git a/src/eva2/tools/math/Jama/QRDecomposition.java b/src/eva2/tools/math/Jama/QRDecomposition.java index ac1ede7f..d837cd3a 100644 --- a/src/eva2/tools/math/Jama/QRDecomposition.java +++ b/src/eva2/tools/math/Jama/QRDecomposition.java @@ -15,13 +15,8 @@ import eva2.tools.math.Jama.util.Maths; * of simultaneous linear equations. This will fail if isFullRank() * returns false. */ - public class QRDecomposition implements java.io.Serializable { -/* ------------------------ - Class variables - * ------------------------ */ - /** * Array for internal storage of decomposition. * @@ -44,17 +39,12 @@ public class QRDecomposition implements java.io.Serializable { */ private double[] Rdiag; -/* ------------------------ - Constructor - * ------------------------ */ - /** * QR Decomposition, computed by Householder reflections. * * @param A Rectangular matrix * @return Structure to access R and the Householder vectors and compute Q. */ - public QRDecomposition(Matrix A) { // Initialize. QR = A.getArrayCopy(); @@ -96,16 +86,11 @@ public class QRDecomposition implements java.io.Serializable { } } -/* ------------------------ - Public Methods - * ------------------------ */ - /** * Is the matrix full rank? * * @return true if R, and hence A, has full rank. */ - public boolean isFullRank() { for (int j = 0; j < n; j++) { if (Rdiag[j] == 0) { @@ -120,7 +105,6 @@ public class QRDecomposition implements java.io.Serializable { * * @return Lower trapezoidal matrix whose columns define the reflections */ - public Matrix getH() { Matrix X = new Matrix(m, n); double[][] H = X.getArray(); @@ -141,7 +125,6 @@ public class QRDecomposition implements java.io.Serializable { * * @return R */ - public Matrix getR() { Matrix X = new Matrix(n, n); double[][] R = X.getArray(); @@ -164,7 +147,6 @@ public class QRDecomposition implements java.io.Serializable { * * @return Q */ - public Matrix getQ() { Matrix X = new Matrix(m, n); double[][] Q = X.getArray(); @@ -197,7 +179,6 @@ public class QRDecomposition implements java.io.Serializable { * @throws IllegalArgumentException Matrix row dimensions must agree. * @throws RuntimeException Matrix is rank deficient. */ - public Matrix solve(Matrix B) { if (B.getRowDimension() != m) { throw new IllegalArgumentException("Matrix row dimensions must agree."); diff --git a/src/eva2/tools/math/Jama/SingularValueDecomposition.java b/src/eva2/tools/math/Jama/SingularValueDecomposition.java index 15507ff2..a3a12b39 100644 --- a/src/eva2/tools/math/Jama/SingularValueDecomposition.java +++ b/src/eva2/tools/math/Jama/SingularValueDecomposition.java @@ -20,10 +20,6 @@ import eva2.tools.math.Jama.util.Maths; public class SingularValueDecomposition implements java.io.Serializable { -/* ------------------------ - Class variables - * ------------------------ */ - /** * Arrays for internal storage of U and V. * @@ -47,24 +43,20 @@ public class SingularValueDecomposition implements java.io.Serializable { */ private int m, n; -/* ------------------------ - Constructor - * ------------------------ */ - /** * Construct the singular value decomposition * - * @param A Rectangular matrix + * @param arg A Rectangular matrix * @return Structure to access U, S and V. */ - public SingularValueDecomposition(Matrix Arg) { + public SingularValueDecomposition(Matrix matrix) { // Derived from LINPACK code. // Initialize. - double[][] A = Arg.getArrayCopy(); - m = Arg.getRowDimension(); - n = Arg.getColumnDimension(); + double[][] A = matrix.getArrayCopy(); + m = matrix.getRowDimension(); + n = matrix.getColumnDimension(); int nu = Math.min(m, n); s = new double[Math.min(m + 1, n)]; U = new double[m][nu]; @@ -476,10 +468,6 @@ public class SingularValueDecomposition implements java.io.Serializable { } } -/* ------------------------ - Public Methods - * ------------------------ */ - /** * Return the left singular vectors * diff --git a/src/eva2/tools/math/Mathematics.java b/src/eva2/tools/math/Mathematics.java index b4fe44e8..9cf57e5a 100644 --- a/src/eva2/tools/math/Mathematics.java +++ b/src/eva2/tools/math/Mathematics.java @@ -112,7 +112,6 @@ public class Mathematics { * * @param x a vector * @param y another vector - * @param root what kind of distance funktion * @return the distance of x and y * @throws Exception if x and y have different dimensions an exception is thrown. */ @@ -139,8 +138,6 @@ public class Mathematics { */ public static double[] expandVector(double[] x, int len, double v) { if (len <= x.length) {// not really an error, just perform identity - // System.err.println("Error, invalid length in expandVector, expecting l>" - // + x.length); return x; } else { double[] expanded = new double[len]; diff --git a/src/eva2/tools/math/StatisticUtils.java b/src/eva2/tools/math/StatisticUtils.java index 65e363d9..8e6fa9b3 100644 --- a/src/eva2/tools/math/StatisticUtils.java +++ b/src/eva2/tools/math/StatisticUtils.java @@ -399,43 +399,6 @@ public class StatisticUtils { return corrCoefficient; } - /** - * Main method for testing this class. - */ - public static void main(String[] ops) { - double[][] vs = {{356.873, -498.563, 130.923, -223.684, 494.296, 380.739, 481.353, 344.571, 501.105, -166.109}, - {199.116, -423.448, 487.898, 344.579, 140.709, 89.007, -259.310, 512.000, 152.069, -440.778}, - {439.128, 112.370, -422.820, -43.119, -297.609, -438.940, 488.914, -512.000, -407.847, 386.611}, - {395.772, 191.634, -511.999, -93.078, -282.853, -444.621, 491.291, -512.000, -407.620, 386.493}}; - - vs[1] = Mathematics.rotate(vs[0], AbstractProblemDouble.initializeDefaultRotationMatrix(10, 10)); - - for (int i = 0; i < vs.length; i++) { - for (int j = 0; j < vs.length; j++) { - System.out.print("\t" + correlation(vs[i], vs[j])); - } - System.out.println(); - } -// vs[1]=Mathematics.rotate(vs[0], AbstractProblemDouble.initializeDefaultRotationMatrix(30, 10)); -// vs[2]=Mathematics.rotate(vs[0], AbstractProblemDouble.initializeDefaultRotationMatrix(50, 10)); -// vs[3]=Mathematics.rotate(vs[0], AbstractProblemDouble.initializeDefaultRotationMatrix(70, 10)); - - vs = new double[][]{{0.1, 0.9}, - {0.8, 0.2}, -// {0.8,0.2}, - {0.0, 1.0}}; - System.out.println("---"); - -// for (int i=0; iAbstractDataSet. */ public abstract class AbstractDataModifier { - /*-------------------------------------------------------------------------* - * abstract methods - *-------------------------------------------------------------------------*/ - /** * Modifies the X data. */ @@ -46,8 +20,4 @@ public abstract class AbstractDataModifier { * Modifies the data. */ public abstract void modify(double[] setX, double[] setY); -} - -/**************************************************************************** - * END OF FILE - ****************************************************************************/ \ No newline at end of file +} \ No newline at end of file diff --git a/src/eva2/tools/math/interpolation/AbstractDataSet.java b/src/eva2/tools/math/interpolation/AbstractDataSet.java index 73139f72..96857e15 100644 --- a/src/eva2/tools/math/interpolation/AbstractDataSet.java +++ b/src/eva2/tools/math/interpolation/AbstractDataSet.java @@ -1,35 +1,6 @@ -/////////////////////////////////////////////////////////////////////////////// -// Filename: $RCSfile: AbstractDataSet.java,v $ -// Purpose: Some interpolation stuff. -// Language: Java -// Compiler: JDK 1.4 -// Authors: Joerg K. Wegner -// Version: $Revision: 1.1 $ -// $Date: 2003/07/22 19:25:04 $ -// $Author: wegnerj $ -// -// Copyright (c) Dept. Computer Architecture, University of Tuebingen, Germany -// -/////////////////////////////////////////////////////////////////////////////// - package eva2.tools.math.interpolation; -/*==========================================================================* - * IMPORTS - *==========================================================================*/ - -/*==========================================================================* -* CLASS DECLARATION -*==========================================================================*/ - public abstract class AbstractDataSet { - /*-------------------------------------------------------------------------* - * public member variables - *-------------------------------------------------------------------------*/ - - /*--------------------------------------------------------------o-----------* - * protected member variables - *-------------------------------------------------------------------------*/ /** * double array of X data. * @@ -43,10 +14,6 @@ public abstract class AbstractDataSet { */ protected double[] yDoubleData = {1, 1}; - /*-------------------------------------------------------------------------* - * abstract methods - *-------------------------------------------------------------------------*/ - /** * Returns the length of the data set * @@ -115,6 +82,3 @@ public abstract class AbstractDataSet { modifier.modify(xDoubleData, yDoubleData); } } -/**************************************************************************** - * END OF FILE - ****************************************************************************/ diff --git a/src/eva2/tools/math/interpolation/BasicDataSet.java b/src/eva2/tools/math/interpolation/BasicDataSet.java index ccb43fc9..adee202e 100644 --- a/src/eva2/tools/math/interpolation/BasicDataSet.java +++ b/src/eva2/tools/math/interpolation/BasicDataSet.java @@ -1,17 +1,3 @@ -/////////////////////////////////////////////////////////////////////////////// -// Filename: $RCSfile: BasicDataSet.java,v $ -// Purpose: Some interpolation stuff. -// Language: Java -// Compiler: JDK 1.4 -// Authors: Joerg K. Wegner -// Version: $Revision: 1.1 $ -// $Date: 2003/07/22 19:25:11 $ -// $Author: wegnerj $ -// -// Copyright (c) Dept. Computer Architecture, University of Tuebingen, Germany -// -/////////////////////////////////////////////////////////////////////////////// - package eva2.tools.math.interpolation; /** diff --git a/src/eva2/tools/math/interpolation/InterpolationException.java b/src/eva2/tools/math/interpolation/InterpolationException.java index 6eb40d8d..7d6363fc 100644 --- a/src/eva2/tools/math/interpolation/InterpolationException.java +++ b/src/eva2/tools/math/interpolation/InterpolationException.java @@ -1,28 +1,4 @@ -/////////////////////////////////////////////////////////////////////////////// -// Filename: $RCSfile: InterpolationException.java,v $ -// Purpose: Some interpolation stuff. -// Language: Java -// Compiler: JDK 1.4 -// Authors: Joerg K. Wegner -// Version: $Revision: 1.1 $ -// $Date: 2003/07/22 19:25:17 $ -// $Author: wegnerj $ -// -// Copyright (c) Dept. Computer Architecture, University of Tuebingen, Germany -// -/////////////////////////////////////////////////////////////////////////////// - package eva2.tools.math.interpolation; - -/*==========================================================================* - * IMPORTS - *==========================================================================*/ - - -/*==========================================================================* - * CLASS DECLARATION - *==========================================================================*/ - /** * Exception for interpolation error. */ @@ -35,8 +11,4 @@ public class InterpolationException extends Exception { public InterpolationException(String s) { super(s); } -} - -/**************************************************************************** - * END OF FILE - ****************************************************************************/ \ No newline at end of file +} \ No newline at end of file diff --git a/src/eva2/tools/math/interpolation/LinearInterpolation.java b/src/eva2/tools/math/interpolation/LinearInterpolation.java index e830f555..7280dde9 100644 --- a/src/eva2/tools/math/interpolation/LinearInterpolation.java +++ b/src/eva2/tools/math/interpolation/LinearInterpolation.java @@ -15,12 +15,6 @@ package eva2.tools.math.interpolation; -/*==========================================================================* - * IMPORTS - *==========================================================================*/ - -//import cern.jet.stat.*; - /** * Defines the routines for the spline interpolation of data. */ diff --git a/src/eva2/tools/math/interpolation/PolyInterpolation.java b/src/eva2/tools/math/interpolation/PolyInterpolation.java deleted file mode 100644 index b94dde04..00000000 --- a/src/eva2/tools/math/interpolation/PolyInterpolation.java +++ /dev/null @@ -1,405 +0,0 @@ -package eva2.tools.math.interpolation; - -/** - * Defines the routines for the interpolation of data. - */ -public class PolyInterpolation { - AbstractDataSet abstractDataSet = null; - boolean sloppy = true; - double[] polynomialCoefficients = null; - - /** - * Initializes this class. - */ - public PolyInterpolation() throws InterpolationException { - this.abstractDataSet = null; - sloppy = true; - polynomialCoefficients = null; - } - - /** - * Initializes this class and calculates the coefficients of the polynom. - * - * @param abstractDataSet the AbstractDataSet - */ - public PolyInterpolation(AbstractDataSet abstractDataSet) - throws InterpolationException { - this.abstractDataSet = abstractDataSet; - sloppy = true; - this.polynomialCoefficients = calculatePolynomialCoefficients(); - } - - /** - * Initializes this class and calculates the coefficients of the polynom. - * - * @param abstractDataSet the AbstractDataSet - * @param sloppy if true Neville's algorithm which is used in the - * polynomialInterpolation-routines does only print a - * warning message on the screen and does not throw an - * Exception if two x values are identical. - */ - public PolyInterpolation(AbstractDataSet abstractDataSet, boolean sloppy) - throws InterpolationException { - this.abstractDataSet = abstractDataSet; - this.sloppy = sloppy; - this.polynomialCoefficients = calculatePolynomialCoefficients(); - } - - /** - * Sets the new AbstractDataSet and calculates the coefficients - * of the polynom. - * - * @param abstractDataSet the AbstractDataSet - */ - public void setAbstractDataSet(AbstractDataSet abstractDataSet) - throws InterpolationException { - this.abstractDataSet = abstractDataSet; - this.polynomialCoefficients = calculatePolynomialCoefficients(); - } - - /** - * Uses the polynom with the calculated coefficients to calculate the - * y value. This algorithm was taken from:
- * - * William H. Press, Saul A. Teukolosky, William T. Vetterling, Brian P. Flannery, - * "Numerical Recipes in C - The Art of Scientific Computing", Second Edition, - * Cambridge University Press, - * ISBN 0-521-43108-5, - * chapter 5, pages 173-176.
- * The Neville's algorithm which is used in the polynomialInterpolation- - * routines returns also the error of this interpolated point. - * - * @param x the x value - * @return the interpolated y value - * @see #polynomialInterpolation(double) - * @see #polynomialInterpolation(AbstractDataSet, double) - * @see #polynomialInterpolation(double[], double[], double) - * @see #getYandDerivatives(double, int) - * @see #calculatePolynomialCoefficients() - * @see #calculatePolynomialCoefficients(AbstractDataSet) - * @see #calculatePolynomialCoefficients(double[], double[]) - */ - - public double getY(double x) { - int n = polynomialCoefficients.length - 1; - double y = polynomialCoefficients[n]; - for (int j = n - 1; j >= 0; j--) { - y = y * x + polynomialCoefficients[j]; - } - - return y; - } - - /** - * Uses the polynom with the calculated coefficients to calculate the - * y value and the derivatives at the point x, - * y. This algorithm was taken from:
- * - * William H. Press, Saul A. Teukolosky, William T. Vetterling, Brian P. Flannery, - * "Numerical Recipes in C - The Art of Scientific Computing", Second Edition, - * Cambridge University Press, - * ISBN 0-521-43108-5, - * chapter 5, pages 173-176.
- * The Neville's algorithm which is used in the polynomialInterpolation- - * routines returns also the error of this interpolated point. - * - * @param x the x value - * @param ndDerivateNumber the number of the calculated derivatives - * @return the interpolated y value at ...[0], the 1st derivativ value at - * ...[1], the 2nd derivativ at ...[2] and so on ... - * @see #getY(double) - * @see #polynomialInterpolation(double) - * @see #polynomialInterpolation(AbstractDataSet, double) - * @see #polynomialInterpolation(double[], double[], double) - * @see #calculatePolynomialCoefficients() - * @see #calculatePolynomialCoefficients(AbstractDataSet) - * @see #calculatePolynomialCoefficients(double[], double[]) - */ - public double[] getYandDerivatives(double x, int ndDerivateNumber) - throws InterpolationException { - if (ndDerivateNumber < 0) { - throw new InterpolationException("Negative derivative numbers make no sense."); - } else if (ndDerivateNumber == 0) { - double[] pd = new double[1]; - pd[0] = getY(x); - return pd; - } - - int nnd, j, i; - int nc = polynomialCoefficients.length - 1; - double[] pd = new double[ndDerivateNumber + 1]; - double cnst = 1.0; - - pd[0] = polynomialCoefficients[nc]; - for (j = 1; j <= ndDerivateNumber; j++) { - pd[j] = 0.0; - } - for (i = nc - 1; i >= 0; i--) { - nnd = (ndDerivateNumber < (nc - i) ? ndDerivateNumber : nc - i); - for (j = nnd; j >= 1; j--) { - pd[j] = pd[j] * x + pd[j - 1]; - } - pd[0] = pd[0] * x + polynomialCoefficients[i]; - } - for (i = 2; i <= ndDerivateNumber; i++) { - cnst *= i; - pd[i] *= cnst; - } - - return pd; - } - - /** - * Neville's interpolation algorithm. This algorithm was taken from:
- * - * William H. Press, Saul A. Teukolosky, William T. Vetterling, Brian P. Flannery, - * "Numerical Recipes in C - The Art of Scientific Computing", Second Edition, - * Cambridge University Press, - * ISBN 0-521-43108-5, - * chapter 3, pages 108-122.
- * - * @param x the x value - * @return the interpolated y value and the interpolation error - * @see #polynomialInterpolation(AbstractDataSet, double) - * @see #polynomialInterpolation(double[], double[], double) - * @see #getY(double) - * @see #getYandDerivatives(double, int) - * @see #calculatePolynomialCoefficients() - * @see #calculatePolynomialCoefficients(AbstractDataSet) - * @see #calculatePolynomialCoefficients(double[], double[]) - */ - public PolynomialInterpolationResult polynomialInterpolation(double x) - throws InterpolationException { - if (abstractDataSet == null) { - throw new InterpolationException( - "No data." + " The AbstractDataSet was not defined."); - } - return polynomialInterpolation( - abstractDataSet.getXData(), - abstractDataSet.getYData(), - x); - } - - /** - * Neville's interpolation algorithm. This algorithm was taken from:
- * - * William H. Press, Saul A. Teukolosky, William T. Vetterling, Brian P. Flannery, - * "Numerical Recipes in C - The Art of Scientific Computing", Second Edition, - * Cambridge University Press, - * ISBN 0-521-43108-5, - * chapter 3, pages 108-122.
- * - * @param abstractDataSet the AbstractDataSet - * @param x the x value - * @return the interpolated y value and the interpolation error - * @see #polynomialInterpolation(double) - * @see #polynomialInterpolation(double[], double[], double) - * @see #getY(double) - * @see #getYandDerivatives(double, int) - * @see #calculatePolynomialCoefficients() - * @see #calculatePolynomialCoefficients(AbstractDataSet) - * @see #calculatePolynomialCoefficients(double[], double[]) - */ - public PolynomialInterpolationResult polynomialInterpolation( - AbstractDataSet abstractDataSet, - double x) - throws InterpolationException { - if (abstractDataSet == null) { - throw new InterpolationException( - "No data." + " The AbstractDataSet was not defined."); - } - return polynomialInterpolation( - abstractDataSet.getXData(), - abstractDataSet.getYData(), - x); - } - - /** - * Neville's interpolation algorithm. This algorithm was taken from:
- * - * William H. Press, Saul A. Teukolosky, William T. Vetterling, Brian P. Flannery, - * "Numerical Recipes in C - The Art of Scientific Computing", Second Edition, - * Cambridge University Press, - * ISBN 0-521-43108-5, - * chapter 3, pages 108-122.
- * - * @param xa the array of x values - * @param ya the array of y values - * @param x the x value - * @return the interpolated y value and the interpolation error - * @see #polynomialInterpolation(double) - * @see #polynomialInterpolation(AbstractDataSet, double) - * @see #getY(double) - * @see #getYandDerivatives(double, int) - * @see #calculatePolynomialCoefficients() - * @see #calculatePolynomialCoefficients(AbstractDataSet) - * @see #calculatePolynomialCoefficients(double[], double[]) - */ - public PolynomialInterpolationResult polynomialInterpolation( - double[] xa, - double[] ya, - double x) - throws InterpolationException { - if (xa == null || ya == null) { - throw new InterpolationException("No data."); - } - int i, m, ns = 1; - double den, dif, dift, ho, hp, w; - double[] c = new double[xa.length + 1]; - double[] d = new double[xa.length + 1]; - PolynomialInterpolationResult result = - new PolynomialInterpolationResult(); - - dif = Math.abs(x - xa[0]); - for (i = 1; i <= xa.length; i++) { - if ((dift = Math.abs(x - xa[i - 1])) < dif) { - ns = i; - dif = dift; - } - c[i] = ya[i - 1]; - d[i] = ya[i - 1]; - } - result.y = ya[ns - 1]; - ns--; - for (m = 1; m < xa.length; m++) { - for (i = 1; i <= xa.length - m; i++) { - ho = xa[i - 1] - x; - hp = xa[i + m - 1] - x; - w = c[i + 1] - d[i]; - if ((den = ho - hp) == 0.0) { - if (sloppy) { - System.out.println("Two identical x values. The values must be distinct."); - den = 1.0; - } else { - throw new InterpolationException("Two identical x values."); - } - } - den = w / den; - d[i] = hp * den; - c[i] = ho * den; - } - result.y - += (result.yError = - (2 * ns < (xa.length - m) ? c[ns + 1] : d[ns--])); - } - return result; - } - - /** - * Calculates the coefficients of a polynom of the grade N-1. This - * interpolation algorithm was taken from:
- * - * William H. Press, Saul A. Teukolosky, William T. Vetterling, Brian P. Flannery, - * "Numerical Recipes in C - The Art of Scientific Computing", Second Edition, - * Cambridge University Press, - * ISBN 0-521-43108-5, - * chapter 3, pages 108-122.
- * - * @return the array with the polynomial coefficients y = ...[0] + - * ...[1]*x2 + ...[2]*x3 + ... - * @see #calculatePolynomialCoefficients(AbstractDataSet) - * @see #calculatePolynomialCoefficients(double[], double[]) - * @see #polynomialInterpolation(double) - * @see #polynomialInterpolation(AbstractDataSet, double) - * @see #polynomialInterpolation(double[], double[], double) - * @see #getY(double) - * @see #getYandDerivatives(double, int) - */ - public double[] calculatePolynomialCoefficients() - throws InterpolationException { - if (abstractDataSet == null) { - throw new InterpolationException( - "No data." + " The AbstractDataSet was not defined."); - } - return calculatePolynomialCoefficients( - abstractDataSet.getXData(), - abstractDataSet.getYData()); - } - - /** - * Calculates the coefficients of a polynom of the grade N-1. This - * interpolation algorithm was taken from:
- * - * William H. Press, Saul A. Teukolosky, William T. Vetterling, Brian P. Flannery, - * "Numerical Recipes in C - The Art of Scientific Computing", Second Edition, - * Cambridge University Press, - * ISBN 0-521-43108-5, - * chapter 3, pages 108-122.
- * - * @param abstractDataSet the AbstractDataSet - * @return the array with the polynomial coefficients y = ...[0] + - * ...[1]*x2 + ...[2]*x3 + ... - * @see #calculatePolynomialCoefficients() - * @see #calculatePolynomialCoefficients(double[], double[]) - * @see #polynomialInterpolation(double) - * @see #polynomialInterpolation(AbstractDataSet, double) - * @see #polynomialInterpolation(double[], double[], double) - * @see #getY(double) - * @see #getYandDerivatives(double, int) - */ - public double[] calculatePolynomialCoefficients(AbstractDataSet abstractDataSet) - throws InterpolationException { - if (abstractDataSet == null) { - throw new InterpolationException( - "No data." + " The AbstractDataSet was not defined."); - } - return calculatePolynomialCoefficients( - abstractDataSet.getXData(), - abstractDataSet.getYData()); - } - - /** - * Calculates the coefficients of a polynom of the grade N-1. This - * interpolation algorithm was taken from:
- * - * William H. Press, Saul A. Teukolosky, William T. Vetterling, Brian P. Flannery, - * "Numerical Recipes in C - The Art of Scientific Computing", Second Edition, - * Cambridge University Press, - * ISBN 0-521-43108-5, - * chapter 3, pages 108-122.
- * - * @param x the array of x values - * @param y the array of y values - * @return the array with the polynomial coefficients y = ...[0] + - * ...[1]*x2 + ...[2]*x3 + ... - * @see #calculatePolynomialCoefficients() - * @see #calculatePolynomialCoefficients(AbstractDataSet) - * @see #polynomialInterpolation(double) - * @see #polynomialInterpolation(AbstractDataSet, double) - * @see #polynomialInterpolation(double[], double[], double) - * @see #getY(double) - * @see #getYandDerivatives(double, int) - */ - public double[] calculatePolynomialCoefficients(double x[], double y[]) { - int k, j, i, n = x.length - 1; - double phi, ff, b; - double[] s = new double[n + 1]; - double[] cof = new double[n + 1]; - - for (i = 0; i <= n; i++) { - s[i] = cof[i] = 0.0; - } - s[n] = -x[0]; - - for (i = 1; i <= n; i++) { - for (j = n - i; j <= n - 1; j++) { - s[j] -= x[i] * s[j + 1]; - } - s[n] -= x[i]; - } - - for (j = 0; j < n; j++) { - phi = n + 1; - for (k = n; k >= 1; k--) { - phi = k * s[k] + x[j] * phi; - } - ff = y[j] / phi; - b = 1.0; - for (k = n; k >= 0; k--) { - cof[k] += b * ff; - b = s[k] + x[j] * b; - } - } - return cof; - } -} \ No newline at end of file diff --git a/src/eva2/tools/math/interpolation/SplineInterpolation.java b/src/eva2/tools/math/interpolation/SplineInterpolation.java index 0bd42019..a4b61694 100644 --- a/src/eva2/tools/math/interpolation/SplineInterpolation.java +++ b/src/eva2/tools/math/interpolation/SplineInterpolation.java @@ -1,23 +1,5 @@ -/////////////////////////////////////////////////////////////////////////////// -// Filename: $RCSfile: SplineInterpolation.java,v $ -// Purpose: Some interpolation stuff. -// Language: Java -// Compiler: JDK 1.4 -// Authors: Joerg K. Wegner -// Version: $Revision: 1.1 $ -// $Date: 2003/07/22 19:25:42 $ -// $Author: wegnerj $ -// -// Copyright (c) Dept. Computer Architecture, University of Tuebingen, Germany -// -/////////////////////////////////////////////////////////////////////////////// - package eva2.tools.math.interpolation; -/*==========================================================================* - * IMPORTS - *==========================================================================*/ - /** * Defines the routines for the spline interpolation of data. */ @@ -28,16 +10,10 @@ public class SplineInterpolation { double[] yArray = null; boolean ascendingData = true; - /*------------------------------------------------------------------------* - * constructor - *------------------------------------------------------------------------*/ - /** * Initializes this class. */ public SplineInterpolation() throws InterpolationException { - this.abstractDataSet = null; - this.secondDerivative = null; } /** @@ -62,7 +38,6 @@ public class SplineInterpolation { double[] x = abstractDataSet.getXData(); double[] y = abstractDataSet.getYData(); boolean ascending = false; - boolean descending = false; int n = x.length; xArray = new double[n]; @@ -76,17 +51,11 @@ public class SplineInterpolation { //if(descending)throw new InterpolationException("The x values must be"+ // " in continous ascending/descending order."); ascending = true; - } else { - //if(ascending)throw new InterpolationException("The x values must be"+ - // " in continous ascending/descending order."); - descending = true; } } ascendingData = ascending; if (ascendingData) { - xArray = null; - yArray = null; xArray = abstractDataSet.getXData(); yArray = abstractDataSet.getYData(); } @@ -212,7 +181,7 @@ public class SplineInterpolation { } } h = xa[khi] - xa[klo]; - //System.out.println(""+x+" between "+xa[khi]+" "+xa[klo]); + if (h == 0.0) { throw new InterpolationException("Two identical x values. The values must be distinct."); } @@ -262,7 +231,6 @@ public class SplineInterpolation { } } h = xa[khi] - xa[klo]; - //System.out.println(""+x+" between "+xa[khi]+" "+xa[klo]); if (h == 0.0) { throw new InterpolationException("Two identical x values. The values must be distinct."); } @@ -274,8 +242,4 @@ public class SplineInterpolation { + ((3 * (b * b) - 1) * h * y2a[khi]) / 6.0; return dydx; } -} - -/**************************************************************************** - * END OF FILE - ****************************************************************************/ \ No newline at end of file +} \ No newline at end of file