A generational evolution experiment has to inherit from Teem::Experiment because it is an experiment and from Teem::Evaluable because it can evaluate genomes and return a fitness. You can thus create one by copying and renaming the NullExperiment.h/.cpp files:
NullExperiment.h:
#ifndef __NULL_EXPERIMENT_H #define __NULL_EXPERIMENT_H #include "../ga/Evolution.h" #include "../ga/GenerationalEvolution.h" #include "Experiment.h" namespace Teem { class NullExperiment: public Experiment, public Evaluable { public: virtual void setupDecoders(GenotypeDecoders &decoders); virtual void compute(GenotypeDecoders &decoders, GenerationalPopulation &individuals, unsigned gen, unsigned ind, EvaluationMode mode); }; } #endif
NullExperiment.cpp:
#include "NullExperiment.h" namespace Teem { // make sure the experiment will be available in experiment list REGISTER_EXPERIMENT(NullExperiment); void NullExperiment::setupDecoders(GenotypeDecoders &decoders) { // Here come the code to setp the GenotypeDecoders, like setting the number of I/O, etc... } void NullExperiment::compute(GenotypeDecoders &decoders, GenerationalPopulation &individuals, unsigned gen, unsigned ind, EvaluationMode mode) { // Here come the code of evaluating the individuals, whose genomes are decoded using decoders. // Fitness has to be returned in individuals for (size_t i=0; i<individuals.size(); i++) { individuals[i].fitness = 0; } } }
You then have to change the class name and the content of the macro REGISTER_EXPERIMENT(your_experiment_class_name) so that your experiment will appear in the list of available experiments (the list can be displayed by teem -l).