net.sourceforge.cilib.problem
Class OptimisationProblemAdapter

java.lang.Object
  extended by net.sourceforge.cilib.problem.OptimisationProblemAdapter
All Implemented Interfaces:
Serializable, OptimisationProblem, Problem, Cloneable
Direct Known Subclasses:
BinaryMSAProblem, ClusteringProblem, CompetitiveCoevolutionProblemAdapter, CooperativeOptimisationProblemAdapter, CriterionBasedMOProblemAdapter, FunctionDimensionMappingProblem, FunctionLearningProblem, FunctionOptimisationProblem, KnightCoverageProblem, MappingProblem, MSAProblem, PerformanceEvaluationOptimizationProblem, RNAOptimisationProblem

public abstract class OptimisationProblemAdapter
extends Object
implements OptimisationProblem

This is a convenience class that keeps track of the number of fitness evaluations. This class can be extend instead of implementing OptimisationProblem directly.

The contract of returning an instance of InferiorFitness for solutions outside the problem search space is implemented by getFitness(Type, boolean)

Author:
Edwin Peer
See Also:
Serialized Form

Field Summary
protected  DataSetBuilder dataSetBuilder
           
protected  AtomicInteger fitnessEvaluations
           
 
Constructor Summary
OptimisationProblemAdapter()
           
OptimisationProblemAdapter(OptimisationProblemAdapter copy)
           
 
Method Summary
 void accept(ProblemVisitor visitor)
          Accept the provided Visitor and perform the Visitor.visit(Object) method.
protected abstract  Fitness calculateFitness(Type solution)
          Determine the Fitness of the current Problem instance based on the provided solution.
 void changeEnvironment()
          Change the environment.
 ChangeStrategy getChangeStrategy()
          Get the current problem change strategy.
abstract  OptimisationProblemAdapter getClone()
          Create a cloned copy of the current object and return it.
 DataSetBuilder getDataSetBuilder()
          Get the associated DataSetBuilder.
 Fitness getFitness(Type solution, boolean count)
          Returns the fitness of a potential solution to this problem.
 int getFitnessEvaluations()
          Returns the number of times the underlying fitness function has been evaluated.
 void setChangeStrategy(ChangeStrategy changeStrategy)
          Set the ChangeStrategy for this problem.
 void setDataSetBuilder(DataSetBuilder dsb)
          Set the DataSetBuilder for this optimistion problem.
 
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
 

Field Detail

fitnessEvaluations

protected AtomicInteger fitnessEvaluations

dataSetBuilder

protected DataSetBuilder dataSetBuilder
Constructor Detail

OptimisationProblemAdapter

public OptimisationProblemAdapter()

OptimisationProblemAdapter

public OptimisationProblemAdapter(OptimisationProblemAdapter copy)
Method Detail

getClone

public abstract OptimisationProblemAdapter getClone()
Description copied from interface: OptimisationProblem
Create a cloned copy of the current object and return it. In general the created copy will be a deep copy of the provided instance. As a result this operation an be quite expensive if used incorrectly.

Specified by:
getClone in interface OptimisationProblem
Specified by:
getClone in interface Problem
Specified by:
getClone in interface Cloneable
Returns:
An exact clone of the current object instance.
See Also:
Object.clone()

calculateFitness

protected abstract Fitness calculateFitness(Type solution)
Determine the Fitness of the current Problem instance based on the provided solution.

Parameters:
solution - The Type representing the candidate solution.
Returns:
The Fitness of the solution in the current Problem.
See Also:
getFitness(Type, boolean)

getFitness

public final Fitness getFitness(Type solution,
                                boolean count)
Returns the fitness of a potential solution to this problem. The solution object is described by the domain of this problem, see OptimisationProblem.getDomain(). An instance of InferiorFitness should be returned if the solution falls outside the search space of this problem.

Specified by:
getFitness in interface OptimisationProblem
Parameters:
solution - The potential solution found by the optimisation algorithm.
count - True if this call should contribute to the fitness evaluation count, see OptimisationProblem.getFitnessEvaluations().
Returns:
The fitness of the solution.

getFitnessEvaluations

public final int getFitnessEvaluations()
Returns the number of times the underlying fitness function has been evaluated.

Specified by:
getFitnessEvaluations in interface OptimisationProblem
Returns:
The number fitness evaluations.

getDataSetBuilder

public DataSetBuilder getDataSetBuilder()
Get the associated DataSetBuilder.

Specified by:
getDataSetBuilder in interface OptimisationProblem
Returns:
The currently associated DataSetBuilder.

setDataSetBuilder

public void setDataSetBuilder(DataSetBuilder dsb)
Set the DataSetBuilder for this optimistion problem.

Specified by:
setDataSetBuilder in interface OptimisationProblem
Parameters:
dsb - The DataSetBuilder to be set on the current OptimisationProblem.

accept

public void accept(ProblemVisitor visitor)
Accept the provided Visitor and perform the Visitor.visit(Object) method.

Specified by:
accept in interface OptimisationProblem
Parameters:
visitor - The visitor which has operations to perform.

changeEnvironment

public void changeEnvironment()
Change the environment. TODO: this might need to be refactored.

Specified by:
changeEnvironment in interface Problem

getChangeStrategy

public ChangeStrategy getChangeStrategy()
Get the current problem change strategy.

Returns:
The current ChangeStrategy.

setChangeStrategy

public void setChangeStrategy(ChangeStrategy changeStrategy)
Set the ChangeStrategy for this problem.

Parameters:
changeStrategy - The ChangeStrategy to set.


Copyright © 2009 CIRG. All Rights Reserved.