|
From: Gary P. <gpa...@gm...> - 2009-06-01 08:07:42
|
The Vector container class was overloaded with far too much responsibility. The decision was made to split the classes and have the Vector class be responsible for mathematical vector operations and that the Vector should be specialized for Numeric types. A companion container class "TypeList" has been added to perform the remainder of the fucntions that the Vector was performing. Gary Pampara (4): Vector for Numeric types. Modified Neural Networks to use Type container. Remainder of classes for Vector changes. Corrected index issue with subList(). pom.xml | 2 +- .../ClonedPopulationInitialisationStrategy.java | 2 +- .../cilib/bioinf/rnaprediction/RNAInitialiser.java | 5 +- .../cilib/bioinf/rnaprediction/RNAParticle.java | 7 +- .../bioinf/rnaprediction/RNAVelocityUpdate.java | 3 +- .../cilib/clustering/kmeans/KMeans.java | 2 +- .../cilib/cooperative/CooperativeEntity.java | 4 +- .../continuous/dynamic/moo/fda1/FDA1_f2.java | 2 +- .../continuous/dynamic/moo/fda1/FDA1_h.java | 4 +- .../continuous/dynamic/moo/fda2/FDA2_f2.java | 2 +- .../continuous/dynamic/moo/fda2/FDA2_h.java | 6 +- .../discrete/LongestCommonSubsequence.java | 4 +- .../sourceforge/cilib/games/agent/NeuralAgent.java | 3 +- .../neural/NeuralOutputInterpretationStrategy.java | 5 +- .../state/evaluation/NeuralStateEvaluator.java | 6 +- .../predatorprey/NeuralPredatorOutputStrategy.java | 13 +- .../predatorprey/NeuralPreyOutputStrategy.java | 15 +- .../cilib/games/items/GridLocation.java | 11 +- .../measurement/RecordItemLocationMeasure.java | 7 +- src/main/java/net/sourceforge/cilib/hs/HS.java | 7 +- .../java/net/sourceforge/cilib/math/StatUtils.java | 6 +- .../net/sourceforge/cilib/math/VectorMath.java | 29 +- .../measurement/multiple/CompositeMeasurement.java | 4 +- .../measurement/multiple/ParetoOptimalFront.java | 6 +- .../measurement/multiple/ParetoOptimalSet.java | 3 +- .../neuralnetwork/basicFFNN/FFNNTopology.java | 5 +- .../neuralnetwork/basicFFNN/TrainAndTestNN.java | 3 +- .../foundation/EvaluationMediator.java | 5 +- .../cilib/neuralnetwork/foundation/NNError.java | 4 +- .../foundation/NeuralNetworkProblem.java | 3 +- .../foundation/NeuralNetworkTopology.java | 3 +- .../BatchTrainingSetEpochStrategy.java | 4 +- ...chasticTrainingGeneralisationEpochStrategy.java | 5 +- .../foundation/measurements/AreaUnderROC.java | 6 +- .../foundation/measurements/NNOutput.java | 4 +- .../neuralnetwork/generic/GenericTopology.java | 3 +- .../generic/LayeredGenericTopology.java | 7 +- .../DynamicPatternSelectionData.java | 4 +- .../errorfunctions/ClassificationErrorReal.java | 6 +- .../generic/errorfunctions/MSEErrorFunction.java | 4 +- .../FFNNEvaluationMediator.java | 9 +- .../SAILAEvaluationMediator.java | 22 +- .../topologyvisitors/WeightExtractingVisitor.java | 3 +- .../generic/trainingstrategies/ErrorSignal.java | 4 +- .../FFNN_GD_TrainingStrategy.java | 8 +- .../trainingstrategies/SquaredErrorFunction.java | 3 +- .../testarea/TestErrorINCLearnWithTrainer.java | 3 +- .../testarea/TestFFNNandGDTrainer.java | 3 +- .../testarea/TestNeuronAndEvaluateFFNN.java | 5 +- .../testarea/TestSAILAwithTrainer.java | 3 +- .../problem/changestrategy/ChangeStrategy.java | 6 +- .../problem/dataset/StringDataSetBuilder.java | 3 - .../pso/dynamic/ChargedVelocityUpdateStrategy.java | 3 +- .../net/sourceforge/cilib/type/DomainBuilder.java | 38 +- .../net/sourceforge/cilib/type/types/Type.java | 29 +- .../cilib/type/types/container/AbstractList.java | 106 +--- .../cilib/type/types/container/Randomizable.java | 38 + .../cilib/type/types/container/TypeList.java | 268 +++++++ .../cilib/type/types/container/Vector.java | 726 +++++++------------- .../sourceforge/cilib/util/ClusteringUtils.java | 3 +- .../net/sourceforge/cilib/util/VectorUtils.java | 24 +- src/site/site.xml | 22 +- .../sourceforge/cilib/entity/IndividualTest.java | 2 - .../measurement/multiple/MultipleFitnessTest.java | 22 +- .../multiple/MultipleSolutionsTest.java | 6 +- .../single/BestParticlePositionTest.java | 8 +- .../cilib/measurement/single/DiameterTest.java | 16 +- .../measurement/single/ParticlePositionsTest.java | 6 +- .../cilib/measurement/single/SolutionTest.java | 6 +- .../sourceforge/cilib/type/DomainParserTest.java | 71 +- .../cilib/type/StringBasedDomainRegistryTest.java | 8 +- .../cilib/type/types/container/TypeListTest.java | 48 ++ .../cilib/type/types/container/VectorTest.java | 189 +----- .../cilib/util/ClusteringUtilsTest.java | 12 +- .../sourceforge/cilib/util/VectorUtilsTest.java | 13 - .../net/sourceforge/cilib/xml/XMLFileTest.java | 11 +- 76 files changed, 999 insertions(+), 972 deletions(-) create mode 100644 src/main/java/net/sourceforge/cilib/type/types/container/Randomizable.java create mode 100644 src/main/java/net/sourceforge/cilib/type/types/container/TypeList.java create mode 100644 src/test/java/net/sourceforge/cilib/type/types/container/TypeListTest.java |
|
From: Gary P. <gpa...@gm...> - 2009-06-01 08:07:45
|
Changed the manner in which the Type Vector works. Vectors are generally
associated with mathmatical operations and as a result, the Vector has
now been made a specialization of AbstractList<E>.
For general object containment in a list type structure, please use the
TypeList class which has been added.
---
.../ClonedPopulationInitialisationStrategy.java | 2 +-
.../cilib/bioinf/rnaprediction/RNAInitialiser.java | 5 +-
.../cilib/bioinf/rnaprediction/RNAParticle.java | 7 +-
.../bioinf/rnaprediction/RNAVelocityUpdate.java | 3 +-
.../cilib/clustering/kmeans/KMeans.java | 2 +-
.../continuous/dynamic/moo/fda1/FDA1_f2.java | 2 +-
.../continuous/dynamic/moo/fda1/FDA1_h.java | 4 +-
.../continuous/dynamic/moo/fda2/FDA2_f2.java | 2 +-
.../continuous/dynamic/moo/fda2/FDA2_h.java | 6 +-
.../discrete/LongestCommonSubsequence.java | 4 +-
src/main/java/net/sourceforge/cilib/hs/HS.java | 7 +-
.../java/net/sourceforge/cilib/math/StatUtils.java | 6 +-
.../net/sourceforge/cilib/math/VectorMath.java | 29 ++--
.../cilib/type/types/container/AbstractList.java | 90 ++--------
.../cilib/type/types/container/Randomizable.java | 35 ++++
.../cilib/type/types/container/TypeList.java | 198 ++++++++++++++++++++
.../cilib/type/types/container/VectorTest.java | 106 ++++-------
17 files changed, 325 insertions(+), 183 deletions(-)
create mode 100644 src/main/java/net/sourceforge/cilib/type/types/container/Randomizable.java
create mode 100644 src/main/java/net/sourceforge/cilib/type/types/container/TypeList.java
diff --git a/src/main/java/net/sourceforge/cilib/algorithm/initialisation/ClonedPopulationInitialisationStrategy.java b/src/main/java/net/sourceforge/cilib/algorithm/initialisation/ClonedPopulationInitialisationStrategy.java
index 7996f4d..ff64e98 100644
--- a/src/main/java/net/sourceforge/cilib/algorithm/initialisation/ClonedPopulationInitialisationStrategy.java
+++ b/src/main/java/net/sourceforge/cilib/algorithm/initialisation/ClonedPopulationInitialisationStrategy.java
@@ -67,7 +67,7 @@ public class ClonedPopulationInitialisationStrategy extends PopulationInitialisa
* @param problem The <tt>Problem</tt> to use in the initialisation of the topology.
* @throws InitialisationException if the initialisation cannot take place.
*/
- @SuppressWarnings("unchecked")
+ @Override
public void initialise(Topology topology, OptimisationProblem problem) {
if (problem == null)
throw new InitialisationException("No problem has been specified");
diff --git a/src/main/java/net/sourceforge/cilib/bioinf/rnaprediction/RNAInitialiser.java b/src/main/java/net/sourceforge/cilib/bioinf/rnaprediction/RNAInitialiser.java
index ff992fa..ce7a7cd 100644
--- a/src/main/java/net/sourceforge/cilib/bioinf/rnaprediction/RNAInitialiser.java
+++ b/src/main/java/net/sourceforge/cilib/bioinf/rnaprediction/RNAInitialiser.java
@@ -24,8 +24,7 @@ package net.sourceforge.cilib.bioinf.rnaprediction;
import net.sourceforge.cilib.math.random.generator.MersenneTwister;
import net.sourceforge.cilib.problem.OptimisationProblem;
import net.sourceforge.cilib.type.types.Type;
-import net.sourceforge.cilib.type.types.container.Vector;
-
+import net.sourceforge.cilib.type.types.container.TypeList;
/**
* @author mneethling
@@ -81,7 +80,7 @@ public class RNAInitialiser {
* @return The initial velocity.
*/
public Type getInitialVelocity(OptimisationProblem problem) {
- Vector mv = new Vector();
+ TypeList mv = new TypeList();
mv.add(new RNAConformation());
mv.add(new RNAConformation());
return mv;
diff --git a/src/main/java/net/sourceforge/cilib/bioinf/rnaprediction/RNAParticle.java b/src/main/java/net/sourceforge/cilib/bioinf/rnaprediction/RNAParticle.java
index 6a2d592..2483428 100644
--- a/src/main/java/net/sourceforge/cilib/bioinf/rnaprediction/RNAParticle.java
+++ b/src/main/java/net/sourceforge/cilib/bioinf/rnaprediction/RNAParticle.java
@@ -28,6 +28,7 @@ import net.sourceforge.cilib.problem.InferiorFitness;
import net.sourceforge.cilib.problem.OptimisationProblem;
import net.sourceforge.cilib.pso.particle.AbstractParticle;
import net.sourceforge.cilib.type.types.Type;
+import net.sourceforge.cilib.type.types.container.TypeList;
import net.sourceforge.cilib.type.types.container.Vector;
/**
@@ -40,7 +41,7 @@ public class RNAParticle extends AbstractParticle {
private RNAConformation position;
private RNAConformation bestPosition;
- private Vector velocity;
+ private TypeList velocity;
private Fitness bestFitness;
@@ -54,7 +55,7 @@ public class RNAParticle extends AbstractParticle {
public RNAParticle() {
position = new RNAConformation();
bestPosition = new RNAConformation();
- velocity = new Vector();
+ velocity = new TypeList();
}
/**
@@ -169,7 +170,7 @@ public class RNAParticle extends AbstractParticle {
position = (RNAConformation) i.getInitialPosition(problem);
bestPosition.clear();
bestPosition.addAll(position);
- velocity = (Vector) i.getInitialVelocity(problem);
+ velocity = (TypeList) i.getInitialVelocity(problem);
bestFitness = InferiorFitness.instance();
neighbourhoodBest = this;
//fitnessCalc = new SimpleRNAFitness();
diff --git a/src/main/java/net/sourceforge/cilib/bioinf/rnaprediction/RNAVelocityUpdate.java b/src/main/java/net/sourceforge/cilib/bioinf/rnaprediction/RNAVelocityUpdate.java
index da72fa7..230b39c 100644
--- a/src/main/java/net/sourceforge/cilib/bioinf/rnaprediction/RNAVelocityUpdate.java
+++ b/src/main/java/net/sourceforge/cilib/bioinf/rnaprediction/RNAVelocityUpdate.java
@@ -27,6 +27,7 @@ import java.util.Random;
import net.sourceforge.cilib.entity.Particle;
import net.sourceforge.cilib.math.random.generator.KnuthSubtractive;
import net.sourceforge.cilib.pso.velocityupdatestrategies.VelocityUpdateStrategy;
+import net.sourceforge.cilib.type.types.container.TypeList;
import net.sourceforge.cilib.type.types.container.Vector;
/**
@@ -83,7 +84,7 @@ public class RNAVelocityUpdate implements VelocityUpdateStrategy {
*/
public void updateVelocity(Particle particle) {
- Vector velocity = (Vector) particle.getVelocity();
+ TypeList velocity = (TypeList) particle.getVelocity();
RNAConformation openStems = (RNAConformation) velocity.get(0);
RNAConformation closeStems = (RNAConformation) velocity.get(1);
diff --git a/src/main/java/net/sourceforge/cilib/clustering/kmeans/KMeans.java b/src/main/java/net/sourceforge/cilib/clustering/kmeans/KMeans.java
index 178ff47..beba140 100644
--- a/src/main/java/net/sourceforge/cilib/clustering/kmeans/KMeans.java
+++ b/src/main/java/net/sourceforge/cilib/clustering/kmeans/KMeans.java
@@ -155,7 +155,7 @@ public class KMeans extends SingularAlgorithm {
Vector tmp = centroidsInitialisationStrategy.initialise(helper.getClusteringProblem(), helper.getClusterableDataSet());
// this first centroid will do
- return tmp.subVector(0, centroid.getDimension() - 1);
+ return tmp.subList(0, centroid.getDimension() - 1);
}
/**
diff --git a/src/main/java/net/sourceforge/cilib/functions/continuous/dynamic/moo/fda1/FDA1_f2.java b/src/main/java/net/sourceforge/cilib/functions/continuous/dynamic/moo/fda1/FDA1_f2.java
index 2ef5e2c..afbfa72 100755
--- a/src/main/java/net/sourceforge/cilib/functions/continuous/dynamic/moo/fda1/FDA1_f2.java
+++ b/src/main/java/net/sourceforge/cilib/functions/continuous/dynamic/moo/fda1/FDA1_f2.java
@@ -146,7 +146,7 @@ public class FDA1_f2 extends ContinuousFunction {
*/
public double evaluate(Vector x) {
- Vector y = x.subVector(1, x.getDimension()-1);
+ Vector y = x.subList(1, x.getDimension()-1);
double g = this.fda1_g.evaluate(y);
double h = this.fda1_h.evaluate(x);
diff --git a/src/main/java/net/sourceforge/cilib/functions/continuous/dynamic/moo/fda1/FDA1_h.java b/src/main/java/net/sourceforge/cilib/functions/continuous/dynamic/moo/fda1/FDA1_h.java
index fb31ae1..b63b0c2 100755
--- a/src/main/java/net/sourceforge/cilib/functions/continuous/dynamic/moo/fda1/FDA1_h.java
+++ b/src/main/java/net/sourceforge/cilib/functions/continuous/dynamic/moo/fda1/FDA1_h.java
@@ -147,9 +147,9 @@ public class FDA1_h extends ContinuousFunction {
public double evaluate(Vector x) {
//only the first element
- Vector y = x.subVector(0, 0);
+ Vector y = x.subList(0, 0);
//all the elements except the first element
- Vector z = x.subVector(1, x.getDimension()-1);
+ Vector z = x.subList(1, x.getDimension()-1);
//evaluate the fda1_g function
double g = this.fda1_g.evaluate(z);
//evaluate the fda1_f1 function
diff --git a/src/main/java/net/sourceforge/cilib/functions/continuous/dynamic/moo/fda2/FDA2_f2.java b/src/main/java/net/sourceforge/cilib/functions/continuous/dynamic/moo/fda2/FDA2_f2.java
index 50b944a..2e5ecdd 100755
--- a/src/main/java/net/sourceforge/cilib/functions/continuous/dynamic/moo/fda2/FDA2_f2.java
+++ b/src/main/java/net/sourceforge/cilib/functions/continuous/dynamic/moo/fda2/FDA2_f2.java
@@ -147,7 +147,7 @@ public class FDA2_f2 extends ContinuousFunction {
public double evaluate(Vector x) {
Vector y = x;
if (x.getDimension() > 1)
- y = x.subVector(1, fda2_g.getDimension()); //-1
+ y = x.subList(1, fda2_g.getDimension()); //-1
double g = this.fda2_g.evaluate(y);
double h = this.fda2_h.evaluate(x);
diff --git a/src/main/java/net/sourceforge/cilib/functions/continuous/dynamic/moo/fda2/FDA2_h.java b/src/main/java/net/sourceforge/cilib/functions/continuous/dynamic/moo/fda2/FDA2_h.java
index 5f45fa2..7836cba 100755
--- a/src/main/java/net/sourceforge/cilib/functions/continuous/dynamic/moo/fda2/FDA2_h.java
+++ b/src/main/java/net/sourceforge/cilib/functions/continuous/dynamic/moo/fda2/FDA2_h.java
@@ -217,9 +217,9 @@ public class FDA2_h extends ContinuousFunction {
Vector xII = x;
Vector xIII = x;
if (x.getDimension() > 1) {
- xI = x.subVector(0, 0);
- xII = x.subVector(1, 15);
- xIII = x.subVector(16, x.getDimension()-1);
+ xI = x.subList(0, 0);
+ xII = x.subList(1, 15);
+ xIII = x.subList(16, x.getDimension()-1);
}
double f = this.fda2_f.evaluate(xI);
diff --git a/src/main/java/net/sourceforge/cilib/functions/discrete/LongestCommonSubsequence.java b/src/main/java/net/sourceforge/cilib/functions/discrete/LongestCommonSubsequence.java
index 90e132b..34b9494 100644
--- a/src/main/java/net/sourceforge/cilib/functions/discrete/LongestCommonSubsequence.java
+++ b/src/main/java/net/sourceforge/cilib/functions/discrete/LongestCommonSubsequence.java
@@ -99,10 +99,8 @@ public class LongestCommonSubsequence extends DiscreteFunction {
*/
private int length(Vector x) {
int count = 0;
- Iterator<Type> i = x.iterator();
- while (i.hasNext()) {
- Numeric n = (Numeric) i.next();
+ for (Numeric n : x) {
if (n.getBit())
count++;
}
diff --git a/src/main/java/net/sourceforge/cilib/hs/HS.java b/src/main/java/net/sourceforge/cilib/hs/HS.java
index 4d40e29..38bb51d 100644
--- a/src/main/java/net/sourceforge/cilib/hs/HS.java
+++ b/src/main/java/net/sourceforge/cilib/hs/HS.java
@@ -33,7 +33,6 @@ import net.sourceforge.cilib.math.random.RandomNumber;
import net.sourceforge.cilib.problem.OptimisationProblem;
import net.sourceforge.cilib.problem.OptimisationSolution;
import net.sourceforge.cilib.type.types.Real;
-import net.sourceforge.cilib.type.types.container.AbstractList;
import net.sourceforge.cilib.type.types.container.Vector;
/**
@@ -197,7 +196,7 @@ public class HS extends SingularAlgorithm {
// Real newHarmonyValue;
for (int i = 0; i < problem.getDomain().getDimension(); ++i) {
if (random1.getUniform() < harmonyMemoryConsideringRate.getParameter()) {
- Harmony selectedHarmony = (Harmony) this.harmonyMemory.get((int) random2.getUniform(0, harmonyMemory.size()-1));
+ Harmony selectedHarmony = this.harmonyMemory.get((int) random2.getUniform(0, harmonyMemory.size()-1));
Vector selectedHarmonyContents = (Vector) selectedHarmony.getCandidateSolution();
Real newHarmonyValue = (Real) selectedHarmonyContents.get(i).getClone();
if (random1.getUniform() < pitchAdjustingRate.getParameter()) {
@@ -209,8 +208,8 @@ public class HS extends SingularAlgorithm {
newHarmonyVector.set(i, newHarmonyValue);
}
else {
- double upper = ((AbstractList) problem.getDomain().getBuiltRepresenation()).getNumeric(i).getBounds().getUpperBound();
- double lower = ((AbstractList) problem.getDomain().getBuiltRepresenation()).getNumeric(i).getBounds().getLowerBound();
+ double upper = ((Vector) problem.getDomain().getBuiltRepresenation()).get(i).getBounds().getUpperBound();
+ double lower = ((Vector) problem.getDomain().getBuiltRepresenation()).get(i).getBounds().getLowerBound();
newHarmonyVector.set(i, new Real(random3.getUniform(lower, upper)));
}
}
diff --git a/src/main/java/net/sourceforge/cilib/math/StatUtils.java b/src/main/java/net/sourceforge/cilib/math/StatUtils.java
index fa84e36..792211c 100644
--- a/src/main/java/net/sourceforge/cilib/math/StatUtils.java
+++ b/src/main/java/net/sourceforge/cilib/math/StatUtils.java
@@ -24,6 +24,7 @@ package net.sourceforge.cilib.math;
import java.util.Collection;
import net.sourceforge.cilib.problem.dataset.ClusterableDataSet.Pattern;
+import net.sourceforge.cilib.type.types.Numeric;
import net.sourceforge.cilib.type.types.container.Vector;
/**
@@ -86,7 +87,7 @@ public final class StatUtils {
* Calculates the variance of the given set/cluster/collection of @{link Pattern}s.
*
* This is illustrated in Equation 4.c of:<br/>
- * @InProceedings{ 657864, author = "Maria Halkidi and Michalis Vazirgiannis", title =
+ * {@literal @}InProceedings{ 657864, author = "Maria Halkidi and Michalis Vazirgiannis", title =
* "Clustering Validity Assessment: Finding the Optimal Partitioning of a Data
* Set", booktitle = "Proceedings of the IEEE International Conference on Data
* Mining", year = "2001", isbn = "0-7695-1119-8", pages = "187--194", publisher =
@@ -104,7 +105,8 @@ public final class StatUtils {
variance.reset(); // initialize the variance to be all zeroes
for (Pattern pattern : set) {
Vector diffSquare = pattern.data.subtract(center);
- diffSquare = diffSquare.multiply(diffSquare);
+ for (Numeric numeric : diffSquare)
+ numeric.setReal(numeric.getReal()*numeric.getReal());
variance = variance.plus(diffSquare);
}
return variance.norm() / set.size();
diff --git a/src/main/java/net/sourceforge/cilib/math/VectorMath.java b/src/main/java/net/sourceforge/cilib/math/VectorMath.java
index 46efeae..e62bd6d 100644
--- a/src/main/java/net/sourceforge/cilib/math/VectorMath.java
+++ b/src/main/java/net/sourceforge/cilib/math/VectorMath.java
@@ -31,35 +31,34 @@ import net.sourceforge.cilib.type.types.container.Vector;
public interface VectorMath {
/**
- * Adding this {@see net.sourceforge.cilib.type.types.Vector} to another
- * will result in a resultant {@see net.sourceforge.cilib.type.types.Vector}.
+ * Adding this {@code Vector} to another will result in a resultant {@code Vector}.
*
- * @param vector The {@see net.sourceforge.cilib.type.types.Vector} to add to the current one
- * @return The resultant {@see net.sourceforge.cilib.type.types.Vector}
+ * @param vector The {@code Vector} to add to the current one
+ * @return The resultant {@code Vector}
*/
public Vector plus(Vector vector);
/**
- *
- * @param vector
- * @return
+ * Subtract the provided {@code Vector} from the current {@code Vector}.
+ * The result of the subtraction operation is a new {@code Vector} instance,
+ * maintaining the immutability of the operation.
+ * @param vector The {@code Vector} to subtract.
+ * @return A new {@code Vector} instance representing the result of the operation.
*/
public Vector subtract(Vector vector);
/**
- *
- * @param vector
- * @return
+ * Divide the elements of the current {@code Vector} by the provided {@code scalar}.
+ * @param scalar The value to divide all elements within the {@code Vector} by.
+ * @return A new {@code Vector} instance containing the result of the operator.
*/
- public Vector divide(Vector vector);
public Vector divide(double scalar);
/**
- *
- * @param vector
- * @return
+ * Multiply a {@code scalar} with each component in the {@code Vector}.
+ * @param scalar The scalar to multiply in.
+ * @return A new {@code Vector} instance containing the result of the operator.
*/
- public Vector multiply(Vector vector);
public Vector multiply(double scalar);
/**
diff --git a/src/main/java/net/sourceforge/cilib/type/types/container/AbstractList.java b/src/main/java/net/sourceforge/cilib/type/types/container/AbstractList.java
index a53e2b4..50fc7b6 100644
--- a/src/main/java/net/sourceforge/cilib/type/types/container/AbstractList.java
+++ b/src/main/java/net/sourceforge/cilib/type/types/container/AbstractList.java
@@ -21,7 +21,6 @@
*/
package net.sourceforge.cilib.type.types.container;
-import net.sourceforge.cilib.type.types.Numeric;
import net.sourceforge.cilib.type.types.Type;
import net.sourceforge.cilib.type.types.TypeUtil;
@@ -30,13 +29,13 @@ import net.sourceforge.cilib.type.types.TypeUtil;
*
* @author Gary Pampara
*/
-public abstract class AbstractList implements StructuredType<Type> {
+public abstract class AbstractList<E extends Type> implements StructuredType<E> {
private static final long serialVersionUID = -7855489699409219241L;
/**
* {@inheritDoc}
*/
- public abstract AbstractList getClone();
+ public abstract AbstractList<E> getClone();
/**
* {@inheritDoc}
@@ -53,43 +52,43 @@ public abstract class AbstractList implements StructuredType<Type> {
* @param index The index to inspect to return.
* @return The {@linkplain Type} found at <code>index</code>.
*/
- public abstract Type get(int index);
+ public abstract E get(int index);
/**
* Set the {@linkplain Type} at the index <code>index</code>.
* @param index The index to set.
* @param value The value to set.
*/
- public abstract void set(int index, Type value);
+ public abstract void set(int index, E value);
/**
* Insert the provided {@linkplain Type} at the specified {@code index}.
* @param index The index where to insert the {@linkplain Type}.
* @param value The value to set.
*/
- public abstract void insert(int index, Type value);
+ public abstract void insert(int index, E value);
/**
* Add the provided {@linkplain Type} to the end of the current list.
* @param value The {@linkplain Type} to add.
*/
- public void append(Type value) {
+ public void append(E value) {
int position = TypeUtil.getDimension(this);
insert(position, value);
}
/**
* Add the provided {@linkplain AbstractList} to the end of the current list.
- * @param vector The object to add.
+ * @param list The object to add.
* @return <code>true</code> if the operation was successful, <code>false</code> otherwise.
*/
- public abstract boolean append(AbstractList vector);
+ public abstract boolean append(AbstractList<E> list);
/**
* Prepend the provided {@linkplain Type} to the from of this list.
* @param value The {@linkplain Type} to prepend.
*/
- public void prepend(Type value) {
+ public void prepend(E value) {
insert(0, value);
}
@@ -98,56 +97,7 @@ public abstract class AbstractList implements StructuredType<Type> {
* @param vector The object to add.
* @return <code>true</code> if the operation was successful, <code>false</code> otherwise.
*/
- public abstract boolean prepend(AbstractList vector);
-
- /**
- * Get the {@linkplain Numeric} at the given <code>index</code>.
- * @param index The index of the desired {@linkplain Numeric}.
- * @return The {@linkplain Numeric} at position <code>index</code>.
- */
- public abstract Numeric getNumeric(int index);
-
- /**
- * Get the bit-value of the {@linkplain Type} at the given <code>index</code>.
- * @param index The index of the desired {@linkplain Numeric}.
- * @return The bit-value at position <code>index</code>.
- */
- public abstract boolean getBit(int index);
-
- /**
- * Set the value of the {@linkplain net.sourceforge.cilib.type.types.Bit} located at position <code>index</code>.
- * @param index The index of the bit to set the value.
- * @param value The value of the bit to set.
- */
- public abstract void setBit(int index, boolean value);
-
- /**
- * Get the value specified at {@code index} as an {@code int}.
- * @param index The index of the value to get.
- * @return The value at {@code index}.
- */
- public abstract int getInt(int index);
-
- /**
- * Set the value at {@code index} to {@code value}.
- * @param index The index of the value to set.
- * @param value The value to set.s
- */
- public abstract void setInt(int index, int value);
-
- /**
- * Get the value at {@code index} as a {@code double}.
- * @param index The index of the value to get.
- * @return The value as a {@code double}.
- */
- public abstract double getReal(int index);
-
- /**
- * Set the value at {@code index} to {@code value}.
- * @param index The index of the value to set.
- * @param value The value to set.
- */
- public abstract void setReal(int index, double value);
+ public abstract boolean prepend(AbstractList<E> list);
/**
* Create an <code>Object []</code> from this <code>Vector</code>.
@@ -156,13 +106,6 @@ public abstract class AbstractList implements StructuredType<Type> {
public abstract Object[] toArray();
/**
- * Get the {@linkplain Type} instance at the given index.
- * @param index The position of the {@linkplain Type} to return.
- * @return The {@linkplain Type} at index {@literal index}.
- */
- protected abstract Type getType(int index);
-
- /**
* Get the representation of this <tt>Vector</tt> object in the form expressed by the domain notation.
* This method calls the <code>getRepresentation</code> method for each element in the <tt>Vector</tt>.
* This method is also a bit clever in the sense that it will try to detect elements with the same
@@ -211,7 +154,7 @@ public abstract class AbstractList implements StructuredType<Type> {
* @param toIndex The last index to end the sub-vector at.
* @return The created sub-vector instance.
*/
- public abstract AbstractList subVector(int fromIndex, int toIndex);
+ public abstract AbstractList<E> subList(int fromIndex, int toIndex);
/**
* Create a new (cloned) <tt>Vector</tt> consisting of <tt>rhs</tt> that has been appended to
@@ -223,8 +166,8 @@ public abstract class AbstractList implements StructuredType<Type> {
* @return A new <tt>Vector</tt> consisting of the concatenation of <tt>lhs</tt> and
* <tt>rhs</tt>.
*/
- public static AbstractList append(AbstractList lhs, AbstractList rhs) {
- AbstractList cat = lhs.getClone();
+ public static <T extends Type> AbstractList<T> append(AbstractList<T> lhs, AbstractList<T> rhs) {
+ AbstractList<T> cat = lhs.getClone();
cat.append(rhs.getClone());
return cat;
}
@@ -299,11 +242,4 @@ public abstract class AbstractList implements StructuredType<Type> {
return toString('[', ']', delimiter);
}
- /**
- * Initialise the {@linkplain Type} to contain <code>size</code> elements all of the type
- * <code>element</code>.
- * @param size The required size
- * @param element The {@linkplain Type} to use to initialise the {@linkplain AbstractList}.
- */
- public abstract void initialise(int size, Type element);
}
diff --git a/src/main/java/net/sourceforge/cilib/type/types/container/Randomizable.java b/src/main/java/net/sourceforge/cilib/type/types/container/Randomizable.java
new file mode 100644
index 0000000..be15611
--- /dev/null
+++ b/src/main/java/net/sourceforge/cilib/type/types/container/Randomizable.java
@@ -0,0 +1,35 @@
+/**
+ * Copyright (C) 2003 - 2008
+ * Computational Intelligence Research Group (CIRG@UP)
+ * Department of Computer Science
+ * University of Pretoria
+ * South Africa
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package net.sourceforge.cilib.type.types.container;
+
+/**
+ *
+ * @author gpampara
+ */
+public interface Randomizable {
+ public boolean randomize();
+}
diff --git a/src/main/java/net/sourceforge/cilib/type/types/container/TypeList.java b/src/main/java/net/sourceforge/cilib/type/types/container/TypeList.java
new file mode 100644
index 0000000..5398e22
--- /dev/null
+++ b/src/main/java/net/sourceforge/cilib/type/types/container/TypeList.java
@@ -0,0 +1,198 @@
+/*
+ * Copyright (C) 2003 - 2008
+ * Computational Intelligence Research Group (CIRG@UP)
+ * Department of Computer Science
+ * University of Pretoria
+ * South Africa
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package net.sourceforge.cilib.type.types.container;
+
+import java.util.ArrayList;
+
+import java.util.Iterator;
+import java.util.List;
+import net.sourceforge.cilib.container.visitor.Visitor;
+import net.sourceforge.cilib.type.types.Type;
+
+/**
+ * Concrete implementation of the {@see net.sourceforge.cilib.type.types.Vector}
+ * class. Any {@see net.sourceforge.cilib.type.types.Type} object may be contained
+ * within this object.
+ *
+ * @author Gary Pampara
+ * @author Edwin Peer
+ */
+public class TypeList extends AbstractList<Type> {
+ private static final long serialVersionUID = 136711882764612609L;
+ private List<Type> components;
+
+ public TypeList() {
+ this.components = new ArrayList<Type>();
+ }
+
+ /**
+ *
+ * @param copy
+ */
+ public TypeList(TypeList copy) {
+ this.components = new ArrayList<Type>(copy.components.size());
+
+ for (Type type : copy.components)
+ this.components.add(type.getClone());
+ }
+
+ @Override
+ public TypeList getClone() {
+ return new TypeList(this);
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean equals(Object other) {
+ if (other == this)
+ return true;
+
+ if ((other == null) || (this.getClass() != other.getClass()))
+ return false;
+
+ TypeList otherList = (TypeList) other;
+ return this.components.equals(otherList.components);
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public int hashCode() {
+ int hash = 7;
+ hash = 31 * hash + (this.components == null ? 0 : this.components.hashCode());
+ return hash;
+ }
+
+ @Override
+ public Type get(int index) {
+ return this.components.get(index);
+ }
+
+ @Override
+ public void set(int index, Type value) {
+ this.components.set(index, value);
+ }
+
+ @Override
+ public void insert(int index, Type value) {
+ this.components.add(index, value);
+ }
+
+ @Override
+ public boolean append(AbstractList<Type> list) {
+ for (Type type : list)
+ this.components.add(type);
+
+ return true;
+ }
+
+ @Override
+ public boolean prepend(AbstractList<Type> list) {
+ for (int i = list.size()-1; i >= 0; i--)
+ this.components.add(0, list.get(i));
+
+ return true;
+ }
+
+ @Override
+ public Object[] toArray() {
+ return this.components.toArray();
+ }
+
+ @Override
+ public TypeList subList(int fromIndex, int toIndex) {
+ List<Type> result = this.components.subList(fromIndex, toIndex);
+ TypeList sublist = ...
[truncated message content] |
|
From: Gary P. <gpa...@gm...> - 2009-06-01 08:07:53
|
The Vector class has been altered to not accept any type of object other
than a Numeric.
Migrated all Vector related calls to TypeList.
---
.../sourceforge/cilib/games/agent/NeuralAgent.java | 3 +-
.../neural/NeuralOutputInterpretationStrategy.java | 5 +-
.../state/evaluation/NeuralStateEvaluator.java | 6 +-
.../predatorprey/NeuralPredatorOutputStrategy.java | 13 +-
.../predatorprey/NeuralPreyOutputStrategy.java | 15 +-
.../cilib/games/items/GridLocation.java | 11 +-
.../measurement/RecordItemLocationMeasure.java | 7 +-
.../measurement/multiple/CompositeMeasurement.java | 4 +-
.../measurement/multiple/ParetoOptimalFront.java | 6 +-
.../measurement/multiple/ParetoOptimalSet.java | 3 +-
.../neuralnetwork/basicFFNN/FFNNTopology.java | 5 +-
.../neuralnetwork/basicFFNN/TrainAndTestNN.java | 3 +-
.../foundation/EvaluationMediator.java | 5 +-
.../cilib/neuralnetwork/foundation/NNError.java | 4 +-
.../foundation/NeuralNetworkProblem.java | 3 +-
.../foundation/NeuralNetworkTopology.java | 3 +-
.../BatchTrainingSetEpochStrategy.java | 4 +-
...chasticTrainingGeneralisationEpochStrategy.java | 5 +-
.../foundation/measurements/AreaUnderROC.java | 6 +-
.../foundation/measurements/NNOutput.java | 4 +-
.../neuralnetwork/generic/GenericTopology.java | 3 +-
.../generic/LayeredGenericTopology.java | 7 +-
.../DynamicPatternSelectionData.java | 4 +-
.../errorfunctions/ClassificationErrorReal.java | 6 +-
.../generic/errorfunctions/MSEErrorFunction.java | 4 +-
.../FFNNEvaluationMediator.java | 9 +-
.../SAILAEvaluationMediator.java | 22 +-
.../topologyvisitors/WeightExtractingVisitor.java | 3 +-
.../generic/trainingstrategies/ErrorSignal.java | 4 +-
.../FFNN_GD_TrainingStrategy.java | 8 +-
.../trainingstrategies/SquaredErrorFunction.java | 3 +-
.../testarea/TestErrorINCLearnWithTrainer.java | 3 +-
.../testarea/TestFFNNandGDTrainer.java | 3 +-
.../testarea/TestNeuronAndEvaluateFFNN.java | 5 +-
.../testarea/TestSAILAwithTrainer.java | 3 +-
.../cilib/type/types/container/Randomizable.java | 13 +-
.../cilib/type/types/container/TypeList.java | 4 +
.../cilib/type/types/container/Vector.java | 725 +++++++-------------
.../net/sourceforge/cilib/util/VectorUtils.java | 24 +-
39 files changed, 398 insertions(+), 570 deletions(-)
diff --git a/src/main/java/net/sourceforge/cilib/games/agent/NeuralAgent.java b/src/main/java/net/sourceforge/cilib/games/agent/NeuralAgent.java
index ce39421..7ae9102 100644
--- a/src/main/java/net/sourceforge/cilib/games/agent/NeuralAgent.java
+++ b/src/main/java/net/sourceforge/cilib/games/agent/NeuralAgent.java
@@ -32,6 +32,7 @@ import net.sourceforge.cilib.neuralnetwork.generic.topologybuilders.FFNNgenericT
import net.sourceforge.cilib.type.DomainRegistry;
import net.sourceforge.cilib.type.StringBasedDomainRegistry;
import net.sourceforge.cilib.type.types.Type;
+import net.sourceforge.cilib.type.types.container.TypeList;
import net.sourceforge.cilib.type.types.container.Vector;
@@ -132,7 +133,7 @@ public class NeuralAgent extends Agent {
Vector input = stateInputStrategy.getNeuralInputArray(this, game);
StandardPattern pattern = new StandardPattern(input, input);
//get the output vector
- Vector NNOutput = neuralNetworkTopology.evaluate(pattern);//perform NN iteration, get output
+ TypeList NNOutput = neuralNetworkTopology.evaluate(pattern);//perform NN iteration, get output
outputInterpretationStrategy.applyOutputToState(NNOutput, this, game);
}
diff --git a/src/main/java/net/sourceforge/cilib/games/agent/neural/NeuralOutputInterpretationStrategy.java b/src/main/java/net/sourceforge/cilib/games/agent/neural/NeuralOutputInterpretationStrategy.java
index 938cd42..184c35a 100644
--- a/src/main/java/net/sourceforge/cilib/games/agent/neural/NeuralOutputInterpretationStrategy.java
+++ b/src/main/java/net/sourceforge/cilib/games/agent/neural/NeuralOutputInterpretationStrategy.java
@@ -22,9 +22,10 @@
package net.sourceforge.cilib.games.agent.neural;
import net.sourceforge.cilib.games.agent.Agent;
+import net.sourceforge.cilib.games.agent.NeuralAgent;
import net.sourceforge.cilib.games.game.Game;
import net.sourceforge.cilib.games.states.GameState;
-import net.sourceforge.cilib.type.types.container.Vector;
+import net.sourceforge.cilib.type.types.container.TypeList;
/**
* @author leo
@@ -46,5 +47,5 @@ public abstract class NeuralOutputInterpretationStrategy {
* @param currentPlayer the agent that is represented by the Neural Network
* @param oldState the game state to be altered
*/
- public abstract void applyOutputToState(Vector outputData, Agent currentPlayer, Game<GameState> oldState);
+ public abstract void applyOutputToState(TypeList outputData, Agent currentPlayer, Game<GameState> oldState);
}
diff --git a/src/main/java/net/sourceforge/cilib/games/agent/state/evaluation/NeuralStateEvaluator.java b/src/main/java/net/sourceforge/cilib/games/agent/state/evaluation/NeuralStateEvaluator.java
index dc2c070..4c0c912 100644
--- a/src/main/java/net/sourceforge/cilib/games/agent/state/evaluation/NeuralStateEvaluator.java
+++ b/src/main/java/net/sourceforge/cilib/games/agent/state/evaluation/NeuralStateEvaluator.java
@@ -30,7 +30,9 @@ import net.sourceforge.cilib.games.states.GameState;
import net.sourceforge.cilib.neuralnetwork.generic.datacontainers.StandardPattern;
import net.sourceforge.cilib.neuralnetwork.generic.topologybuilders.FFNNgenericTopologyBuilder;
import net.sourceforge.cilib.type.DomainRegistry;
+import net.sourceforge.cilib.type.types.Numeric;
import net.sourceforge.cilib.type.types.Type;
+import net.sourceforge.cilib.type.types.container.TypeList;
import net.sourceforge.cilib.type.types.container.Vector;
/**
@@ -65,8 +67,8 @@ public class NeuralStateEvaluator extends NeuralAgent implements StateEvaluator
Vector input = stateInputStrategy.getNeuralInputArray(this, state);
StandardPattern pattern = new StandardPattern(input, input);
//get the output vector
- Vector NNOutput = neuralNetworkTopology.evaluate(pattern);//perform NN iteration, get output
- return NNOutput.getReal(0);
+ TypeList NNOutput = neuralNetworkTopology.evaluate(pattern);//perform NN iteration, get output
+ return ((Numeric) NNOutput.get(0)).getReal();
}
/**
diff --git a/src/main/java/net/sourceforge/cilib/games/game/predatorprey/NeuralPredatorOutputStrategy.java b/src/main/java/net/sourceforge/cilib/games/game/predatorprey/NeuralPredatorOutputStrategy.java
index 4a81d7c..eb14e53 100644
--- a/src/main/java/net/sourceforge/cilib/games/game/predatorprey/NeuralPredatorOutputStrategy.java
+++ b/src/main/java/net/sourceforge/cilib/games/game/predatorprey/NeuralPredatorOutputStrategy.java
@@ -25,7 +25,8 @@ import net.sourceforge.cilib.games.agent.neural.NeuralOutputInterpretationStrate
import net.sourceforge.cilib.games.agent.Agent;
import net.sourceforge.cilib.games.game.Game;
import net.sourceforge.cilib.games.items.GameToken;
-import net.sourceforge.cilib.type.types.container.Vector;
+import net.sourceforge.cilib.type.types.Numeric;
+import net.sourceforge.cilib.type.types.container.TypeList;
/**
* @author leo
@@ -40,21 +41,21 @@ public class NeuralPredatorOutputStrategy extends
* {@inheritDoc}
*/
@Override
- public void applyOutputToState(Vector outputData, Agent currentPlayer, Game oldState) {
+ public void applyOutputToState(TypeList outputData, Agent currentPlayer, Game oldState) {
if(!(oldState instanceof PredatorPreyGame))
throw new RuntimeException("Invalid game for this agent");
if(!currentPlayer.getAgentToken().equals(GameToken.PredatorPrey.PREDATOR))
throw new RuntimeException("This strategy can only be used on a prey player");
PredatorPreyGame game = (PredatorPreyGame)oldState;
int x = 0;
- if(outputData.getReal(0) > 0.0) //move on x axis
- if(outputData.getReal(1) > 0.0) //move right
+ if(((Numeric) outputData.get(0)).getReal() > 0.0) //move on x axis
+ if(((Numeric) outputData.get(1)).getReal() > 0.0) //move right
x = 1;
else
x = -1;
int y = 0;
- if(outputData.getReal(2) > 0.0) //move on y axis
- if(outputData.getReal(3) > 0.0) //move down
+ if(((Numeric) outputData.get(2)).getReal() > 0.0) //move on y axis
+ if(((Numeric) outputData.get(3)).getReal() > 0.0) //move down
y = 1;
else
y = -1;
diff --git a/src/main/java/net/sourceforge/cilib/games/game/predatorprey/NeuralPreyOutputStrategy.java b/src/main/java/net/sourceforge/cilib/games/game/predatorprey/NeuralPreyOutputStrategy.java
index 96ebd04..dd86b24 100644
--- a/src/main/java/net/sourceforge/cilib/games/game/predatorprey/NeuralPreyOutputStrategy.java
+++ b/src/main/java/net/sourceforge/cilib/games/game/predatorprey/NeuralPreyOutputStrategy.java
@@ -25,7 +25,8 @@ import net.sourceforge.cilib.games.agent.Agent;
import net.sourceforge.cilib.games.agent.neural.NeuralOutputInterpretationStrategy;
import net.sourceforge.cilib.games.game.Game;
import net.sourceforge.cilib.games.items.GameToken;
-import net.sourceforge.cilib.type.types.container.Vector;
+import net.sourceforge.cilib.type.types.Numeric;
+import net.sourceforge.cilib.type.types.container.TypeList;
/**
* @author leo
@@ -40,7 +41,7 @@ public class NeuralPreyOutputStrategy extends
* {@inheritDoc}
*/
@Override
- public void applyOutputToState(Vector outputData, Agent currentPlayer, Game oldState) {
+ public void applyOutputToState(TypeList outputData, Agent currentPlayer, Game oldState) {
if(!(oldState instanceof PredatorPreyGame))
throw new RuntimeException("Invalid game for this agent");
@@ -49,19 +50,19 @@ public class NeuralPreyOutputStrategy extends
PredatorPreyGame game = (PredatorPreyGame)oldState;
int moveAmount = 1;
- if(outputData.getReal(0) > 0.0) //move 2 squares
+ if(((Numeric) outputData.get(0)).getReal() > 0.0) //move 2 squares
moveAmount = 2;
int x = 0;
- if(outputData.getReal(1) > 0.0) //move on x axis
- if(outputData.getReal(2) > 0.0) //move right
+ if(((Numeric) outputData.get(1)).getReal() > 0.0) //move on x axis
+ if(((Numeric) outputData.get(2)).getReal() > 0.0) //move right
x = 1;
else
x = -1;
int y = 0;
- if(outputData.getReal(3) > 0.0) //move on y axis
- if(outputData.getReal(4) > 0.0) //move down
+ if(((Numeric) outputData.get(3)).getReal() > 0.0) //move on y axis
+ if(((Numeric) outputData.get(4)).getReal() > 0.0) //move down
y = 1;
else
y = -1;
diff --git a/src/main/java/net/sourceforge/cilib/games/items/GridLocation.java b/src/main/java/net/sourceforge/cilib/games/items/GridLocation.java
index ba14f96..fb646dd 100644
--- a/src/main/java/net/sourceforge/cilib/games/items/GridLocation.java
+++ b/src/main/java/net/sourceforge/cilib/games/items/GridLocation.java
@@ -22,6 +22,7 @@
package net.sourceforge.cilib.games.items;
import net.sourceforge.cilib.type.types.Int;
+import net.sourceforge.cilib.type.types.Numeric;
import net.sourceforge.cilib.type.types.Type;
import net.sourceforge.cilib.type.types.container.Vector;
import net.sourceforge.cilib.util.DistanceMeasure;
@@ -58,7 +59,7 @@ public class GridLocation extends Vector implements ItemLocation {
throw new UnsupportedOperationException("Cannot set the postition to a vector with a different dimention");
}
this.clear();
- for(Type t: newPos){
+ for(Numeric t : newPos){
this.add(t.getClone());
}
}
@@ -90,10 +91,10 @@ public class GridLocation extends Vector implements ItemLocation {
for(int i = 0; i < ((Vector)amount).size(); ++i){
int newVal = ((Vector)amount).getInt(i) + this.getInt(i);
- if(newVal < this.getNumeric(i).getBounds().getLowerBound())
- newVal = (int)this.getNumeric(i).getBounds().getLowerBound();
- else if(newVal > this.getNumeric(i).getBounds().getUpperBound())
- newVal = (int)this.getNumeric(i).getBounds().getUpperBound();
+ if(newVal < this.get(i).getBounds().getLowerBound())
+ newVal = (int)this.get(i).getBounds().getLowerBound();
+ else if(newVal > this.get(i).getBounds().getUpperBound())
+ newVal = (int)this.get(i).getBounds().getUpperBound();
this.setInt(i, newVal);
}
}
diff --git a/src/main/java/net/sourceforge/cilib/games/measurement/RecordItemLocationMeasure.java b/src/main/java/net/sourceforge/cilib/games/measurement/RecordItemLocationMeasure.java
index c13f42b..0a7a9fd 100644
--- a/src/main/java/net/sourceforge/cilib/games/measurement/RecordItemLocationMeasure.java
+++ b/src/main/java/net/sourceforge/cilib/games/measurement/RecordItemLocationMeasure.java
@@ -25,6 +25,7 @@ import net.sourceforge.cilib.games.game.Game;
import net.sourceforge.cilib.games.items.GameItem;
import net.sourceforge.cilib.games.states.GameState;
import net.sourceforge.cilib.games.states.ListGameState;
+import net.sourceforge.cilib.type.types.Numeric;
import net.sourceforge.cilib.type.types.Type;
import net.sourceforge.cilib.type.types.container.Vector;
@@ -36,9 +37,9 @@ import net.sourceforge.cilib.type.types.container.Vector;
*/
public class RecordItemLocationMeasure extends SingleAgentMeasure {
private static final long serialVersionUID = -7742916583743476119L;
- Vector locations;
+ private Vector locations;
+
public RecordItemLocationMeasure() {
- super();
locations = new Vector();
}
@@ -81,7 +82,7 @@ public class RecordItemLocationMeasure extends SingleAgentMeasure {
if(!(state instanceof ListGameState))
throw new RuntimeException("Impliment for other state types");
GameItem item = ((ListGameState)state).getItem(itemToken);
- locations.add(item.getLocation().getClone());
+ locations.add((Numeric) item.getLocation().getClone());
}
}
diff --git a/src/main/java/net/sourceforge/cilib/measurement/multiple/CompositeMeasurement.java b/src/main/java/net/sourceforge/cilib/measurement/multiple/CompositeMeasurement.java
index 20fe3e0..268eb28 100644
--- a/src/main/java/net/sourceforge/cilib/measurement/multiple/CompositeMeasurement.java
+++ b/src/main/java/net/sourceforge/cilib/measurement/multiple/CompositeMeasurement.java
@@ -28,7 +28,7 @@ import net.sourceforge.cilib.algorithm.population.MultiPopulationBasedAlgorithm;
import net.sourceforge.cilib.algorithm.population.PopulationBasedAlgorithm;
import net.sourceforge.cilib.measurement.Measurement;
import net.sourceforge.cilib.type.types.Type;
-import net.sourceforge.cilib.type.types.container.Vector;
+import net.sourceforge.cilib.type.types.container.TypeList;
/**
* Measurement to perform measurements on a set of contained {@code Algorithm}
@@ -68,7 +68,7 @@ public class CompositeMeasurement implements Measurement {
*/
@Override
public Type getValue(Algorithm algorithm) {
- Vector vector = new Vector();
+ TypeList vector = new TypeList();
MultiPopulationBasedAlgorithm multi = (MultiPopulationBasedAlgorithm) algorithm;
diff --git a/src/main/java/net/sourceforge/cilib/measurement/multiple/ParetoOptimalFront.java b/src/main/java/net/sourceforge/cilib/measurement/multiple/ParetoOptimalFront.java
index 74023ab..e3330c8 100644
--- a/src/main/java/net/sourceforge/cilib/measurement/multiple/ParetoOptimalFront.java
+++ b/src/main/java/net/sourceforge/cilib/measurement/multiple/ParetoOptimalFront.java
@@ -30,7 +30,7 @@ import net.sourceforge.cilib.problem.Fitness;
import net.sourceforge.cilib.problem.MOFitness;
import net.sourceforge.cilib.problem.OptimisationSolution;
import net.sourceforge.cilib.type.types.Type;
-import net.sourceforge.cilib.type.types.container.Vector;
+import net.sourceforge.cilib.type.types.container.TypeList;
/**
* <p>
@@ -62,11 +62,11 @@ public class ParetoOptimalFront implements Measurement {
@Override
public Type getValue(Algorithm algorithm) {
- Vector allFitnessValues = new Vector();
+ TypeList allFitnessValues = new TypeList();
Collection<OptimisationSolution> solutions = Archive.get();
for (OptimisationSolution solution : solutions) {
MOFitness fitnesses = (MOFitness) solution.getFitness();
- Vector fitnessValues = new Vector();
+ TypeList fitnessValues = new TypeList();
for (int i = 0; i < fitnesses.getDimension(); ++i) {
Fitness fitness = fitnesses.getFitness(i);
fitnessValues.add(fitness);
diff --git a/src/main/java/net/sourceforge/cilib/measurement/multiple/ParetoOptimalSet.java b/src/main/java/net/sourceforge/cilib/measurement/multiple/ParetoOptimalSet.java
index b40e1ff..b2486a4 100644
--- a/src/main/java/net/sourceforge/cilib/measurement/multiple/ParetoOptimalSet.java
+++ b/src/main/java/net/sourceforge/cilib/measurement/multiple/ParetoOptimalSet.java
@@ -28,6 +28,7 @@ import net.sourceforge.cilib.measurement.Measurement;
import net.sourceforge.cilib.moo.archive.Archive;
import net.sourceforge.cilib.problem.OptimisationSolution;
import net.sourceforge.cilib.type.types.Type;
+import net.sourceforge.cilib.type.types.container.TypeList;
import net.sourceforge.cilib.type.types.container.Vector;
/**
@@ -59,7 +60,7 @@ public class ParetoOptimalSet implements Measurement {
@Override
public Type getValue(Algorithm algorithm) {
- Vector allPositions = new Vector();
+ TypeList allPositions = new TypeList();
Collection<OptimisationSolution> solutions = Archive.get();
for (OptimisationSolution solution : solutions) {
Vector position = (Vector) solution.getPosition();
diff --git a/src/main/java/net/sourceforge/cilib/neuralnetwork/basicFFNN/FFNNTopology.java b/src/main/java/net/sourceforge/cilib/neuralnetwork/basicFFNN/FFNNTopology.java
index a762513..ffaedf9 100644
--- a/src/main/java/net/sourceforge/cilib/neuralnetwork/basicFFNN/FFNNTopology.java
+++ b/src/main/java/net/sourceforge/cilib/neuralnetwork/basicFFNN/FFNNTopology.java
@@ -26,6 +26,7 @@ import java.util.ArrayList;
import net.sourceforge.cilib.neuralnetwork.foundation.NNPattern;
import net.sourceforge.cilib.neuralnetwork.foundation.NeuralNetworkTopology;
import net.sourceforge.cilib.type.types.Real;
+import net.sourceforge.cilib.type.types.container.TypeList;
import net.sourceforge.cilib.type.types.container.Vector;
/**
@@ -102,7 +103,7 @@ public class FFNNTopology implements NeuralNetworkTopology {
* (non-Javadoc)
* @see net.sourceforge.cilib.NeuralNetwork.Foundation.NeuralNetworkTopology#evaluate(net.sourceforge.cilib.NeuralNetwork.Foundation.NNPattern)
*/
- public Vector evaluate(NNPattern p) {
+ public TypeList evaluate(NNPattern p) {
// Still need to check here for right length vector then exception
// Does not delete the activation of hidden or output units, used to feed back...
// zeroes activation before doing a feedforward though...
@@ -143,7 +144,7 @@ public class FFNNTopology implements NeuralNetworkTopology {
}
// convert to ArrayList...
- Vector temp = new Vector();
+ TypeList temp = new TypeList();
output = new ArrayList<Double>();
for (int i = 0; i < nrOutput; i++) {
temp.add(new Real(outputResult[i]));
diff --git a/src/main/java/net/sourceforge/cilib/neuralnetwork/basicFFNN/TrainAndTestNN.java b/src/main/java/net/sourceforge/cilib/neuralnetwork/basicFFNN/TrainAndTestNN.java
index f53a8d3..afe82d4 100644
--- a/src/main/java/net/sourceforge/cilib/neuralnetwork/basicFFNN/TrainAndTestNN.java
+++ b/src/main/java/net/sourceforge/cilib/neuralnetwork/basicFFNN/TrainAndTestNN.java
@@ -34,6 +34,7 @@ import net.sourceforge.cilib.neuralnetwork.generic.datacontainers.StandardPatter
import net.sourceforge.cilib.neuralnetwork.generic.errorfunctions.MSEErrorFunction;
import net.sourceforge.cilib.stoppingcondition.MaximumIterations;
import net.sourceforge.cilib.type.types.Real;
+import net.sourceforge.cilib.type.types.container.TypeList;
import net.sourceforge.cilib.type.types.container.Vector;
/**
@@ -110,7 +111,7 @@ public final class TrainAndTestNN {
StandardPattern p = new StandardPattern(in, null);
- Vector result = neuralNetworkTopology.evaluate(p);
+ TypeList result = neuralNetworkTopology.evaluate(p);
//output line - add any status here that reports on the manual pattern entered.
System.out.println("test result: 1 and 1 = 0.6 --> " + ((Real) result.get(0)).getReal());
diff --git a/src/main/java/net/sourceforge/cilib/neuralnetwork/foundation/EvaluationMediator.java b/src/main/java/net/sourceforge/cilib/neuralnetwork/foundation/EvaluationMediator.java
index 64a37d9..d218bf5 100644
--- a/src/main/java/net/sourceforge/cilib/neuralnetwork/foundation/EvaluationMediator.java
+++ b/src/main/java/net/sourceforge/cilib/neuralnetwork/foundation/EvaluationMediator.java
@@ -29,6 +29,7 @@ import net.sourceforge.cilib.algorithm.SingularAlgorithm;
import net.sourceforge.cilib.neuralnetwork.foundation.epochstrategy.EmptyEpochStrategy;
import net.sourceforge.cilib.neuralnetwork.foundation.epochstrategy.EpochStrategy;
import net.sourceforge.cilib.problem.OptimisationSolution;
+import net.sourceforge.cilib.type.types.container.TypeList;
import net.sourceforge.cilib.type.types.container.Vector;
@@ -104,7 +105,7 @@ public class EvaluationMediator extends SingularAlgorithm {
this.epochStrategy.performIteration(this);
}
- public void computeErrorIteration(NNError[] err, Vector output, NNPattern input){
+ public void computeErrorIteration(NNError[] err, TypeList output, NNPattern input){
for (int e = 0; e < err.length; e++){
err[e].computeIteration(output, input);
@@ -113,7 +114,7 @@ public class EvaluationMediator extends SingularAlgorithm {
}
// This might not be needed in this class.
- public Vector evaluate(NNPattern p) {
+ public TypeList evaluate(NNPattern p) {
return topology.evaluate(p);
}
// public abstract Vector evaluate(NNPattern p);
diff --git a/src/main/java/net/sourceforge/cilib/neuralnetwork/foundation/NNError.java b/src/main/java/net/sourceforge/cilib/neuralnetwork/foundation/NNError.java
index 3ea4e60..0a4a971 100644
--- a/src/main/java/net/sourceforge/cilib/neuralnetwork/foundation/NNError.java
+++ b/src/main/java/net/sourceforge/cilib/neuralnetwork/foundation/NNError.java
@@ -22,14 +22,14 @@
package net.sourceforge.cilib.neuralnetwork.foundation;
import net.sourceforge.cilib.problem.Fitness;
-import net.sourceforge.cilib.type.types.container.Vector;
+import net.sourceforge.cilib.type.types.container.TypeList;
/**
* TODO: Complete this javadoc.
*/
public interface NNError extends Fitness, Initializable {
- public void computeIteration(Vector output, NNPattern input);
+ public void computeIteration(TypeList output, NNPattern input);
public void finaliseError();
diff --git a/src/main/java/net/sourceforge/cilib/neuralnetwork/foundation/NeuralNetworkProblem.java b/src/main/java/net/sourceforge/cilib/neuralnetwork/foundation/NeuralNetworkProblem.java
index b0eae27..8671d11 100644
--- a/src/main/java/net/sourceforge/cilib/neuralnetwork/foundation/NeuralNetworkProblem.java
+++ b/src/main/java/net/sourceforge/cilib/neuralnetwork/foundation/NeuralNetworkProblem.java
@@ -28,6 +28,7 @@ import net.sourceforge.cilib.problem.ProblemVisitor;
import net.sourceforge.cilib.problem.dataset.DataSetBuilder;
import net.sourceforge.cilib.type.DomainRegistry;
import net.sourceforge.cilib.type.types.Type;
+import net.sourceforge.cilib.type.types.container.TypeList;
import net.sourceforge.cilib.type.types.container.Vector;
/**
@@ -70,7 +71,7 @@ public class NeuralNetworkProblem implements OptimisationProblem, Initializable
return evaluationStrategy.getErrorDt();
}
- public Vector evaluate(Vector in){
+ public TypeList evaluate(Vector in){
StandardPattern p = new StandardPattern(in, null);
return evaluationStrategy.evaluate(p);
}
diff --git a/src/main/java/net/sourceforge/cilib/neuralnetwork/foundation/NeuralNetworkTopology.java b/src/main/java/net/sourceforge/cilib/neuralnetwork/foundation/NeuralNetworkTopology.java
index a8eacdc..5a96df0 100644
--- a/src/main/java/net/sourceforge/cilib/neuralnetwork/foundation/NeuralNetworkTopology.java
+++ b/src/main/java/net/sourceforge/cilib/neuralnetwork/foundation/NeuralNetworkTopology.java
@@ -22,6 +22,7 @@
package net.sourceforge.cilib.neuralnetwork.foundation;
+import net.sourceforge.cilib.type.types.container.TypeList;
import net.sourceforge.cilib.type.types.container.Vector;
/**
@@ -31,7 +32,7 @@ import net.sourceforge.cilib.type.types.container.Vector;
*/
public interface NeuralNetworkTopology extends Initializable{
- public Vector evaluate(NNPattern p);
+ public TypeList evaluate(NNPattern p);
public Vector getWeights();
diff --git a/src/main/java/net/sourceforge/cilib/neuralnetwork/foundation/epochstrategy/BatchTrainingSetEpochStrategy.java b/src/main/java/net/sourceforge/cilib/neuralnetwork/foundation/epochstrategy/BatchTrainingSetEpochStrategy.java
index 5322126..36bcde1 100644
--- a/src/main/java/net/sourceforge/cilib/neuralnetwork/foundation/epochstrategy/BatchTrainingSetEpochStrategy.java
+++ b/src/main/java/net/sourceforge/cilib/neuralnetwork/foundation/epochstrategy/BatchTrainingSetEpochStrategy.java
@@ -23,7 +23,7 @@ package net.sourceforge.cilib.neuralnetwork.foundation.epochstrategy;
import net.sourceforge.cilib.neuralnetwork.foundation.EvaluationMediator;
import net.sourceforge.cilib.neuralnetwork.foundation.NeuralNetworkDataIterator;
-import net.sourceforge.cilib.type.types.container.Vector;
+import net.sourceforge.cilib.type.types.container.TypeList;
public class BatchTrainingSetEpochStrategy implements EpochStrategy {
@@ -37,7 +37,7 @@ public class BatchTrainingSetEpochStrategy implements EpochStrategy {
//iterate over each applicable pattern in training dataset
while (iteratorDt.hasMore()){
- Vector output = evaluationMediator.getTopology().evaluate(iteratorDt.value());
+ TypeList output = evaluationMediator.getTopology().evaluate(iteratorDt.value());
evaluationMediator.incrementEvaluationsPerEpoch();
//compute the per pattern error.
diff --git a/src/main/java/net/sourceforge/cilib/neuralnetwork/foundation/epochstrategy/StochasticTrainingGeneralisationEpochStrategy.java b/src/main/java/net/sourceforge/cilib/neuralnetwork/foundation/epochstrategy/StochasticTrainingGeneralisationEpochStrategy.java
index a248e86..442930d 100644
--- a/src/main/java/net/sourceforge/cilib/neuralnetwork/foundation/epochstrategy/StochasticTrainingGeneralisationEpochStrategy.java
+++ b/src/main/java/net/sourceforge/cilib/neuralnetwork/foundation/epochstrategy/StochasticTrainingGeneralisationEpochStrategy.java
@@ -23,6 +23,7 @@ package net.sourceforge.cilib.neuralnetwork.foundation.epochstrategy;
import net.sourceforge.cilib.neuralnetwork.foundation.EvaluationMediator;
import net.sourceforge.cilib.neuralnetwork.foundation.NeuralNetworkDataIterator;
+import net.sourceforge.cilib.type.types.container.TypeList;
import net.sourceforge.cilib.type.types.container.Vector;
public class StochasticTrainingGeneralisationEpochStrategy implements
@@ -43,7 +44,7 @@ public class StochasticTrainingGeneralisationEpochStrategy implements
//iterate over each applicable pattern in training dataset
while(iteratorDt.hasMore()){
- Vector output = evaluationMediator.getTopology().evaluate(iteratorDt.value());
+ TypeList output = evaluationMediator.getTopology().evaluate(iteratorDt.value());
evaluationMediator.incrementEvaluationsPerEpoch();
//compute the per pattern error, use it to train the topology stochastically be default
@@ -62,7 +63,7 @@ public class StochasticTrainingGeneralisationEpochStrategy implements
while(iteratorDg.hasMore()){
- Vector outputDg = evaluationMediator.getTopology().evaluate(iteratorDg.value());
+ TypeList outputDg = evaluationMediator.getTopology().evaluate(iteratorDg.value());
//compute the per pattern error, use it to train the topology stochastically be default
evaluationMediator.computeErrorIteration(evaluationMediator.getErrorDg(), outputDg, iteratorDg.value());
diff --git a/src/main/java/net/sourceforge/cilib/neuralnetwork/foundation/measurements/AreaUnderROC.java b/src/main/java/net/sourceforge/cilib/neuralnetwork/foundation/measurements/AreaUnderROC.java
index 67e09df..e105834 100644
--- a/src/main/java/net/sourceforge/cilib/neuralnetwork/foundation/measurements/AreaUnderROC.java
+++ b/src/main/java/net/sourceforge/cilib/neuralnetwork/foundation/measurements/AreaUnderROC.java
@@ -30,7 +30,7 @@ import net.sourceforge.cilib.neuralnetwork.foundation.NeuralNetworkTopology;
import net.sourceforge.cilib.type.types.Real;
import net.sourceforge.cilib.type.types.StringType;
import net.sourceforge.cilib.type.types.Type;
-import net.sourceforge.cilib.type.types.container.Vector;
+import net.sourceforge.cilib.type.types.container.TypeList;
/**
* TODO: Fill in some javadoc.
@@ -82,7 +82,7 @@ public class AreaUnderROC implement...
[truncated message content] |
|
From: Gary P. <gpa...@gm...> - 2009-06-01 08:08:02
|
Fixed the out by one error with the Vector and TypeList classes.
java.util.List defines a subList() method that is used internally. It,
unfortunately, results in a selection from the range: [from, to).
The last element was being forgotten.
Signed-off-by: Gary Pampara <gpa...@gm...>
---
.../cilib/cooperative/CooperativeEntity.java | 4 +-
.../problem/changestrategy/ChangeStrategy.java | 6 +-
.../pso/dynamic/ChargedVelocityUpdateStrategy.java | 3 +-
.../net/sourceforge/cilib/type/DomainBuilder.java | 38 ++++++--
.../cilib/type/types/container/TypeList.java | 3 +-
.../cilib/type/types/container/Vector.java | 3 +-
.../sourceforge/cilib/util/ClusteringUtils.java | 3 +-
.../sourceforge/cilib/entity/IndividualTest.java | 2 -
.../clustering/ClusteringFitnessFunctionTest.java | 1 +
.../measurement/multiple/MultipleFitnessTest.java | 22 ++--
.../multiple/MultipleSolutionsTest.java | 6 +-
.../single/BestParticlePositionTest.java | 8 +-
.../cilib/measurement/single/DiameterTest.java | 16 ++--
.../measurement/single/ParticlePositionsTest.java | 6 +-
.../cilib/measurement/single/SolutionTest.java | 6 +-
.../sourceforge/cilib/type/DomainParserTest.java | 9 +-
.../cilib/type/StringBasedDomainRegistryTest.java | 8 +-
.../cilib/type/types/container/VectorTest.java | 111 --------------------
.../cilib/util/ClusteringUtilsTest.java | 12 +-
.../sourceforge/cilib/util/VectorUtilsTest.java | 13 ---
20 files changed, 91 insertions(+), 189 deletions(-)
diff --git a/src/main/java/net/sourceforge/cilib/cooperative/CooperativeEntity.java b/src/main/java/net/sourceforge/cilib/cooperative/CooperativeEntity.java
index b44c8d7..38723b4 100644
--- a/src/main/java/net/sourceforge/cilib/cooperative/CooperativeEntity.java
+++ b/src/main/java/net/sourceforge/cilib/cooperative/CooperativeEntity.java
@@ -26,8 +26,10 @@ import net.sourceforge.cilib.entity.Entity;
import net.sourceforge.cilib.problem.Fitness;
import net.sourceforge.cilib.problem.InferiorFitness;
import net.sourceforge.cilib.problem.OptimisationProblem;
+import net.sourceforge.cilib.type.types.Numeric;
import net.sourceforge.cilib.type.types.Type;
import net.sourceforge.cilib.type.types.container.StructuredType;
+import net.sourceforge.cilib.type.types.container.TypeList;
import net.sourceforge.cilib.type.types.container.Vector;
/**
@@ -89,7 +91,7 @@ public class CooperativeEntity extends AbstractEntity {
if(value instanceof Vector)
context.append((Vector) value);
else
- context.append(value);
+ context.append((Numeric) value);
}
public void append(Entity entity) {
diff --git a/src/main/java/net/sourceforge/cilib/problem/changestrategy/ChangeStrategy.java b/src/main/java/net/sourceforge/cilib/problem/changestrategy/ChangeStrategy.java
index 8f29a17..35b3611 100644
--- a/src/main/java/net/sourceforge/cilib/problem/changestrategy/ChangeStrategy.java
+++ b/src/main/java/net/sourceforge/cilib/problem/changestrategy/ChangeStrategy.java
@@ -39,9 +39,9 @@ import net.sourceforge.cilib.problem.Problem;
public interface ChangeStrategy {
/**
- * Test if a change should be applied on the provided {@code problem} instance.
- * @param problem The problem on which a change test is to be applied.
- * @return {@code true} if a change should be applied, {@code false} otherwise.
+ * Determine whether a change should be applied to the provided {@code problem} instance.
+ * @param problem The problem on which a change is to be applied.
+ * @return {@code true} if a change occoured, {@code false} otherwise.
*/
public boolean shouldApply(Problem problem);
diff --git a/src/main/java/net/sourceforge/cilib/pso/dynamic/ChargedVelocityUpdateStrategy.java b/src/main/java/net/sourceforge/cilib/pso/dynamic/ChargedVelocityUpdateStrategy.java
index f8f65a7..1600157 100644
--- a/src/main/java/net/sourceforge/cilib/pso/dynamic/ChargedVelocityUpdateStrategy.java
+++ b/src/main/java/net/sourceforge/cilib/pso/dynamic/ChargedVelocityUpdateStrategy.java
@@ -72,8 +72,7 @@ public class ChargedVelocityUpdateStrategy extends StandardVelocityUpdate {
Vector bestPosition = (Vector) particle.getBestPosition();
Vector nBestPosition = (Vector) particle.getNeighbourhoodBest().getBestPosition();
- Vector acceleration = new Vector(velocity.getDimension());
- acceleration.initialise(velocity.getDimension(), new Real(0));
+ Vector acceleration = new Vector(velocity.getDimension(), new Real(0.0));
PSO pso = (PSO) Algorithm.get();
Iterator<Particle> iter = null;
// make iter point to the current particle
diff --git a/src/main/java/net/sourceforge/cilib/type/DomainBuilder.java b/src/main/java/net/sourceforge/cilib/type/DomainBuilder.java
index 1640208..f6a4637 100644
--- a/src/main/java/net/sourceforge/cilib/type/DomainBuilder.java
+++ b/src/main/java/net/sourceforge/cilib/type/DomainBuilder.java
@@ -26,8 +26,11 @@ import java.io.IOException;
import java.io.StreamTokenizer;
import net.sourceforge.cilib.type.creator.TypeCreator;
+import net.sourceforge.cilib.type.types.Numeric;
import net.sourceforge.cilib.type.types.Type;
+import net.sourceforge.cilib.type.types.container.AbstractList;
import net.sourceforge.cilib.type.types.container.StructuredType;
+import net.sourceforge.cilib.type.types.container.TypeList;
import net.sourceforge.cilib.type.types.container.Vector;
/**
@@ -52,7 +55,7 @@ import net.sourceforge.cilib.type.types.container.Vector;
*/
public class DomainBuilder {
- private Vector representation;
+ private TypeList representation;
private StreamTokenizer parser;
private double lower;
private double upper;
@@ -74,9 +77,8 @@ public class DomainBuilder {
* @param expandedDomain The expanded domain string
* @return A container containing the built represenation
*/
- public Vector build(String expandedDomain) {
-
- representation = new Vector();
+ public StructuredType build(String expandedDomain) {
+ representation = new TypeList();
parser = new StreamTokenizer(new CharArrayReader(expandedDomain.toCharArray()));
try {
@@ -87,7 +89,7 @@ public class DomainBuilder {
throw new RuntimeException("IOException occoured during building of the domain\n" + e);
}
- return representation;
+ return getBuiltRepresenation();
}
@@ -97,7 +99,10 @@ public class DomainBuilder {
* @return The constructed <tt>Type</tt> object representing the domain string.
*/
public StructuredType getBuiltRepresenation() {
- return this.representation;
+ if (isVector(representation))
+ return toVector(representation);
+
+ return representation;
}
@@ -109,8 +114,8 @@ public class DomainBuilder {
parser.nextToken();
if ((char) parser.ttype == '[') {
- final Vector tmp = this.representation;
- this.representation = new Vector();
+ final TypeList tmp = this.representation;
+ this.representation = new TypeList();
buildDomain();
parser.nextToken();
@@ -292,4 +297,21 @@ public class DomainBuilder {
throw new RuntimeException("Parser error: " + c + " was expected but received: " + (char) parser.ttype);
}
+ private boolean isVector(TypeList representation) {
+ for (Type type : representation)
+ if (!(type instanceof Numeric))
+ return false;
+
+ return true;
+ }
+
+ private AbstractList toVector(TypeList representation) {
+ Vector vector = new Vector(representation.size());
+
+ for (Type type : representation)
+ vector.add((Numeric) type);
+
+ return vector;
+ }
+
}
diff --git a/src/main/java/net/sourceforge/cilib/type/types/container/TypeList.java b/src/main/java/net/sourceforge/cilib/type/types/container/TypeList.java
index 345ce84..bb907cd 100644
--- a/src/main/java/net/sourceforge/cilib/type/types/container/TypeList.java
+++ b/src/main/java/net/sourceforge/cilib/type/types/container/TypeList.java
@@ -127,7 +127,8 @@ public class TypeList extends AbstractList<Type> {
@Override
public TypeList subList(int fromIndex, int toIndex) {
- List<Type> result = this.components.subList(fromIndex, toIndex);
+ // Need to bump up the toIndex because the List.subList() operation is upper bound exclusive.
+ List<Type> result = this.components.subList(fromIndex, toIndex+1);
TypeList sublist = new TypeList();
for (Type type : result)
diff --git a/src/main/java/net/sourceforge/cilib/type/types/container/Vector.java b/src/main/java/net/sourceforge/cilib/type/types/container/Vector.java
index ba9acab..c9be1df 100644
--- a/src/main/java/net/sourceforge/cilib/type/types/container/Vector.java
+++ b/src/main/java/net/sourceforge/cilib/type/types/container/Vector.java
@@ -187,7 +187,8 @@ public class Vector extends AbstractList<Numeric> implements VectorMath, Resetab
*/
@Override
public Vector subList(int fromIndex, int toIndex) {
- List<Numeric> list = this.components.subList(fromIndex, toIndex);
+ // Change the final bound to be incremented by. List.subList() is exclusive on the upper bound.
+ List<Numeric> list = this.components.subList(fromIndex, toIndex+1);
Vector result = new Vector();
for (Numeric numeric : list)
diff --git a/src/main/java/net/sourceforge/cilib/util/ClusteringUtils.java b/src/main/java/net/sourceforge/cilib/util/ClusteringUtils.java
index 86880bd..a769292 100644
--- a/src/main/java/net/sourceforge/cilib/util/ClusteringUtils.java
+++ b/src/main/java/net/sourceforge/cilib/util/ClusteringUtils.java
@@ -198,7 +198,8 @@ public final class ClusteringUtils {
int dimension = centroids.size() / numberOfClusters;
for (int i = 0; i < numberOfClusters; i++) {
- originalCentroids.add(centroids.subVector(i * dimension, (i * dimension) + dimension - 1));
+ Vector list = centroids.subList(i * dimension, (i * dimension) + dimension - 1);
+ originalCentroids.add(list);
}
}
diff --git a/src/test/java/net/sourceforge/cilib/entity/IndividualTest.java b/src/test/java/net/sourceforge/cilib/entity/IndividualTest.java
index 488b8dc..3a462da 100644
--- a/src/test/java/net/sourceforge/cilib/entity/IndividualTest.java
+++ b/src/test/java/net/sourceforge/cilib/entity/IndividualTest.java
@@ -26,9 +26,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import net.sourceforge.cilib.ec.Individual;
-import net.sourceforge.cilib.type.types.Blackboard;
import net.sourceforge.cilib.type.types.Real;
-import net.sourceforge.cilib.type.types.Type;
import net.sourceforge.cilib.type.types.container.Vector;
import org.junit.Test;
diff --git a/src/test/java/net/sourceforge/cilib/functions/clustering/ClusteringFitnessFunctionTest.java b/src/test/java/net/sourceforge/cilib/functions/clustering/ClusteringFitnessFunctionTest.java
index c1de919..e3f7964 100644
--- a/src/test/java/net/sourceforge/cilib/functions/clustering/ClusteringFitnessFunctionTest.java
+++ b/src/test/java/net/sourceforge/cilib/functions/clustering/ClusteringFitnessFunctionTest.java
@@ -84,6 +84,7 @@ public class ClusteringFitnessFunctionTest {
@Test
public void testEvaluate() {
// the evaluate method arranges the clusters and centroids
+ System.out.println(function.evaluate(centroids));
assertEquals(4.27188655918496, function.evaluate(centroids), DELTA);
}
diff --git a/src/test/java/net/sourceforge/cilib/measurement/multiple/MultipleFitnessTest.java b/src/test/java/net/sourceforge/cilib/measurement/multiple/MultipleFitnessTest.java
index 6a6659a..0301b81 100644
--- a/src/test/java/net/sourceforge/cilib/measurement/multiple/MultipleFitnessTest.java
+++ b/src/test/java/net/sourceforge/cilib/measurement/multiple/MultipleFitnessTest.java
@@ -4,17 +4,17 @@
* Department of Computer Science
* University of Pretoria
* South Africa
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -27,26 +27,26 @@ import static org.junit.Assert.assertTrue;
import net.sourceforge.cilib.measurement.Measurement;
import net.sourceforge.cilib.type.DomainParser;
import net.sourceforge.cilib.type.types.StringType;
-import net.sourceforge.cilib.type.types.container.Vector;
+import net.sourceforge.cilib.type.types.container.TypeList;
import org.junit.Test;
/**
- *
+ *
* @author Gary Pampara
*/
public class MultipleFitnessTest {
-
+
@Test
public void testMultipleFitnessDomain() {
Measurement m = new MultipleFitness();
-
+
DomainParser parser = new DomainParser();
parser.parse(m.getDomain());
-
- Vector vector = (Vector) parser.getBuiltRepresentation();
-
- assertEquals(1, vector.getDimension());
+
+ TypeList vector = (TypeList) parser.getBuiltRepresentation();
+
+ assertEquals(1, vector.size());
assertTrue(vector.get(0) instanceof StringType);
}
diff --git a/src/test/java/net/sourceforge/cilib/measurement/multiple/MultipleSolutionsTest.java b/src/test/java/net/sourceforge/cilib/measurement/multiple/MultipleSolutionsTest.java
index 7ea536f..e477da9 100644
--- a/src/test/java/net/sourceforge/cilib/measurement/multiple/MultipleSolutionsTest.java
+++ b/src/test/java/net/sourceforge/cilib/measurement/multiple/MultipleSolutionsTest.java
@@ -27,7 +27,7 @@ import static org.junit.Assert.assertTrue;
import net.sourceforge.cilib.measurement.Measurement;
import net.sourceforge.cilib.type.DomainParser;
import net.sourceforge.cilib.type.types.StringType;
-import net.sourceforge.cilib.type.types.container.Vector;
+import net.sourceforge.cilib.type.types.container.TypeList;
import org.junit.Test;
@@ -44,9 +44,9 @@ public class MultipleSolutionsTest {
DomainParser parser = new DomainParser();
parser.parse(m.getDomain());
- Vector vector = (Vector) parser.getBuiltRepresentation();
+ TypeList vector = (TypeList) parser.getBuiltRepresentation();
- assertEquals(1, vector.getDimension());
+ assertEquals(1, vector.size());
assertTrue(vector.get(0) instanceof StringType);
}
}
diff --git a/src/test/java/net/sourceforge/cilib/measurement/single/BestParticlePositionTest.java b/src/test/java/net/sourceforge/cilib/measurement/single/BestParticlePositionTest.java
index 291f83d..4d4bdb9 100644
--- a/src/test/java/net/sourceforge/cilib/measurement/single/BestParticlePositionTest.java
+++ b/src/test/java/net/sourceforge/cilib/measurement/single/BestParticlePositionTest.java
@@ -22,12 +22,12 @@
package net.sourceforge.cilib.measurement.single;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
import net.sourceforge.cilib.measurement.Measurement;
import net.sourceforge.cilib.type.DomainParser;
import net.sourceforge.cilib.type.types.StringType;
-import net.sourceforge.cilib.type.types.container.Vector;
+import net.sourceforge.cilib.type.types.container.TypeList;
import org.junit.Test;
@@ -44,10 +44,10 @@ public class BestParticlePositionTest {
DomainParser parser = new DomainParser();
parser.parse(m.getDomain());
- Vector t = (Vector) parser.getBuiltRepresentation();
+ TypeList t = (TypeList) parser.getBuiltRepresentation();
assertTrue(t.get(0) instanceof StringType);
- assertEquals(1, t.getDimension());
+ assertEquals(1, t.size());
}
}
diff --git a/src/test/java/net/sourceforge/cilib/measurement/single/DiameterTest.java b/src/test/java/net/sourceforge/cilib/measurement/single/DiameterTest.java
index cad1f52..e7c5071 100644
--- a/src/test/java/net/sourceforge/cilib/measurement/single/DiameterTest.java
+++ b/src/test/java/net/sourceforge/cilib/measurement/single/DiameterTest.java
@@ -4,17 +4,17 @@
* Department of Computer Science
* University of Pretoria
* South Africa
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -32,20 +32,20 @@ import net.sourceforge.cilib.type.types.container.Vector;
import org.junit.Test;
/**
- *
+ *
* @author Gary Pampara
*/
public class DiameterTest {
-
+
@Test
public void testDiameterTestDomain() {
Measurement m = new Diameter();
-
+
DomainParser parser = new DomainParser();
parser.parse(m.getDomain());
-
+
Vector vector = (Vector) parser.getBuiltRepresentation();
-
+
assertEquals(1, vector.getDimension());
assertTrue(vector.get(0) instanceof Real);
}
diff --git a/src/test/java/net/sourceforge/cilib/measurement/single/ParticlePositionsTest.java b/src/test/java/net/sourceforge/cilib/measurement/single/ParticlePositionsTest.java
index 3fdf322..1e1800d 100644
--- a/src/test/java/net/sourceforge/cilib/measurement/single/ParticlePositionsTest.java
+++ b/src/test/java/net/sourceforge/cilib/measurement/single/ParticlePositionsTest.java
@@ -27,7 +27,7 @@ import static org.junit.Assert.assertTrue;
import net.sourceforge.cilib.measurement.Measurement;
import net.sourceforge.cilib.type.DomainParser;
import net.sourceforge.cilib.type.types.StringType;
-import net.sourceforge.cilib.type.types.container.Vector;
+import net.sourceforge.cilib.type.types.container.TypeList;
import org.junit.Test;
@@ -44,9 +44,9 @@ public class ParticlePositionsTest {
DomainParser parser = new DomainParser();
parser.parse(m.getDomain());
- Vector vector = (Vector) parser.getBuiltRepresentation();
+ TypeList vector = (TypeList) parser.getBuiltRepresentation();
- assertEquals(1, vector.getDimension());
+ assertEquals(1, vector.size());
assertTrue(vector.get(0) instanceof StringType);
}
}
diff --git a/src/test/java/net/sourceforge/cilib/measurement/single/SolutionTest.java b/src/test/java/net/sourceforge/cilib/measurement/single/SolutionTest.java
index 3245408..a00da70 100644
--- a/src/test/java/net/sourceforge/cilib/measurement/single/SolutionTest.java
+++ b/src/test/java/net/sourceforge/cilib/measurement/single/SolutionTest.java
@@ -27,7 +27,7 @@ import static org.junit.Assert.assertTrue;
import net.sourceforge.cilib.measurement.Measurement;
import net.sourceforge.cilib.type.DomainParser;
import net.sourceforge.cilib.type.types.StringType;
-import net.sourceforge.cilib.type.types.container.Vector;
+import net.sourceforge.cilib.type.types.container.TypeList;
import org.junit.Test;
@@ -44,9 +44,9 @@ public class SolutionTest {
DomainParser parser = new DomainParser();
parser.parse(m.getDomain());
- Vector vector = (Vector) parser.getBuiltRepresentation();
+ TypeList vector = (TypeList) parser.getBuiltRepresentation();
- assertEquals(1, vector.getDimension());
+ assertEquals(1, vector.size());
assertTrue(vector.get(0) instanceof StringType);
}
diff --git a/src/test/java/net/sourceforge/cilib/type/DomainParserTest.java b/src/test/java/net/sourceforge/cilib/type/DomainParserTest.java
index 100bcd8..ca30397 100644
--- a/src/test/java/net/sourceforge/cilib/type/DomainParserTest.java
+++ b/src/test/java/net/sourceforge/cilib/type/DomainParserTest.java
@@ -22,6 +22,7 @@
package net.sourceforge.cilib.type;
+import net.sourceforge.cilib.type.types.container.TypeList;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -146,13 +147,13 @@ public class DomainParserTest {
try {
parser.parse("[R(-30.0,30.0)^4]^5");
- Vector matrix = (Vector) parser.getBuiltRepresentation();
+ TypeList matrix = (TypeList) parser.getBuiltRepresentation();
// Test the dimensionality
- assertEquals(5, matrix.getDimension());
+ assertEquals(5, matrix.size());
- for (int i = 0; i < matrix.getDimension(); i++) {
- assertEquals(4, ((Vector)matrix.get(i)).getDimension());
+ for (int i = 0; i < matrix.size(); i++) {
+ assertEquals(4, ((TypeList)matrix.get(i)).size());
}
// Test object equality
diff --git a/src/test/java/net/sourceforge/cilib/type/StringBasedDomainRegistryTest.java b/src/test/java/net/sourceforge/cilib/type/StringBasedDomainRegistryTest.java
index f1d7b8b..6385942 100644
--- a/src/test/java/net/sourceforge/cilib/type/StringBasedDomainRegistryTest.java
+++ b/src/test/java/net/sourceforge/cilib/type/StringBasedDomainRegistryTest.java
@@ -23,7 +23,7 @@
package net.sourceforge.cilib.type;
import net.sourceforge.cilib.type.types.TypeUtil;
-import net.sourceforge.cilib.type.types.container.Vector;
+import net.sourceforge.cilib.type.types.container.TypeList;
import org.junit.Assert;
import org.junit.Test;
@@ -38,9 +38,9 @@ public class StringBasedDomainRegistryTest {
DomainRegistry registry = new StringBasedDomainRegistry();
registry.setDomainString("[R(-5.0, 5.0)^10]^10");
- Vector matrix = (Vector) registry.getBuiltRepresenation();
- Assert.assertEquals(10, matrix.getDimension());
- Assert.assertEquals(10, ((Vector) matrix.get(0)).size());
+ TypeList matrix = (TypeList) registry.getBuiltRepresenation();
+ Assert.assertEquals(10, matrix.size());
+ Assert.assertEquals(10, ((TypeList) matrix.get(0)).size());
Assert.assertTrue(TypeUtil.isInsideBounds(matrix));
}
}
diff --git a/src/test/java/net/sourceforge/cilib/type/types/container/VectorTest.java b/src/test/java/net/sourceforge/cilib/type/types/container/VectorTest.java
index 914f37f..1b03f92 100644
--- a/src/test/java/net/sourceforge/cilib/type/types/container/VectorTest.java
+++ b/src/test/java/net/sourceforge/cilib/type/types/container/VectorTest.java
@@ -27,7 +27,6 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import net.sourceforge.cilib.type.types.Bit;
@@ -440,69 +439,6 @@ public class VectorTest {
}
}
- @Test(expected = UnsupportedOperationException.class)
- public void invalidVectorDivision() {
- Vector a = new Vector();
- Vector b = new Vector();
-
- for(int i = 1; i < 11; i++)
- a.append(new Real(i));
- for(int i = 1; i < 10; i++)
- b.prepend(new Real(i));
-
- a.divide(b);
- }
-
- @Test(expected = ArithmeticException.class)
- public void vectorDivisionByZero() {
- Vector a = new Vector();
- Vector b = new Vector();
-
- for(int i = 1; i < 11; i++)
- a.append(new Real(i));
- for(int i = 1; i < 10; i++)
- b.prepend(new Real(i));
-
- b.prepend(new Real(0));
-
- a.divide(b);
- }
-
- @Test
- public void testVectorDivision() {
- Vector a = new Vector();
- Vector b = new Vector();
-
- for(int i = 1; i < 11; i++)
- a.append(new Real(i));
- for(int i = 1; i < 10; i++)
- b.prepend(new Real(i));
-
- b.prepend(new Real(0));
- b.get(0).setReal(10);
- Vector divided = a.divide(b);
-
- assertNotNull(a);
- assertNotNull(b);
- assertNotNull(divided);
- assertNotSame(a, b);
- assertNotSame(divided, a);
- assertNotSame(divided, b);
-
- for(int i = 0; i < 10; i++) {
- assertNotNull(a.get(i));
- assertNotNull(b.get(i));
- assertNotNull(divided.get(i));
- assertNotSame(a.get(i), b.get(i));
- assertNotSame(divided.get(i), a.get(i));
- assertNotSame(divided.get(i), b.get(i));
-
- assertEquals(a.getReal(i), (i + 1.0), 0.0);
- assertEquals(b.getReal(i), (10.0 - i), 0.0);
- assertEquals(divided.getReal(i), ((i + 1) / (10.0 - i)), 0.0);
- }
- }
-
@Test(expected = ArithmeticException.class)
public void vectorDivisionByScalarZero() {
Vector a = new Vector();
@@ -536,53 +472,6 @@ public class VectorTest {
}
}
- @Test(expected = UnsupportedOperationException.class)
- public void invalidVectorMultiplication() {
- Vector a = new Vector();
- Vector b = new Vector();
-
- for(int i = 0; i < 10; i++)
- a.append(new Real(i));
- for(int i = 0; i < 9; i++)
- b.prepend(new Real(i));
-
- a.multiply(b);
- }
-
- @Test
- public void testVectorMultiplication() {
- Vector a = new Vector();
- Vector b = new Vector();
-
- for(int i = 0; i < 10; i++)
- a.append(new Real(i));
- for(int i = 0; i < 9; i++)
- b.prepend(new Real(i));
-
- b.prepend(new Real(9));
- Vector product = a.multiply(b);
-
- assertNotNull(a);
- assertNotNull(b);
- assertNotNull(product);
- assertNotSame(a, b);
- assertNotSame(product, a);
- assertNotSame(product, b);
-
- for(int i = 0; i < 10; i++) {
- assertNotNull(a.get(i));
- assertNotNull(b.get(i));
- assertNotNull(product.get(i));
- assertNotSame(a.get(i), b.get(i));
- assertNotSame(product.get(i), a.get(i));
- assertNotSame(product.get(i), b.get(i));
-
- assertEquals(a.getReal(i), (double)i, 0.0);
- assertEquals(b.getReal(i), (9.0 - i), 0.0);
- assertEquals(product.getReal(i), (i * (9.0 - i)), 0.0);
- }
- }
-
@Test
public void testScalarMultiplication() {
Vector a = new Vector();
diff --git a/src/test/java/net/sourceforge/cilib/util/ClusteringUtilsTest.java b/src/test/java/net/sourceforge/cilib/util/ClusteringUtilsTest.java
index 822946c..9331544 100644
--- a/src/test/java/net/sourceforge/cilib/util/ClusteringUtilsTest.java
+++ b/src/test/java/net/sourceforge/cilib/util/ClusteringUtilsTest.java
@@ -262,17 +262,17 @@ public class ClusteringUtilsTest {
@Test(expected = IndexOutOfBoundsException.class)
public void testArrangedCentroids() {
- assertThat(arrangedCentroids.get(0), equalTo(centroids.subVector(0, 1)));
+ assertThat(arrangedCentroids.get(0), equalTo(centroids.subList(0, 1)));
- assertThat(arrangedCentroids.get(1), equalTo(centroids.subVector(2, 3)));
+ assertThat(arrangedCentroids.get(1), equalTo(centroids.subList(2, 3)));
- assertThat(arrangedCentroids.get(2), equalTo(centroids.subVector(4, 5)));
+ assertThat(arrangedCentroids.get(2), equalTo(centroids.subList(4, 5)));
- assertThat(arrangedCentroids.get(3), equalTo(centroids.subVector(6, 7)));
+ assertThat(arrangedCentroids.get(3), equalTo(centroids.subList(6, 7)));
- assertThat(arrangedCentroids.get(4), equalTo(centroids.subVector(8, 9)));
+ assertThat(arrangedCentroids.get(4), equalTo(centroids.subList(8, 9)));
- assertThat(arrangedCentroids.get(5), equalTo(centroids.subVector(10, 11)));
+ assertThat(arrangedCentroids.get(5), equalTo(centroids.subList(10, 11)));
// the last centroid is useless, i.e. no pattern "belongs" to it
// should throw an exception (no such element / index out of bounds)
diff --git a/src/test/java/net/sourceforge/cilib/util/VectorUtilsTest.java b/src/test/java/net/sourceforge/cilib/util/VectorUtilsTest.java
index 35cd661..01aed31 100644
--- a/src/test/java/net/sourceforge/cilib/util/VectorUtilsTest.java
+++ b/src/test/java/net/sourceforge/cilib/util/VectorUtilsTest.java
@@ -60,12 +60,6 @@ public class VectorUtilsTest {
}
}
- @Test(expected = UnsupportedOperationException.class)
- public void createUpperBoundVector() {
- vector.add(new Vector());
- VectorUtils.createUpperBoundVector(vector);
- }
-
@Test
public void testLowerBounds() {
int i = 1;
@@ -76,11 +70,4 @@ public class VectorUtilsTest {
}
}
- @Test(expected = UnsupportedOperationException.class)
- public void createLowerBoundVector() {
- vector.add(new Vector());
- VectorUtils.createLowerBoundVector(vector);
- }
-
-
}
--
1.6.2.3
...
[truncated message content] |
|
From: Gary P. <gpa...@gm...> - 2009-06-01 08:08:04
|
The Vector and TypeList classes had a bug where they interpreted a range
of values [fromIndex, toIndex) instead of [fromIndex, toIndex].
Signed-off-by: Gary Pampara <gpa...@gm...>
---
pom.xml | 2 +-
.../problem/dataset/StringDataSetBuilder.java | 3 -
.../net/sourceforge/cilib/type/types/Type.java | 29 ++++++-
.../cilib/type/types/container/AbstractList.java | 16 +++-
.../cilib/type/types/container/TypeList.java | 87 +++++++++++++++++---
src/site/site.xml | 22 ++++-
.../clustering/ClusteringFitnessFunctionTest.java | 1 -
.../sourceforge/cilib/type/DomainParserTest.java | 62 ++++++--------
.../cilib/type/types/container/TypeListTest.java | 48 +++++++++++
.../cilib/type/types/container/VectorTest.java | 10 ++
.../net/sourceforge/cilib/xml/XMLFileTest.java | 11 ++-
11 files changed, 223 insertions(+), 68 deletions(-)
create mode 100644 src/test/java/net/sourceforge/cilib/type/types/container/TypeListTest.java
diff --git a/pom.xml b/pom.xml
index ba9cb3d..3be1913 100644
--- a/pom.xml
+++ b/pom.xml
@@ -54,7 +54,7 @@
<distributionManagement>
<site>
<id>sourceforge</id>
- <url>sftp://web.sourceforge.net/home/groups/c/ci/cilib/htdocs</url>
+ <url>scp://shell.sourceforge.net/home/groups/c/ci/cilib/htdocs</url>
</site>
</distributionManagement>
<developers>
diff --git a/src/main/java/net/sourceforge/cilib/problem/dataset/StringDataSetBuilder.java b/src/main/java/net/sourceforge/cilib/problem/dataset/StringDataSetBuilder.java
index e1f9370..3e0e45d 100644
--- a/src/main/java/net/sourceforge/cilib/problem/dataset/StringDataSetBuilder.java
+++ b/src/main/java/net/sourceforge/cilib/problem/dataset/StringDataSetBuilder.java
@@ -39,7 +39,6 @@ public class StringDataSetBuilder extends TextDataSetBuilder {
public StringDataSetBuilder() {
this.strings = new ArrayList<String>();
- // System.out.println("Building...");
}
public StringDataSetBuilder(StringDataSetBuilder rhs) {
@@ -66,7 +65,6 @@ public class StringDataSetBuilder extends TextDataSetBuilder {
String result = in.readLine();
while (result != null) {
- // System.out.println(result);
strings.add(result);
result = in.readLine();
@@ -75,7 +73,6 @@ public class StringDataSetBuilder extends TextDataSetBuilder {
catch (IOException ioException) {
throw new RuntimeException(ioException);
}
- // System.out.println("Data set(s) initialised, proceeding...");
}
}
diff --git a/src/main/java/net/sourceforge/cilib/type/types/Type.java b/src/main/java/net/sourceforge/cilib/type/types/Type.java
index 4cb56f2..a33cca8 100644
--- a/src/main/java/net/sourceforge/cilib/type/types/Type.java
+++ b/src/main/java/net/sourceforge/cilib/type/types/Type.java
@@ -25,6 +25,7 @@ import net.sourceforge.cilib.util.Cloneable;
/**
* {@code Type} interface for all type-objects that are used within CIlib.
+ * The types are built on an extend the Java Collections Framework.
*/
public interface Type extends Cloneable {
@@ -35,15 +36,35 @@ public interface Type extends Cloneable {
public Type getClone();
/**
- * {@inheritDoc}
+ * Compare the specified object with this type for equality. Returns
+ * {@code true} if and only if the specified object is also an instance
+ * of the same type.
+ * @param o The object to compare.
+ * @return {@code true} if equality exists, {@code false} otherwise.
* @see Object#equals(Object)
*/
@Override
- public boolean equals(Object other);
+ public boolean equals(Object o);
/**
- * {@inheritDoc}
- * @see Object#hashCode()
+ * Returns the hash code value for this list. The hash code of a list
+ * is defined to be the result of the following calculation:
+ * <pre>
+ * int hashCode = 7;
+ * Iterator<E> i = list.iterator();
+ * while (i.hasNext()) {
+ * E obj = i.next();
+ * hashCode = 31*hashCode + (obj==null ? 0 : obj.hashCode());
+ * }
+ * </pre>
+ * This ensures that <tt>type1.equals(type2)</tt> implies that
+ * <tt>type1.hashCode()==type2.hashCode()</tt> for any two types,
+ * <tt>type1</tt> and <tt>type2</tt>, as required by the general
+ * contract of {@link Object#hashCode}.
+ *
+ * @return the hash code value for this list
+ * @see Object#equals(Object)
+ * @see #equals(Object)
*/
@Override
public int hashCode();
diff --git a/src/main/java/net/sourceforge/cilib/type/types/container/AbstractList.java b/src/main/java/net/sourceforge/cilib/type/types/container/AbstractList.java
index 50fc7b6..a3ff4b4 100644
--- a/src/main/java/net/sourceforge/cilib/type/types/container/AbstractList.java
+++ b/src/main/java/net/sourceforge/cilib/type/types/container/AbstractList.java
@@ -27,6 +27,7 @@ import net.sourceforge.cilib.type.types.TypeUtil;
/**
* The basic definition for all {@linkplain Type} objects that are based on a list.
*
+ * @param <E> The type element.
* @author Gary Pampara
*/
public abstract class AbstractList<E extends Type> implements StructuredType<E> {
@@ -35,16 +36,19 @@ public abstract class AbstractList<E extends Type> implements StructuredType<E>
/**
* {@inheritDoc}
*/
+ @Override
public abstract AbstractList<E> getClone();
/**
* {@inheritDoc}
*/
- public abstract boolean equals(Object obj);
+ @Override
+ public abstract boolean equals(Object o);
/**
* {@inheritDoc}
*/
+ @Override
public abstract int hashCode();
/**
@@ -94,7 +98,7 @@ public abstract class AbstractList<E extends Type> implements StructuredType<E>
/**
* Add the provided {@linkplain AbstractList} to the start of the current list.
- * @param vector The object to add.
+ * @param list The object to add.
* @return <code>true</code> if the operation was successful, <code>false</code> otherwise.
*/
public abstract boolean prepend(AbstractList<E> list);
@@ -150,15 +154,16 @@ public abstract class AbstractList<E extends Type> implements StructuredType<E>
/**
* Create a sub vector from the current {@linkplain Vector}.
- * @param fromIndex The index to start the sub-vector from.
- * @param toIndex The last index to end the sub-vector at.
- * @return The created sub-vector instance.
+ * @param fromIndex The index to start the sub-list from.
+ * @param toIndex The last index to end the sub-list at.
+ * @return The created sub-list instance.
*/
public abstract AbstractList<E> subList(int fromIndex, int toIndex);
/**
* Create a new (cloned) <tt>Vector</tt> consisting of <tt>rhs</tt> that has been appended to
* <tt>lhs</tt>.
+ * @param <T> The type element.
* @param lhs The <tt>Vector</tt> that will form the front part of the new (cloned)
* <tt>Vector</tt>.
* @param rhs The <tt>Vector</tt> that will form the back part of the new (cloned)
@@ -228,6 +233,7 @@ public abstract class AbstractList<E extends Type> implements StructuredType<E>
/**
* {@inheritDoc}
*/
+ @Override
public String toString() {
return toString('[', ']', ',');
}
diff --git a/src/main/java/net/sourceforge/cilib/type/types/container/TypeList.java b/src/main/java/net/sourceforge/cilib/type/types/container/TypeList.java
index bb907cd..a257e95 100644
--- a/src/main/java/net/sourceforge/cilib/type/types/container/TypeList.java
+++ b/src/main/java/net/sourceforge/cilib/type/types/container/TypeList.java
@@ -29,28 +29,32 @@ import net.sourceforge.cilib.container.visitor.Visitor;
import net.sourceforge.cilib.type.types.Type;
/**
- * Concrete implementation of the {@see net.sourceforge.cilib.type.types.Vector}
- * class. Any {@see net.sourceforge.cilib.type.types.Type} object may be contained
- * within this object.
+ * General list container for all {@code Type} instances.
*
- * @author Gary Pampara
- * @author Edwin Peer
+ * @author gpampara
*/
public class TypeList extends AbstractList<Type> {
private static final long serialVersionUID = 136711882764612609L;
private List<Type> components;
+ /**
+ * Create a new instance.
+ */
public TypeList() {
this.components = new ArrayList<Type>();
}
+ /**
+ * Create a new instance with the predefined size.
+ * @param size The predefined size.
+ */
public TypeList(int size) {
this.components = new ArrayList<Type>();
}
/**
- *
- * @param copy
+ * Create a copy of the provided instance.
+ * @param copy The instance to copy.
*/
public TypeList(TypeList copy) {
this.components = new ArrayList<Type>(copy.components.size());
@@ -59,6 +63,9 @@ public class TypeList extends AbstractList<Type> {
this.components.add(type.getClone());
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public TypeList getClone() {
return new TypeList(this);
@@ -68,14 +75,15 @@ public class TypeList extends AbstractList<Type> {
/**
* {@inheritDoc}
*/
- public boolean equals(Object other) {
- if (other == this)
+ @Override
+ public boolean equals(Object o) {
+ if (o == this)
return true;
- if ((other == null) || (this.getClass() != other.getClass()))
+ if ((o == null) || (this.getClass() != o.getClass()))
return false;
- TypeList otherList = (TypeList) other;
+ TypeList otherList = (TypeList) o;
return this.components.equals(otherList.components);
}
@@ -83,27 +91,40 @@ public class TypeList extends AbstractList<Type> {
/**
* {@inheritDoc}
*/
+ @Override
public int hashCode() {
int hash = 7;
hash = 31 * hash + (this.components == null ? 0 : this.components.hashCode());
return hash;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Type get(int index) {
return this.components.get(index);
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void set(int index, Type value) {
this.components.set(index, value);
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void insert(int index, Type value) {
this.components.add(index, value);
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean append(AbstractList<Type> list) {
for (Type type : list)
@@ -112,6 +133,9 @@ public class TypeList extends AbstractList<Type> {
return true;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean prepend(AbstractList<Type> list) {
for (int i = list.size()-1; i >= 0; i--)
@@ -120,11 +144,17 @@ public class TypeList extends AbstractList<Type> {
return true;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Object[] toArray() {
return this.components.toArray();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public TypeList subList(int fromIndex, int toIndex) {
// Need to bump up the toIndex because the List.subList() operation is upper bound exclusive.
@@ -137,11 +167,17 @@ public class TypeList extends AbstractList<Type> {
return sublist;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean add(Type element) {
return this.components.add(element);
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean addAll(StructuredType<? extends Type> structure) {
for (Type type : structure)
@@ -150,36 +186,59 @@ public class TypeList extends AbstractList<Type> {
return true;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void clear() {
this.components.clear();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean contains(Type element) {
return this.components.contains(element);
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean isEmpty() {
return this.components.isEmpty();
}
+ /**
+ * Returns an iterator over the elements in this list in proper sequence.
+ *
+ * @return an iterator over the elements in this list in proper sequence
+ */
@Override
public Iterator<Type> iterator() {
return this.components.iterator();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean remove(Type element) {
return this.components.remove(element);
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Type remove(int index) {
return this.components.remove(index);
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean removeAll(StructuredType<Type> structure) {
for (Type type : structure)
@@ -188,11 +247,17 @@ public class TypeList extends AbstractList<Type> {
return true;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public int size() {
return this.components.size();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void accept(Visitor<Type> visitor) {
for (Type type : this.components)
diff --git a/src/site/site.xml b/src/site/site.xml
index a263ada..58beb77 100644
--- a/src/site/site.xml
+++ b/src/site/site.xml
@@ -6,17 +6,17 @@
Department of Computer Science
University of Pretoria
South Africa
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -36,7 +36,7 @@
</bannerRight>
<poweredBy>
- <logo
+ <logo
href="http://sourceforge.net/projects/cilib"
img="http://sflogo.sourceforge.net/sflogo.php?group_id=72233&type=11"
name="Get Computational Intelligence Library at SourceForge.net. Fast, secure and Free Open Source software downloads"
@@ -50,6 +50,20 @@
</poweredBy>
<body>
+ <head>
+ <meta content="Computational Intelligence, CI, Artificial Intelligence, AI, PSO, Particle swarm optimization, Evolutionary computation, GA, Genetic Algorithm, DE, Differential evolution, ABC, Artificial Bee Colony" name="KEYWORDS"/>
+ <script type="text/javascript">
+ var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
+ document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+ </script>
+ <script type="text/javascript">
+ try {
+ var pageTracker = _gat._getTracker("UA-4962709-1");
+ pageTracker._trackPageview();
+ } catch(err) {}
+ </script>
+ </head>
+
<links>
<item name="SoureForge.net project page"
href="http://www.sourceforge.net/projects/cilib" />
diff --git a/src/test/java/net/sourceforge/cilib/functions/clustering/ClusteringFitnessFunctionTest.java b/src/test/java/net/sourceforge/cilib/functions/clustering/ClusteringFitnessFunctionTest.java
index e3f7964..c1de919 100644
--- a/src/test/java/net/sourceforge/cilib/functions/clustering/ClusteringFitnessFunctionTest.java
+++ b/src/test/java/net/sourceforge/cilib/functions/clustering/ClusteringFitnessFunctionTest.java
@@ -84,7 +84,6 @@ public class ClusteringFitnessFunctionTest {
@Test
public void testEvaluate() {
// the evaluate method arranges the clusters and centroids
- System.out.println(function.evaluate(centroids));
assertEquals(4.27188655918496, function.evaluate(centroids), DELTA);
}
diff --git a/src/test/java/net/sourceforge/cilib/type/DomainParserTest.java b/src/test/java/net/sourceforge/cilib/type/DomainParserTest.java
index ca30397..a6e1872 100644
--- a/src/test/java/net/sourceforge/cilib/type/DomainParserTest.java
+++ b/src/test/java/net/sourceforge/cilib/type/DomainParserTest.java
@@ -4,17 +4,17 @@
* Department of Computer Science
* University of Pretoria
* South Africa
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -32,11 +32,11 @@ import net.sourceforge.cilib.type.types.container.Vector;
import org.junit.Test;
/**
- *
+ *
* @author Gary Pampara
*/
public class DomainParserTest {
-
+
@Test
public void testParseReal() {
DomainParser parser = new DomainParser();
@@ -55,8 +55,8 @@ public class DomainParserTest {
fail("Parser cannot handle parsing of R! " + e.getMessage());
}
}
-
-
+
+
@Test
public void testParseBit() {
DomainParser parser = new DomainParser();
@@ -70,7 +70,7 @@ public class DomainParserTest {
fail("Parser cannot handle parsing of B! " + e.getMessage());
}
}
-
+
@Test
public void testParseInteger() {
@@ -90,11 +90,11 @@ public class DomainParserTest {
assertEquals("Z(0.0,1.0),Z(0.0,1.0),Z(0.0,1.0),Z(0.0,1.0),Z(0.0,1.0),Z(0.0,1.0),Z(0.0,1.0),Z(0.0,1.0),Z(0.0,1.0),Z(0.0,1.0)", parser.expandDomainString("Z(0,1)^10"));
}
catch (Exception e) {
- fail("Parser cannot handle parsing of Z! " + e.getMessage());
+ fail("Parser cannot handle parsing of Z! " + e.getMessage());
}
}
-
-
+
+
@Test
public void testParseString() {
DomainParser parser = new DomainParser();
@@ -106,8 +106,8 @@ public class DomainParserTest {
fail("Parser cannot handle parsing of T! " + e.getMessage());
}
}
-
-
+
+
@Test
public void testParseComplexDomain() {
DomainParser parser = new DomainParser();
@@ -121,7 +121,7 @@ public class DomainParserTest {
}
}
-
+
/**
* This test determines if the parser can successfully parse and build
* domains that can be represented as a matrix (also regarded as second order
@@ -139,30 +139,30 @@ public class DomainParserTest {
fail("Parser cannot handle martix representation domains! " + e.getMessage());
}
}
-
-
+
+
@Test
public void testBuildMatrixDomain() {
DomainParser parser = new DomainParser();
try {
parser.parse("[R(-30.0,30.0)^4]^5");
-
+
TypeList matrix = (TypeList) parser.getBuiltRepresentation();
-
+
// Test the dimensionality
assertEquals(5, matrix.size());
-
+
for (int i = 0; i < matrix.size(); i++) {
assertEquals(4, ((TypeList)matrix.get(i)).size());
}
-
+
// Test object equality
Vector v1 = (Vector) matrix.get(0);
Vector v2 = (Vector) matrix.get(1);
Vector v3 = (Vector) matrix.get(2);
Vector v4 = (Vector) matrix.get(3);
Vector v5 = (Vector) matrix.get(4);
-
+
assertTrue(assertObjectNotSame(v1, v2));
assertTrue(assertObjectNotSame(v1, v3));
assertTrue(assertObjectNotSame(v1, v4));
@@ -173,32 +173,24 @@ public class DomainParserTest {
assertTrue(assertObjectNotSame(v3, v4));
assertTrue(assertObjectNotSame(v3, v4));
assertTrue(assertObjectNotSame(v4, v5));
- }
-
- catch (Exception e) {
-
+ } catch (Exception e) {
+
}
}
-
-// @Test
-// public void expansionOfPredefinedDomain() {
-// parser.parse("[R(4.3, 7.9), R(2.0, 4.4), R(1.0, 6.9), R(0.1, 2.5)]^3");
-// System.out.println(parser.getBuiltRepresentation());
-// }
-
+
/**
- *
+ *
* @param v1
* @param v2
* @return
*/
private boolean assertObjectNotSame(Vector v1, Vector v2) {
-
+
for (int i = 0; i < v1.getDimension(); i++) {
if (v1.get(i).equals(v2.get(i)))
return false;
}
-
+
return true;
}
diff --git a/src/test/java/net/sourceforge/cilib/type/types/container/TypeListTest.java b/src/test/java/net/sourceforge/cilib/type/types/container/TypeListTest.java
new file mode 100644
index 0000000..273f93e
--- /dev/null
+++ b/src/test/java/net/sourceforge/cilib/type/types/container/TypeListTest.java
@@ -0,0 +1,48 @@
+/**
+ * Copyright (C) 2003 - 2008
+ * Computational Intelligence Research Group (CIRG@UP)
+ * Department of Computer Science
+ * University of Pretoria
+ * South Africa
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+package net.sourceforge.cilib.type.types.container;
+
+import net.sourceforge.cilib.type.types.Int;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ * @author gpampara
+ */
+public class TypeListTest {
+
+ @Test
+ public void subList() {
+ TypeList list = new TypeList();
+ list.add(new Vector());
+ list.add(new BinaryTree());
+ list.add(new Int());
+ list.add(new Set());
+ list.add(new NaryTree());
+
+ TypeList subList = list.subList(0, 3);
+
+ Assert.assertEquals(4, subList.size());
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/net/sourceforge/cilib/type/types/container/VectorTest.java b/src/test/java/net/sourceforge/cilib/type/types/container/VectorTest.java
index 1b03f92..86ef5d9 100644
--- a/src/test/java/net/sourceforge/cilib/type/types/container/VectorTest.java
+++ b/src/test/java/net/sourceforge/cilib/type/types/container/VectorTest.java
@@ -34,7 +34,9 @@ import net.sourceforge.cilib.type.types.Int;
import net.sourceforge.cilib.type.types.Numeric;
import net.sourceforge.cilib.type.types.Real;
+import net.sourceforge.cilib.util.VectorUtils;
import org.junit.AfterClass;
+import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -511,4 +513,12 @@ public class VectorTest {
assertTrue(a.equals(a));
assertTrue(a.equals(b));
}
+
+ @Test
+ public void subList() {
+ Vector original = VectorUtils.create(1, 2, 3, 4, 5, 6, 7, 8, 9);
+ Vector subVector = original.subList(0, 3);
+
+ Assert.assertEquals(4, subVector.size());
+ }
}
diff --git a/src/test/java/net/sourceforge/cilib/xml/XMLFileTest.java b/src/test/java/net/sourceforge/cilib/xml/XMLFileTest.java
index f56e89b..772bd93 100644
--- a/src/test/java/net/sourceforge/cilib/xml/XMLFileTest.java
+++ b/src/test/java/net/sourceforge/cilib/xml/XMLFileTest.java
@@ -4,17 +4,17 @@
* Department of Computer Science
* University of Pretoria
* South Africa
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -53,6 +53,9 @@ public class XMLFileTest {
* <p>
* Tests will pass if all the instance creation succeeds.
* </p>
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws IOException
*/
@Test
public void simulationConstruction() throws ParserConfigurationException, SAXException, IOException {
@@ -67,7 +70,7 @@ public class XMLFileTest {
NodeList simulations = doc.getElementsByTagName("simulation");
ProgressListener progress = new ProgressText(simulations.getLength());
-
+
for (int i = 0; i < simulations.getLength(); ++i) {
if(progress != null)
progress.setSimulation(i);
--
1.6.2.3
|