|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.rubecula.darwin.domain.fitness.Fitness_ com.rubecula.darwin.examples.travelingsalesman.RouteFitness
public class RouteFitness
Field Summary |
---|
Fields inherited from class com.rubecula.darwin.domain.fitness.Fitness_ |
---|
LOG |
Constructor Summary | |
---|---|
RouteFitness()
|
|
RouteFitness(com.rubecula.jexpression.Evaluator evaluator)
TODO use a real function listener (instead of null) |
Method Summary | |
---|---|
protected double |
bandwidth(java.lang.String key)
Concrete sub-classes must implement this method to indicate how sharp the fitness curve should be with respect to the possible values of the variate. |
protected double |
calculateFitness(double travelTime,
double radius,
java.lang.String traitId,
java.lang.String factorId)
Calculate fitness according to the pseudo-Poisson distribution function. |
double |
getAdjustment()
|
double |
getClientFactor()
|
java.lang.Number |
getEnvironmentFactor()
|
ExpressionMap |
getExpressions()
|
double |
getFitness(Trait trait,
EcoFactor factor)
Calculate the fitness for the trait and the factor. |
double |
getScale()
|
double |
getTimeToTravel()
|
int |
getWeight(java.lang.String character,
EcoFactor factor)
|
void |
resetAdjustment(java.lang.Number factor,
java.lang.String trait)
Scale adjustment field by value of factor (if not null). |
void |
resetEnvironmentFactor(java.lang.String trait,
EcoFactor factor)
|
protected double |
scaleFactor(java.lang.String key)
Scale down the factor by the "scale". |
protected double |
scaleTrait(java.lang.String key)
Scale down the travel time by the "timeToTravel". |
void |
setClientFactor(double clientFactor)
This is a factor which adjusts the for the number of clients in the route. |
void |
setScale(double scale)
Set the approximate size of the radius of points of interest in the same distance units as used in the client map. |
void |
setTimeToTravel(double timeToTravel)
Set the time to travel a unit distance, where time is in the same units as the times-to-travel eco factor and the distance units are the same as those used for the client positions. |
Methods inherited from class com.rubecula.darwin.domain.fitness.Fitness_ |
---|
compare, equals, getExpression, getExpressionTerms, getFitnessFunction, getTolerance, hashCode, setTolerance, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public RouteFitness()
public RouteFitness(com.rubecula.jexpression.Evaluator evaluator)
evaluator
- Method Detail |
---|
public double getAdjustment()
public double getClientFactor()
setClientFactor(double)
.public java.lang.Number getEnvironmentFactor()
getEnvironmentFactor
in interface Fitness
getEnvironmentFactor
in class Fitness_
Fitness.getEnvironmentFactor()
public ExpressionMap getExpressions()
getExpressions
in interface HasExpressions
String
/ EvalExpressionMutable
pairs.
The String key for each EvalExpressionMutable
is the name
by which that expression will be known in the user interface.HasExpressions.getExpressions()
public double getFitness(Trait trait, EcoFactor factor) throws FitnessException
getFitness
in interface Fitness
FitnessException
Fitness.getFitness(com.rubecula.darwin.domain.helper.Trait,
com.rubecula.darwin.domain.helper.EcoFactor)
public double getScale()
public double getTimeToTravel()
public int getWeight(java.lang.String character, EcoFactor factor)
getWeight
in interface Fitness
character
- the identifier (or key) of the phenotypic character whose
traits/variants will be measured for fitness against the given
factor.
Fitness.getWeight(String,
com.rubecula.darwin.domain.helper.EcoFactor)
public void resetAdjustment(java.lang.Number factor, java.lang.String trait)
resetAdjustment
in interface Fitness
resetAdjustment
in class Fitness_
factor
- if 1 is passed in then nothing changes.trait
- XXXFitness_.resetAdjustment(java.lang.Number,
String)
public void resetEnvironmentFactor(java.lang.String trait, EcoFactor factor)
resetEnvironmentFactor
in interface Fitness
resetEnvironmentFactor
in class Fitness_
trait
- XXXfactor
- XXXFitness.resetEnvironmentFactor(String,
EcoFactor)
public void setClientFactor(double clientFactor)
clientFactor / (N + clientFactor)
where N
is
the number of clients.
An appropriate value is around 10 or 12. The higher the value, the closer
the adjustment comes to 1.0 and the lower the fitness values for routes
with many clients. When fitness values are low, more organisms are culled
and we have therefore a smaller gene pool to evolve.
OTOH, if this value is too small, the more likely the time to travel the
route will actually be too good (less then the expected) possibly
favoring some routes that take longer than other routes.
clientFactor
- public void setScale(double scale)
scale
- public void setTimeToTravel(double timeToTravel)
timeToTravel
- protected double bandwidth(java.lang.String key)
Fitness_
bandwidth
in class Fitness_
key
- the key which determines which bandwidth to get (trait or
ecofactor).
Fitness_.bandwidth(String)
protected double calculateFitness(double travelTime, double radius, java.lang.String traitId, java.lang.String factorId) throws FitnessException
travelTime/radius/pi
, scaled down by the
value of getTimeToTravel()
which is in theory the time travel
one unit of distance and also by (nClients/ getClientFactor()
+
1) .
The target (an estimate of the perfect value) is 1 scaled down by
getScale()
.
The shape factor is the result of calling bandwidth(String)
.
Ideally, the target should be higher than and very close to 1.0; the
value should be slightly greater than the target;
If the values are inappropriate, you can adjust them by changing the time
to travel setting, the scale setting, the client factor setting, or the
bandwidth value.
If the resulting fitness values are too low, the population will suffer.
The fitness calculated and returned will be:
bandwidth(String)
.
calculateFitness
in class Fitness_
travelTime
- radius
- traitId
- factorId
-
calculateFitness(double, double, String, String)
with
travelTime/radius/pi/adjustment for the first parameter.
FitnessException
protected double scaleFactor(java.lang.String key)
scaleFactor
in class Fitness_
key
- the key (identifier) of the ecoFactor
Fitness_.scaleFactor(String)
protected double scaleTrait(java.lang.String key)
scaleTrait
in class Fitness_
key
- the key (identifier) of the trait
Fitness_.scaleTrait(java.lang.String)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |