-
Notifications
You must be signed in to change notification settings - Fork 0
/
distributeART.cpp
86 lines (71 loc) · 2.59 KB
/
distributeART.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
#include <iostream>
#include <vector>
#include <time.h>
#include <eigen3/Eigen/Dense>
#include "csvUtil.h"
#include "globals.h"
//
int art_cols = 5;
int art_rows = 410;
Eigen::MatrixXd art_cov = readCSV("art_cov.csv", art_cols, art_rows);
double propART[nCD4][nArt];
void distributeART(int time_index){
Eigen::VectorXd art_cov_row = art_cov.row(time_index);
for(int ii=0; ii<nCD4; ii++){
if (ii==0){
propART[ii][0] = 1;
propART[ii][1] = 0;
}
else {
propART[ii][0] = 1 - art_cov_row(ii-1);
propART[ii][1] = art_cov_row(ii-1);
}
}
// sum over pop
// order is important!
// tricky handling the summation
int hiv = 1; // we only care about hiv compartments
double artSum;
for (int age : ageBins){
for (int male : maleBins){
for (int risk : riskBins){
for (int cd4 : cd4Bins){
for (int vl : vlBins){
for (int circ : circBins){
for (int prep : prepBins){
for (int condom : condomBins){
artSum = 0;
// compile sum over art for each unique combo of other bins
//make sure you're summing index is always last
// in this case it happens to be by default
for (int art : artBins){
artSum += popCount[hiv][age][male][risk][cd4][vl][circ][prep][condom][art];
}
// now apply the sum
for (int art : artBins){
popCount[hiv][age][male][risk][cd4][vl][circ][prep][condom][art] = artSum * propART[cd4][art];
}
}
}
}
}
}
}
}
}
}
// clang++ -O3 -std=c++11 -g distributeArt.cpp csvUtil.cpp globals.cpp
// int main(){
// int timeIndex = 0;
// clock_t tStart;
// clock_t tEnd;
// initPop("pop_0.out");
// tStart = clock();
// distributeART(timeIndex); //0 based
// tEnd = clock();
// std::cout << "time took: " << (double)(tEnd - tStart)/CLOCKS_PER_SEC << std::endl;
// std::stringstream filename;
// filename << "distributeART_" << timeIndex << ".cout";
// writePop(filename.str(), timeIndex);
// return 0;
// }