net.sourceforge.cilib.entity
Class AbstractEntity

java.lang.Object
  extended by net.sourceforge.cilib.entity.AbstractEntity
All Implemented Interfaces:
Serializable, Comparable<Entity>, CandidateSolution, Entity, Cloneable
Direct Known Subclasses:
AbstractBee, AbstractParticle, CooperativeEntity, Harmony, Individual

public abstract class AbstractEntity
extends Object
implements Entity, CandidateSolution

Abstract class definition for all concrete Entity objects. This class defines the Entity main data structure for the values stored within the Entity itself.

See Also:
Serialized Form

Constructor Summary
protected AbstractEntity()
          Initialise the candidate solution of the Entity.
protected AbstractEntity(AbstractEntity copy)
          Copy constructor.
 
Method Summary
 boolean equals(Object object)
           It doesn;t make sense to compare the meta data of the entity.
 Fitness getBestFitness()
          Return the best fitness associated with this Entity, provided a best fitness is defined on the Entity.
 StructuredType getCandidateSolution()
          Get the value of the CandidateSolution maintained by this Entity.
 Fitness getFitness()
          Get the fitness of the CandidateSolution maintained by this Entity.
 FitnessCalculator getFitnessCalculator()
          Get the current FitnessCalculator for the current Entity.
 long getId()
          Get the identifier associated with the Entity instance.
 Blackboard<Enum<?>,Type> getProperties()
          Get the properties associate with the Entity.
 int hashCode()
          
 void setCandidateSolution(StructuredType candidateSolution)
          Set the Type maintained by this Entitys CandidateSolution.
 void setFitnessCalculator(FitnessCalculator fitnessCalculator)
          Set the FitnessCalculator for the current Entity.
 void setProperties(Blackboard<Enum<?>,Type> properties)
          Set the properties for the current Entity.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sourceforge.cilib.entity.Entity
calculateFitness, calculateFitness, compareTo, getClone, getDimension, initialise, reinitialise
 

Constructor Detail

AbstractEntity

protected AbstractEntity()
Initialise the candidate solution of the Entity.


AbstractEntity

protected AbstractEntity(AbstractEntity copy)
Copy constructor. Instantiate and copy the given instance.

Parameters:
copy - The instance to copy.
Method Detail

equals

public boolean equals(Object object)
It doesn;t make sense to compare the meta data of the entity. In other words, the properties of the entity may vary, but the entity is still the same entity.

Overrides:
equals in class Object
Parameters:
object - The object to compare equality.

hashCode

public int hashCode()

Overrides:
hashCode in class Object

getProperties

public final Blackboard<Enum<?>,Type> getProperties()
Get the properties associate with the Entity.

Specified by:
getProperties in interface CandidateSolution
Specified by:
getProperties in interface Entity
Returns:
The properties within a Blackboard.

setProperties

public final void setProperties(Blackboard<Enum<?>,Type> properties)
Set the properties for the current Entity.

Specified by:
setProperties in interface CandidateSolution
Specified by:
setProperties in interface Entity
Parameters:
properties - The Blackboard containing the new properties.

getCandidateSolution

public StructuredType getCandidateSolution()
Get the value of the CandidateSolution maintained by this Entity.

Specified by:
getCandidateSolution in interface CandidateSolution
Specified by:
getCandidateSolution in interface Entity
Returns:
The candidate solution as a Type.

getFitness

public Fitness getFitness()
Get the fitness of the CandidateSolution maintained by this Entity.

Specified by:
getFitness in interface CandidateSolution
Specified by:
getFitness in interface Entity
Returns:
The Fitness of the candidate solution.

setCandidateSolution

public void setCandidateSolution(StructuredType candidateSolution)
Set the Type maintained by this Entitys CandidateSolution.

Specified by:
setCandidateSolution in interface CandidateSolution
Specified by:
setCandidateSolution in interface Entity
Parameters:
candidateSolution - The Type that will be the new value of the Entity CandidateSolution.

getBestFitness

public Fitness getBestFitness()
Return the best fitness associated with this Entity, provided a best fitness is defined on the Entity. If a best fitness is not defined, the current fitness is returned as it is the best current fitness. Entity objects that need to use this method need to override it in their implementation, for example with Particle objects.

Specified by:
getBestFitness in interface Entity
Returns:
The associated best Fitness value.

getFitnessCalculator

public FitnessCalculator getFitnessCalculator()
Get the current FitnessCalculator for the current Entity.

Specified by:
getFitnessCalculator in interface Entity
Returns:
The FitnessCalculator associated with this Entity.

setFitnessCalculator

public void setFitnessCalculator(FitnessCalculator fitnessCalculator)
Set the FitnessCalculator for the current Entity.

Parameters:
fitnessCalculator - The value to set.

getId

public long getId()
Get the identifier associated with the Entity instance.

Specified by:
getId in interface Entity
Returns:
The associated identifier.


Copyright © 2009 CIRG. All Rights Reserved.