More general cleanup.

refs #2
This commit is contained in:
Fabian Becker 2014-10-22 21:19:57 +02:00
parent 945889dcaf
commit cb5c709f4b
72 changed files with 409 additions and 1978 deletions

View File

@ -185,9 +185,6 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
return false; return false;
} }
// Age will not be used
//if (this.age != indy.age) return false;
// checking on mutation/crossover probabilities // checking on mutation/crossover probabilities
if (this.mutationProbability != indy.mutationProbability) { if (this.mutationProbability != indy.mutationProbability) {
return false; return false;
@ -203,7 +200,6 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
if (!this.crossoverOperator.equals(indy.crossoverOperator)) { if (!this.crossoverOperator.equals(indy.crossoverOperator)) {
return false; return false;
} }
// System.err.println("Check whether this is semantically meant by equality!!! (AbstractEAIndividual.equals())");
return true; return true;
} else { } else {
return false; return false;
@ -235,10 +231,6 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
return "AbstractEAIndividual"; return "AbstractEAIndividual";
} }
// public String getIndividualName() {
// return this.name;
// }
/** /**
* This method is used when a new offspring is created the increment the * This method is used when a new offspring is created the increment the
* name. * name.
@ -276,28 +268,6 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
*/ */
public abstract boolean equalGenotypes(AbstractEAIndividual individual); 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 * 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) { public void init(InterfaceOptimizationProblem opt) {
initializationOperator.initialize(this, opt); initializationOperator.initialize(this, opt);
// this.defaultInit(opt);
this.mutationOperator.init(this, opt); this.mutationOperator.init(this, opt);
this.crossoverOperator.init(this, opt); this.crossoverOperator.init(this, opt);
} }
@ -411,7 +380,6 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
sb.append("[ "); sb.append("[ ");
for (int i = 0; i < parentTree.length; i++) { for (int i = 0; i < parentTree.length; i++) {
sb.append(parentTree[i].getHeritageTree(depth - 1)); sb.append(parentTree[i].getHeritageTree(depth - 1));
// if ((i+1) < parentTree.length) sb.append(", ");
} }
sb.append("] "); sb.append("] ");
} }
@ -779,7 +747,6 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
} else { } else {
return (constrViolComp > 0); return (constrViolComp > 0);
} }
// return isDominatingFitnessNotEqual(getFitness(), indy.getFitness());
} }
/** /**
@ -1087,8 +1054,6 @@ public abstract class AbstractEAIndividual implements IndividualInterface, java.
} else if (individual instanceof InterfaceDataTypeDouble) { } else if (individual instanceof InterfaceDataTypeDouble) {
double[] d = ((InterfaceDataTypeDouble) individual).getDoubleData(); double[] d = ((InterfaceDataTypeDouble) individual).getDoubleData();
for (int i = 0; i < d.length; i++) { 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]); fm.format("% .3f", d[i]);
if ((i + 1) < d.length) { if ((i + 1) < d.length) {
sb.append(separator); sb.append(separator);

View File

@ -4,11 +4,6 @@ package eva2.optimization.individuals;
* This interface gives access to a double phenotype and except * This interface gives access to a double phenotype and except
* for problemspecific operators should only be used by the * for problemspecific operators should only be used by the
* optimization problem. * 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 { public interface InterfaceDataTypeDouble {

View File

@ -90,10 +90,6 @@ public class OBGAIndividualPermutationData extends AbstractEAIndividual implemen
} }
} }
/************************************************************************************
* AbstractEAIndividual methods
*/
/** /**
* This method will initialize the individual with a given value for the * This method will initialize the individual with a given value for the
* phenotype. * phenotype.
@ -203,11 +199,11 @@ public class OBGAIndividualPermutationData extends AbstractEAIndividual implemen
perm[p] = new int[this.genotype[p].length]; perm[p] = new int[this.genotype[p].length];
ArrayList pot = new ArrayList(); ArrayList pot = new ArrayList();
for (int i = 0; i < this.sizePermutation()[p]; i++) { for (int i = 0; i < this.sizePermutation()[p]; i++) {
pot.add(new Integer(firstindex[p] + i)); pot.add(firstindex[p] + i);
} }
int i = 0; int i = 0;
while (!pot.isEmpty()) { 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++; i++;
} }
} }

View File

@ -296,10 +296,11 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
/** /**
* This method will generate one new individual from the given population * 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 * @return AbstractEAIndividual
*/ */
public AbstractEAIndividual generateNewIndividual(Population pop, int parentIndex) { public AbstractEAIndividual generateNewIndividual(Population population, int parentIndex) {
AbstractEAIndividual indy; AbstractEAIndividual indy;
InterfaceDataTypeDouble esIndy; InterfaceDataTypeDouble esIndy;
@ -309,11 +310,11 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
parents = null; parents = null;
} }
try { 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) { 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; esIndy = (InterfaceDataTypeDouble) indy;
} catch (java.lang.ClassCastException e) { } catch (java.lang.ClassCastException e) {
throw new RuntimeException("Differential Evolution currently requires InterfaceESIndividual as basic data type!"); 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) { switch (this.DEType) {
case DE1_Rand_1: { case DE1_Rand_1: {
// this is DE1 or DE/rand/1 // this is DE1 or DE/rand/1
double[] delta = this.fetchDeltaRandom(pop); double[] delta = this.fetchDeltaRandom(population);
if (parents != null) { if (parents != null) {
parents.add(pop.getEAIndividual(parentIndex)); parents.add(population.getEAIndividual(parentIndex));
} // Add wherever oX is used directly } // Add wherever oX is used directly
for (int i = 0; i < oX.length; i++) { for (int i = 0; i < oX.length; i++) {
vX[i] = oX[i] + this.getCurrentF() * delta[i]; vX[i] = oX[i] + this.getCurrentF() * delta[i];
@ -336,10 +337,10 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
} }
case DE_CurrentToRand: { case DE_CurrentToRand: {
// this is DE/current-to-rand/1 // this is DE/current-to-rand/1
double[] rndDelta = this.fetchDeltaRandom(pop); double[] rndDelta = this.fetchDeltaRandom(population);
double[] bestDelta = this.fetchDeltaCurrentRandom(pop, esIndy); double[] bestDelta = this.fetchDeltaCurrentRandom(population, esIndy);
if (parents != null) { if (parents != null) {
parents.add(pop.getEAIndividual(parentIndex)); parents.add(population.getEAIndividual(parentIndex));
} // Add wherever oX is used directly } // Add wherever oX is used directly
for (int i = 0; i < oX.length; i++) { for (int i = 0; i < oX.length; i++) {
vX[i] = oX[i] + this.getCurrentLambda() * bestDelta[i] + this.getCurrentF() * rndDelta[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: { case DE2_CurrentToBest: {
// this is DE2 or DE/current-to-best/1 // this is DE2 or DE/current-to-best/1
double[] rndDelta = this.fetchDeltaRandom(pop); double[] rndDelta = this.fetchDeltaRandom(population);
double[] bestDelta = this.fetchDeltaBest(pop, esIndy); double[] bestDelta = this.fetchDeltaBest(population, esIndy);
if (parents != null) { if (parents != null) {
parents.add(pop.getEAIndividual(parentIndex)); parents.add(population.getEAIndividual(parentIndex));
} // Add wherever oX is used directly } // Add wherever oX is used directly
for (int i = 0; i < oX.length; i++) { for (int i = 0; i < oX.length; i++) {
vX[i] = oX[i] + this.getCurrentLambda() * bestDelta[i] + this.getCurrentF() * rndDelta[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: { case DE_Best_1: {
// DE/best/1 // DE/best/1
AbstractEAIndividual bestIndy = getBestIndy(pop); AbstractEAIndividual bestIndy = getBestIndy(population);
oX = getGenotype(bestIndy); oX = getGenotype(bestIndy);
if (parents != null) { if (parents != null) {
parents.add(bestIndy); parents.add(bestIndy);
} // Add best instead of preselected } // Add best instead of preselected
double[] delta1 = this.fetchDeltaRandom(pop); double[] delta1 = this.fetchDeltaRandom(population);
for (int i = 0; i < oX.length; i++) { for (int i = 0; i < oX.length; i++) {
vX[i] = oX[i] + this.getCurrentF() * delta1[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: { case DE_Best_2: {
// DE/best/2 // DE/best/2
AbstractEAIndividual bestIndy = getBestIndy(pop); AbstractEAIndividual bestIndy = getBestIndy(population);
oX = getGenotype(bestIndy); oX = getGenotype(bestIndy);
if (parents != null) { if (parents != null) {
parents.add(bestIndy); parents.add(bestIndy);
} // Add best instead of preselected } // Add best instead of preselected
double[] delta1 = this.fetchDeltaRandom(pop); double[] delta1 = this.fetchDeltaRandom(population);
double[] delta2 = this.fetchDeltaRandom(pop); double[] delta2 = this.fetchDeltaRandom(population);
for (int i = 0; i < oX.length; i++) { for (int i = 0; i < oX.length; i++) {
vX[i] = oX[i] + this.getCurrentF() * delta1[i] + this.getCurrentF() * delta2[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: { case TrigonometricDE: {
// this is trigonometric mutation // this is trigonometric mutation
if (parents != null) { if (parents != null) {
parents.add(pop.getEAIndividual(parentIndex)); parents.add(population.getEAIndividual(parentIndex));
} // Add wherever oX is used directly } // Add wherever oX is used directly
if (RNG.flipCoin(this.mt)) { if (RNG.flipCoin(this.mt)) {
double[] xk, xl; double[] xk, xl;
@ -396,8 +397,8 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
InterfaceDataTypeDouble indy1 = null, indy2 = null; InterfaceDataTypeDouble indy1 = null, indy2 = null;
try { try {
// and i got indy! // and i got indy!
indy1 = (InterfaceDataTypeDouble) pop.get(RNG.randomInt(0, pop.size() - 1)); indy1 = (InterfaceDataTypeDouble) population.get(RNG.randomInt(0, population.size() - 1));
indy2 = (InterfaceDataTypeDouble) pop.get(RNG.randomInt(0, pop.size() - 1)); indy2 = (InterfaceDataTypeDouble) population.get(RNG.randomInt(0, population.size() - 1));
if (parents != null) { if (parents != null) {
parents.add((AbstractEAIndividual) indy1); parents.add((AbstractEAIndividual) indy1);
parents.add((AbstractEAIndividual) indy2); parents.add((AbstractEAIndividual) indy2);
@ -416,9 +417,9 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
} }
} else { } else {
// this is DE1 // this is DE1
double[] delta = this.fetchDeltaRandom(pop); double[] delta = this.fetchDeltaRandom(population);
if (parents != null) { if (parents != null) {
parents.add(pop.getEAIndividual(parentIndex)); parents.add(population.getEAIndividual(parentIndex));
} // Add wherever oX is used directly } // Add wherever oX is used directly
for (int i = 0; i < oX.length; i++) { for (int i = 0; i < oX.length; i++) {
vX[i] = oX[i] + this.getCurrentF() * delta[i]; vX[i] = oX[i] + this.getCurrentF() * delta[i];

View File

@ -61,7 +61,6 @@ public abstract class AbstractDynTransProblem extends AbstractSynchronousOptimiz
double delta = transLength(getCurrentProblemTime()); double delta = transLength(getCurrentProblemTime());
if (isExtraPlot()) { if (isExtraPlot()) {
if (myplot != null) { if (myplot != null) {
// myplot.addGraph(0, 1);
myplot.jump(); myplot.jump();
} else { } else {
double[] tmpD = new double[2]; 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); this.myplot = new Plot("population measures", "x1", "x2", tmpD, tmpD);
} }
myplot.setConnectedPoint(population.getFunctionCalls(), delta, 0); myplot.setConnectedPoint(population.getFunctionCalls(), delta, 0);
//myplot.setUnconnectedPoint(population.getFunctionCalls(), population.getPopulationMeasures()[2], 2);
} else { } else {
myplot = null; myplot = null;
} }
@ -142,10 +140,6 @@ public abstract class AbstractDynTransProblem extends AbstractSynchronousOptimiz
return problemDimension; return problemDimension;
} }
/**
* ***************************************************************************
* These are for the GUI
*/
@Override @Override
public String getStringRepresentationForProblem(InterfaceOptimizer opt) { public String getStringRepresentationForProblem(InterfaceOptimizer opt) {
return "DynTransProblem"; return "DynTransProblem";

View File

@ -52,11 +52,9 @@ public abstract class AbstractDynamicOptimizationProblem extends AbstractOptimiz
* A constructor. * A constructor.
*/ */
public AbstractDynamicOptimizationProblem() { public AbstractDynamicOptimizationProblem() {
//System.out.println("AbstractDynamicOptimizationProblem()");
bExtraPlot = false; bExtraPlot = false;
myplot = null; myplot = null;
idealInd = null; idealInd = null;
// initialize(0, 1., 0.1);
} }
/** /**
@ -103,7 +101,6 @@ public abstract class AbstractDynamicOptimizationProblem extends AbstractOptimiz
*/ */
@Override @Override
public void initializePopulation(Population population) { public void initializePopulation(Population population) {
//initializeProblem(); // this shouldnt be necessary
this.initPopulationAt(population, getCurrentProblemTime()); this.initPopulationAt(population, getCurrentProblemTime());
} }
@ -225,7 +222,6 @@ public abstract class AbstractDynamicOptimizationProblem extends AbstractOptimiz
*/ */
public abstract AbstractEAIndividual getCurrentOptimum(); public abstract AbstractEAIndividual getCurrentOptimum();
/******************** The most important methods ****************************************/
/** /**
* This method evaluates a single individual and sets the fitness value at default time stamp 0. * 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()); evaluateAt(individual, getCurrentProblemTime());
} }
/**********************************************************************************************************************
* These are for GUI
*/
/** /**
* Override population evaluation to do some data output. * Override population evaluation to do some data output.
* *
@ -289,26 +282,10 @@ public abstract class AbstractDynamicOptimizationProblem extends AbstractOptimiz
*/ */
@Override @Override
public void evaluatePopulationEnd(Population population) { 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()); AbstractEAIndividual popBest = (AbstractEAIndividual) (population.getBestIndividual());
if (idealInd == null) { if (idealInd == null) {
idealInd = (AbstractEAIndividual) popBest.clone(); 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) { protected void setExtraPlot(boolean doPlot) {

View File

@ -377,7 +377,7 @@ public abstract class AbstractMultiModalProblemKnown extends AbstractProblemDoub
*/ */
@Override @Override
public void setDefaultAccuracy(double epsilon) { public void setDefaultAccuracy(double epsilon) {
super.SetDefaultAccuracy(epsilon); super.setDefaultAccuracy(epsilon);
} }
@Override @Override

View File

@ -65,16 +65,9 @@ public abstract class AbstractMultiObjectiveOptimizationProblem extends Abstract
if (border == null) { if (border == null) {
prob.border = new double[fitness.length][2]; prob.border = new double[fitness.length][2];
} else if (fitness.length != prob.border.length) { } 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]; prob.border = new double[fitness.length][2];
} }
for (int j = 0; j < fitness.length; j++) { 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][0] = Math.min(prob.border[j][0], fitness[j]);
prob.border[j][1] = Math.max(prob.border[j][1], 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++) { for (int i = 0; i < pop.size(); i++) {
tmpFitLen = ((AbstractEAIndividual) pop.get(i)).getFitness().length; tmpFitLen = ((AbstractEAIndividual) pop.get(i)).getFitness().length;
if (tmpFitLen <= 1) { if (tmpFitLen <= 1) {
//System.out.println("There is a single objective individual in the population!");
return false; return false;
} }
if (tmpFitLen != bestFitLen) { if (tmpFitLen != bestFitLen) {
//System.out.println("Not all individual have equal length fitness!");
return false; return false;
} }
} }
@ -232,16 +223,9 @@ public abstract class AbstractMultiObjectiveOptimizationProblem extends Abstract
if (border == null) { if (border == null) {
this.border = new double[fitness.length][2]; this.border = new double[fitness.length][2];
} else if (fitness.length != this.border.length) { } 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]; this.border = new double[fitness.length][2];
} }
for (int j = 0; j < fitness.length; j++) { 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][0] = Math.min(this.border[j][0], fitness[j]);
this.border[j][1] = Math.max(this.border[j][1], 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) { public static void drawProblem(Population pFront, Population archive, Plot plot) {
ArchivingAllDominating tmpArch = new ArchivingAllDominating(); ArchivingAllDominating tmpArch = new ArchivingAllDominating();
// Population tmpPop = null;
// i want to plot the pareto front for MOEA and other strategies // i want to plot the pareto front for MOEA and other strategies
// but i have to differentiate between the case where // but i have to differentiate between the case where
@ -377,7 +360,6 @@ public abstract class AbstractMultiObjectiveOptimizationProblem extends Abstract
Population tmpPop = null; Population tmpPop = null;
if (p.getGeneration() > 2) { 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 // i want to plot the pareto front for MOEA and other strategies
// but i have to differentiate between the case where // but i have to differentiate between the case where
// there is a true MOEA at work and where the // there is a true MOEA at work and where the
@ -519,13 +501,13 @@ public abstract class AbstractMultiObjectiveOptimizationProblem extends Abstract
@Override @Override
public Double getDoublePlotValue(Population pop) { public Double getDoublePlotValue(Population pop) {
if (AbstractMultiObjectiveOptimizationProblem.isPopulationMultiObjective(pop)) { if (AbstractMultiObjectiveOptimizationProblem.isPopulationMultiObjective(pop)) {
return new Double(this.calculateMetric(pop)); return this.calculateMetric(pop);
} else { } else {
// in this case the local Pareto-Front could be multi-objective // in this case the local Pareto-Front could be multi-objective
if (AbstractMultiObjectiveOptimizationProblem.isPopulationMultiObjective(this.paretoFront)) { if (AbstractMultiObjectiveOptimizationProblem.isPopulationMultiObjective(this.paretoFront)) {
return new Double(this.calculateMetric(this.paretoFront)); return this.calculateMetric(this.paretoFront);
} else { } 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)); return ToolBox.appendArrays(result, super.getAdditionalDataValue(pop));
} }
/*
* (non-Javadoc)
* @see eva2.problems.AbstractOptimizationProblem#getAdditionalDataInfo(eva2.optimization.PopulationInterface)
*/
@Override @Override
public String[] getAdditionalDataInfo() { public String[] getAdditionalDataInfo() {
String[] superInfo = super.getAdditionalDataInfo(); String[] superInfo = super.getAdditionalDataInfo();
@ -569,10 +547,6 @@ public abstract class AbstractMultiObjectiveOptimizationProblem extends Abstract
"Pareto metric on the collected pareto front"}, superInfo); "Pareto metric on the collected pareto front"}, superInfo);
} }
/*
* (non-Javadoc)
* @see eva2.problems.InterfaceOptimizationProblem#getStringRepresentationForProblem(eva2.optimization.strategies.InterfaceOptimizer)
*/
@Override @Override
public String getStringRepresentationForProblem(InterfaceOptimizer opt) { public String getStringRepresentationForProblem(InterfaceOptimizer opt) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
@ -608,32 +582,6 @@ public abstract class AbstractMultiObjectiveOptimizationProblem extends Abstract
return this.outputDimension; 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 * This method allows you to set a Multiobjective to
* Singleobjective converter if you choose to. * Singleobjective converter if you choose to.

View File

@ -71,7 +71,6 @@ public abstract class AbstractOptimizationProblem implements InterfaceOptimizati
private int parallelthreads = 1; private int parallelthreads = 1;
protected AbstractEAIndividual template = null; protected AbstractEAIndividual template = null;
// private transient ArrayList<ParamChangeListener> changeListeners = null;
private double defaultAccuracy = 0.001; // default accuracy for identifying optima. private double defaultAccuracy = 0.001; // default accuracy for identifying optima.
@ -102,8 +101,6 @@ public abstract class AbstractOptimizationProblem implements InterfaceOptimizati
@Override @Override
public abstract void initializeProblem(); public abstract void initializeProblem();
/******************** The most important methods ****************************************/
/** /**
* This method inits a given population * This method inits a given population
* *
@ -205,8 +202,6 @@ public abstract class AbstractOptimizationProblem implements InterfaceOptimizati
population.init(); population.init();
} }
/******************** Some output methods *******************************************/
/** /**
* This method allows you to output a string that describes a found solution * This method allows you to output a string that describes a found solution
* in a way that is most suitable for a given problem. * 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 clusterSigma minimum cluster distance
* @param maxEvalsPerIndy maximum number of evaluations or -1 to take the maximum * @param maxEvalsPerIndy maximum number of evaluations or -1 to take the maximum
* @return * @return
* @see #isPotentialOptimumNMS(AbstractEAIndividual, double, double, int)
*/ */
public static Population extractPotentialOptima(AbstractOptimizationProblem prob, Population pop, public static Population extractPotentialOptima(AbstractOptimizationProblem prob, Population pop,
double epsilonPhenoSpace, double epsilonFitConv, double clusterSigma, int maxEvalsPerIndy) { double epsilonPhenoSpace, double epsilonFitConv, double clusterSigma, int maxEvalsPerIndy) {
Population potOptima = new Population(); Population potOptima = new Population();
for (int i = 0; i < pop.size(); ++i) { for (int i = 0; i < pop.size(); ++i) {
//System.out.println("Refining " + i + " of " + population.size());
AbstractEAIndividual indy = pop.getEAIndividual(i); AbstractEAIndividual indy = pop.getEAIndividual(i);
// System.out.println("bef: " + indy.toString());
boolean isConverged = AbstractOptimizationProblem.isPotentialOptimumNMS(prob, indy, epsilonPhenoSpace, epsilonFitConv, maxEvalsPerIndy); boolean isConverged = AbstractOptimizationProblem.isPotentialOptimumNMS(prob, indy, epsilonPhenoSpace, epsilonFitConv, maxEvalsPerIndy);
if (isConverged) { if (isConverged) {
potOptima.addIndividual(indy); potOptima.addIndividual(indy);
@ -514,11 +506,7 @@ public abstract class AbstractOptimizationProblem implements InterfaceOptimizati
return false; // dont waste any more evaluations on this candidate return false; // dont waste any more evaluations on this candidate
} }
} }
if (overallDist < epsilon) { return overallDist < epsilon;
return true;
} else {
return false;
}
} }
/** /**
@ -565,21 +553,8 @@ public abstract class AbstractOptimizationProblem implements InterfaceOptimizati
} }
int evalsPerf = PostProcess.processSingleCandidatesNMCMA(PostProcessMethod.nelderMead, pop, term, initRelPerturb, prob); int evalsPerf = PostProcess.processSingleCandidatesNMCMA(PostProcessMethod.nelderMead, pop, term, initRelPerturb, prob);
overallDist = metric.distance(indy, pop.getBestEAIndividual()); 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.movedDistanceKey, overallDist);
orig.putData(PostProcess.movedToPositionKey, pop.getBestEAIndividual().getDoublePosition()); 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); return (overallDist < epsilonPhenoSpace);
} }
@ -588,10 +563,6 @@ public abstract class AbstractOptimizationProblem implements InterfaceOptimizati
return defaultAccuracy; return defaultAccuracy;
} }
public void SetDefaultAccuracy(double defAcc) {
defaultAccuracy = defAcc;
}
public void setDefaultAccuracy(double defAcc) { public void setDefaultAccuracy(double defAcc) {
defaultAccuracy = defAcc; defaultAccuracy = defAcc;
} }

View File

@ -8,8 +8,7 @@ public abstract class AbstractParallelOptimizationProblem extends AbstractOptimi
private boolean parallelize = false; private boolean parallelize = false;
@Override @Override
public void initializeProblem() { public void initializeProblem() { }
}
/** /**
* This method returns a global info string * This method returns a global info string

View File

@ -11,8 +11,6 @@ import java.util.BitSet;
/** /**
* An abstract problem based on binary data. * An abstract problem based on binary data.
*
* @author mkron
*/ */
public abstract class AbstractProblemBinary extends AbstractOptimizationProblem { public abstract class AbstractProblemBinary extends AbstractOptimizationProblem {
@ -63,16 +61,6 @@ public abstract class AbstractProblemBinary extends AbstractOptimizationProblem
*/ */
public abstract int getProblemDimension(); 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 @Override
public void initializePopulation(Population population) { public void initializePopulation(Population population) {
((InterfaceDataTypeBinary) this.template).setBinaryDataLength(this.getProblemDimension()); ((InterfaceDataTypeBinary) this.template).setBinaryDataLength(this.getProblemDimension());
@ -84,9 +72,6 @@ public abstract class AbstractProblemBinary extends AbstractOptimizationProblem
initTemplate(); initTemplate();
} }
/**********************************************************************************************************************
* These are for GUI
*/
/** /**
* This method allows the CommonJavaObjectEditorPanel to read the * This method allows the CommonJavaObjectEditorPanel to read the
* name to the current object. * name to the current object.
@ -122,5 +107,4 @@ public abstract class AbstractProblemBinary extends AbstractOptimizationProblem
sb.append(this.getProblemDimension()); sb.append(this.getProblemDimension());
return sb.toString(); return sb.toString();
} }
} }

View File

@ -86,7 +86,7 @@ public abstract class AbstractProblemDouble extends AbstractOptimizationProblem
protected void cloneObjects(AbstractProblemDouble o) { protected void cloneObjects(AbstractProblemDouble o) {
this.defaultRange = o.defaultRange; this.defaultRange = o.defaultRange;
this.noise = o.noise; this.noise = o.noise;
this.SetDefaultAccuracy(o.getDefaultAccuracy()); this.setDefaultAccuracy(o.getDefaultAccuracy());
if (o.template != null) { if (o.template != null) {
this.template = (AbstractEAIndividual) o.template.clone(); this.template = (AbstractEAIndividual) o.template.clone();
} }

View File

@ -77,11 +77,6 @@ public abstract class AbstractProblemInteger extends AbstractOptimizationProblem
*/ */
public abstract double[] evaluate(int[] x); public abstract double[] evaluate(int[] x);
/**
* *******************************************************************************************************************
* These are for GUI
*/
@Override @Override
public String getName() { public String getName() {
return "AbstractProblemInteger"; return "AbstractProblemInteger";

View File

@ -11,10 +11,6 @@ import eva2.optimization.population.Population;
* so that the problem changes after every evaluation. This of course under the simplification * 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 * 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). * can not be taken into account (or just discretely approximated).
*
* @author M.Kronfeld
* <p/>
* Jan 4, 2007
*/ */
public abstract class AbstractSynchronousOptimizationProblem extends public abstract class AbstractSynchronousOptimizationProblem extends
AbstractDynamicOptimizationProblem { AbstractDynamicOptimizationProblem {
@ -31,7 +27,6 @@ public abstract class AbstractSynchronousOptimizationProblem extends
* measures the "distance" which the problem shifts when it changes * measures the "distance" which the problem shifts when it changes
*/ */
protected double shiftPerChange; 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 @Override
protected void changeProblemAt(double problemTime) { protected void changeProblemAt(double problemTime) {
incProblemTime(shiftPerChange); incProblemTime(shiftPerChange);
evalsSinceChange = 0.; evalsSinceChange = 0.;
} }
/* (non-Javadoc)
* @see eva2.server.oa.go.OptimizationProblems.AbstractDynamicOptimizationProblem#problemToChangeAt(double)
*/
@Override @Override
protected boolean problemToChangeAt(double problemTime) { protected boolean problemToChangeAt(double problemTime) {
return (evalsSinceChange >= constantProblemEvals); return (evalsSinceChange >= constantProblemEvals);
@ -78,9 +67,6 @@ public abstract class AbstractSynchronousOptimizationProblem extends
constantProblemEvals = constEvals; constantProblemEvals = constEvals;
} }
/* (non-Javadoc)
* @see eva2.server.oa.go.OptimizationProblems.AbstractDynamicOptimizationProblem#countEvaluation()
*/
@Override @Override
protected void countEvaluation() { protected void countEvaluation() {
evalsSinceChange += 1.; evalsSinceChange += 1.;
@ -99,7 +85,6 @@ public abstract class AbstractSynchronousOptimizationProblem extends
@Override @Override
public void setFrequency(double frequency) { public void setFrequency(double frequency) {
super.setFrequency(frequency); super.setFrequency(frequency);
//if (frequency > 1.) System.out.println("warning, frequency should be <= 1 (setFrequency)");
if (isFrequencyRelative()) { if (isFrequencyRelative()) {
// bogus. this must be reset right before population evaluation // bogus. this must be reset right before population evaluation
setConstantProblemEvals(9999999); setConstantProblemEvals(9999999);
@ -109,10 +94,6 @@ public abstract class AbstractSynchronousOptimizationProblem extends
} }
} }
/* (non-Javadoc)
* @see eva2.server.oa.go.OptimizationProblems.AbstractDynamicOptimizationProblem#setFrequencyRelative(boolean)
*/
@Override @Override
public void setFrequencyRelative(boolean frequencyRelative) { public void setFrequencyRelative(boolean frequencyRelative) {
super.setFrequencyRelative(frequencyRelative); super.setFrequencyRelative(frequencyRelative);
@ -127,4 +108,4 @@ public abstract class AbstractSynchronousOptimizationProblem extends
setConstantProblemEvals(population.size() / getFrequency()); setConstantProblemEvals(population.size() / getFrequency());
} }
} }
} }

View File

@ -347,7 +347,6 @@ public class BKnapsackProblem extends AbstractProblemBinary implements java.io.S
result.append(this.punish); result.append(this.punish);
result.append("\n"); result.append("\n");
result.append("Solution representation:\n"); result.append("Solution representation:\n");
//result += this.template.getSolutionRepresentationFor();
return result.toString(); return result.toString();
} }

View File

@ -154,11 +154,6 @@ public class DynJumpProblem extends eva2.problems.AbstractDynTransProblem {
return null; return null;
} }
/**
* ***********************************************************************
* These are for the GUI
*/
@Override @Override
public String getStringRepresentationForProblem(InterfaceOptimizer opt) { public String getStringRepresentationForProblem(InterfaceOptimizer opt) {
return "DynJumpProblem"; return "DynJumpProblem";

View File

@ -53,7 +53,6 @@ public class ExternalRuntimeProblem extends AbstractOptimizationProblem
writer.write(c); writer.write(c);
writer.flush(); writer.flush();
} }
// System.out.println("monitor-thread finished!");
} catch (IOException ioe) { } catch (IOException ioe) {
System.err.println("IOException in MonitorInputStreamThread/ExternalRuntimeProblem: " + ioe.getMessage()); System.err.println("IOException in MonitorInputStreamThread/ExternalRuntimeProblem: " + ioe.getMessage());
ioe.printStackTrace(System.err); ioe.printStackTrace(System.err);
@ -208,7 +207,6 @@ public class ExternalRuntimeProblem extends AbstractOptimizationProblem
@Override @Override
public void evaluate(AbstractEAIndividual individual) { public void evaluate(AbstractEAIndividual individual) {
double[] x; double[] x;
// double[] fitness;
x = getXVector(individual); x = getXVector(individual);
@ -266,7 +264,6 @@ public class ExternalRuntimeProblem extends AbstractOptimizationProblem
line = line.trim(); line = line.trim();
String[] parts = line.split(colSepRegExp); String[] parts = line.split(colSepRegExp);
Collections.addAll(results, parts); Collections.addAll(results, parts);
// results.add(line);
} }
br.close(); br.close();
} catch (IOException e) { } catch (IOException e) {
@ -463,7 +460,6 @@ public class ExternalRuntimeProblem extends AbstractOptimizationProblem
this.additionalArg = additionalArg; this.additionalArg = additionalArg;
} }
// @Override
@Override @Override
public Object getInitializationRange() { public Object getInitializationRange() {
if (initializationRange == null) { if (initializationRange == null) {

View File

@ -69,7 +69,6 @@ public class F13Problem extends AbstractProblemDoubleOffset implements Interface
result[0] -= xi * Math.sin(Math.sqrt(Math.abs(xi))); result[0] -= xi * Math.sin(Math.sqrt(Math.abs(xi)));
} }
result[0] += (418.9829 * problemDimension); result[0] += (418.9829 * problemDimension);
// res = cn-sum_i(xi*sin(sqrt(abs(xi))))
return result; return result;
} }
@ -86,19 +85,16 @@ public class F13Problem extends AbstractProblemDoubleOffset implements Interface
result += "Dimension : " + this.problemDimension + "\n"; result += "Dimension : " + this.problemDimension + "\n";
result += "Noise level : " + this.getNoise() + "\n"; result += "Noise level : " + this.getNoise() + "\n";
result += "Solution representation:\n"; result += "Solution representation:\n";
//result += this.template.getSolutionRepresentationFor();
return result; return result;
} }
@Override @Override
public SolutionHistogram getHistogram() { public SolutionHistogram getHistogram() {
// EVAERROR.errorMsgOnce("Warning: Restore line in getHistogram for evaluation on F13Problem ???");
if (getProblemDimension() < 15) { if (getProblemDimension() < 15) {
return new SolutionHistogram(0, 800, 16); return new SolutionHistogram(0, 800, 16);
} else if (getProblemDimension() < 25) { } else if (getProblemDimension() < 25) {
return new SolutionHistogram(0, 1600, 16); return new SolutionHistogram(0, 1600, 16);
} }
// else if (getProblemDimension() < 35) return new SolutionHistogram(0, 1600, 16);
else { else {
return new SolutionHistogram(0, 3200, 12); return new SolutionHistogram(0, 3200, 12);
} }
@ -117,6 +113,6 @@ public class F13Problem extends AbstractProblemDoubleOffset implements Interface
@Override @Override
public void setDefaultAccuracy(double v) { public void setDefaultAccuracy(double v) {
super.SetDefaultAccuracy(v); super.setDefaultAccuracy(v);
} }
} }

View File

@ -15,7 +15,7 @@ public class F15Problem extends AbstractProblemDouble implements Serializable, I
public F15Problem() { public F15Problem() {
super(); super();
super.SetDefaultAccuracy(0.00001); super.setDefaultAccuracy(0.00001);
setDefaultRange(10); setDefaultRange(10);
} }

View File

@ -137,7 +137,7 @@ public class F6Problem extends AbstractProblemDoubleOffset
@Override @Override
public void setDefaultAccuracy(double acc) { public void setDefaultAccuracy(double acc) {
super.SetDefaultAccuracy(acc); super.setDefaultAccuracy(acc);
} }
@Override @Override

View File

@ -12,8 +12,6 @@ import eva2.tools.EVAERROR;
* function by scaling it logarithmically. This avoids ugly functions in GP. To activate scaling, * 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 * set the scStart and scLimit parameters to positive values. Function values y with |y|>scStart
* will be rescaled to values below scLimit. * will be rescaled to values below scLimit.
*
* @author mkron
*/ */
public class GPFunctionProblem extends AbstractProblemDouble implements InterfaceProgramProblem { public class GPFunctionProblem extends AbstractProblemDouble implements InterfaceProgramProblem {
InterfaceProgram gpProblem = null; InterfaceProgram gpProblem = null;
@ -109,7 +107,7 @@ public class GPFunctionProblem extends AbstractProblemDouble implements Interfac
/** /**
* Scale the allover fitness value. * Scale the allover fitness value.
* *
* @param doubleValue * @param v
* @return * @return
*/ */
public double scaleFit(double v) { 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 @Override
public int getProblemDimension() { public int getProblemDimension() {
return dim; return dim;

View File

@ -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 * 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 * there's so much going on. For cases where the evaluation function is very time-consuming, adding sleep time
* might be an option. * might be an option.
*
* @author mkron
*/ */
public class MatlabEvalMediator { public class MatlabEvalMediator {
volatile Boolean requesting = false; volatile Boolean requesting = false;
@ -71,13 +69,7 @@ public class MatlabEvalMediator {
double[] requestEval(MatlabProblem mp, Object x) { double[] requestEval(MatlabProblem mp, Object x) {
this.mp = mp; this.mp = mp;
question = x; question = x;
// System.err.println("IN REQUESTEVAL, x is " + BeanInspector.toString(x));
if (question.getClass().isArray()) { 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) { if (question == null) {
System.err.println("Error: requesting evaluation for null array!"); 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()); System.err.println("Error, requesting evaluation for invalid data type! " + question.getClass());
} }
} }
// logMPAndSysOut("Synch requesting A requestEval " + getState());
synchronized (requesting) { //MdP synchronized (requesting) { //MdP
// logMPAndSysOut(" in synch requesting A requestEval " + getState());
if (requesting) { if (requesting) {
String msg = "Warning: already in requesting state when request arrived!"; String msg = "Warning: already in requesting state when request arrived!";
System.err.println(msg); System.err.println(msg);
logMP(msg); logMP(msg);
} }
requesting = true; 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 { try {
requests.acquire(); requests.acquire();
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -123,7 +95,6 @@ public class MatlabEvalMediator {
} }
logMP("-- Requesting done\n"); logMP("-- Requesting done\n");
// matlab is finished, answer is here // matlab is finished, answer is here
//return null;
return getAnswer(); // return to JE with answer return getAnswer(); // return to JE with answer
} }

View File

@ -53,15 +53,10 @@ public class MatlabProblem extends AbstractOptimizationProblem implements Interf
this.handler = o.handler; this.handler = o.handler;
this.runnable = o.runnable; this.runnable = o.runnable;
this.allowSingleRunnable = o.allowSingleRunnable; this.allowSingleRunnable = o.allowSingleRunnable;
// this.jmInterface = new String(o.jmInterface);
this.problemDimension = o.problemDimension; 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.range = o.range;
this.dataType = o.dataType; this.dataType = o.dataType;
this.initialRange = o.initialRange; this.initialRange = o.initialRange;
// this.mtCmd = o.mtCmd;
// currArray = null;
} }
@Override @Override
@ -69,15 +64,6 @@ public class MatlabProblem extends AbstractOptimizationProblem implements Interf
return new MatlabProblem(this); 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. * 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); 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 * Constructor of real or integer valued problem, the range will be converted
* to integer in the latter case. * 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) { private void init(int dim, MatlabProblemDataTypeEnum datType, double[][] globalRange, double[][] initRange, String outFile) {
this.problemDimension = dim; 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 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]; this.range = new double[globalRange.length][globalRange[0].length];
for (int i = 0; i < this.range.length; i++) { for (int i = 0; i < this.range.length; i++) {
@ -344,7 +319,6 @@ public class MatlabProblem extends AbstractOptimizationProblem implements Interf
* @param outputFilePrefix * @param outputFilePrefix
* @param specParams * @param specParams
* @param specValues * @param specValues
* @see OptimizerFactory.getOptRunnable
*/ */
public void optimize(final int optType, String outputFilePrefix, Object[] specParams, Object[] specValues) { public void optimize(final int optType, String outputFilePrefix, Object[] specParams, Object[] specValues) {
if (allowSingleRunnable && (runnable != null) && (!runnable.isFinished())) { if (allowSingleRunnable && (runnable != null) && (!runnable.isFinished())) {

View File

@ -150,7 +150,10 @@ public class PSymbolicRegression extends AbstractOptimizationProblem implements
/** /**
* This method inits a given population * 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) { public static void initPopulation(Population pop, InterfaceProgramProblem prob, boolean useInnerConsts, int numConsts) {
AbstractEAIndividual template; AbstractEAIndividual template;
@ -240,8 +243,8 @@ public class PSymbolicRegression extends AbstractOptimizationProblem implements
for (int j = 0; j < this.numberOfCheckPoints; j++) { for (int j = 0; j < this.numberOfCheckPoints; j++) {
setCheckPoint(x, j); setCheckPoint(x, j);
tmpValue = ((Double) program.evaluate(this)).doubleValue(); tmpValue = (Double) program.evaluate(this);
fitness += Math.pow((this.targetFunction.evaluateFunction(this.x) - ((Double) program.evaluate(this)).doubleValue()), 2); fitness += Math.pow((this.targetFunction.evaluateFunction(this.x) - (Double) program.evaluate(this)), 2);
} }
fitness /= (double) this.numberOfCheckPoints; fitness /= (double) this.numberOfCheckPoints;
@ -262,7 +265,7 @@ public class PSymbolicRegression extends AbstractOptimizationProblem implements
program = ((InterfaceDataTypeProgram) this.overallBestIndividuum).getProgramData()[0]; program = ((InterfaceDataTypeProgram) this.overallBestIndividuum).getProgramData()[0];
for (int i = 0; i < this.numberOfCheckPoints; i++) { for (int i = 0; i < this.numberOfCheckPoints; i++) {
setCheckPoint(x, i); setCheckPoint(x, i);
tmpValue = ((Double) program.evaluate(this)).doubleValue(); tmpValue = (Double) program.evaluate(this);
this.plot.setConnectedPoint(this.x[0], tmpValue, 0); this.plot.setConnectedPoint(this.x[0], tmpValue, 0);
tmpValue = this.targetFunction.evaluateFunction(this.x); tmpValue = this.targetFunction.evaluateFunction(this.x);
this.plot.setConnectedPoint(this.x[0], tmpValue, 1); this.plot.setConnectedPoint(this.x[0], tmpValue, 1);
@ -309,9 +312,6 @@ public class PSymbolicRegression extends AbstractOptimizationProblem implements
@Override @Override
public Object getSensorValue(String sensor) { public Object getSensorValue(String sensor) {
return PSymbolicRegression.getSensorValue(sensor, x, constants); 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; return vars;
} }
int index = Integer.parseInt(sensor.substring(1)); int index = Integer.parseInt(sensor.substring(1));
return new Double(vars[index]); return vars[index];
} catch (Exception e) { } catch (Exception e) {
System.err.println("Warning, unable to access " + sensor); System.err.println("Warning, unable to access " + sensor);
return vars; return vars;
} }
} else if (sensor.charAt(0) == 'C') { } else if (sensor.charAt(0) == 'C') {
int index = Integer.parseInt(sensor.substring(1)); int index = Integer.parseInt(sensor.substring(1));
return new Double(consts[index]); return consts[index];
} else if (sensor.charAt(0) == 'N') { } else if (sensor.charAt(0) == 'N') {
return (double) vars.length; return (double) vars.length;
} else { } 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 // no actuators in this problem
} }
/**********************************************************************************************************************
* These are for GUI
*/
/** /**
* This method allows the CommonJavaObjectEditorPanel to read the * This method allows the CommonJavaObjectEditorPanel to read the
* name to the current object. * name to the current object.
@ -702,10 +696,4 @@ public class PSymbolicRegression extends AbstractOptimizationProblem implements
System.out.println("Evaluated individual: " + indy); System.out.println("Evaluated individual: " + indy);
return indy.getFitness(); 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);
// }
} }

View File

@ -257,9 +257,6 @@ public class TF1Problem extends AbstractMultiObjectiveOptimizationProblem implem
} }
} }
/**********************************************************************************************************************
* These are for GUI
*/
/** /**
* This method allows the CommonJavaObjectEditorPanel to read the * This method allows the CommonJavaObjectEditorPanel to read the
* name to the current object. * 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."; 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 * 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."; 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 * Since you can apply single objective optimization algorithms on
* multi-objective problems, the problem needs a way to log the pareto- * multi-objective problems, the problem needs a way to log the pareto-

View File

@ -1,11 +1,6 @@
package eva2.problems.regression; 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 { public interface InterfaceRegressionFunction {

View File

@ -1,11 +1,6 @@
package eva2.problems.regression; 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 { 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; return result;
} }
/**********************************************************************************************************************
* These are for GUI
*/
/** /**
* This method allows the CommonJavaObjectEditorPanel to read the * This method allows the CommonJavaObjectEditorPanel to read the
* name to the current object. * name to the current object.

View File

@ -1,11 +1,6 @@
package eva2.problems.regression; 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 { 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; return result;
} }
/**********************************************************************************************************************
* These are for GUI
*/
/** /**
* This method allows the CommonJavaObjectEditorPanel to read the * This method allows the CommonJavaObjectEditorPanel to read the
* name to the current object. * name to the current object.

View File

@ -1,11 +1,6 @@
package eva2.problems.regression; 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 { 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; return result;
} }
/**********************************************************************************************************************
* These are for GUI
*/
/** /**
* This method allows the CommonJavaObjectEditorPanel to read the * This method allows the CommonJavaObjectEditorPanel to read the
* name to the current object. * name to the current object.

View File

@ -1,11 +1,6 @@
package eva2.problems.regression; 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 { 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; return result;
} }
/**********************************************************************************************************************
* These are for GUI
*/
/** /**
* This method allows the CommonJavaObjectEditorPanel to read the * This method allows the CommonJavaObjectEditorPanel to read the
* name to the current object. * name to the current object.

View File

@ -1,11 +1,6 @@
package eva2.problems.regression; 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 { public class RFRaidl_F1 implements InterfaceRegressionFunction, java.io.Serializable {
@ -37,9 +32,6 @@ public class RFRaidl_F1 implements InterfaceRegressionFunction, java.io.Serializ
return result; return result;
} }
/**********************************************************************************************************************
* These are for GUI
*/
/** /**
* This method allows the CommonJavaObjectEditorPanel to read the * This method allows the CommonJavaObjectEditorPanel to read the
* name to the current object. * name to the current object.

View File

@ -1,11 +1,7 @@
package eva2.problems.regression; 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 { public class RFRaidl_F2 implements InterfaceRegressionFunction, java.io.Serializable {
@ -37,9 +33,6 @@ public class RFRaidl_F2 implements InterfaceRegressionFunction, java.io.Serializ
return result; return result;
} }
/**********************************************************************************************************************
* These are for GUI
*/
/** /**
* This method allows the CommonJavaObjectEditorPanel to read the * This method allows the CommonJavaObjectEditorPanel to read the
* name to the current object. * name to the current object.

View File

@ -1,11 +1,7 @@
package eva2.problems.regression; 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 { public class RFRaidl_F3 implements InterfaceRegressionFunction, java.io.Serializable {
@ -37,9 +33,6 @@ public class RFRaidl_F3 implements InterfaceRegressionFunction, java.io.Serializ
return result; return result;
} }
/**********************************************************************************************************************
* These are for GUI
*/
/** /**
* This method allows the CommonJavaObjectEditorPanel to read the * This method allows the CommonJavaObjectEditorPanel to read the
* name to the current object. * name to the current object.

View File

@ -48,10 +48,6 @@ public class Serializer {
objectStream.writeObject(objToStore); objectStream.writeObject(objToStore);
objectStream.flush(); objectStream.flush();
objectStream.close(); objectStream.close();
String output;
Gson gson = new Gson();
output = gson.toJson(objToStore);
System.out.println(output);
} catch (java.io.NotSerializableException ex) { } catch (java.io.NotSerializableException ex) {
LOGGER.log(Level.SEVERE, "Object is not serializable!", ex); LOGGER.log(Level.SEVERE, "Object is not serializable!", ex);
} }

View File

@ -68,10 +68,6 @@ public class Chart2DDPointContentSelectable implements InterfaceDPointWithConten
this.size = d; this.size = d;
} }
/*********************************************************************************************
* The InterfaceSelectablePointIcon
*/
/** /**
* This method allows to add a selection listner to the PointIcon * This method allows to add a selection listner to the PointIcon
* it should need more than one listener to this abstruse event * it should need more than one listener to this abstruse event

View File

@ -2,7 +2,6 @@ package eva2.tools.chart2d;
import java.awt.*; import java.awt.*;
/** /**
* *
*/ */

View File

@ -1,6 +1,5 @@
package eva2.tools.chart2d; package eva2.tools.chart2d;
import eva2.gui.plot.InterfaceDPointWithContent; import eva2.gui.plot.InterfaceDPointWithContent;
import eva2.optimization.individuals.AbstractEAIndividual; import eva2.optimization.individuals.AbstractEAIndividual;
import eva2.problems.InterfaceOptimizationProblem; import eva2.problems.InterfaceOptimizationProblem;
@ -10,13 +9,6 @@ import java.awt.*;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; 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 { public class Chart2DDPointIconContent implements InterfaceDPointWithContent, DPointIcon {
AbstractEAIndividual individual; AbstractEAIndividual individual;

View File

@ -1,9 +1,7 @@
package eva2.tools.chart2d; package eva2.tools.chart2d;
import java.awt.*; import java.awt.*;
/** /**
* *
*/ */

View File

@ -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 { public class Chart2DDPointIconPoint implements DPointIcon {

View File

@ -36,8 +36,7 @@ public class DArea extends JComponent implements DParent, Printable {
*/ */
private static final long serialVersionUID = 1461387400381365146L; private static final long serialVersionUID = 1461387400381365146L;
private boolean auto_focus = false, auto_grid = false, private boolean autoFocus = false, autoGrid = false, gridToFront = false;
grid_to_front = false;
/** /**
* the container in which all DElements of the area are contained except the * 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 * maximal number of grid lines
*/ */
private int max_grid = 10; private int maxGrid = 10;
/** /**
* the measures of the area it calculates the coordinates * 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 * 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, protected DRectangle minRect = DEFAULT_MIN_RECT,
visible_rect = 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 * 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 * initializes the DArea with the specialized initial capacity of components
* (@see java.util.Vector) * (@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 = new DContainer();
container.setDParent(this); container.setDParent(this);
grid = new DGrid(visible_rect, 1, 1); grid = new DGrid(visibleRect, 1, 1);
grid.setVisible(false); grid.setVisible(false);
grid.setDParent(this); grid.setDParent(this);
measures = new DMeasures(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 * @return DRectangle the size and position of the visible area
*/ */
public DRectangle getDRectangle() { public DRectangle getDRectangle() {
DRectangle rect = (DRectangle) visible_rect.clone(); DRectangle rect = (DRectangle) visibleRect.clone();
if (min_x != null) { if (minX != null) {
rect.setX(Math.max(rect.getX(), getMinX())); rect.setX(Math.max(rect.getX(), getMinX()));
} }
if (min_y != null) { if (minY != null) {
rect.setY(Math.max(rect.getY(), getMinY())); rect.setY(Math.max(rect.getY(), getMinY()));
} }
if (max_x != null) { if (maxX != null) {
rect.setWidth(Math.min(rect.getWidth(), getMaxX() - getMinX())); rect.setWidth(Math.min(rect.getWidth(), getMaxX() - getMinX()));
} }
if (max_y != null) { if (maxY != null) {
rect.setHeight(Math.min(rect.getHeight(), getMaxY() - getMinY())); rect.setHeight(Math.min(rect.getHeight(), getMaxY() - getMinY()));
} }
return rect; return rect;
@ -185,10 +184,7 @@ public class DArea extends JComponent implements DParent, Printable {
* @deprecated see getMaxX, getMaxY, getMinX, getMinY * @deprecated see getMaxX, getMaxY, getMinX, getMinY
*/ */
public DRectangle getMaxRectangle() { public DRectangle getMaxRectangle() {
return new DRectangle(min_x.doubleValue(), min_y.doubleValue(), max_x return new DRectangle(minX, minY, maxX - minX, maxY - minY);
.doubleValue()
- min_x.doubleValue(), max_y.doubleValue()
- min_y.doubleValue());
} }
/** /**
@ -197,8 +193,8 @@ public class DArea extends JComponent implements DParent, Printable {
* @return the maxmal x-value * @return the maxmal x-value
*/ */
public double getMaxX() { public double getMaxX() {
if (max_x != null) { if (maxX != null) {
return max_x.doubleValue(); return maxX;
} }
return 0; return 0;
} }
@ -209,46 +205,12 @@ public class DArea extends JComponent implements DParent, Printable {
* @return the maximal y-value * @return the maximal y-value
*/ */
public double getMaxY() { public double getMaxY() {
if (max_y != null) { if (maxY != null) {
return max_y.doubleValue(); return maxY;
} }
return 0; 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 * method returns the minimal rectangle which is set as the visible when all
* elements are removed and the area is on auto focus * 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 * @return the minmal rectangle
*/ */
public DRectangle getMinRectangle() { 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 * @return the minmal x-value
*/ */
public double getMinX() { public double getMinX() {
if (min_x != null) { if (minX != null) {
return min_x.doubleValue(); return minX;
} }
return 0; return 0;
} }
@ -277,8 +239,8 @@ public class DArea extends JComponent implements DParent, Printable {
* @return the minmal y-value * @return the minmal y-value
*/ */
public double getMinY() { public double getMinY() {
if (min_y != null) { if (minY != null) {
return min_y.doubleValue(); return minY;
} }
return 0; return 0;
} }
@ -289,25 +251,25 @@ public class DArea extends JComponent implements DParent, Printable {
* @return DRectangle the size and position of the visible area * @return DRectangle the size and position of the visible area
*/ */
public SlimRect getSlimRectangle() { public SlimRect getSlimRectangle() {
SlimRect srect = new SlimRect(visible_rect.getX(), visible_rect.getY(), SlimRect srect = new SlimRect(visibleRect.getX(), visibleRect.getY(),
visible_rect.getWidth(), visible_rect.getHeight()); visibleRect.getWidth(), visibleRect.getHeight());
if (min_x != null) { if (minX != null) {
srect.x = Math.max(srect.x, getMinX()); srect.x = Math.max(srect.x, getMinX());
} }
if (min_y != null) { if (minY != null) {
srect.y = Math.max(srect.y, getMinY()); srect.y = Math.max(srect.y, getMinY());
} }
if (max_x != null) { if (maxX != null) {
srect.width = Math.min(srect.width, getMaxX() - getMinX()); srect.width = Math.min(srect.width, getMaxX() - getMinX());
} }
if (max_y != null) { if (maxY != null) {
srect.height = Math.min(srect.height, getMaxY() - getMinY()); srect.height = Math.min(srect.height, getMaxY() - getMinY());
} }
return srect; return srect;
} }
public DFunction getYScale() { 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 * @return true if the grid is on, else false
*/ */
public boolean hasAutoGrid() { public boolean hasAutoGrid() {
return auto_grid; return autoGrid;
} }
/** /**
@ -335,7 +297,7 @@ public class DArea extends JComponent implements DParent, Printable {
* @return <code>true</code> or <code>false</code> * @return <code>true</code> or <code>false</code>
*/ */
public boolean isOnAutoFocus() { public boolean isOnAutoFocus() {
return auto_focus; return autoFocus;
} }
/** /**
@ -355,23 +317,23 @@ public class DArea extends JComponent implements DParent, Printable {
*/ */
@Override @Override
public void paint(Graphics g) { public void paint(Graphics g) {
if (auto_focus) { if (autoFocus) {
container.restore(); container.restore();
visible_rect = (DRectangle) container.getRectangle().clone(); visibleRect = (DRectangle) container.getRectangle().clone();
// grid.updateDistByRect(visible_rect); // grid.updateDistByRect(visibleRect);
} }
if (visible_rect.isEmpty()) { if (visibleRect.isEmpty()) {
visible_rect = (DRectangle) min_rect.clone(); visibleRect = (DRectangle) minRect.clone();
// grid.updateDistByRect(visible_rect); // grid.updateDistByRect(visibleRect);
} }
super.paint(g); super.paint(g);
measures.setGraphics(g); measures.setGraphics(g);
if (grid.isVisible() && !grid_to_front) { if (grid.isVisible() && !gridToFront) {
paintGrid(measures); paintGrid(measures);
} }
container.paint(measures); container.paint(measures);
if (grid.isVisible() && grid_to_front) { if (grid.isVisible() && gridToFront) {
paintGrid(measures); 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 * method paints the grid how the method paints the grid depends on whether
* the area is wrapped in a <code>ScaledBorder</code> or not and on the * the area is wrapped in a <code>ScaledBorder</code> or not and on the
* auto_grid option * autoGrid option
*/ */
private void paintGrid(DMeasures m) { private void paintGrid(DMeasures m) {
grid.rectangle = getDRectangle(); grid.rectangle = getDRectangle();
if (auto_grid) { if (autoGrid) {
Border b = getBorder(); Border b = getBorder();
if (b instanceof ScaledBorder) { if (b instanceof ScaledBorder) {
ScaledBorder sb = (ScaledBorder) b; ScaledBorder sb = (ScaledBorder) b;
@ -392,16 +354,16 @@ public class DArea extends JComponent implements DParent, Printable {
} else { } else {
grid.setDistances(ScaledBorder.aBitBigger(grid.rectangle grid.setDistances(ScaledBorder.aBitBigger(grid.rectangle
.getWidth() .getWidth()
/ max_grid), ScaledBorder.aBitBigger(grid.rectangle / maxGrid), ScaledBorder.aBitBigger(grid.rectangle
.getHeight() .getHeight()
/ max_grid)); / maxGrid));
} }
} }
grid.paint(m); 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 * an instance of ScaledBorder
* *
* @param sb the ScaledBorder around the area * @param sb the ScaledBorder around the area
@ -412,9 +374,9 @@ public class DArea extends JComponent implements DParent, Printable {
FontMetrics fm = m.getGraphics().getFontMetrics(); FontMetrics fm = m.getGraphics().getFontMetrics();
grid.setDistances(sb.getSrcdX(fm, d), sb.getSrcdY(fm, d)); 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); grid.paint(m);
} else {// selber malen } else {
Graphics g = m.g; Graphics g = m.g;
g.setColor(grid.getColor()); g.setColor(grid.getColor());
@ -438,16 +400,16 @@ public class DArea extends JComponent implements DParent, Printable {
double pos; double pos;
for (; (pos = x * grid.getHorDist()) < src_rect.x + src_rect.width; x++) { for (; (pos = x * grid.getHorDist()) < src_rect.x + src_rect.width; x++) {
if (m.x_scale != null) { if (m.xScale != null) {
pos = m.x_scale.getImageOf(pos); pos = m.xScale.getImageOf(pos);
} }
Point p1 = m.getPoint(pos, miny), p2 = m.getPoint(pos, maxy); Point p1 = m.getPoint(pos, miny), p2 = m.getPoint(pos, maxy);
g.drawLine(p1.x, p1.y, p2.x, p2.y); g.drawLine(p1.x, p1.y, p2.x, p2.y);
} }
for (; (pos = y * grid.getVerDist()) < src_rect.y + src_rect.height; y++) { for (; (pos = y * grid.getVerDist()) < src_rect.y + src_rect.height; y++) {
if (m.y_scale != null) { if (m.yScale != null) {
pos = m.y_scale.getImageOf(pos); pos = m.yScale.getImageOf(pos);
} }
Point p1 = m.getPoint(minx, pos), p2 = m.getPoint(maxx, pos); Point p1 = m.getPoint(minx, pos), p2 = m.getPoint(maxx, pos);
g.drawLine(p1.x, p1.y, p2.x, p2.y); 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)) { if (!(sb instanceof ScaledBorder)) {
sb = null; sb = null;
} else { } else {
((ScaledBorder) sb).show_outer_border = false; ((ScaledBorder) sb).showOuterBorder = false;
} }
PagePrinter printer = new PagePrinter(this, g, pf); PagePrinter printer = new PagePrinter(this, g, pf);
int ret = printer.print(); int ret = printer.print();
if (sb != null) { if (sb != null) {
((ScaledBorder) sb).show_outer_border = true; ((ScaledBorder) sb).showOuterBorder = true;
} }
return ret; return ret;
} }
@ -489,35 +451,35 @@ public class DArea extends JComponent implements DParent, Printable {
* method resets the maximal x-value * method resets the maximal x-value
*/ */
public void releaseMaxX() { public void releaseMaxX() {
max_x = null; maxX = null;
} }
/** /**
* method resets the maximal y-value * method resets the maximal y-value
*/ */
public void releaseMaxY() { public void releaseMaxY() {
max_y = null; maxY = null;
} }
/** /**
* method resets the minimal x-value * method resets the minimal x-value
*/ */
public void releaseMinX() { public void releaseMinX() {
min_x = null; minX = null;
} }
/** /**
* method resets the minimal y-value * method resets the minimal y-value
*/ */
public void releaseMinY() { public void releaseMinY() {
min_y = null; minY = null;
} }
/** /**
* removes all elements from the area * removes all elements from the area
*/ */
public void removeAllDElements() { public void removeAllDElements() {
visible_rect = (DRectangle) min_rect.clone(); visibleRect = (DRectangle) minRect.clone();
container.removeAllDElements(); container.removeAllDElements();
} }
@ -542,13 +504,11 @@ public class DArea extends JComponent implements DParent, Printable {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Cannot repaint a null DRectangle"); "Cannot repaint a null DRectangle");
} }
if (r.isAll() || auto_focus) { if (r.isAll() || autoFocus) {
repaint(); repaint();
} else { } else {
Point p1 = measures.getPoint(r.getX(), r.getY()), p2 = measures Point p1 = measures.getPoint(r.getX(), r.getY()), p2 = measures
.getPoint(r.getX() + r.getWidth(), r.getY() + r.getHeight()); .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) { if (p1 == null || p2 == null) {
repaint(); repaint();
} else { } else {
@ -570,8 +530,8 @@ public class DArea extends JComponent implements DParent, Printable {
* @param b on or off * @param b on or off
*/ */
public void setAutoFocus(boolean b) { public void setAutoFocus(boolean b) {
boolean old = auto_focus; boolean old = autoFocus;
auto_focus = b; autoFocus = b;
if (old != b) { if (old != b) {
repaint(); repaint();
} }
@ -588,10 +548,10 @@ public class DArea extends JComponent implements DParent, Printable {
grid.rectangle = getDRectangle(); grid.rectangle = getDRectangle();
grid.setVisible(true); grid.setVisible(true);
} }
if (b == auto_grid) { if (b == autoGrid) {
return; return;
} }
auto_grid = b; autoGrid = b;
repaint(); repaint();
} }
@ -603,16 +563,16 @@ public class DArea extends JComponent implements DParent, Printable {
* @param ver_dist the vertical distance * @param ver_dist the vertical distance
*/ */
public void setGrid(double hor_dist, double ver_dist) { 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); grid.setDParent(this);
auto_grid = false; autoGrid = false;
repaint(); repaint();
} }
/** /**
* sets the color of the grid * sets the color of the grid
* *
* @param java .awt.Color * @param color The new grid color
*/ */
public void setGridColor(Color color) { public void setGridColor(Color color) {
grid.setColor(color); grid.setColor(color);
@ -625,8 +585,8 @@ public class DArea extends JComponent implements DParent, Printable {
* @param aFlag grid t front or not * @param aFlag grid t front or not
*/ */
public void setGridToFront(boolean aFlag) { public void setGridToFront(boolean aFlag) {
boolean old = grid_to_front; boolean old = gridToFront;
grid_to_front = aFlag; gridToFront = aFlag;
if (old != aFlag && grid.isVisible()) { if (old != aFlag && grid.isVisible()) {
repaint(); repaint();
} }
@ -652,8 +612,8 @@ public class DArea extends JComponent implements DParent, Printable {
if (no < 1) { if (no < 1) {
return; return;
} }
int old = max_grid; int old = maxGrid;
max_grid = no; maxGrid = no;
if (old != no) { if (old != no) {
repaint(); repaint();
} }
@ -666,11 +626,11 @@ public class DArea extends JComponent implements DParent, Printable {
* @param max the maximal x-value * @param max the maximal x-value
*/ */
public void setMaxX(double max) { public void setMaxX(double max) {
if (max < min_rect.getX() + min_rect.getWidth()) { if (max < minRect.getX() + minRect.getWidth()) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Maximal x-value axes intersects minmal rectangle."); "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 * @param may the maximal y-value
*/ */
public void setMaxY(double may) { public void setMaxY(double may) {
if (may < min_rect.getY() + min_rect.getHeight()) { if (may < minRect.getY() + minRect.getHeight()) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Maximal y-value axes intersects minmal rectangle."); "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) { public void setMinRectangle(DRectangle rect) {
if (rect.isEmpty()) { if (rect.isEmpty()) {
min_rect = DEFAULT_MIN_RECT; minRect = DEFAULT_MIN_RECT;
} else { } 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 * @param mix the minimal x-value
*/ */
public void setMinX(double mix) { public void setMinX(double mix) {
if (mix > min_rect.getX()) { if (mix > minRect.getX()) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Mimimal y-value axes intersects minmal rectangle."); "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 * @param miy the minimal y-value
*/ */
public void setMinY(double miy) { public void setMinY(double miy) {
if (miy > min_rect.getY()) { if (miy > minRect.getY()) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Mimimal y-value axes intersects minmal rectangle."); "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"); + "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) { && rect.getHeight() > 0) {
auto_focus = false; autoFocus = false;
visible_rect = (DRectangle) rect.clone(); visibleRect = (DRectangle) rect.clone();
repaint(); repaint();
} }
} }
@ -783,10 +743,10 @@ public class DArea extends JComponent implements DParent, Printable {
* @param x_s the scale function for the x-axis * @param x_s the scale function for the x-axis
*/ */
public void setXScale(DFunction x_s) { public void setXScale(DFunction x_s) {
if (x_s == null && measures.x_scale == null) { if (x_s == null && measures.xScale == null) {
return; return;
} }
measures.x_scale = x_s; measures.xScale = x_s;
repaint(); repaint();
} }
@ -798,14 +758,10 @@ public class DArea extends JComponent implements DParent, Printable {
* @param y_s the scale function for the y-axis * @param y_s the scale function for the y-axis
*/ */
public void setYScale(DFunction y_s) { public void setYScale(DFunction y_s) {
if (y_s == null && measures.y_scale == null) { if (y_s == null && measures.yScale == null) {
return; return;
} }
measures.y_scale = y_s; measures.yScale = y_s;
repaint(); repaint();
} }
} }
/****************************************************************************
* END OF FILE
****************************************************************************/

View File

@ -1,14 +1,5 @@
package eva2.tools.chart2d; package eva2.tools.chart2d;
/**
* Title:
* Description:
* Copyright: Copyright (c) 2001
* Company:
* @author
* @version 1.0
*/
/** /**
* This class stores an array of double values. * This class stores an array of double values.
* It can be used as data stack for an DPointSet object. * It can be used as data stack for an DPointSet object.
@ -16,8 +7,8 @@ package eva2.tools.chart2d;
* been modified. * been modified.
*/ */
public class DArray implements DIntDoubleMap { public class DArray implements DIntDoubleMap {
private int initial_capacity, size; private int initialCapacity, size;
private double capacity_multiplier = 2, max, min, minPositive = -1; private double capacityMultiplier = 2, max, min, minPositive = -1;
private double[] value; private double[] value;
/** /**
@ -32,30 +23,28 @@ public class DArray implements DIntDoubleMap {
* Constructor for an DArray object with default value for the capacity * Constructor for an DArray object with default value for the capacity
* multiplier (2). * multiplier (2).
* *
* @param initial_capacity the initial capacity of the array * @param initialCapacity the initial capacity of the array
*/ */
public DArray(int initial_capacity) { public DArray(int initialCapacity) {
this(initial_capacity, 2); this(initialCapacity, 2);
} }
/** /**
* Constructor for an DArray object * Constructor for an DArray object
* *
* @param initial_capacity the initial capacity of the array * @param initialCapacity the initial capacity of the array
* @param capacity_multiplier the capacity multiplier when the array overflows * @param capacityMultiplier the capacity multiplier when the array overflows
*/ */
public DArray(int initial_capacity, double capacity_multiplier) { public DArray(int initialCapacity, double capacityMultiplier) {
if (initial_capacity < 1) { if (initialCapacity < 1) {
throw throw new IllegalArgumentException("The initial capacity has to be at least 1");
new IllegalArgumentException("The initial capacity has to be at least 1");
} }
if (capacity_multiplier <= 1) { if (capacityMultiplier <= 1) {
throw throw new IllegalArgumentException("The capacity multiplier has to be bigger than 1");
new IllegalArgumentException("The capacity multiplier has to be bigger than 1");
} }
this.initial_capacity = initial_capacity; this.initialCapacity = initialCapacity;
value = new double[initial_capacity]; value = new double[initialCapacity];
this.capacity_multiplier = capacity_multiplier; this.capacityMultiplier = capacityMultiplier;
} }
/** /**
@ -67,25 +56,24 @@ public class DArray implements DIntDoubleMap {
@Override @Override
public boolean setImage(int source, double image) { public boolean setImage(int source, double image) {
if (source < 0 || source >= size) { if (source < 0 || source >= size) {
throw throw new ArrayIndexOutOfBoundsException(source);
new ArrayIndexOutOfBoundsException(source);
} }
boolean min_max_changed = false, restore = false; boolean minMaxChanged = false, restore = false;
if (image < min) { if (image < min) {
min = image; min = image;
min_max_changed = true; minMaxChanged = true;
} else if (image > max) { } else if (image > max) {
max = image; max = image;
min_max_changed = true; minMaxChanged = true;
} }
if (value[source] == min || value[source] == max || (value[source] == minPositive)) { if (value[source] == min || value[source] == max || (value[source] == minPositive)) {
restore = true; restore = true;
} }
value[source] = image; value[source] = image;
if (restore) { 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 * @param source the source value
* @return the image value * @return the image value
*/ */
// public double getImage(int source){
// if(source<0 || source>=size) throw
// new ArrayIndexOutOfBoundsException(source);
// return value[source];
// }
@Override @Override
public double getImage(int source) { public double getImage(int source) {
if (source < 0) { if (source < 0) {
new ArrayIndexOutOfBoundsException(source); throw new ArrayIndexOutOfBoundsException(source);
} }
if (source >= size && size > 1) { if (source >= size && size > 1) {
return value[size - 1]; return value[size - 1];
@ -121,37 +104,37 @@ public class DArray implements DIntDoubleMap {
@Override @Override
public boolean addImage(double image) { public boolean addImage(double image) {
if (size >= value.length) { if (size >= value.length) {
int new_length = (int) (value.length * capacity_multiplier); int newLength = (int) (value.length * capacityMultiplier);
if (!(new_length > value.length)) { if (!(newLength > value.length)) {
new_length++; newLength++;
} }
double[] new_val = new double[new_length]; double[] new_val = new double[newLength];
System.arraycopy(value, 0, new_val, 0, value.length); System.arraycopy(value, 0, new_val, 0, value.length);
value = new_val; value = new_val;
} }
boolean min_max_changed = false; boolean minMaxChanged = false;
if (size == 0) { if (size == 0) {
min = image; min = image;
max = image; max = image;
min_max_changed = true; minMaxChanged = true;
if (image > 0) { if (image > 0) {
minPositive = image; minPositive = image;
} }
} else { } else {
if ((image > 0) && ((image < minPositive) || (minPositive < 0))) { if ((image > 0) && ((image < minPositive) || (minPositive < 0))) {
minPositive = image; minPositive = image;
min_max_changed = true; minMaxChanged = true;
} }
if (image > max) { if (image > max) {
max = image; max = image;
min_max_changed = true; minMaxChanged = true;
} else if (image < min) { } else if (image < min) {
min = image; min = image;
min_max_changed = true; minMaxChanged = true;
} }
} }
value[size++] = image; value[size++] = image;
return min_max_changed; return minMaxChanged;
} }
/** /**
@ -200,7 +183,7 @@ public class DArray implements DIntDoubleMap {
@Override @Override
public void reset() { public void reset() {
size = 0; size = 0;
value = new double[initial_capacity]; value = new double[initialCapacity];
} }
/** /**
@ -211,8 +194,7 @@ public class DArray implements DIntDoubleMap {
@Override @Override
public double getMinImageValue() { public double getMinImageValue() {
if (size == 0) { if (size == 0) {
throw throw new IllegalArgumentException("DArray is empty. No minimal value exists");
new IllegalArgumentException("DArray is empty. No minimal value exists");
} }
return min; return min;
} }
@ -225,8 +207,7 @@ public class DArray implements DIntDoubleMap {
@Override @Override
public double getMinPositiveImageValue() { public double getMinPositiveImageValue() {
if (size == 0) { if (size == 0) {
throw throw new IllegalArgumentException("DArray is empty. No minimal value exists");
new IllegalArgumentException("DArray is empty. No minimal value exists");
} }
return (minPositive < 0) ? max : minPositive; return (minPositive < 0) ? max : minPositive;
} }
@ -239,8 +220,7 @@ public class DArray implements DIntDoubleMap {
@Override @Override
public double getMaxImageValue() { public double getMaxImageValue() {
if (size == 0) { if (size == 0) {
throw throw new IllegalArgumentException("DArray is empty. No maximal value exists");
new IllegalArgumentException("DArray is empty. No maximal value exists");
} }
return max; return max;
} }

View File

@ -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; package eva2.tools.chart2d;
import java.awt.*; import java.awt.*;

View File

@ -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; package eva2.tools.chart2d;
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import java.awt.*; import java.awt.*;
/*==========================================================================*
* CLASS DECLARATION
*==========================================================================*/
/** /**
* <code>DComponent</code> is the mother of all objects which can be displayed * <code>DComponent</code> is the mother of all objects which can be displayed
* by a <code>DArea</code> object, even when it would be also enough to * by a <code>DArea</code> object, even when it would be also enough to
@ -133,7 +113,6 @@ public abstract class DComponent implements DElement {
*/ */
@Override @Override
public void repaint() { public void repaint() {
//System.out.println("DComponent.repaint()");
if (parent != null) { if (parent != null) {
parent.repaint(getRectangle()); parent.repaint(getRectangle());
} }
@ -179,8 +158,4 @@ public abstract class DComponent implements DElement {
return visible; return visible;
} }
} }
/****************************************************************************
* END OF FILE
****************************************************************************/

View File

@ -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; package eva2.tools.chart2d;
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import java.awt.*; import java.awt.*;
import java.util.Vector; import java.util.Vector;
/*==========================================================================*
* CLASS DECLARATION
*==========================================================================*/
public class DContainer extends DComponent implements DParent { public class DContainer extends DComponent implements DParent {
/** /**
* the elements of the container and their keys ( Strings ) * the elements of the container and their keys ( Strings )
@ -78,14 +58,12 @@ public class DContainer extends DComponent implements DParent {
if (e instanceof DParent) { if (e instanceof DParent) {
DParent he = (DParent) e, me = this; DParent he = (DParent) e, me = this;
if (he == me) { if (he == me) {
throw new throw new IllegalArgumentException("Adding DParent to itself");
IllegalArgumentException("Adding DParent to itself");
} }
me = getDParent(); me = getDParent();
while (me != null) { while (me != null) {
if (he == me) { if (he == me) {
throw new throw new IllegalArgumentException("Adding DContainer's parent to itself");
IllegalArgumentException("Adding DContainer's parent to itself");
} }
if (me instanceof DElement) { if (me instanceof DElement) {
me = ((DElement) me).getDParent(); me = ((DElement) me).getDParent();
@ -164,8 +142,6 @@ public class DContainer extends DComponent implements DParent {
return (index < keys.size()) ? elements.get(index) : null; return (index < keys.size()) ? elements.get(index) : null;
} }
// implementing DComponent:
/** /**
* method calls all currently visible DElements of the container to paint * method calls all currently visible DElements of the container to paint
* themselves by the given DMeasures object * themselves by the given DMeasures object
@ -247,8 +223,4 @@ public class DContainer extends DComponent implements DParent {
} }
return !old.equals(rectangle); return !old.equals(rectangle);
} }
} }
/****************************************************************************
* END OF FILE
****************************************************************************/

View File

@ -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; package eva2.tools.chart2d;
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import java.awt.*; import java.awt.*;
/*==========================================================================*
* INTERFACE DECLARATION
*==========================================================================*/
/** /**
* some useful methods for objects which should be paintable in a scaled area * some useful methods for objects which should be paintable in a scaled area
*/ */
@ -49,8 +29,4 @@ public interface DElement {
void setDBorder(DBorder b); void setDBorder(DBorder b);
DBorder getDBorder(); DBorder getDBorder();
} }
/****************************************************************************
* END OF FILE
****************************************************************************/

View File

@ -50,8 +50,8 @@ public abstract class DFunction extends DComponent {
Point last = null, next; Point last = null, next;
for (int i = 0; i < int_w; i++) { for (int i = 0; i < int_w; i++) {
double x_val = src_rect.x + i / (double) int_w * src_rect.width; double x_val = src_rect.x + i / (double) int_w * src_rect.width;
if (m.x_scale != null) { if (m.xScale != null) {
x_val = m.x_scale.getImageOf(x_val); x_val = m.xScale.getImageOf(x_val);
} }
if (isDefinedAt(x_val)) { if (isDefinedAt(x_val)) {
next = m.getPoint(x_val, getImageOf(x_val)); next = m.getPoint(x_val, getImageOf(x_val));

View File

@ -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; package eva2.tools.chart2d;
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import eva2.tools.math.Mathematics; import eva2.tools.math.Mathematics;
import java.awt.*; import java.awt.*;
/*==========================================================================*
* CLASS DECLARATION
*==========================================================================*/
/** /**
* this class paints a grid with certain line distances on a DParent * 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 * the distances between the lines
*/ */
private double hor_dist, ver_dist; private double horDist, verDist;
private Color DEFAULT_COLOR = Color.lightGray; 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 * constructor with the size and position of the grid and the line distances
* *
* @param rectangle the rectangle around the grid * @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! * 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! * 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.rectangle = rectangle;
this.hor_dist = hor_dist; this.horDist = horDist;
this.ver_dist = ver_dist; this.verDist = verDist;
color = DEFAULT_COLOR; 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 * constructor with the size and position of the grid and the line distances
* *
* @param rectangle the rectangle around the grid * @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! * 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! * not in pixel coordinates!
* @param color the color of the grid * @param color the color of the grid
* ( can also be set by setColor( java.awt.Color ) ) * ( 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.rectangle = rectangle;
this.hor_dist = hor_dist; this.horDist = horDist;
this.ver_dist = ver_dist; this.verDist = verDist;
this.color = color; this.color = color;
} }
public void setDistances(double hor, double ver) { public void setDistances(double hor, double ver) {
hor_dist = hor; horDist = hor;
ver_dist = ver; verDist = ver;
// System.out.println("set new Grid distances " + this.toString());
} }
public double getHorDist() { public double getHorDist() {
return hor_dist; return horDist;
} }
public double getVerDist() { public double getVerDist() {
return ver_dist; return verDist;
} }
/** /**
@ -98,18 +77,12 @@ public class DGrid extends DComponent {
DPoint p1, p2; DPoint p1, p2;
DLine l; DLine l;
minX = Mathematics.firstMultipleAbove(rectangle.getX(), hor_dist); minX = Mathematics.firstMultipleAbove(rectangle.getX(), horDist);
minY = Mathematics.firstMultipleAbove(rectangle.getY(), ver_dist); minY = Mathematics.firstMultipleAbove(rectangle.getY(), verDist);
// 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;
p1 = new DPoint(0, rectangle.getY()); p1 = new DPoint(0, rectangle.getY());
p2 = new DPoint(0, rectangle.getY() + rectangle.getHeight()); 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; p1.x = p2.x = pos;
l = new DLine(p1, p2, color); l = new DLine(p1, p2, color);
l.paint(m); l.paint(m);
@ -122,22 +95,17 @@ public class DGrid extends DComponent {
p1.y = p2.y = pos; p1.y = p2.y = pos;
l = new DLine(p1, p2, color); l = new DLine(p1, p2, color);
l.paint(m); l.paint(m);
if (pos + ver_dist <= pos) { if (pos + verDist <= pos) {
System.err.println("Overflow error in DGrid!"); System.err.println("Overflow error in DGrid!");
pos *= 1.01; pos *= 1.01;
} else { } else {
pos += ver_dist; pos += verDist;
} }
// System.out.println("pos is " + pos + ", loop until " + rectangle.y + rectangle.height);
} }
} }
@Override @Override
public String toString() { public String toString() {
return "chart2d.DGrid[ hor: " + hor_dist + ", ver: " + ver_dist + " ]"; return "chart2d.DGrid[ hor: " + horDist + ", ver: " + verDist + " ]";
} }
} }
/****************************************************************************
* END OF FILE
****************************************************************************/

View File

@ -1,14 +1,5 @@
package eva2.tools.chart2d; 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 * 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 * values which can be displayed in a DArea. All modifications of the values can

View File

@ -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; package eva2.tools.chart2d;
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import java.awt.*; import java.awt.*;
/*==========================================================================*
* CLASS DECLARATION
*==========================================================================*/
public class DLine extends DComponent { public class DLine extends DComponent {
DPoint start, end; DPoint start, end;
@ -78,8 +58,4 @@ public class DLine extends DComponent {
public String toString() { public String toString() {
return "DLine[(" + start.x + "," + start.y + ") --> (" + end.x + "," + end.y + ", color: " + color + "]"; return "DLine[(" + start.x + "," + start.y + ") --> (" + end.x + "," + end.y + ", color: " + color + "]";
} }
} }
/****************************************************************************
* END OF FILE
****************************************************************************/

View File

@ -14,13 +14,12 @@ public class DMeasures implements Serializable {
* *
*/ */
private static final long serialVersionUID = 243092480517044848L; private static final long serialVersionUID = 243092480517044848L;
private boolean under_construction = false;
// when in use for a DArea: // when in use for a DArea:
Graphics g; Graphics g;
// when in use for a ScaledBorder: // when in use for a ScaledBorder:
ScaledBorder sb; ScaledBorder sb;
// for both: // for both:
DFunction x_scale, y_scale; DFunction xScale, yScale;
Component comp; Component comp;
Insets insets; Insets insets;
@ -55,11 +54,11 @@ public class DMeasures implements Serializable {
return null; return null;
} }
try { try {
if (x_scale != null) { if (xScale != null) {
x = x_scale.getSourceOf(x); x = xScale.getSourceOf(x);
} }
if (y_scale != null) { if (yScale != null) {
y = y_scale.getSourceOf(y); y = yScale.getSourceOf(y);
} }
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
return null; return null;
@ -93,11 +92,11 @@ public class DMeasures implements Serializable {
dx = rect.x + rect.width * x / (double) dim.width; dx = rect.x + rect.width * x / (double) dim.width;
dy = rect.y + rect.height * (1 - y / (double) dim.height); dy = rect.y + rect.height * (1 - y / (double) dim.height);
try { try {
if (x_scale != null) { if (xScale != null) {
dx = x_scale.getImageOf(dx); dx = xScale.getImageOf(dx);
} }
if (y_scale != null) { if (yScale != null) {
dy = y_scale.getImageOf(dy); dy = yScale.getImageOf(dy);
} }
} catch (IllegalArgumentException nde) { } catch (IllegalArgumentException nde) {
return null; return null;
@ -105,16 +104,6 @@ public class DMeasures implements Serializable {
return new DPoint(dx, dy); 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. * 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 * @return the visible rectangle
*/ */
public SlimRect getSlimRectangle() { public SlimRect getSlimRectangle() {
// if( under_construction ) System.out.println("DMeasures.getDRectangle");
if (sb != null) { 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(); return ((DArea) comp).getSlimRectangle();
} }
@ -138,9 +126,6 @@ public class DMeasures implements Serializable {
* @return the Graphics object ( or null if no object was set ) * @return the Graphics object ( or null if no object was set )
*/ */
public Graphics getGraphics() { public Graphics getGraphics() {
if (under_construction) {
System.out.println("DMeasures.getGraphics");
}
if (g != null) { if (g != null) {
Dimension d = comp.getSize(); Dimension d = comp.getSize();
Insets insets = getInsets(); Insets insets = getInsets();
@ -156,9 +141,6 @@ public class DMeasures implements Serializable {
* used by DArea to set a new Graphics object * used by DArea to set a new Graphics object
*/ */
void setGraphics(Graphics g) { void setGraphics(Graphics g) {
if (under_construction) {
System.out.println("DMeasures.setGraphics");
}
this.g = g; this.g = g;
} }
@ -170,8 +152,8 @@ public class DMeasures implements Serializable {
void update(Component c, Insets insets) { void update(Component c, Insets insets) {
this.comp = c; this.comp = c;
this.insets = insets; this.insets = insets;
x_scale = sb.x_scale; xScale = sb.xScale;
y_scale = sb.y_scale; yScale = sb.yScale;
} }
private Dimension getInner() { private Dimension getInner() {
@ -182,60 +164,28 @@ public class DMeasures implements Serializable {
return d; 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 <code>null</code>
// *
// * @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 * method returns the image rectangle of the given rectangle
* they differ if there are scale functions selected which are not the identity * 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 * if the given rectangle does not belong to the definition area of the scale
* functions, the method returns <code>null</code> * functions, the method returns <code>null</code>
* *
* @param rect the source rectangle
* @return the source of it * @return the source of it
*/ */
SlimRect getImageOf(double xpos, double ypos, double width, double height) { SlimRect getImageOf(double xpos, double ypos, double width, double height) {
// if( under_construction ) System.out.println("DMeasures.getImageOf: "+rect); if (xScale == null && yScale == null) {
if (x_scale == null && y_scale == null) {
return new SlimRect(xpos, ypos, width, height); return new SlimRect(xpos, ypos, width, height);
} }
double x1 = xpos, y1 = ypos, x2 = xpos + width, y2 = ypos + height; double x1 = xpos, y1 = ypos, x2 = xpos + width, y2 = ypos + height;
try { try {
if (x_scale != null) { if (xScale != null) {
x1 = x_scale.getImageOf(x1); x1 = xScale.getImageOf(x1);
x2 = x_scale.getImageOf(x2); x2 = xScale.getImageOf(x2);
} }
if (y_scale != null) { if (yScale != null) {
y1 = y_scale.getImageOf(y1); y1 = yScale.getImageOf(y1);
y2 = y_scale.getImageOf(y2); y2 = yScale.getImageOf(y2);
} }
} catch (IllegalArgumentException nde) { } catch (IllegalArgumentException nde) {
return null; return null;
@ -247,47 +197,6 @@ public class DMeasures implements Serializable {
return getImageOf(srect.x, srect.y, srect.width, srect.height); 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 <code>null</code>
// *
// * @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 * method returns the source rectangle of the given rectangle
* they differ if there are scale functions selected which are not the identity * 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 * @return the source of it
*/ */
SlimRect getSourceOf(double x, double y, double width, double height) { 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)) { if (!getSlimRectangle().contains(x, y, width, height)) {
// System.out.println("case not contains");
return null; return null;
//throw new IllegalArgumentException("The rectangle lies not in the currently painted rectangle");
} }
if (x_scale == null && y_scale == null) { if (xScale == null && yScale == null) {
// System.out.println("Case scale null");
return new SlimRect(x, y, width, height); return new SlimRect(x, y, width, height);
} }
double x1 = x, y1 = y, x2 = x + width, y2 = y + height; double x1 = x, y1 = y, x2 = x + width, y2 = y + height;
try { try {
if (x_scale != null) { if (xScale != null) {
x1 = x_scale.getSourceOf(x1); x1 = xScale.getSourceOf(x1);
x2 = x_scale.getSourceOf(x2); x2 = xScale.getSourceOf(x2);
} }
if (y_scale != null) { if (yScale != null) {
y1 = y_scale.getSourceOf(y1); y1 = yScale.getSourceOf(y1);
y2 = y_scale.getSourceOf(y2); y2 = yScale.getSourceOf(y2);
} }
} catch (IllegalArgumentException nde) { } catch (IllegalArgumentException nde) {
return null; return null;
@ -329,15 +234,6 @@ public class DMeasures implements Serializable {
} }
return new SlimRect(x1, y1, x2 - x1, y2 - y1); 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) { SlimRect getSourceOf(SlimRect srect) {
return getSourceOf(srect.x, srect.y, srect.width, srect.height); return getSourceOf(srect.x, srect.y, srect.width, srect.height);
@ -349,8 +245,4 @@ public class DMeasures implements Serializable {
} }
return ((DArea) comp).getInsets(); return ((DArea) comp).getInsets();
} }
} }
/****************************************************************************
* END OF FILE
****************************************************************************/

View File

@ -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; package eva2.tools.chart2d;
/*==========================================================================*
* INTERFACE DECLARATION
*==========================================================================*/
public interface DParent { public interface DParent {
void addDElement(DElement e); void addDElement(DElement e);
@ -31,8 +14,4 @@ public interface DParent {
void addDBorder(DBorder b); void addDBorder(DBorder b);
void restoreBorder(); void restoreBorder();
} }
/****************************************************************************
* END OF FILE
****************************************************************************/

View File

@ -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; package eva2.tools.chart2d;
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import java.awt.*; import java.awt.*;
/*==========================================================================*
* CLASS DECLARATION
*==========================================================================*/
public class DPoint extends DComponent { public class DPoint extends DComponent {
public double x, y; public double x, y;
public String label; public String label;
@ -104,8 +84,4 @@ public class DPoint extends DComponent {
text += "x: " + x + ", y: " + y + ", color: " + color + "]"; text += "x: " + x + ", y: " + y + ", color: " + color + "]";
return text; return text;
} }
} }
/****************************************************************************
* END OF FILE
****************************************************************************/

View File

@ -1,15 +1,5 @@
package eva2.tools.chart2d; 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.*; import java.awt.*;
/** /**

View File

@ -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; package eva2.tools.chart2d;
/*
* ==========================================================================* IMPORTS
*==========================================================================
*/
import eva2.tools.math.Mathematics; import eva2.tools.math.Mathematics;
import java.awt.*; import java.awt.*;
@ -19,11 +9,6 @@ public class DPointSet extends DComponent {
protected DPointIcon icon = null; protected DPointIcon icon = null;
/*
* -------------------------------------------------------------------------* private member
* variables
*-------------------------------------------------------------------------
*/
protected DIntDoubleMap x, y; protected DIntDoubleMap x, y;
protected boolean connected; protected boolean connected;
protected Stroke stroke = new BasicStroke(); protected Stroke stroke = new BasicStroke();
@ -48,8 +33,7 @@ public class DPointSet extends DComponent {
public DPointSet(DIntDoubleMap x_values, DIntDoubleMap y_values) { public DPointSet(DIntDoubleMap x_values, DIntDoubleMap y_values) {
if (x_values.getSize() != y_values.getSize()) { if (x_values.getSize() != y_values.getSize()) {
throw new IllegalArgumentException( throw new IllegalArgumentException("The number of x-values has to be the same than the number of y-values");
"The number of x-values has to be the same than the number of y-values");
} }
x = x_values; x = x_values;
y = y_values; y = y_values;
@ -57,10 +41,6 @@ public class DPointSet extends DComponent {
setDBorder(new DBorder(1, 1, 1, 1)); setDBorder(new DBorder(1, 1, 1, 1));
} }
/*
* -------------------------------------------------------------------------* public methods
*-------------------------------------------------------------------------
*/
@Override @Override
public void paint(DMeasures m) { public void paint(DMeasures m) {
Graphics2D g = (Graphics2D) m.getGraphics(); 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<73>t clear."
// );
// return size;
// }
/** /**
* *
*/ */

View File

@ -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; package eva2.tools.chart2d;
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import eva2.tools.EVAERROR; import eva2.tools.EVAERROR;
import java.awt.*; import java.awt.*;
/*==========================================================================*
* CLASS DECLARATION
*==========================================================================*/
public class DRectangle extends DComponent { public class DRectangle extends DComponent {
private double x, y; private double x, y;
private double width, height; private double width, height;
@ -356,8 +336,4 @@ public class DRectangle extends DComponent {
public boolean isEmpty() { public boolean isEmpty() {
return status == EMPTY; return status == EMPTY;
} }
} }
/****************************************************************************
* END OF FILE
****************************************************************************/

View File

@ -33,23 +33,23 @@ public class ScaledBorder implements Border {
/** /**
* distance between the x-values in digits * distance between the x-values in digits
*/ */
int x_value2value = 2; int xValue2value = 2;
/** /**
* distance between y-label and y-values in digit width * 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 * 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 * distance between values and arrows in pixels
*/ */
int x_values2arrow = 10, int xValues2arrow = 10,
y_values2arrow = 10; yValues2arrow = 10;
/** /**
* distance between arrows and outer border * distance between arrows and outer border
@ -59,19 +59,19 @@ public class ScaledBorder implements Border {
/** /**
* distance between labels and the border in pixels * distance between labels and the border in pixels
*/ */
public int x_label2border = 6, public int xLabel2border = 6,
y_label2border = 6; yLabel2border = 6;
/** /**
* the size of the source rectangle * the size of the source rectangle
* that means before the values are mdified by scale functions * that means before the values are mdified by scale functions
*/ */
SlimRect src_rect = null; SlimRect srcRect = null;
/** /**
* the minimal increment of the scales * the minimal increment of the scales
*/ */
public double minimal_increment; public double minimalIncrement;
/** /**
* the displayed labels * the displayed labels
@ -86,26 +86,26 @@ public class ScaledBorder implements Border {
/** /**
* the border which is shown around the scaled border * the border which is shown around the scaled border
*/ */
Border outer_border; Border outerBorder;
/** /**
* flag if the outer border should be displayed * 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 * scale functions if, for example, an logarithmic function is needed instead
* of a linear. * of a linear.
*/ */
public DFunction x_scale, y_scale; public DFunction xScale, yScale;
/** /**
* formatters of the x- and y-axis numbers * formatters of the x- and y-axis numbers
* *
* @see java.text.NumberFormat * @see java.text.NumberFormat
*/ */
private NumberFormat format_x = new DecimalFormat(), private NumberFormat formatX = new DecimalFormat(),
format_y = new DecimalFormat(); formatY = new DecimalFormat();
/** /**
* Possible patterns for the number formats used by a border. * 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 nextYPattern = 1;
private int nextXPattern = 1; private int nextXPattern = 1;
private double src_dX = -1, src_dY = -1; private double srcDX = -1, srcDY = -1;
private boolean do_refresh, private boolean doRefresh,
auto_scale_x = true, autoScaleX = true,
auto_scale_y = true; autoScaleY = true;
private Insets old_insets; private Insets oldInsets;
private DMeasures m; private DMeasures m;
@ -148,7 +148,7 @@ public class ScaledBorder implements Border {
* surrounded by the specified <code>Border<code/> * surrounded by the specified <code>Border<code/>
*/ */
public ScaledBorder(Border outer) { public ScaledBorder(Border outer) {
outer_border = outer; outerBorder = outer;
m = new DMeasures(this); m = new DMeasures(this);
} }
@ -157,7 +157,7 @@ public class ScaledBorder implements Border {
* x-values by itself * x-values by itself
*/ */
public void setAutoScaleX() { public void setAutoScaleX() {
auto_scale_x = true; autoScaleX = true;
} }
/** /**
@ -165,7 +165,7 @@ public class ScaledBorder implements Border {
* y-values by itself * y-values by itself
*/ */
public void setAutoScaleY() { public void setAutoScaleY() {
auto_scale_y = true; autoScaleY = true;
} }
/** /**
@ -176,8 +176,8 @@ public class ScaledBorder implements Border {
* and the source values * and the source values
*/ */
public void setSrcdX(double dX) { public void setSrcdX(double dX) {
auto_scale_x = false; autoScaleX = false;
src_dX = dX; srcDX = dX;
} }
/** /**
@ -188,8 +188,8 @@ public class ScaledBorder implements Border {
* and the source values * and the source values
*/ */
public void setSrcdY(double dY) { public void setSrcdY(double dY) {
auto_scale_y = false; autoScaleY = false;
src_dY = dY; srcDY = dY;
} }
/** /**
@ -217,61 +217,61 @@ public class ScaledBorder implements Border {
if (background == null) { if (background == null) {
background = c.getBackground(); background = c.getBackground();
} }
Color old_color = g.getColor(); Color oldColor = g.getColor();
g.setColor(background); g.setColor(background);
g.fillRect(x, y, width, height); 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 Insets outerInsets = new Insets(0, 0, 0, 0);// insets of the outer border
if (show_outer_border) { if (showOuterBorder) {
outer_border.paintBorder(c, g, x, y, width, height); outerBorder.paintBorder(c, g, x, y, width, height);
outer_insets = outer_border.getBorderInsets(c); outerInsets = outerBorder.getBorderInsets(c);
} }
do_refresh = true; doRefresh = true;
Insets inner_insets = getBorderInsets(c); Insets innerInsets = getBorderInsets(c);
Dimension d = c.getSize(), Dimension d = c.getSize(),
cd = new Dimension(d.width - inner_insets.left - inner_insets.right, cd = new Dimension(d.width - innerInsets.left - innerInsets.right,
d.height - inner_insets.top - inner_insets.bottom); d.height - innerInsets.top - innerInsets.bottom);
FontMetrics fm = g.getFontMetrics(); FontMetrics fm = g.getFontMetrics();
int fontAsc = fm.getAscent(); int fontAsc = fm.getAscent();
do_refresh = false; doRefresh = false;
m.update(c, inner_insets); m.update(c, innerInsets);
// axes // axes
g.setColor(foreground); g.setColor(foreground);
g.drawLine(inner_insets.left, inner_insets.top, g.drawLine(innerInsets.left, innerInsets.top,
inner_insets.left, inner_insets.top + cd.height); innerInsets.left, innerInsets.top + cd.height);
g.drawLine(inner_insets.left, inner_insets.top + cd.height, g.drawLine(innerInsets.left, innerInsets.top + cd.height,
inner_insets.left + cd.width, inner_insets.top + cd.height); innerInsets.left + cd.width, innerInsets.top + cd.height);
if (showArrows) { if (showArrows) {
g.drawLine(inner_insets.left, inner_insets.top, g.drawLine(innerInsets.left, innerInsets.top,
inner_insets.left, inner_insets.top - y_values2arrow); innerInsets.left, innerInsets.top - yValues2arrow);
g.drawLine(inner_insets.left - markerLength, inner_insets.top - y_values2arrow, g.drawLine(innerInsets.left - markerLength, innerInsets.top - yValues2arrow,
inner_insets.left, inner_insets.top - y_values2arrow - arrowLength); innerInsets.left, innerInsets.top - yValues2arrow - arrowLength);
g.drawLine(inner_insets.left + markerLength, inner_insets.top - y_values2arrow, g.drawLine(innerInsets.left + markerLength, innerInsets.top - yValues2arrow,
inner_insets.left, inner_insets.top - y_values2arrow - arrowLength); innerInsets.left, innerInsets.top - yValues2arrow - arrowLength);
g.drawLine(inner_insets.left - markerLength, inner_insets.top - y_values2arrow, g.drawLine(innerInsets.left - markerLength, innerInsets.top - yValues2arrow,
inner_insets.left + markerLength, inner_insets.top - y_values2arrow); innerInsets.left + markerLength, innerInsets.top - yValues2arrow);
g.drawLine(inner_insets.left + cd.width, inner_insets.top + cd.height, g.drawLine(innerInsets.left + cd.width, innerInsets.top + cd.height,
inner_insets.left + cd.width + x_values2arrow, inner_insets.top + cd.height); innerInsets.left + cd.width + xValues2arrow, innerInsets.top + cd.height);
g.drawLine(inner_insets.left + cd.width + x_values2arrow, g.drawLine(innerInsets.left + cd.width + xValues2arrow,
inner_insets.top + cd.height - markerLength, innerInsets.top + cd.height - markerLength,
inner_insets.left + cd.width + x_values2arrow + arrowLength, innerInsets.left + cd.width + xValues2arrow + arrowLength,
inner_insets.top + cd.height); innerInsets.top + cd.height);
g.drawLine(inner_insets.left + cd.width + x_values2arrow, g.drawLine(innerInsets.left + cd.width + xValues2arrow,
inner_insets.top + cd.height + markerLength, innerInsets.top + cd.height + markerLength,
inner_insets.left + cd.width + x_values2arrow + arrowLength, innerInsets.left + cd.width + xValues2arrow + arrowLength,
inner_insets.top + cd.height); innerInsets.top + cd.height);
g.drawLine(inner_insets.left + cd.width + x_values2arrow, g.drawLine(innerInsets.left + cd.width + xValues2arrow,
inner_insets.top + cd.height - markerLength, innerInsets.top + cd.height - markerLength,
inner_insets.left + cd.width + x_values2arrow, innerInsets.left + cd.width + xValues2arrow,
inner_insets.top + cd.height + markerLength); innerInsets.top + cd.height + markerLength);
} }
if (yLabel != null) { if (yLabel != null) {
@ -279,31 +279,31 @@ public class ScaledBorder implements Border {
AffineTransform T = new AffineTransform(0, 1, 1, 0, 0, 0); AffineTransform T = new AffineTransform(0, 1, 1, 0, 0, 0);
Font old = g.getFont(), f = old.deriveFont(T); Font old = g.getFont(), f = old.deriveFont(T);
g.setFont(f); 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); g.setFont(old);
} }
if (xLabel != null) { if (xLabel != null) {
g.drawString( g.drawString(
xLabel, inner_insets.left + (cd.width - fm.stringWidth(xLabel)) / 2, xLabel, innerInsets.left + (cd.width - fm.stringWidth(xLabel)) / 2,
d.height - outer_insets.bottom - x_label2border - fm.getDescent()); d.height - outerInsets.bottom - xLabel2border - fm.getDescent());
} }
if (src_rect.x == 0 && src_rect.y == 0) { if (srcRect.x == 0 && srcRect.y == 0) {
int v2m = fm.stringWidth("0") / y_values2marker; int v2m = fm.stringWidth("0") / yValues2marker;
g.drawString("0", inner_insets.left - fm.stringWidth("0") - v2m - markerLength, g.drawString("0", innerInsets.left - fm.stringWidth("0") - v2m - markerLength,
inner_insets.top + cd.height + fontAsc); innerInsets.top + cd.height + fontAsc);
g.drawLine(inner_insets.left, inner_insets.top + cd.height + fm.getAscent(), g.drawLine(innerInsets.left, innerInsets.top + cd.height + fm.getAscent(),
inner_insets.left, inner_insets.top + cd.height); innerInsets.left, innerInsets.top + cd.height);
g.drawLine(inner_insets.left, inner_insets.top + cd.height, g.drawLine(innerInsets.left, innerInsets.top + cd.height,
inner_insets.left - fm.stringWidth("0") - v2m - markerLength, innerInsets.left - fm.stringWidth("0") - v2m - markerLength,
inner_insets.top + cd.height); innerInsets.top + cd.height);
} }
drawYValues(g, inner_insets); drawYValues(g, innerInsets);
drawXValues(g, inner_insets, cd); 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) { private void drawYValues(Graphics g, Insets insets) {
FontMetrics fm = g.getFontMetrics(); 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; double v, scaledV, minx = srcRect.x;
if (x_scale != null) { if (xScale != null) {
minx = x_scale.getImageOf(minx); minx = xScale.getImageOf(minx);
} }
v = startVal; v = startVal;
while (v <= src_rect.y + src_rect.height) { while (v <= srcRect.y + srcRect.height) {
if (y_scale != null) { if (yScale != null) {
scaledV = y_scale.getImageOf(v); scaledV = yScale.getImageOf(v);
} else { } else {
scaledV = v; scaledV = v;
} }
String text = format_y.format(scaledV); String text = formatY.format(scaledV);
try { try {
scaledV = format_y.parse(text).doubleValue(); scaledV = formatY.parse(text).doubleValue();
} catch (java.text.ParseException ex) { } catch (java.text.ParseException ex) {
} }
Point p = m.getPoint(minx, scaledV); Point p = m.getPoint(minx, scaledV);
@ -341,11 +341,10 @@ public class ScaledBorder implements Border {
p.y + fontAsc / 2); p.y + fontAsc / 2);
g.drawLine(insets.left - markerLength, p.y, insets.left, p.y); g.drawLine(insets.left - markerLength, p.y, insets.left, p.y);
} }
if (v + src_dY <= v) { if (v + srcDY <= v) {
// System.err.println("Overflow error B in ScaledBorder! v,src_dY:" + v + ", " + src_dY);
v *= 1.01; v *= 1.01;
} }
v += src_dY; v += srcDY;
} }
} }
@ -354,82 +353,82 @@ public class ScaledBorder implements Border {
} }
public double getSrcdY(int fontMetricsHeight, int componentHeight) { public double getSrcdY(int fontMetricsHeight, int componentHeight) {
if ((!do_refresh && src_dY != -1) || !auto_scale_y) { if ((!doRefresh && srcDY != -1) || !autoScaleY) {
return src_dY; return srcDY;
} }
int max = componentHeight / fontMetricsHeight; 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 !!"); System.err.println("Error, infinite value in ScaledBorder:getSrcdY !!");
} }
double minsrc_dY = 2 * src_rect.height / (double) max; // die 2 einfach mal so eingesetzt <-------------------------- double minsrc_dY = 2 * srcRect.height / (double) max; // die 2 einfach mal so eingesetzt <--------------------------
src_dY = aBitBigger(minsrc_dY); srcDY = aBitBigger(minsrc_dY);
if (src_dY < minimal_increment) { if (srcDY < minimalIncrement) {
src_dY = minimal_increment; srcDY = minimalIncrement;
} }
return src_dY; return srcDY;
} }
private void drawXValues(Graphics g, Insets insets, Dimension cd) { private void drawXValues(Graphics g, Insets insets, Dimension cd) {
FontMetrics fm = g.getFontMetrics(); FontMetrics fm = g.getFontMetrics();
double mx = cd.width / src_rect.width; double mx = cd.width / srcRect.width;
int n, labelX, 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); n = (int) (srcRect.x / srcDX);
if (n * src_dX < src_rect.x || (src_rect.x == 0 && src_rect.y == 0)) { if (n * srcDX < srcRect.x || (srcRect.x == 0 && srcRect.y == 0)) {
n++; n++;
} }
int fontAsc = fm.getAscent(), xLineY = insets.top + cd.height; int fontAsc = fm.getAscent(), xLineY = insets.top + cd.height;
labelX = xnull + (int) (n * src_dX * mx); labelX = xnull + (int) (n * srcDX * mx);
while (n * src_dX <= src_rect.x + src_rect.width) { while (n * srcDX <= srcRect.x + srcRect.width) {
double v = n * src_dX; double v = n * srcDX;
if (x_scale != null) { if (xScale != null) {
v = x_scale.getImageOf(v); v = xScale.getImageOf(v);
} }
String text = format_x.format(v); String text = formatX.format(v);
try { try {
v = format_x.parse(text).doubleValue(); v = formatX.parse(text).doubleValue();
} catch (java.text.ParseException ex) { } catch (java.text.ParseException ex) {
} }
int strW = fm.stringWidth(text); int strW = fm.stringWidth(text);
g.drawString(text, labelX - strW / 2, xLineY + fontAsc); g.drawString(text, labelX - strW / 2, xLineY + fontAsc);
g.drawLine(labelX, xLineY, labelX, xLineY + markerLength); g.drawLine(labelX, xLineY, labelX, xLineY + markerLength);
n++; n++;
labelX = xnull + (int) (n * src_dX * mx); labelX = xnull + (int) (n * srcDX * mx);
} }
} }
public double getSrcdX(FontMetrics fm, Dimension cd) { public double getSrcdX(FontMetrics fm, Dimension cd) {
if ((!do_refresh && src_dX != -1) || !auto_scale_x) { if ((!doRefresh && srcDX != -1) || !autoScaleX) {
return src_dX; return srcDX;
} }
int digit_width = fm.stringWidth("0"), int digit_width = fm.stringWidth("0"),
max = cd.width / (digit_width * (x_value2value + 1)); max = cd.width / (digit_width * (xValue2value + 1));
src_dX = src_rect.width / (double) max; srcDX = srcRect.width / (double) max;
int n, labelX, olsrc_dX; int n, labelX, olsrc_dX;
boolean ok = false; boolean ok = false;
while (!ok) { while (!ok) {
src_dX = aBitBigger(src_dX); srcDX = aBitBigger(srcDX);
n = (int) (src_rect.x / src_dX); n = (int) (srcRect.x / srcDX);
if (n * src_dX < src_rect.x) { if (n * srcDX < srcRect.x) {
n++; n++;
} }
olsrc_dX = 0; olsrc_dX = 0;
boolean suits = true, first = true; boolean suits = true, first = true;
while (suits && n * src_dX <= src_rect.x + src_rect.width) { while (suits && n * srcDX <= srcRect.x + srcRect.width) {
double v = n * src_dX; double v = n * srcDX;
if (x_scale != null) { if (xScale != null) {
v = x_scale.getImageOf(v); v = xScale.getImageOf(v);
} }
String text = format_x.format(v); String text = formatX.format(v);
int strW = fm.stringWidth(text); int strW = fm.stringWidth(text);
labelX = (int) (((n * src_dX - src_rect.x) / src_rect.width) * cd.width) - strW / 2; labelX = (int) (((n * srcDX - srcRect.x) / srcRect.width) * cd.width) - strW / 2;
if (!first && labelX <= olsrc_dX + digit_width * x_value2value) { if (!first && labelX <= olsrc_dX + digit_width * xValue2value) {
suits = false; suits = false;
} else { } else {
olsrc_dX = labelX + strW; olsrc_dX = labelX + strW;
@ -439,10 +438,10 @@ public class ScaledBorder implements Border {
} }
ok = suits; ok = suits;
} }
if (src_dX < minimal_increment) { if (srcDX < minimalIncrement) {
src_dX = minimal_increment; srcDX = minimalIncrement;
} }
return src_dX; return srcDX;
} }
/** /**
@ -484,7 +483,7 @@ public class ScaledBorder implements Border {
@Override @Override
public boolean isBorderOpaque() { public boolean isBorderOpaque() {
return outer_border.isBorderOpaque(); return outerBorder.isBorderOpaque();
} }
/** /**
@ -545,13 +544,12 @@ public class ScaledBorder implements Border {
* *
* @param bXorY * @param bXorY
* @param pattern * @param pattern
* @see #java.text.DecimalFormat.applyPattern
*/ */
public void applyPattern(boolean bXorY, String pattern) { public void applyPattern(boolean bXorY, String pattern) {
if (bXorY) { if (bXorY) {
((java.text.DecimalFormat) format_x).applyPattern(pattern); ((java.text.DecimalFormat) formatX).applyPattern(pattern);
} else { } else {
((java.text.DecimalFormat) format_y).applyPattern(pattern); ((java.text.DecimalFormat) formatY).applyPattern(pattern);
} }
} }
@ -562,15 +560,15 @@ public class ScaledBorder implements Border {
*/ */
@Override @Override
public Insets getBorderInsets(Component c) { public Insets getBorderInsets(Component c) {
if (!do_refresh && old_insets != null) { if (!doRefresh && oldInsets != null) {
return old_insets; return oldInsets;
} }
Graphics g = c.getGraphics(); Graphics g = c.getGraphics();
Insets insets = new Insets(0, 0, 0, 0); Insets insets = new Insets(0, 0, 0, 0);
if (show_outer_border) { if (showOuterBorder) {
insets = outer_border.getBorderInsets(c); insets = outerBorder.getBorderInsets(c);
} }
if (g == null) { if (g == null) {
@ -584,76 +582,76 @@ public class ScaledBorder implements Border {
if (c instanceof DArea) { if (c instanceof DArea) {
DArea area = (DArea) c; DArea area = (DArea) c;
DMeasures m = area.getDMeasures(); DMeasures m = area.getDMeasures();
src_rect = m.getSourceOf(area.getSlimRectangle()); srcRect = m.getSourceOf(area.getSlimRectangle());
x_scale = area.getDMeasures().x_scale; xScale = area.getDMeasures().xScale;
y_scale = area.getDMeasures().y_scale; yScale = area.getDMeasures().yScale;
} }
// left: // left:
if (yLabel != null) { if (yLabel != null) {
insets.left += fm.getAscent() + fm.getDescent(); insets.left += fm.getAscent() + fm.getDescent();
} }
insets.left += y_label2values * digit_width; insets.left += yLabel2values * digit_width;
getSrcdY(fm, c.getSize()); getSrcdY(fm, c.getSize());
double start, n, inc; double start, n, inc;
int maxWidth = 0; int maxWidth = 0;
start = src_dY * (int) (src_rect.y / src_dY); start = srcDY * (int) (srcRect.y / srcDY);
n = start; n = start;
if (n < src_rect.y) { if (n < srcRect.y) {
n += src_dY; n += srcDY;
} }
if (((src_rect.y + src_rect.height) - start) / src_dY > 20) { if (((srcRect.y + srcRect.height) - start) / srcDY > 20) {
inc = ((src_rect.y + src_rect.height) - start) / 20.; inc = ((srcRect.y + srcRect.height) - start) / 20.;
} else { } else {
inc = src_dY; inc = srcDY;
} }
if ((n + inc) == n) { if ((n + inc) == n) {
System.err.println("Warning, too small increase step size!"); 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 // TODO here might be a bug for mean values
double v = n; double v = n;
if (y_scale != null) { if (yScale != null) {
v = y_scale.getImageOf(v); v = yScale.getImageOf(v);
} }
int w = fm.stringWidth(format_y.format(v)); int w = fm.stringWidth(formatY.format(v));
if (w > maxWidth) { if (w > maxWidth) {
maxWidth = w; 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: // bottom:
insets.bottom += 1 + fontHeight + x_label2border; insets.bottom += 1 + fontHeight + xLabel2border;
if (xLabel != null) { if (xLabel != null) {
insets.bottom += fontHeight; insets.bottom += fontHeight;
} }
// top: // top:
if (showArrows) { if (showArrows) {
insets.top += y_values2arrow + arrowLength; insets.top += yValues2arrow + arrowLength;
} }
insets.top += axis2border; insets.top += axis2border;
// right: // right:
if (showArrows) { if (showArrows) {
insets.right += x_values2arrow + arrowLength; insets.right += xValues2arrow + arrowLength;
} }
insets.right += axis2border; insets.right += axis2border;
getSrcdX(fm, c.getSize()); 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) { if (k < 0) {
k++; k++;
} }
int w = fm.stringWidth(format_x.format(k * src_dX)); int w = fm.stringWidth(formatX.format(k * srcDX));
if (w / 2 > insets.right) { if (w / 2 > insets.right) {
insets.right = w / 2; insets.right = w / 2;
} }
old_insets = insets; oldInsets = insets;
return insets; return insets;
} }
} }

View File

@ -3,8 +3,6 @@ package eva2.tools.chart2d;
/** /**
* Encapsulates a slim rectangle structure with x, y, width and height and * Encapsulates a slim rectangle structure with x, y, width and height and
* nothing else. Makes some painting calculations quite a bit faster. * nothing else. Makes some painting calculations quite a bit faster.
*
* @author mkron
*/ */
public class SlimRect { public class SlimRect {
double x, y, width, height; double x, y, width, height;

View File

@ -13,10 +13,6 @@ package eva2.tools.math.Jama;
public class CholeskyDecomposition implements java.io.Serializable { public class CholeskyDecomposition implements java.io.Serializable {
/* ------------------------
Class variables
* ------------------------ */
/** /**
* Array for internal storage of decomposition. * Array for internal storage of decomposition.
* *
@ -38,10 +34,6 @@ public class CholeskyDecomposition implements java.io.Serializable {
*/ */
private boolean isspd; private boolean isspd;
/* ------------------------
Constructor
* ------------------------ */
/** /**
* Cholesky algorithm for symmetric and positive definite matrix. * Cholesky algorithm for symmetric and positive definite matrix.
* *

View File

@ -64,10 +64,6 @@ public class EigenvalueDecomposition implements java.io.Serializable {
*/ */
private double[] ort; private double[] ort;
/* ------------------------
Private Methods
* ------------------------ */
// Symmetric Householder reduction to tridiagonal form. // Symmetric Householder reduction to tridiagonal form.
private void tred2() { private void tred2() {
@ -855,21 +851,16 @@ public class EigenvalueDecomposition implements java.io.Serializable {
} }
} }
/* ------------------------
Constructor
* ------------------------ */
/** /**
* Check for symmetry, then construct the eigenvalue decomposition * Check for symmetry, then construct the eigenvalue decomposition
* *
* @param A Square matrix * @param arg A Square matrix
* @return Structure to access D and V. * @return Structure to access D and V.
*/ */
public EigenvalueDecomposition(Matrix Arg) { public EigenvalueDecomposition(Matrix matrix) {
double[][] A = Arg.getArray(); double[][] A = matrix.getArray();
n = Arg.getColumnDimension(); n = matrix.getColumnDimension();
V = new double[n][n]; V = new double[n][n];
d = new double[n]; d = new double[n];
e = new double[n]; e = new double[n];
@ -910,10 +901,6 @@ public class EigenvalueDecomposition implements java.io.Serializable {
} }
} }
/* ------------------------
Public Methods
* ------------------------ */
/** /**
* Return the eigenvector matrix * Return the eigenvector matrix
* *

View File

@ -40,10 +40,6 @@ public class LUDecomposition implements java.io.Serializable {
*/ */
private int[] piv; private int[] piv;
/* ------------------------
Constructor
* ------------------------ */
/** /**
* LU Decomposition * LU Decomposition
* *
@ -52,11 +48,6 @@ public class LUDecomposition implements java.io.Serializable {
*/ */
public LUDecomposition(Matrix A) { 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(); LU = A.getArrayCopy();
m = A.getRowDimension(); m = A.getRowDimension();
n = A.getColumnDimension(); n = A.getColumnDimension();
@ -124,69 +115,6 @@ public class LUDecomposition implements java.io.Serializable {
} }
} }
/* ------------------------
Temporary, experimental code.
------------------------ *\
\** LU Decomposition, computed by Gaussian elimination.
<P>
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.
<P>
@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? * Is the matrix nonsingular?
* *
@ -195,7 +123,6 @@ public class LUDecomposition implements java.io.Serializable {
public boolean isNonsingular() { public boolean isNonsingular() {
for (int j = 0; j < n; j++) { for (int j = 0; j < n; j++) {
//System.out.println("LU[j][j]"+LU[j][j]);
if (LU[j][j] == 0) { if (LU[j][j] == 0) {
return false; return false;
} }
@ -253,7 +180,6 @@ public class LUDecomposition implements java.io.Serializable {
* *
* @return piv * @return piv
*/ */
public int[] getPivot() { public int[] getPivot() {
int[] p = new int[m]; int[] p = new int[m];
System.arraycopy(piv, 0, p, 0, m); System.arraycopy(piv, 0, p, 0, m);
@ -265,7 +191,6 @@ public class LUDecomposition implements java.io.Serializable {
* *
* @return (double) piv * @return (double) piv
*/ */
public double[] getDoublePivot() { public double[] getDoublePivot() {
double[] vals = new double[m]; double[] vals = new double[m];
for (int i = 0; i < m; i++) { for (int i = 0; i < m; i++) {
@ -280,7 +205,6 @@ public class LUDecomposition implements java.io.Serializable {
* @return det(A) * @return det(A)
* @throws IllegalArgumentException Matrix must be square * @throws IllegalArgumentException Matrix must be square
*/ */
public double det() { public double det() {
if (m != n) { if (m != n) {
throw new IllegalArgumentException("Matrix must be square."); 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 IllegalArgumentException Matrix row dimensions must agree.
* @throws RuntimeException Matrix is singular. * @throws RuntimeException Matrix is singular.
*/ */
public Matrix solve(Matrix B) { public Matrix solve(Matrix B) {
if (B.getRowDimension() != m) { if (B.getRowDimension() != m) {
throw new IllegalArgumentException("Matrix row dimensions must agree."); throw new IllegalArgumentException("Matrix row dimensions must agree.");
} }
if (!this.isNonsingular()) { if (!this.isNonsingular()) {
//System.out.println("B=");
//B.print(B.getRowDimension(),B.getColumnDimension());
throw new RuntimeException("Matrix is singular."); throw new RuntimeException("Matrix is singular.");
} }

View File

@ -17,7 +17,6 @@ import java.util.Arrays;
import java.util.Locale; import java.util.Locale;
import java.util.Vector; import java.util.Vector;
/** /**
* Jama = Java Matrix class. * Jama = Java Matrix class.
* <p/> * <p/>

View File

@ -15,13 +15,8 @@ import eva2.tools.math.Jama.util.Maths;
* of simultaneous linear equations. This will fail if isFullRank() * of simultaneous linear equations. This will fail if isFullRank()
* returns false. * returns false.
*/ */
public class QRDecomposition implements java.io.Serializable { public class QRDecomposition implements java.io.Serializable {
/* ------------------------
Class variables
* ------------------------ */
/** /**
* Array for internal storage of decomposition. * Array for internal storage of decomposition.
* *
@ -44,17 +39,12 @@ public class QRDecomposition implements java.io.Serializable {
*/ */
private double[] Rdiag; private double[] Rdiag;
/* ------------------------
Constructor
* ------------------------ */
/** /**
* QR Decomposition, computed by Householder reflections. * QR Decomposition, computed by Householder reflections.
* *
* @param A Rectangular matrix * @param A Rectangular matrix
* @return Structure to access R and the Householder vectors and compute Q. * @return Structure to access R and the Householder vectors and compute Q.
*/ */
public QRDecomposition(Matrix A) { public QRDecomposition(Matrix A) {
// Initialize. // Initialize.
QR = A.getArrayCopy(); QR = A.getArrayCopy();
@ -96,16 +86,11 @@ public class QRDecomposition implements java.io.Serializable {
} }
} }
/* ------------------------
Public Methods
* ------------------------ */
/** /**
* Is the matrix full rank? * Is the matrix full rank?
* *
* @return true if R, and hence A, has full rank. * @return true if R, and hence A, has full rank.
*/ */
public boolean isFullRank() { public boolean isFullRank() {
for (int j = 0; j < n; j++) { for (int j = 0; j < n; j++) {
if (Rdiag[j] == 0) { if (Rdiag[j] == 0) {
@ -120,7 +105,6 @@ public class QRDecomposition implements java.io.Serializable {
* *
* @return Lower trapezoidal matrix whose columns define the reflections * @return Lower trapezoidal matrix whose columns define the reflections
*/ */
public Matrix getH() { public Matrix getH() {
Matrix X = new Matrix(m, n); Matrix X = new Matrix(m, n);
double[][] H = X.getArray(); double[][] H = X.getArray();
@ -141,7 +125,6 @@ public class QRDecomposition implements java.io.Serializable {
* *
* @return R * @return R
*/ */
public Matrix getR() { public Matrix getR() {
Matrix X = new Matrix(n, n); Matrix X = new Matrix(n, n);
double[][] R = X.getArray(); double[][] R = X.getArray();
@ -164,7 +147,6 @@ public class QRDecomposition implements java.io.Serializable {
* *
* @return Q * @return Q
*/ */
public Matrix getQ() { public Matrix getQ() {
Matrix X = new Matrix(m, n); Matrix X = new Matrix(m, n);
double[][] Q = X.getArray(); double[][] Q = X.getArray();
@ -197,7 +179,6 @@ public class QRDecomposition implements java.io.Serializable {
* @throws IllegalArgumentException Matrix row dimensions must agree. * @throws IllegalArgumentException Matrix row dimensions must agree.
* @throws RuntimeException Matrix is rank deficient. * @throws RuntimeException Matrix is rank deficient.
*/ */
public Matrix solve(Matrix B) { public Matrix solve(Matrix B) {
if (B.getRowDimension() != m) { if (B.getRowDimension() != m) {
throw new IllegalArgumentException("Matrix row dimensions must agree."); throw new IllegalArgumentException("Matrix row dimensions must agree.");

View File

@ -20,10 +20,6 @@ import eva2.tools.math.Jama.util.Maths;
public class SingularValueDecomposition implements java.io.Serializable { public class SingularValueDecomposition implements java.io.Serializable {
/* ------------------------
Class variables
* ------------------------ */
/** /**
* Arrays for internal storage of U and V. * Arrays for internal storage of U and V.
* *
@ -47,24 +43,20 @@ public class SingularValueDecomposition implements java.io.Serializable {
*/ */
private int m, n; private int m, n;
/* ------------------------
Constructor
* ------------------------ */
/** /**
* Construct the singular value decomposition * Construct the singular value decomposition
* *
* @param A Rectangular matrix * @param arg A Rectangular matrix
* @return Structure to access U, S and V. * @return Structure to access U, S and V.
*/ */
public SingularValueDecomposition(Matrix Arg) { public SingularValueDecomposition(Matrix matrix) {
// Derived from LINPACK code. // Derived from LINPACK code.
// Initialize. // Initialize.
double[][] A = Arg.getArrayCopy(); double[][] A = matrix.getArrayCopy();
m = Arg.getRowDimension(); m = matrix.getRowDimension();
n = Arg.getColumnDimension(); n = matrix.getColumnDimension();
int nu = Math.min(m, n); int nu = Math.min(m, n);
s = new double[Math.min(m + 1, n)]; s = new double[Math.min(m + 1, n)];
U = new double[m][nu]; U = new double[m][nu];
@ -476,10 +468,6 @@ public class SingularValueDecomposition implements java.io.Serializable {
} }
} }
/* ------------------------
Public Methods
* ------------------------ */
/** /**
* Return the left singular vectors * Return the left singular vectors
* *

View File

@ -112,7 +112,6 @@ public class Mathematics {
* *
* @param x a vector * @param x a vector
* @param y another vector * @param y another vector
* @param root what kind of distance funktion
* @return the distance of x and y * @return the distance of x and y
* @throws Exception if x and y have different dimensions an exception is thrown. * @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) { public static double[] expandVector(double[] x, int len, double v) {
if (len <= x.length) {// not really an error, just perform identity 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; return x;
} else { } else {
double[] expanded = new double[len]; double[] expanded = new double[len];

View File

@ -399,43 +399,6 @@ public class StatisticUtils {
return corrCoefficient; 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; i<vs.length; i++) {
// Mathematics.svAdd(512, vs[i], vs[i]);
// Mathematics.normVect(vs[i], vs[i]);
// System.out.println(BeanInspector.toString(vs[i]));
// }
// System.out.println("entropy cols: " + entropyOverColumns(vs));
// System.out.println("entropy rows: " + entropyOverRows(vs));
}
/** /**
* Computes the entropy of the given array. * Computes the entropy of the given array.
* *
@ -500,9 +463,6 @@ public class StatisticUtils {
* @return * @return
*/ */
public static Matrix rlh(int samples, int dim, double lb, double ub, boolean edges) { public static Matrix rlh(int samples, int dim, double lb, double ub, boolean edges) {
// System.out.println( "Latin Hypercube sampling" );
// ++rlhsamplings;
// perform Latin-Hypercube-Sampling to obtain a stratified sample of // perform Latin-Hypercube-Sampling to obtain a stratified sample of
// function values over the optimization domain // function values over the optimization domain
@ -593,9 +553,7 @@ public class StatisticUtils {
* Returns a list of point matrices which form a latin hypercube sampling of the given space. * Returns a list of point matrices which form a latin hypercube sampling of the given space.
* *
* @param samples * @param samples
* @param dim * @param range
* @param lb
* @param ub
* @param edges * @param edges
* @return * @return
*/ */

View File

@ -1,37 +1,11 @@
///////////////////////////////////////////////////////////////////////////////
// Filename: $RCSfile: AbstractDataModifier.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:24:58 $
// $Author: wegnerj $
//
// Copyright (c) Dept. Computer Architecture, University of Tuebingen, Germany
//
///////////////////////////////////////////////////////////////////////////////
package eva2.tools.math.interpolation; package eva2.tools.math.interpolation;
/*==========================================================================*
* IMPORTS
*==========================================================================*/
/*==========================================================================*
* CLASS DECLARATION
*==========================================================================*/
/** /**
* The minimal set of functions which should implemented in a data modifier for * The minimal set of functions which should implemented in a data modifier for
* <code>AbstractDataSet</code>. * <code>AbstractDataSet</code>.
*/ */
public abstract class AbstractDataModifier { public abstract class AbstractDataModifier {
/*-------------------------------------------------------------------------*
* abstract methods
*-------------------------------------------------------------------------*/
/** /**
* Modifies the X data. * Modifies the X data.
*/ */
@ -46,8 +20,4 @@ public abstract class AbstractDataModifier {
* Modifies the data. * Modifies the data.
*/ */
public abstract void modify(double[] setX, double[] setY); public abstract void modify(double[] setX, double[] setY);
} }
/****************************************************************************
* END OF FILE
****************************************************************************/

View File

@ -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; package eva2.tools.math.interpolation;
/*==========================================================================*
* IMPORTS
*==========================================================================*/
/*==========================================================================*
* CLASS DECLARATION
*==========================================================================*/
public abstract class AbstractDataSet { public abstract class AbstractDataSet {
/*-------------------------------------------------------------------------*
* public member variables
*-------------------------------------------------------------------------*/
/*--------------------------------------------------------------o-----------*
* protected member variables
*-------------------------------------------------------------------------*/
/** /**
* double array of X data. * double array of X data.
* *
@ -43,10 +14,6 @@ public abstract class AbstractDataSet {
*/ */
protected double[] yDoubleData = {1, 1}; protected double[] yDoubleData = {1, 1};
/*-------------------------------------------------------------------------*
* abstract methods
*-------------------------------------------------------------------------*/
/** /**
* Returns the length of the data set * Returns the length of the data set
* *
@ -115,6 +82,3 @@ public abstract class AbstractDataSet {
modifier.modify(xDoubleData, yDoubleData); modifier.modify(xDoubleData, yDoubleData);
} }
} }
/****************************************************************************
* END OF FILE
****************************************************************************/

View File

@ -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; package eva2.tools.math.interpolation;
/** /**

View File

@ -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; package eva2.tools.math.interpolation;
/*==========================================================================*
* IMPORTS
*==========================================================================*/
/*==========================================================================*
* CLASS DECLARATION
*==========================================================================*/
/** /**
* Exception for interpolation error. * Exception for interpolation error.
*/ */
@ -35,8 +11,4 @@ public class InterpolationException extends Exception {
public InterpolationException(String s) { public InterpolationException(String s) {
super(s); super(s);
} }
} }
/****************************************************************************
* END OF FILE
****************************************************************************/

View File

@ -15,12 +15,6 @@
package eva2.tools.math.interpolation; package eva2.tools.math.interpolation;
/*==========================================================================*
* IMPORTS
*==========================================================================*/
//import cern.jet.stat.*;
/** /**
* Defines the routines for the spline interpolation of data. * Defines the routines for the spline interpolation of data.
*/ */

View File

@ -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 <code>AbstractDataSet</code>
*/
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 <code>AbstractDataSet</code>
* @param sloppy if <code>true</code> Neville's algorithm which is used in the
* <code>polynomialInterpolation</code>-routines does only print a
* warning message on the screen and does not throw an
* <code>Exception</code> 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 <code>AbstractDataSet</code> and calculates the coefficients
* of the polynom.
*
* @param abstractDataSet the <code>AbstractDataSet</code>
*/
public void setAbstractDataSet(AbstractDataSet abstractDataSet)
throws InterpolationException {
this.abstractDataSet = abstractDataSet;
this.polynomialCoefficients = calculatePolynomialCoefficients();
}
/**
* Uses the polynom with the calculated coefficients to calculate the
* <code>y</code> value. This algorithm was taken from:<br>
* <a href="http://www.ulib.org/webRoot/Books/Numerical_Recipes/" target="_top">
* 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.</a><br>
* The Neville's algorithm which is used in the <code>polynomialInterpolation</code>-
* 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
* <code>y</code> value and the derivatives at the point <code>x</code>,
* <code>y</code>. This algorithm was taken from:<br>
* <a href="http://www.ulib.org/webRoot/Books/Numerical_Recipes/" target="_top">
* 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.</a><br>
* The Neville's algorithm which is used in the <code>polynomialInterpolation</code>-
* 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:<br>
* <a href="http://www.ulib.org/webRoot/Books/Numerical_Recipes/" target="_top">
* 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.</a><br>
*
* @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:<br>
* <a href="http://www.ulib.org/webRoot/Books/Numerical_Recipes/" target="_top">
* 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.</a><br>
*
* @param abstractDataSet the <code>AbstractDataSet</code>
* @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:<br>
* <a href="http://www.ulib.org/webRoot/Books/Numerical_Recipes/" target="_top">
* 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.</a><br>
*
* @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 <code>N-1</code>. This
* interpolation algorithm was taken from:<br>
* <a href="http://www.ulib.org/webRoot/Books/Numerical_Recipes/" target="_top">
* 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.</a><br>
*
* @return the array with the polynomial coefficients y = ...[0] +
* ...[1]*x<SUP>2</SUP> + ...[2]*x<SUP>3</SUP> + ...
* @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 <code>N-1</code>. This
* interpolation algorithm was taken from:<br>
* <a href="http://www.ulib.org/webRoot/Books/Numerical_Recipes/" target="_top">
* 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.</a><br>
*
* @param abstractDataSet the <code>AbstractDataSet</code>
* @return the array with the polynomial coefficients y = ...[0] +
* ...[1]*x<SUP>2</SUP> + ...[2]*x<SUP>3</SUP> + ...
* @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 <code>N-1</code>. This
* interpolation algorithm was taken from:<br>
* <a href="http://www.ulib.org/webRoot/Books/Numerical_Recipes/" target="_top">
* 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.</a><br>
*
* @param x the array of x values
* @param y the array of y values
* @return the array with the polynomial coefficients y = ...[0] +
* ...[1]*x<SUP>2</SUP> + ...[2]*x<SUP>3</SUP> + ...
* @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;
}
}

View File

@ -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; package eva2.tools.math.interpolation;
/*==========================================================================*
* IMPORTS
*==========================================================================*/
/** /**
* Defines the routines for the spline interpolation of data. * Defines the routines for the spline interpolation of data.
*/ */
@ -28,16 +10,10 @@ public class SplineInterpolation {
double[] yArray = null; double[] yArray = null;
boolean ascendingData = true; boolean ascendingData = true;
/*------------------------------------------------------------------------*
* constructor
*------------------------------------------------------------------------*/
/** /**
* Initializes this class. * Initializes this class.
*/ */
public SplineInterpolation() throws InterpolationException { public SplineInterpolation() throws InterpolationException {
this.abstractDataSet = null;
this.secondDerivative = null;
} }
/** /**
@ -62,7 +38,6 @@ public class SplineInterpolation {
double[] x = abstractDataSet.getXData(); double[] x = abstractDataSet.getXData();
double[] y = abstractDataSet.getYData(); double[] y = abstractDataSet.getYData();
boolean ascending = false; boolean ascending = false;
boolean descending = false;
int n = x.length; int n = x.length;
xArray = new double[n]; xArray = new double[n];
@ -76,17 +51,11 @@ public class SplineInterpolation {
//if(descending)throw new InterpolationException("The x values must be"+ //if(descending)throw new InterpolationException("The x values must be"+
// " in continous ascending/descending order."); // " in continous ascending/descending order.");
ascending = true; ascending = true;
} else {
//if(ascending)throw new InterpolationException("The x values must be"+
// " in continous ascending/descending order.");
descending = true;
} }
} }
ascendingData = ascending; ascendingData = ascending;
if (ascendingData) { if (ascendingData) {
xArray = null;
yArray = null;
xArray = abstractDataSet.getXData(); xArray = abstractDataSet.getXData();
yArray = abstractDataSet.getYData(); yArray = abstractDataSet.getYData();
} }
@ -212,7 +181,7 @@ public class SplineInterpolation {
} }
} }
h = xa[khi] - xa[klo]; h = xa[khi] - xa[klo];
//System.out.println(""+x+" between "+xa[khi]+" "+xa[klo]);
if (h == 0.0) { if (h == 0.0) {
throw new InterpolationException("Two identical x values. The values must be distinct."); throw new InterpolationException("Two identical x values. The values must be distinct.");
} }
@ -262,7 +231,6 @@ public class SplineInterpolation {
} }
} }
h = xa[khi] - xa[klo]; h = xa[khi] - xa[klo];
//System.out.println(""+x+" between "+xa[khi]+" "+xa[klo]);
if (h == 0.0) { if (h == 0.0) {
throw new InterpolationException("Two identical x values. The values must be distinct."); 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; + ((3 * (b * b) - 1) * h * y2a[khi]) / 6.0;
return dydx; return dydx;
} }
} }
/****************************************************************************
* END OF FILE
****************************************************************************/