|
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 implements Measurement{
//Determine winning output, determine if misclassification
NNPattern p = iterDv.value();
- Vector output = this.topology.evaluate(p);
+ TypeList output = this.topology.evaluate(p);
int winningOutput = 99999;
double winningOutputValue = 0.0;
@@ -181,7 +181,7 @@ public class AreaUnderROC implements Measurement{
}
String accuracy = String.valueOf(accuracyVal / totalPats);
- Vector v = new Vector();
+ TypeList v = new TypeList();
v.add(new Real(totalAUC));
v.add(new StringType(countString));
v.add(new StringType(matrix));
diff --git a/src/main/java/net/sourceforge/cilib/neuralnetwork/foundation/measurements/NNOutput.java b/src/main/java/net/sourceforge/cilib/neuralnetwork/foundation/measurements/NNOutput.java
index e571b21..dbc8fcf 100644
--- a/src/main/java/net/sourceforge/cilib/neuralnetwork/foundation/measurements/NNOutput.java
+++ b/src/main/java/net/sourceforge/cilib/neuralnetwork/foundation/measurements/NNOutput.java
@@ -35,7 +35,7 @@ import net.sourceforge.cilib.neuralnetwork.generic.datacontainers.GenericData;
import net.sourceforge.cilib.neuralnetwork.generic.datacontainers.RandomDistributionStrategy;
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;
/**
* Measurement to determine the output of a Neural Network.
@@ -89,7 +89,7 @@ public class NNOutput implements Measurement {
iteratorDc.reset();
while(iteratorDc.hasMore()){
- Vector outputDg = topology.evaluate(iteratorDc.value());
+ TypeList outputDg = topology.evaluate(iteratorDc.value());
try {
out.write(iteratorDc.value().getInput().toString() + " " + outputDg.toString());
diff --git a/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/GenericTopology.java b/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/GenericTopology.java
index a07872d..8a95b00 100644
--- a/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/GenericTopology.java
+++ b/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/GenericTopology.java
@@ -32,6 +32,7 @@ import net.sourceforge.cilib.neuralnetwork.generic.topologyvisitors.GenericTopol
import net.sourceforge.cilib.neuralnetwork.generic.topologyvisitors.RandomWeightInitialiser;
import net.sourceforge.cilib.neuralnetwork.generic.topologyvisitors.SpecificWeightInitialiser;
import net.sourceforge.cilib.neuralnetwork.generic.topologyvisitors.WeightExtractingVisitor;
+import net.sourceforge.cilib.type.types.container.TypeList;
import net.sourceforge.cilib.type.types.container.Vector;
/**
@@ -95,7 +96,7 @@ public abstract class GenericTopology implements NeuralNetworkTopology, Initiali
}
- public abstract Vector evaluate(NNPattern p);
+ public abstract TypeList evaluate(NNPattern p);
public ArrayList<NeuronConfig> getLayer(int index){
diff --git a/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/LayeredGenericTopology.java b/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/LayeredGenericTopology.java
index 116c944..fd87cbb 100644
--- a/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/LayeredGenericTopology.java
+++ b/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/LayeredGenericTopology.java
@@ -26,7 +26,7 @@ import java.util.ArrayList;
import net.sourceforge.cilib.neuralnetwork.foundation.NNPattern;
import net.sourceforge.cilib.neuralnetwork.generic.neuron.NeuronConfig;
import net.sourceforge.cilib.type.types.Type;
-import net.sourceforge.cilib.type.types.container.Vector;
+import net.sourceforge.cilib.type.types.container.TypeList;
/**
* TODO: Complete this javadoc.
@@ -49,9 +49,10 @@ public class LayeredGenericTopology extends GenericTopology {
super.initialize();
}
- public Vector evaluate(NNPattern p){
+ @Override
+ public TypeList evaluate(NNPattern p){
- Vector output = new Vector();
+ TypeList output = new TypeList();
for (int layer = 0; layer < layerList.size(); layer++){
diff --git a/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/datacontainers/DynamicPatternSelectionData.java b/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/datacontainers/DynamicPatternSelectionData.java
index 0234dce..c0de472 100644
--- a/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/datacontainers/DynamicPatternSelectionData.java
+++ b/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/datacontainers/DynamicPatternSelectionData.java
@@ -28,7 +28,7 @@ import net.sourceforge.cilib.neuralnetwork.foundation.NNError;
import net.sourceforge.cilib.neuralnetwork.foundation.NNPattern;
import net.sourceforge.cilib.neuralnetwork.foundation.NeuralNetworkDataIterator;
import net.sourceforge.cilib.neuralnetwork.generic.GenericTopology;
-import net.sourceforge.cilib.type.types.container.Vector;
+import net.sourceforge.cilib.type.types.container.TypeList;
/**
@@ -112,7 +112,7 @@ public class DynamicPatternSelectionData extends GenericData implements Initiali
NNPattern p = dcIter.value();
//Evaluate p against current NN topology.
- Vector output = this.topology.evaluate(p);
+ TypeList output = this.topology.evaluate(p);
//determine informativeness of p
NNError patternError = prototypeError.getClone();
diff --git a/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/errorfunctions/ClassificationErrorReal.java b/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/errorfunctions/ClassificationErrorReal.java
index ec69c85..0b7d206 100644
--- a/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/errorfunctions/ClassificationErrorReal.java
+++ b/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/errorfunctions/ClassificationErrorReal.java
@@ -25,7 +25,7 @@ import net.sourceforge.cilib.neuralnetwork.foundation.NNError;
import net.sourceforge.cilib.neuralnetwork.foundation.NNPattern;
import net.sourceforge.cilib.problem.Fitness;
import net.sourceforge.cilib.type.types.Real;
-import net.sourceforge.cilib.type.types.container.Vector;
+import net.sourceforge.cilib.type.types.container.TypeList;
/**
* @author Stefan
@@ -47,7 +47,7 @@ public class ClassificationErrorReal implements NNError {
}
- public void computeIteration(Vector output, NNPattern input) {
+ public void computeIteration(TypeList output, NNPattern input) {
boolean isCorrect = true;
@@ -90,7 +90,7 @@ public class ClassificationErrorReal implements NNError {
throw new IllegalArgumentException("Incorrect class instance passed");
}
- return (Double.valueOf(this.percentageCorrect)).compareTo((Double) ((ClassificationErrorReal) f).getValue());
+ return (Double.valueOf(this.percentageCorrect)).compareTo(((ClassificationErrorReal) f).getValue());
}
public NNError getClone(){
diff --git a/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/errorfunctions/MSEErrorFunction.java b/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/errorfunctions/MSEErrorFunction.java
index c0fe4ab..80c325d 100644
--- a/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/errorfunctions/MSEErrorFunction.java
+++ b/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/errorfunctions/MSEErrorFunction.java
@@ -27,7 +27,7 @@ import net.sourceforge.cilib.neuralnetwork.foundation.NNPattern;
import net.sourceforge.cilib.neuralnetwork.foundation.NeuralNetworkData;
import net.sourceforge.cilib.problem.Fitness;
import net.sourceforge.cilib.type.types.Real;
-import net.sourceforge.cilib.type.types.container.Vector;
+import net.sourceforge.cilib.type.types.container.TypeList;
/**
* @author stefanv
@@ -96,7 +96,7 @@ public class MSEErrorFunction implements NNError, Initializable {
}
- public void computeIteration(Vector output, NNPattern input) {
+ public void computeIteration(TypeList output, NNPattern input) {
if (input.getTargetLength() != output.size()){
throw new IllegalArgumentException("Output and target lenghts don't match");
diff --git a/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/evaluationmediators/FFNNEvaluationMediator.java b/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/evaluationmediators/FFNNEvaluationMediator.java
index 7fe9c67..775f849 100644
--- a/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/evaluationmediators/FFNNEvaluationMediator.java
+++ b/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/evaluationmediators/FFNNEvaluationMediator.java
@@ -24,12 +24,11 @@ package net.sourceforge.cilib.neuralnetwork.generic.evaluationmediators;
import java.util.List;
import net.sourceforge.cilib.algorithm.Algorithm;
-import net.sourceforge.cilib.entity.visitor.TopologyVisitor;
import net.sourceforge.cilib.neuralnetwork.foundation.EvaluationMediator;
import net.sourceforge.cilib.neuralnetwork.foundation.NNPattern;
import net.sourceforge.cilib.neuralnetwork.foundation.NeuralNetworkDataIterator;
import net.sourceforge.cilib.problem.OptimisationSolution;
-import net.sourceforge.cilib.type.types.container.Vector;
+import net.sourceforge.cilib.type.types.container.TypeList;
/**
* @author stefanv
@@ -72,7 +71,7 @@ public class FFNNEvaluationMediator extends EvaluationMediator {
//iterate over each applicable pattern in training dataset
while(iteratorDt.hasMore()){
- Vector output = topology.evaluate(iteratorDt.value());
+ TypeList output = topology.evaluate(iteratorDt.value());
this.nrEvaluationsPerEpoch++;
//compute the per pattern error, use it to train the topology stochastically be default
@@ -91,7 +90,7 @@ public class FFNNEvaluationMediator extends EvaluationMediator {
while(iteratorDg.hasMore()){
- Vector outputDg = topology.evaluate(iteratorDg.value());
+ TypeList outputDg = topology.evaluate(iteratorDg.value());
//compute the per pattern error, use it to train the topology stochastically be default
this.computeErrorIteration(this.errorDg, outputDg, iteratorDg.value());
@@ -107,7 +106,7 @@ public class FFNNEvaluationMediator extends EvaluationMediator {
}
- public Vector evaluate(NNPattern p) {
+ public TypeList evaluate(NNPattern p) {
return topology.evaluate(p);
}
diff --git a/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/evaluationmediators/SAILAEvaluationMediator.java b/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/evaluationmediators/SAILAEvaluationMediator.java
index 31c04e0..d8dc137 100644
--- a/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/evaluationmediators/SAILAEvaluationMediator.java
+++ b/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/evaluationmediators/SAILAEvaluationMediator.java
@@ -32,7 +32,7 @@ import net.sourceforge.cilib.neuralnetwork.foundation.NeuralNetworkDataIterator;
import net.sourceforge.cilib.neuralnetwork.generic.datacontainers.SAILARealData;
import net.sourceforge.cilib.neuralnetwork.generic.errorfunctions.MSEErrorFunction;
import net.sourceforge.cilib.problem.OptimisationSolution;
-import net.sourceforge.cilib.type.types.container.Vector;
+import net.sourceforge.cilib.type.types.container.TypeList;
/**
@@ -118,7 +118,7 @@ public class SAILAEvaluationMediator extends EvaluationMediator {
iteratorDg = data.getGeneralisationSetIterator();
//set the initial error to the error on Dt = 1 pattern.
- Vector tmpO = topology.evaluate(iteratorDt.value());
+ TypeList tmpO = topology.evaluate(iteratorDt.value());
subsetBeginErrorDt.computeIteration(tmpO, iteratorDt.value());
subsetBeginErrorDg.computeIteration(tmpO, iteratorDg.value());
subsetBeginErrorDt.finaliseError();
@@ -156,7 +156,7 @@ public class SAILAEvaluationMediator extends EvaluationMediator {
//iterate over training set
while(iteratorDt.hasMore()){
- Vector outputDt = topology.evaluate(iteratorDt.value());
+ TypeList outputDt = topology.evaluate(iteratorDt.value());
//compute the per pattern error, use it to train the topology stochastically by default
this.computeErrorIteration(this.errorDt, outputDt, iteratorDt.value());
@@ -174,7 +174,7 @@ public class SAILAEvaluationMediator extends EvaluationMediator {
while(iteratorDg.hasMore()){
- Vector outputDg = topology.evaluate(iteratorDg.value());
+ TypeList outputDg = topology.evaluate(iteratorDg.value());
//compute the per pattern error, use it to train the topology stochastically be default
this.computeErrorIteration(this.errorDg, outputDg, iteratorDg.value());
@@ -234,7 +234,7 @@ public class SAILAEvaluationMediator extends EvaluationMediator {
}
//save the local var this.errorDt[0] as previous
- errorDtPrevious.setValue(((Double) this.errorDt[0].getValue()).doubleValue());
+ errorDtPrevious.setValue((this.errorDt[0].getValue()).doubleValue());
//criterion 4: Error on Dg increases too much
@@ -242,19 +242,19 @@ public class SAILAEvaluationMediator extends EvaluationMediator {
//averageNew = (averageOld * periodsOld + new_sample) / (periodsOld + 1)
epochNumber++;
- averageErrorDg = ((double) (averageErrorDg * (epochNumber - 1)) + ((Double) this.errorDg[0].getValue()).doubleValue()) / (double) epochNumber;
+ averageErrorDg = ((averageErrorDg * (epochNumber - 1)) + (this.errorDg[0].getValue()).doubleValue()) / (double) epochNumber;
history.add(this.errorDt[0]);
double errorDgStdDev = 0;
for(int i = 0; i < history.size(); i++){
- errorDgStdDev += Math.pow(((Double) history.get(i).getValue()).doubleValue() - averageErrorDg, 2);
+ errorDgStdDev += Math.pow((history.get(i).getValue()).doubleValue() - averageErrorDg, 2);
}
errorDgStdDev = Math.sqrt(errorDgStdDev / (double) history.size());
- if (((Double) this.errorDg[0].getValue()).doubleValue() > (averageErrorDg + errorDgStdDev)) {
+ if ((this.errorDg[0].getValue()).doubleValue() > (averageErrorDg + errorDgStdDev)) {
terminate = true;
System.out.println("___________SAILA Termination criterion 4: Validation error rising too much, overfitting detected");
}
@@ -272,15 +272,15 @@ public class SAILAEvaluationMediator extends EvaluationMediator {
subsetEpochCounter = 0;
//criterion 2 reset
- ((MSEErrorFunction) subsetBeginErrorDt).setValue(((Double) this.errorDt[0].getValue()).doubleValue());
- ((MSEErrorFunction) subsetBeginErrorDg).setValue(((Double) this.errorDg[0].getValue()).doubleValue());
+ ((MSEErrorFunction) subsetBeginErrorDt).setValue((this.errorDt[0].getValue()).doubleValue());
+ ((MSEErrorFunction) subsetBeginErrorDg).setValue((this.errorDg[0].getValue()).doubleValue());
}
data.shuffleTrainingSet();
}
- public Vector evaluate(NNPattern p) {
+ public TypeList evaluate(NNPattern p) {
return topology.evaluate(p);
}
diff --git a/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/topologyvisitors/WeightExtractingVisitor.java b/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/topologyvisitors/WeightExtractingVisitor.java
index 32525ae..f52099e 100644
--- a/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/topologyvisitors/WeightExtractingVisitor.java
+++ b/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/topologyvisitors/WeightExtractingVisitor.java
@@ -23,6 +23,7 @@ package net.sourceforge.cilib.neuralnetwork.generic.topologyvisitors;
import net.sourceforge.cilib.neuralnetwork.generic.Weight;
import net.sourceforge.cilib.neuralnetwork.generic.neuron.NeuronConfig;
+import net.sourceforge.cilib.type.types.Numeric;
import net.sourceforge.cilib.type.types.container.Vector;
/**
@@ -42,7 +43,7 @@ public class WeightExtractingVisitor implements GenericTopologyVisitor {
Weight[] neuronWeights = n.getInputWeights();
for (int i = 0; i < neuronWeights.length; i++){
- weights.add(neuronWeights[i].getWeightValue().getClone());
+ weights.add((Numeric) neuronWeights[i].getWeightValue().getClone());
}
}
diff --git a/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/trainingstrategies/ErrorSignal.java b/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/trainingstrategies/ErrorSignal.java
index 2bbc6c7..46a669c 100644
--- a/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/trainingstrategies/ErrorSignal.java
+++ b/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/trainingstrategies/ErrorSignal.java
@@ -25,7 +25,7 @@ import java.util.ArrayList;
import net.sourceforge.cilib.neuralnetwork.generic.Weight;
import net.sourceforge.cilib.type.types.Type;
-import net.sourceforge.cilib.type.types.container.Vector;
+import net.sourceforge.cilib.type.types.container.TypeList;
/**
* @author stefanv
@@ -36,7 +36,7 @@ public interface ErrorSignal {
public Type computeBaseDelta(Type desired, Type output, Type outputFunctionDerivative);
public Type computeRecursiveDelta(Type outputFunctionDerivative,
- Vector delta,
+ TypeList delta,
ArrayList<Weight> w,
Type output);
diff --git a/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/trainingstrategies/FFNN_GD_TrainingStrategy.java b/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/trainingstrategies/FFNN_GD_TrainingStrategy.java
index bbc65cb..9779639 100644
--- a/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/trainingstrategies/FFNN_GD_TrainingStrategy.java
+++ b/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/trainingstrategies/FFNN_GD_TrainingStrategy.java
@@ -33,7 +33,7 @@ import net.sourceforge.cilib.neuralnetwork.generic.Weight;
import net.sourceforge.cilib.neuralnetwork.generic.neuron.NeuronConfig;
import net.sourceforge.cilib.type.types.Real;
import net.sourceforge.cilib.type.types.Type;
-import net.sourceforge.cilib.type.types.container.Vector;
+import net.sourceforge.cilib.type.types.container.TypeList;
/**
* @author stefanv
@@ -112,11 +112,11 @@ public class FFNN_GD_TrainingStrategy implements TrainingStrategy, Observer {
NNPattern p = (NNPattern) args;
ArrayList<NeuronConfig> updateNeuronList = new ArrayList<NeuronConfig>();
- Vector deltaUpdateList = new Vector();
+ TypeList deltaUpdateList = new TypeList();
//iterate over output layer
LayerIterator outputIter = topology.getLayerIterator(topology.getNrLayers() - 1);
- Vector prevDeltaList = new Vector(outputIter.getNrNeurons());
+ TypeList prevDeltaList = new TypeList(outputIter.getNrNeurons());
LayerIterator prevIter = null;
for (NeuronConfig oi = outputIter.value(); outputIter.hasMore(); outputIter.nextNeuron()){
@@ -140,7 +140,7 @@ public class FFNN_GD_TrainingStrategy implements TrainingStrategy, Observer {
//Iterate backwards over all remaining layers L = #nrlayers-1 ... 1. layer 0 not done as input layer
LayerIterator layerIter = topology.getLayerIterator(layer);
- Vector deltaList = new Vector(layerIter.getNrNeurons());
+ TypeList deltaList = new TypeList(layerIter.getNrNeurons());
//iterate over all neurons in layer L
for (NeuronConfig li = layerIter.value(); layerIter.hasMore(); layerIter.nextNeuron()){
diff --git a/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/trainingstrategies/SquaredErrorFunction.java b/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/trainingstrategies/SquaredErrorFunction.java
index 15e52c2..f518907 100644
--- a/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/trainingstrategies/SquaredErrorFunction.java
+++ b/src/main/java/net/sourceforge/cilib/neuralnetwork/generic/trainingstrategies/SquaredErrorFunction.java
@@ -26,6 +26,7 @@ import java.util.ArrayList;
import net.sourceforge.cilib.neuralnetwork.generic.Weight;
import net.sourceforge.cilib.type.types.Real;
import net.sourceforge.cilib.type.types.Type;
+import net.sourceforge.cilib.type.types.container.TypeList;
import net.sourceforge.cilib.type.types.container.Vector;
/**
@@ -55,7 +56,7 @@ public class SquaredErrorFunction implements ErrorSignal {
* {@inheritDoc}
*/
public Type computeRecursiveDelta(Type outputFunctionDerivative,
- Vector delta, ArrayList<Weight> w, Type output) {
+ TypeList delta, ArrayList<Weight> w, Type output) {
double sumResult = 0;
for (int i = 0; i < w.size(); i++){
diff --git a/src/main/java/net/sourceforge/cilib/neuralnetwork/testarea/TestErrorINCLearnWithTrainer.java b/src/main/java/net/sourceforge/cilib/neuralnetwork/testarea/TestErrorINCLearnWithTrainer.java
index c495cef..9d6bbba 100644
--- a/src/main/java/net/sourceforge/cilib/neuralnetwork/testarea/TestErrorINCLearnWithTrainer.java
+++ b/src/main/java/net/sourceforge/cilib/neuralnetwork/testarea/TestErrorINCLearnWithTrainer.java
@@ -38,6 +38,7 @@ import net.sourceforge.cilib.neuralnetwork.generic.trainingstrategies.FFNN_GD_Tr
import net.sourceforge.cilib.neuralnetwork.generic.trainingstrategies.SquaredErrorFunction;
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;
/**
@@ -142,7 +143,7 @@ in.add(new Real(1.234));
StandardPattern p = new StandardPattern(in, null);
-Vector result = topo.evaluate(p);
+TypeList result = topo.evaluate(p);
System.out.println("test result f(0.5) = 0.25 --> : " + ((Real) result.get(0)).getReal());
diff --git a/src/main/java/net/sourceforge/cilib/neuralnetwork/testarea/TestFFNNandGDTrainer.java b/src/main/java/net/sourceforge/cilib/neuralnetwork/testarea/TestFFNNandGDTrainer.java
index 4b6dc50..03f0c28 100644
--- a/src/main/java/net/sourceforge/cilib/neuralnetwork/testarea/TestFFNNandGDTrainer.java
+++ b/src/main/java/net/sourceforge/cilib/neuralnetwork/testarea/TestFFNNandGDTrainer.java
@@ -39,6 +39,7 @@ import net.sourceforge.cilib.neuralnetwork.generic.trainingstrategies.FFNN_GD_Tr
import net.sourceforge.cilib.neuralnetwork.generic.trainingstrategies.SquaredErrorFunction;
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;
/**
@@ -133,7 +134,7 @@ public final class TestFFNNandGDTrainer {
StandardPattern p = new StandardPattern(in, null);
- Vector result = topo.evaluate(p);
+ TypeList result = topo.evaluate(p);
System.out.println("test result input = 0.5, output should be 0.25 --> : " + ((Real) result.get(0)).getReal());
diff --git a/src/main/java/net/sourceforge/cilib/neuralnetwork/testarea/TestNeuronAndEvaluateFFNN.java b/src/main/java/net/sourceforge/cilib/neuralnetwork/testarea/TestNeuronAndEvaluateFFNN.java
index 791dca2..d7e9430 100644
--- a/src/main/java/net/sourceforge/cilib/neuralnetwork/testarea/TestNeuronAndEvaluateFFNN.java
+++ b/src/main/java/net/sourceforge/cilib/neuralnetwork/testarea/TestNeuronAndEvaluateFFNN.java
@@ -33,6 +33,7 @@ import net.sourceforge.cilib.neuralnetwork.generic.trainingstrategies.ErrorSigna
import net.sourceforge.cilib.neuralnetwork.generic.trainingstrategies.FFNN_GD_TrainingStrategy;
import net.sourceforge.cilib.neuralnetwork.generic.trainingstrategies.SquaredErrorFunction;
import net.sourceforge.cilib.type.types.Real;
+import net.sourceforge.cilib.type.types.container.TypeList;
import net.sourceforge.cilib.type.types.container.Vector;
@@ -114,7 +115,7 @@ public final class TestNeuronAndEvaluateFFNN {
targt.add(new Real(0.7666));
NNPattern p = new StandardPattern(ins, targt);
- Vector result = new Vector();
+ TypeList result = new TypeList();
ErrorSignal delta = new SquaredErrorFunction();
@@ -171,7 +172,7 @@ public final class TestNeuronAndEvaluateFFNN {
for (int counter = 0; counter < 100; counter++){
- result = new Vector();
+ result = new TypeList();
result = ffnn.evaluate(p);
real = ((Real) result.get(0)).getReal();
diff --git a/src/main/java/net/sourceforge/cilib/neuralnetwork/testarea/TestSAILAwithTrainer.java b/src/main/java/net/sourceforge/cilib/neuralnetwork/testarea/TestSAILAwithTrainer.java
index 03d654e..06375a2 100644
--- a/src/main/java/net/sourceforge/cilib/neuralnetwork/testarea/TestSAILAwithTrainer.java
+++ b/src/main/java/net/sourceforge/cilib/neuralnetwork/testarea/TestSAILAwithTrainer.java
@@ -38,6 +38,7 @@ import net.sourceforge.cilib.neuralnetwork.generic.trainingstrategies.FFNN_GD_Tr
import net.sourceforge.cilib.neuralnetwork.generic.trainingstrategies.SquaredErrorFunction;
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;
/**
@@ -142,7 +143,7 @@ in.add(new Real(1.234));
StandardPattern p = new StandardPattern(in, null);
-Vector result = topo.evaluate(p);
+TypeList result = topo.evaluate(p);
System.out.println("test result f(0.5) = 0.25 --> : " + ((Real) result.get(0)).getReal());
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
index be15611..d09a8b3 100644
--- a/src/main/java/net/sourceforge/cilib/type/types/container/Randomizable.java
+++ b/src/main/java/net/sourceforge/cilib/type/types/container/Randomizable.java
@@ -19,17 +19,20 @@
* 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;
/**
- *
+ * Implementing this interface allows an object to be "randomizable".
+ * This implies that the object is able to be set into a state that is random.
* @author gpampara
*/
public interface Randomizable {
+
+ /**
+ * Alter the state of the object in a random manner.
+ * @return {@code true} if successful, {@code false} otherwise.
+ */
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
index 5398e22..345ce84 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
@@ -44,6 +44,10 @@ public class TypeList extends AbstractList<Type> {
this.components = new ArrayList<Type>();
}
+ public TypeList(int size) {
+ this.components = new ArrayList<Type>();
+ }
+
/**
*
* @param copy
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 582b6d4..ba9acab 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
@@ -1,4 +1,4 @@
-/*
+/**
* Copyright (C) 2003 - 2008
* Computational Intelligence Research Group (CIRG@UP)
* Department of Computer Science
@@ -22,85 +22,58 @@
package net.sourceforge.cilib.type.types.container;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Iterator;
-
+import java.util.List;
import net.sourceforge.cilib.container.visitor.Visitor;
import net.sourceforge.cilib.math.VectorMath;
-import net.sourceforge.cilib.type.types.TypeUtil;
import net.sourceforge.cilib.type.types.Numeric;
-import net.sourceforge.cilib.type.types.Real;
import net.sourceforge.cilib.type.types.Resetable;
-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
+ * @author gpampara
*/
-public class Vector extends AbstractList implements Resetable, VectorMath {
- private static final long serialVersionUID = 136711882764612609L;
- private ArrayList<Type> components;
+public class Vector extends AbstractList<Numeric> implements VectorMath, Resetable, Randomizable {
+ private static final long serialVersionUID = -4853190809813810272L;
+ private List<Numeric> components;
/**
- * Create a default <code>MixedVector</code> with an initial size of 0.
+ * Create a new empty {@code Vector}.
*/
public Vector() {
- components = new ArrayList<Type>();
+ this.components = new ArrayList<Numeric>();
}
-
/**
- * Create a <code>MixedVector</code> with a default size specified by <code>dimension</code>.
- *
- * @param dimension The size to initialise the <code>MixedVector</code>
+ * Create a new empty {@code Vector} with {@code size} as the initial
+ * capacity.
+ * @param size The initial capacity.
*/
- public Vector(int dimension) {
- components = new ArrayList<Type>(dimension);
- components.ensureCapacity(dimension);
+ public Vector(int size) {
+ this.components =...
[truncated message content] |