00001 #ifndef GLMUTATORSHUFFLING_H_ 00002 #define GLMUTATORSHUFFLING_H_ 00003 #include <iostream> 00004 #include "GLBaseMutator.h" 00005 #include "GLBaseParameters.h" 00006 00011 class GLMutatorShuffling : public GLBaseMutator 00012 { 00013 public: 00014 class TParameters; 00021 GLMutatorShuffling(double mutation_rate, 00022 const GLMutatorShuffling::TParameters * const parameters); 00023 00028 GLMutatorShuffling(const GLMutatorShuffling& source): 00029 GLBaseMutator(source) 00030 {m_parameters = source.m_parameters;} 00031 00035 virtual ~GLMutatorShuffling() {}; 00036 00042 virtual GLBaseMutator* copy() const 00043 { return new GLMutatorShuffling(*this); } 00044 00053 virtual bool mutateOrganism(GLBaseOrganism* organism); 00054 00055 public: 00060 struct TParameters:public GLBaseParameters 00061 { 00077 TParameters(int min_genes_to_shuffle = -1, 00078 int max_genes_to_shuffle = -1, 00079 bool uniform = false) 00080 { 00081 t_min_genes_to_shuffle = min_genes_to_shuffle; 00082 t_max_genes_to_shuffle = max_genes_to_shuffle; 00083 t_uniform = uniform; 00084 //correct parameters if necessary 00085 if ((t_max_genes_to_shuffle == 0) || (t_max_genes_to_shuffle == 1)) 00086 { 00087 t_max_genes_to_shuffle = 2; 00088 } 00089 if ((t_min_genes_to_shuffle == 0) || (t_min_genes_to_shuffle == 1)) 00090 { 00091 t_min_genes_to_shuffle = 2; 00092 } 00093 if ((t_min_genes_to_shuffle > 0) && (t_max_genes_to_shuffle > 0) && 00094 (t_min_genes_to_shuffle > t_max_genes_to_shuffle)) 00095 { 00096 t_min_genes_to_shuffle = t_max_genes_to_shuffle; 00097 } 00098 }//constructor 00099 00102 TParameters(const TParameters *source) 00103 { 00104 t_min_genes_to_shuffle = source->t_min_genes_to_shuffle; 00105 t_max_genes_to_shuffle = source->t_max_genes_to_shuffle; 00106 t_uniform = source->t_uniform; 00107 }//constructor 00108 00113 virtual GLBaseParameters* copy() const 00114 { return new TParameters(this); } 00115 00118 int t_min_genes_to_shuffle; 00120 int t_max_genes_to_shuffle; 00125 bool t_uniform; 00126 }; 00127 private: 00128 TParameters m_parameters; 00129 }; 00130 00131 #endif /*GLMUTATORSHUFFLING_H_*/