-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaps_runner_s_curve.cpp
121 lines (84 loc) · 2.63 KB
/
aps_runner_s_curve.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
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "aps.h"
int main(int iargc, char *argv[]){
//d=8 -> delta_chisq=15.5
//d=5 -> delta_chisq=11
int seed=99;
int dim,ncenters;
int nsamples=10000,n_found=3;
dim=22;
ncenters=3;
if(iargc>1)seed=atoi(argv[1]);
if(iargc>2)ncenters=atoi(argv[2]);
if(iargc>3)dim=atoi(argv[3]);
if(iargc>4){
nsamples=atoi(argv[4]);
}
if(iargc>5)n_found=atoi(argv[5]);
if(seed<0){
seed=int(time(NULL));
if(seed>10000)seed=seed%10000;
}
char timingname[letters],outname[letters];
//what is the name of the file where APS will store its timing information
sprintf(timingname,"timingFiles/s_curve_d%d_c%d_s%d_timing.sav",dim,ncenters,seed);
//what is the name of the file where APS will output the points it sampled
sprintf(outname,"outputFiles/s_curve_d%d_c%d_s%d_output.sav",dim,ncenters,seed);
printf("seed %d\n",seed);
//declare the covariogram for APS's Gaussian process
matern_covariance cv;
//declare the chisquared function APS will be searching
//ellipses_integrable chisq(dim,ncenters);
s_curve chisq(dim,ncenters);
//declare APS
//the '20' below is the number of nearest neighbors to use when seeding the
//Gaussian process
//
//the '11.0' is the \Delta\chi^2 corresponding to a 95% confidence limit
//on a 5-dimensional parameter space
aps aps_test(dim,20,33.9,seed);
//pass chisq to the aps object
aps_test.assign_chisquared(&chisq);
//pass the covariogram to the aps object
aps_test.assign_covariogram(&cv);
//how often will APS stop and write its output
aps_test.set_write_every(3000);
//set the G parameter from equation (4) in the paper
aps_test.set_grat(1.0);
//set the maximum and minimum values in parameter space
array_1d<double> max,min;
max.set_name("driver_max");
min.set_name("driver_min");
max.set_dim(dim);
min.set_dim(dim);
int i,j;
for(i=0;i<dim;i++){
min.set(i,-200.0);
max.set(i,200.0);
}
aps_test.set_timingname(timingname);
aps_test.set_outname(outname);
//initialize aps with 1000 random samples
printf("time to initialize\n");
aps_test.initialize(1000,min,max);
double chival,chivaltest,err;
i=-1;
//search parameter space until the
//chisquared function has been called
//10000 times
//while(aps_test.get_called()<nsamples || aps_test.get_n_active_nodes()>0){
while(aps_test.get_called()<nsamples){
aps_test.search();
}
aps_test.write_pts();
array_1d<double> minpt;
//what is the point in parameter space corresponding to the
//minimum chisquared
aps_test.get_minpt(minpt);
printf("chimin %e\n",aps_test.get_chimin());
printf("ct_aps %d ct_simplex %d total %d\n",
aps_test.get_ct_aps(),aps_test.get_ct_simplex(),
aps_test.get_called());
}