-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
321 lines (290 loc) · 8.21 KB
/
main.cpp
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
// ***************************************
// Worm Chemotaxis
// ***************************************
#include "WormAgent.h"
#include <sstream>
//#define chem_index
//#define trajectories
#define chem_index_robust
// Global constants
// Global variables
int VectSize = 25;
// ------------------------------------
// Behavioral Analysis
// ------------------------------------
void ChemIndex()
{
ofstream ExampleFile;
double t;
long IDUM=time(0);
int repetitions;
RandomState rs;
rs.SetRandomSeed(IDUM);
ExampleFile.open("/Users/Maria/Desktop/experience_dependent_c_elegans/CI_breed100.txt");
TVector<double> phenotype;
phenotype.SetBounds(1, VectSize);
phenotype(1) = 825; //alpha
phenotype(2) = 300.0; // K_hill
phenotype(3) = 50.0; // delta
phenotype(4) = 0.12; //delta_PKG
phenotype(5) = 0.12; // gamma
phenotype(6) = 1.0; // beta
phenotype(7) = 1.0; // delta_ca
phenotype(8) = 2.0; // b
phenotype(9) = 0.7; // beta_DAG
phenotype(10) = 0.001; // delta_DAG
phenotype(11) = 1.39978563772776 - 0.05466237942122176; // alfa_glu
phenotype(12) = 1.0; // alfa_delta
phenotype(13) = 0.0; // theta
phenotype(14) = 0.1; // tau
phenotype(15) = 0.2; // inhWeight
phenotype(16) = 92.0; // b_inh
phenotype(17) = -5.0; // theta_inh
phenotype(18) = 1.0; // excWeight
phenotype(19) = 27.0; // b_exc
phenotype(20) = -40.0; // theta_exc
phenotype(21) = 0.03; // omega_low
phenotype(22) = 50.3; // omega_high
phenotype(23) = 0.0993; // V_low
phenotype(24) = 0.05466237942122176; // alpha_glu_low
phenotype(25) = 100; // C_breed
WormAgent Worm(VectSize);
Worm.SetParameters(phenotype);
for (repetitions = 1; repetitions <= 600; repetitions++)
{
Worm.ResetAgentsBody(rs); //pos inicial (0,0) y condiciones iniciales
#ifdef GRAD_STEP
Worm.InitialiseSensorHistory();
#endif
//Worm.UpdateChemCon(rs);
//t=0;
for (t = StepSize; t < Preexposure; t += StepSize)
{
Worm.UpdateChemConstante(rs);
Worm.UpdateSensors(StepSize);
Worm.Step(StepSize, rs, t);
}
Worm.SetPositionX(0.0);
Worm.SetPositionY(0.0);
//Worm.PrintDetail(ExampleFile, t);
for (t = Preexposure; t <= (Preexposure + RunDuration); t += StepSize)
{
Worm.UpdateChemCon(rs);
Worm.UpdateSensors(StepSize);
Worm.Step(StepSize, rs,t);
}
Worm.PrintDetail(ExampleFile, t);
cout << repetitions << " " << endl;
}
ExampleFile.close();
}
void ExampleRun()
{
ofstream ExampleFile;
double t;
long IDUM=time(0);
int repetitions;
RandomState rs;
rs.SetRandomSeed(IDUM);
ExampleFile.open("/Users/Maria/Desktop/experience_dependent_c_elegans/example.txt");
TVector<double> phenotype;
phenotype.SetBounds(1, VectSize);
phenotype(1) = 825; //alpha
phenotype(2) = 300.0; // K_hill
phenotype(3) = 50.0; // delta
phenotype(4) = 0.12; //delta_PKG
phenotype(5) = 0.12; // gamma
phenotype(6) = 1.0; // beta
phenotype(7) = 1.0; // delta_ca
phenotype(8) = 2.0; // b
phenotype(9) = 0.7; // beta_DAG
phenotype(10) = 0.001; // delta_DAG
phenotype(11) = 1.39978563772776 - 0.05466237942122176; // alfa_glu
phenotype(12) = 1.0; // alfa_delta
phenotype(13) = 0.0; // theta
phenotype(14) = 0.1; // tau
phenotype(15) = 0.2; // inhWeight
phenotype(16) = 92.0; // b_inh
phenotype(17) = -5.0; // theta_inh
phenotype(18) = 1.0; // excWeight
phenotype(19) = 27.0; // b_exc
phenotype(20) = -40.0; // theta_exc
phenotype(21) = 0.03; // omega_low
phenotype(22) = 50.3; // omega_high
phenotype(23) = 0.0993; // V_low
phenotype(24) = 0.05466237942122176; // alpha_glu_low
phenotype(25) = 50; // C_breed
WormAgent Worm(VectSize);
Worm.SetParameters(phenotype);
for (repetitions = 1; repetitions <= 10; repetitions++)
{
Worm.ResetAgentsBody(rs); //pos inicial (0,0) y condiciones iniciales
#ifdef GRAD_STEP
Worm.InitialiseSensorHistory();
#endif
for (t = StepSize; t < Preexposure; t += StepSize)
{
Worm.UpdateChemConstante(rs);
Worm.UpdateSensors(StepSize);
Worm.Step(StepSize, rs, t);
}
Worm.SetPositionX(0.0);
Worm.SetPositionY(0.0);
Worm.PrintDetail(ExampleFile, t);
for (t = Preexposure; t <= (Preexposure + RunDuration); t += StepSize)
{
Worm.UpdateChemCon(rs);
Worm.UpdateSensors(StepSize);
Worm.Step(StepSize, rs,t);
Worm.PrintDetail(ExampleFile, t);
}
}
ExampleFile.close();
}
// ------------------------------------
// robustness analysis
// ------------------------------------
void ChemIndex_robustness()
{
//ofstream ExampleFile;
double t;
long IDUM=time(0);
int repetitions;
RandomState rs;
rs.SetRandomSeed(IDUM);
//ExampleFile.open("/Users/Maria/Desktop/experience_dependent_c_elegans/CI_breed100.txt");
TVector<double> phenotype;
phenotype.SetBounds(1, VectSize);
phenotype(1) = 825; //alpha
phenotype(2) = 300.0; // K_hill
phenotype(3) = 50.0; // delta
phenotype(4) = 0.12; //delta_PKG
phenotype(5) = 0.12; // gamma
phenotype(6) = 1.0; // beta
phenotype(7) = 1.0; // delta_ca
phenotype(8) = 2.0; // b
phenotype(9) = 0.7; // beta_DAG
phenotype(10) = 0.001; // delta_DAG
phenotype(11) = 1.39978563772776 - 0.05466237942122176; // alfa_glu
phenotype(12) = 1.0; // alfa_delta
phenotype(13) = 0.0; // theta
phenotype(14) = 0.1; // tau
phenotype(15) = 0.2; // inhWeight
phenotype(16) = 92.0; // b_inh
phenotype(17) = -5.0; // theta_inh
phenotype(18) = 1.0; // excWeight
phenotype(19) = 27.0; // b_exc
phenotype(20) = -40.0; // theta_exc
phenotype(21) = 0.03; // omega_low
phenotype(22) = 50.3; // omega_high
phenotype(23) = 0.0993; // V_low
phenotype(24) = 0.05466237942122176; // alpha_glu_low
phenotype(25) = 50; // C_breed
int parameter;
for (parameter = 1; parameter < VectSize; parameter++)
//for (parameter = 1; parameter < 3; parameter++)
{
//int chequeo = 1;
//if (parameter >1)
//{
// chequeo = parameter-1;
//}
//cout << phenotype(chequeo) << endl;
double old_value = phenotype(parameter);
phenotype(parameter) = phenotype(parameter)*0.8;
//phenotype(parameter) = phenotype(parameter)*1;
double CI_HIGH, CI_LOW, CI_START;
CI_HIGH = 0.0;
CI_LOW = 0.0;
CI_START = 0.0;
WormAgent Worm(VectSize);
Worm.SetParameters(phenotype);
TVector<double> cis;
cis.SetBounds(1, 6);
int count_cis = 1;
for (repetitions = 1; repetitions <= 600; repetitions++)
{
Worm.ResetAgentsBody(rs); //pos inicial (0,0) y condiciones iniciales
#ifdef GRAD_STEP
Worm.InitialiseSensorHistory();
#endif
//Worm.UpdateChemCon(rs);
//t=0;
for (t = StepSize; t < Preexposure; t += StepSize)
{
Worm.UpdateChemConstante(rs);
Worm.UpdateSensors(StepSize);
Worm.Step(StepSize, rs, t);
}
Worm.SetPositionX(0.0);
Worm.SetPositionY(0.0);
//Worm.PrintDetail(ExampleFile, t);
for (t = Preexposure; t <= (Preexposure + RunDuration); t += StepSize)
{
Worm.UpdateChemCon(rs);
Worm.UpdateSensors(StepSize);
Worm.Step(StepSize, rs,t);
}
//Worm.PrintDetail(ExampleFile, t);
//cout << repetitions << " " << endl;
if ( (pow(Worm.PositionX(),2) + pow(Worm.PositionY(),2)) < 1.0){
CI_START+=1;
}
else if ( ( pow((Worm.PositionX()-3.0),2) + pow(Worm.PositionY(),2) ) < pow(1.05,2) ){
CI_HIGH+=1;
}
else if ( ( pow((Worm.PositionX()+3.0),2) + pow(Worm.PositionY(),2) ) < pow(1.05,2) ) {
CI_LOW+=1;
}
if (repetitions%100 == 0){
double chem_index_final;
if (CI_START<100.0)
{
chem_index_final = (CI_HIGH-CI_LOW)/(100.0-CI_START);
}
else
{
chem_index_final = 0;
}
cis(count_cis) = chem_index_final;
count_cis = count_cis +1;
CI_HIGH = 0.0;
CI_LOW = 0.0;
CI_START = 0.0;
}
}
cout << old_value << " " << phenotype(parameter) << " ";
phenotype(parameter) = old_value;
//cout << phenotype(parameter) << endl;
for (int idx=1; idx<=6;idx++)
{
cout << cis(idx) << " ";
}
cout << endl;
}
//ExampleFile.close();
}
// ------------------------------------
// The main program
// ------------------------------------
#ifdef chem_index_robust
int main (int argc, const char* argv[])
{
ChemIndex_robustness();
return 0;
}
#endif
#ifdef chem_index
int main (int argc, const char* argv[])
{
ChemIndex();
return 0;
}
#endif
#ifdef trajectories
int main (int argc, const char* argv[])
{
ExampleRun();
return 0;
}
#endif