-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCellA.cpp
More file actions
73 lines (56 loc) · 1.35 KB
/
CellA.cpp
File metadata and controls
73 lines (56 loc) · 1.35 KB
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
//==============================
// INCLUDES
//==============================
#include "CellA.h"
//==============================
// DEFINITION STATIC ATTRIBUTES
//==============================
//==============================
// CONSTRUCTORS
//==============================
CellA::CellA():Cell()
{
this->compute_fitness();
geno_ = GenA;
}
CellA::CellA(float cAi, float cBi, float cCi):Cell(cAi, cBi, cCi)
{
this->compute_fitness();
geno_ = GenA;
}
//==============================
// DESTRUCTOR
//==============================
CellA::~CellA(){}
//==============================
// PUBLIC METHODS
//==============================
float* CellA::metabolism(float s_cA, float s_cB, float s_cC)
/*
Set the metalism of the cell
*/
{
//s_cA stands for Spot cA
//ms_cA stands for Modified Spot cA
float ms_cA = 0, ms_cB = 0, ms_cC = 0;
//Diffeq
cA_ += 0.1*(s_cA * rAA_); //Absorb
cB_ += 0.1*(cA_ * rAB_); //Transform
cA_ += 0.1*(-cA_ * rAB_); //Remove used product
ms_cA = -0.1*(rAA_ * s_cA);
//prepare the returned array
float* ms_c = new float[3];
ms_c[0] = ms_cA;
ms_c[1] = ms_cB;
ms_c[2] = ms_cC;
this->compute_fitness();
//WARNING : will need to free space in Environment calling metabolism !!
return ms_c;
}
void CellA::compute_fitness()
/*
Update fitness
*/
{
fit_ = (cB_ > min_fit_) ? cB_ : 0;
}