-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtest_main.R
164 lines (143 loc) · 5.11 KB
/
test_main.R
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
#
# test_main.R Test the main function
#
rm(list = ls())
options(warn = 2)
source('main.R')
SHOW_CLIMATE_PLOTS <- TRUE
TRACE_CLIMATE_MODEL <- FALSE
STAN_REFRESH <- 0
PARALLEL_STAN <- FALSE
WHICH_MODEL <- 'ar1'
max_p <- 1
max_q <- 0
debug <- TRUE
if(!debug){
future <- FALSE
adaptation <- TRUE
full_history <- FALSE
load_previous <- TRUE
if (future) {
burn.in <- 135
n.seq <- 14
horizon <- 6
} else {
burn.in = 51
n.seq = 14
horizon = 6
#nyears = burn.in + n.seq * horizon, #135,
}
ptm0 <- proc.time()
x <- main(parameters = c(runif(3, min = 0.0001, max = 0.9999), # seg, ideo, risk.tak
0, # true model: 0 = slow.tsi, 1 = log.co2
runif(2, min = 0.0001, max = 0.9999)), # n.edge and n.traders
out = "fraction_converge",
safeNprint=TRUE,
iterations = 1,
burn.in = burn.in,
n.seq = n.seq,
horizon = horizon,
nyears = burn.in + n.seq * horizon,
record = TRUE,
full_history = full_history,
adaptation = adaptation,
visu = TRUE,
# saving and loading climate data
load_previous = load_previous,
saving = TRUE
)
ptm1 <- proc.time()
cat("First process finished in", paste_with_names(prettyNum(head(ptm1 - ptm0,3), big.mark=',')), 'seconds')
y <- main(parameters = c(runif(3, min = 0.0001, max = 0.9999), # seg, ideo, risk.tak
1, # true model: 0 = slow.tsi, 1 = log.co2
runif(2, min = 0.0001, max = 0.9999)), # n.edge and n.traders
out = "fraction_converge",
safeNprint=TRUE,
iterations = 1,
burn.in = burn.in,
n.seq = n.seq,
horizon = horizon,
nyears = burn.in + n.seq * horizon,
record = TRUE,
full_history = full_history,
adaptation = adaptation,
visu = TRUE,
# saving and loading climate data
load_previous = load_previous,
saving = TRUE
)
ptm2 <- proc.time()
cat("Second process finished in", paste_with_names(prettyNum(head(ptm2 - ptm1,3), big.mark=',')), 'seconds')
} else{
##############################################################################
## Debug
##############################################################################
future <- TRUE
adaptation <- FALSE
load_previous <- TRUE
saving <- TRUE
full_history <- TRUE
if (future) {
burn.in <- 135
n.seq <- 14
horizon <- 6
} else {
burn.in = 51
n.seq = 14
horizon = 6
#nyears = burn.in + n.seq * horizon, #135,
}
ptm0 <- proc.time()
iteration <- 1
id <- c()
true.model <- c()
mean.true <- c()
mean.false <- c()
for (iteration in seq(iteration)){
x <- main(parameters = c(runif(3, min = 0.0001, max = 0.9999), # seg, ideo, risk.tak
1, # true model: 0 = slow.tsi, 1 = log.co2
runif(2, min = 0.0001, max = 0.9999)), # n.edge and n.traders
out = "fraction_converge",
safeNprint=FALSE,
iterations = 1,
burn.in = burn.in,
n.seq = n.seq,
horizon = horizon,
nyears = burn.in + n.seq * horizon,
record = TRUE,
full_history = full_history,
adaptation = adaptation,
# saving and loading climate data
load_previous = load_previous,
saving = saving,
perfect = TRUE
)
id <- append(id,iteration)
true.model <- append(true.model, x[[length(x)]]$true.model)
mean.true <- append(mean.true, mean(V(x[[length(x)]])$money[V(x[[length(x)]])$approx == x[[length(x)]]$true.model]))
mean.false <- append(mean.false, mean(V(x[[length(x)]])$money[V(x[[length(x)]])$approx != x[[length(x)]]$true.model]))
x <- main(parameters = c(runif(3, min = 0.0001, max = 0.9999), # seg, ideo, risk.tak
0, # true model: 0 = slow.tsi, 1 = log.co2
runif(2, min = 0.0001, max = 0.9999)), # n.edge and n.traders
out = "fraction_converge",
safeNprint=FALSE,
iterations = 1,
burn.in = burn.in,
n.seq = n.seq,
horizon = horizon,
nyears = burn.in + n.seq * horizon,
record = TRUE,
full_history = full_history,
adaptation = adaptation,
# saving and loading climate data
load_previous = load_previous,
saving = saving,
perfect = TRUE
)
id <- append(id,iteration)
true.model <- append(true.model, x[[length(x)]]$true.model)
mean.true <- append(mean.true, mean(V(x[[length(x)]])$money[V(x[[length(x)]])$approx == x[[length(x)]]$true.model]))
mean.false <- append(mean.false, mean(V(x[[length(x)]])$money[V(x[[length(x)]])$approx != x[[length(x)]]$true.model]))
}
money.data <- data.frame(id,true.model,mean.true, mean.false)
}