com.rubecula.darwin.examples.travelingsalesman
Class Phenotype_TS

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<String,Trait>
          extended by com.rubecula.darwin.core.TraitMap_Abstract
              extended by com.rubecula.darwin.core.Phenotype_Abstract
                  extended by com.rubecula.darwin.examples.travelingsalesman.Phenotype_TS
All Implemented Interfaces:
Fit, Phenotype, TraitMap, Auditable, Identifiable, Serializable, Cloneable, Map<String,Trait>

public class Phenotype_TS
extends Phenotype_Abstract

Author:
Robin
See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.rubecula.darwin.core.Phenotype_Abstract
log
 
Constructor Summary
Phenotype_TS()
           
 
Method Summary
 boolean equals(Object o)
           
 double evaluateFitness(Phenome phenome, Environment environment)
          This implementation of evaluateFitness is relatively obvious: for each trait in this phenotype, and for every factor in the environment, calculate the fitness and weight and add these to total fitness and total weight.
 Client[] getClients(Environment environment)
           
 Client[] getClientsInOrder(Client[] clients)
           
 Client[] getClientsInOrder(Environment environment)
           
 int hashCode()
           
 
Methods inherited from class com.rubecula.darwin.core.Phenotype_Abstract
audit, audit, audit, getIdentifier
 
Methods inherited from class com.rubecula.darwin.core.TraitMap_Abstract
add, getTrait, size
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, values
 
Methods inherited from class java.util.AbstractMap
toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.rubecula.darwin.core.TraitMap
add, getTrait, size
 

Constructor Detail

Phenotype_TS

public Phenotype_TS()
Method Detail

evaluateFitness

public double evaluateFitness(Phenome phenome,
                              Environment environment)
Description copied from class: Phenotype_Abstract
This implementation of evaluateFitness is relatively obvious: for each trait in this phenotype, and for every factor in the environment, calculate the fitness and weight and add these to total fitness and total weight. Finally, assuming that there was at least one trait, calculate the result as the ratio of total fitness to total weight.

Specified by:
evaluateFitness in interface Fit
Overrides:
evaluateFitness in class Phenotype_Abstract
Parameters:
phenome - the phenome from which we get the fitness function (used to get the fitness/weight for a trait/factor pair).
environment - the environment from which we get the set of eco factors.
Returns:
the result calculated as above.
See Also:
Phenome.getFitnessFunction(), Fit.evaluateFitness(com.rubecula.darwin.core.Phenome, com.rubecula.darwin.core.Environment)

getClients

public Client[] getClients(Environment environment)
Parameters:
environment -
Returns:
an array of Client objects which form the clients of this environment.

getClientsInOrder

public Client[] getClientsInOrder(Client[] clients)
Parameters:
clients - array derived directly from the environment
Returns:
method to get the clients in their order of visitation.

getClientsInOrder

public Client[] getClientsInOrder(Environment environment)
Parameters:
environment -
Returns:
method to get the clients in their order of visitation.

equals

public boolean equals(Object o)
Specified by:
equals in interface Map<String,Trait>
Overrides:
equals in class AbstractMap<String,Trait>

hashCode

public int hashCode()
Specified by:
hashCode in interface Map<String,Trait>
Overrides:
hashCode in class AbstractMap<String,Trait>