OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
OneBitMutation.h
Go to the documentation of this file.
1 #include "boost/smart_ptr.hpp"
2 #include "Util/CmdArguments.h"
3 
5 template <class T> struct OneBitMutation
6 {
7  void mutate(boost::shared_ptr<T> ind, CmdArguments_t args) {
8 
9  int range = ind->genes_m.size();
10  int position = static_cast<int>((rand() / (RAND_MAX + 1.0)) * range);
11  ind->new_gene(position);
12  }
13 };
boost::shared_ptr< CmdArguments > CmdArguments_t
Definition: CmdArguments.h:169
void mutate(boost::shared_ptr< T > ind, CmdArguments_t args)
Definition: OneBitMutation.h:7
Mutate exactly one gene of an individual.
Definition: OneBitMutation.h:5