Evaluations
ISolutionEvaluator
ISolutionEvaluator<S extends ISolution>
is a strategy interface for evaluating solutions. It is parameterized by the type of solutions it supports.
When given a solution, evaluators should return a double value. This value is the fitness of the solution in the context of the problem being solved.
Minimalization
Generally, evolutionary algorithms aim to maximize the fitness function. If you are given with a cost function you need to minimize instead, you will need to transform it somehow into a fitness function. It may be usually done by negating the cost function.
Evaluators may or may not be idempotent - they may return the same value when asked about an identical solution (with regard to representation), or they may return a different value on each consecutive evaluation.
If you want to cache results for efficiency, decorate your evaluator with a CachingSolutionEvaluator<S>
.
CachingSolutionEvaluator
CachingSolutionEvaluator<S extends ISolution>
allows to decorate other evaluators with caching behavior. Remember however that caching makes no sense with non-idempotent evaluators.
Caching
Reminder for developers: When implementing such a cache, use representations instead of solutions as keys. Also, remember to wrap them into weak references.