onemax.ez 1.81 KB
Newer Older
moh_lo's avatar
moh_lo committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
/*_________________________________________________________

This C:\WINDOWS\a_onemax\onemax.ez file was automatically created by GUIDE v0.1b

_________________________________________________________*/

\User declarations:
#define SIZE 100      
float pMutPerGene=0.1;

inline void swap(bool& a, bool& b)
  {bool c=a; a=b; b=c;}
\end

\User functions:

\end

\Initialisation function:

\end

\User classes:
GenomeClass
{
  bool x[SIZE]; 
}
\end

\GenomeClass::initialiser:
  for (int i=0;i<SIZE;i++) Genome.x[i]=tossCoin(.5)?1:0;
\end

\GenomeClass::crossover:
  int CrossoverPosition=random(0,SIZE);

  for(int i=0;i<CrossoverPosition+1;i++)
    swap(child1.x[i],child2.x[i]);
\end

\GenomeClass::mutator:
  int NbMut=0;
  for (int i=0;i<SIZE;i++)
    if (tossCoin(pMutPerGene)){
       NbMut++;
       Genome.x[i]=Genome.x[i]?0:1;
    }
  return NbMut;
\end

\GenomeClass::evaluator:
  int Score=0;         
  for (int i=0; i<SIZE;i++)
    Score+=(int)Genome.x[i];
  return Score;
\end

\GenomeClass::display:

\end

\At each new generation:

\end

\Default run parameters:

// Variation operators:
  Operators are called: Sequentially
  Mutation probability: 0.3
  Crossover probability: 0.8

// Evolution Engine:
  Evaluator goal: Minimise
  Number of generations: 2000
  Evolutionary engine: Custom
  Population size: 100
  Elite: 10
  Fertility: 80
  Genitors selector: Tournament 2
  Selected genitors: 100
  Offspring size: 100
  Reduce parents: Tournament 2
  Surviving parents: 20
  Reduce offspring: Tournament 2
  Surviving offspring: 80
  Final reduce: Tournament 2
  Elitism: Strong

// Island model:
  Number of islands: 5
  Emigration policy: Move
  Migrants selector: Tournament 2
  Migrants destination: Neighbours
  Migration frequency: 0.2
  Number of emigrants: 3
  Immigration replacement: Tournament 2
  Immigration policy: Add
\end