-
Notifications
You must be signed in to change notification settings - Fork 0
/
experiment.c
65 lines (57 loc) · 1.59 KB
/
experiment.c
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
#include "experiment.h"
#include <stdlib.h>
typedef struct ThreadInfo {
int rank;
int start;
int end;
int samples;
int max_timesteps;
experiment* e;
}threadInfo;
experiment experiment_create (int lines, int columns, int max_timesteps) {
experiment e;
e.r = result_create(max_timesteps);
e.boardps[0] = board_create(lines, columns);
e.boardps[1] = board_create(lines, columns);
return e;
}
void experiment_init (experiment* e, double imune, double infected) {
board_init(e->boardps[0], infected, imune);
// board_zero(e->boardps[1]);
e->imune = imune;
e->infected = infected;
result_zero(&e->r);
}
// void experiment_free (experiment* e) {
// board_free(e->boardps[0]);
// board_free(e->boardps[1]);
// result_free(&e->r);
// free(e);
// }
void experiment_print (experiment e) {
board_print(e.boardps[0]);
printf("Initial imunity: %f\n", e.imune);
printf("Initial infected: %f\n", e.infected);
result_print(e.r);
}
void experiment_reset (experiment* e) {
board_init(e->boardps[0], e->infected, e->imune);
// board_zero(e->boards[1]);
}
// void* experiment_run (void* info) {
// threadInfo* t_info = (threadInfo*) info;
// double peak_infected;
// int i, s ,t;
// board *current_board, *future_board;
// for (i = t_info->start; i < t_info->end; i++) {
// srand(time(NULL));
// experiment_init(t_info->e, t_info->e->imune, t_info->e->infected);
// for (s = 0; s < t_info->samples; s++) {
// peak_infected = 0;
// for (t = 0; t < t_info->max_timesteps; t++) {
// current_board = t_info->e->boardps[t%2];
// future_board = t_info->e->boardps[(t+1)%2];
// }
// }
// }
// }