net.sourceforge.cilib.problem.mappingproblem
Class MappingProblem

java.lang.Object
  extended by net.sourceforge.cilib.problem.OptimisationProblemAdapter
      extended by net.sourceforge.cilib.problem.mappingproblem.MappingProblem
All Implemented Interfaces:
Serializable, OptimisationProblem, Problem, Cloneable
Direct Known Subclasses:
LinearMappingProblem

public abstract class MappingProblem
extends OptimisationProblemAdapter

Abstract MappingProblem class that allows for implementing methods of mapping high-dimensional data onto lower dimensions. This class is abstract and merely provides a nice skeleton, similar to the OptimisationProblemAdapter.

Author:
jkroon TODO: change this to use the MatrixDataSetBuilder correctly
See Also:
Serialized Form

Field Summary
 
Fields inherited from class net.sourceforge.cilib.problem.OptimisationProblemAdapter
dataSetBuilder, fitnessEvaluations
 
Constructor Summary
MappingProblem()
           
 
Method Summary
protected  Fitness calculateFitness(Type solution)
          Calculates the fitness of the given matrix.
 double getDistanceInputVect(int i1, int i2)
          Retrieve the distance between the two given input vectors.
 int getInputDim()
          Gets the value of M, the input dimension.
protected abstract  int getMatrixSize()
          This function should return the number of "doubles" required in the matrix in order to perform the mapping.
protected  int getNumInputVectors()
          This function retrieves the number of input vectors that forms part of the dataset.
 int getOutputDim()
          Gets the value of D, the output dimension.
protected abstract  void performMapping(Matrix<Double> inputs, Vector distmatrix, Matrix<Double> outputs)
          This function is there to perform the mapping.
 void setDataSetBuilder(DataSetBuilder dataSetBuilder)
          This method is used during initialisation by the Simulator to provide us with out DataSet.
 void setEvaluator(MappingEvaluator evaluator)
          This function sets the evaluator to use.
 
Methods inherited from class net.sourceforge.cilib.problem.OptimisationProblemAdapter
accept, changeEnvironment, getChangeStrategy, getClone, getDataSetBuilder, getFitness, getFitnessEvaluations, setChangeStrategy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sourceforge.cilib.problem.OptimisationProblem
getBehaviouralDomain, getDomain
 

Constructor Detail

MappingProblem

public MappingProblem()
Method Detail

calculateFitness

protected final Fitness calculateFitness(Type solution)
Calculates the fitness of the given matrix. This wraps arounds the evaluateMapping function. It may call evaluateMapping multiple times for every call to calculateFitness depending on the dataset.

Specified by:
calculateFitness in class OptimisationProblemAdapter
Parameters:
solution - The solution to evaluate. This must conform to the domain.
Returns:
The Fitness of the solution in the current Problem.
See Also:
OptimisationProblemAdapter.getFitness(Type, boolean)

performMapping

protected abstract void performMapping(Matrix<Double> inputs,
                                       Vector distmatrix,
                                       Matrix<Double> outputs)
This function is there to perform the mapping. It must not alter the values in the inputs or distmatrix array. It should place the mapped to vectoers in the outputs array. All arrays are pre-allocated. The distmatrix is a single dimensional array - of the size specified by getMatrixSize().

Parameters:
inputs - The input vectors - do not alter.
distmatrix - The matrix as supplied by the Algorithm - do not alter.
outputs - Place your resulting output vectors in here.

getMatrixSize

protected abstract int getMatrixSize()
This function should return the number of "doubles" required in the matrix in order to perform the mapping.

Returns:
The size of the mapping matrix.

getInputDim

public final int getInputDim()
Gets the value of M, the input dimension.

Returns:
The current value of M.

getOutputDim

public final int getOutputDim()
Gets the value of D, the output dimension.

Returns:
The current value of D.

getNumInputVectors

protected final int getNumInputVectors()
This function retrieves the number of input vectors that forms part of the dataset.


setEvaluator

public final void setEvaluator(MappingEvaluator evaluator)
This function sets the evaluator to use.

Parameters:
The - evaluator to use.

setDataSetBuilder

public void setDataSetBuilder(DataSetBuilder dataSetBuilder)
This method is used during initialisation by the Simulator to provide us with out DataSet. This method loads the actual data from the DataSet.

Specified by:
setDataSetBuilder in interface OptimisationProblem
Overrides:
setDataSetBuilder in class OptimisationProblemAdapter
Parameters:
dataset - The dataset from which to retrieve the data.

getDistanceInputVect

public final double getDistanceInputVect(int i1,
                                         int i2)
Retrieve the distance between the two given input vectors.

Parameters:
i1 - Index of the first vector
i2 - Index of the second vector
Returns:
the distance between the two vectors.


Copyright © 2009 CIRG. All Rights Reserved.