ECF 1.5
IntGenotypeCrxAverage.cpp
1#include <ecf/ECF.h>
2#include <ecf/ECF_base.h>
3#include <cmath>
4#include <sstream>
5#include "IntGenotype.h"
6
7namespace IntGenotype
8{
9
10 bool IntGenotypeCrxAverage::mate(GenotypeP gen1, GenotypeP gen2, GenotypeP child) {
11
12 IntGenotype* p1 = (IntGenotype*)(gen1.get());
13 IntGenotype* p2 = (IntGenotype*)(gen2.get());
14 IntGenotype* ch = (IntGenotype*)(child.get());
15
16 //uint prva = (int) p1->getUBound();
17 //uint druga = (int) p2->getUBound();
18 //
19 //for (uint i = 0; i < p1->intValues.size(); i++) {
20 // if (p1->intValues[i] < prva)
21 // prva = p1->intValues[i];
22 // if (p2->intValues[i] < druga)
23 // druga = p2->intValues[i];
24 //}
25
26 //for (uint i = 0; i < p1->intValues.size(); i++) {
27 // p1->intValues[i] = p1->intValues[i] - prva;
28 // p2->intValues[i] = p2->intValues[i] - druga;
29 //}
30
31 for (uint i = 0; i < p1->intValues.size(); i++) {
32 ch->intValues[i] = (int) (0.5 * (p1->intValues[i]) + 0.5 * (p2->intValues[i]));
33 }
34
35
36 return true;
37 }
38
39}
bool mate(GenotypeP gen1, GenotypeP gen2, GenotypeP child)