From 40ee7ad5aeadeb9823e1cd6e1218a1999c608a65 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 9 Jul 2012 08:39:37 -0600 Subject: New libgenetic. Genetic algorithms, only good. --- src/operatorbasic.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/operatorbasic.h (limited to 'src/operatorbasic.h') diff --git a/src/operatorbasic.h b/src/operatorbasic.h new file mode 100644 index 0000000..2eaf198 --- /dev/null +++ b/src/operatorbasic.h @@ -0,0 +1,32 @@ +#ifndef GENETIC_OPERATOR_BASIC_H +#define GENETIC_OPERATOR_BASIC_H + +#include "genetic/operator.h" + +namespace Genetic +{ + /** + * Very simple genetic operator that covers all the basics. It will do + * single cut Phenotype splicing between two parents, and random mutation + * on the child. All work is based on a progenitor Phenotype, which is the + * template for creating new, random Phenotypes. OperatorBasic takes + * ownership of the progenitor and will delete it when OperatorBasic is + * destroyed. + */ + class OperatorBasic : public Operator + { + public: + OperatorBasic( Phenotype *pProgenitor, float fMutationRate ); + virtual ~OperatorBasic(); + + virtual Phenotype *random(); + virtual int parentCount() { return 2; } + virtual Phenotype *mate( const PhenotypeList &lParents ); + + private: + Phenotype *pProgenitor; + float fMutationRate; + }; +}; + +#endif -- cgit v1.2.3