-
Notifications
You must be signed in to change notification settings - Fork 0
/
GridSearch.java
49 lines (41 loc) · 1.27 KB
/
GridSearch.java
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
public class GridSearch extends Optimizer {
double[] min;
double[] max;
double[] step;
double[] cur;
// Checks every single spot possible. Very accurate but very slow.
GridSearch(double[] pmin, double[] pmax, double[] pstep) {
min = pmin;
max = pmax;
step = pstep;
cur = pmin;
}
// Not correctly coded, pseudocode below. Needs implementation and testing.
@Override
double iterate() {
double besterr = super.obj.evaluate(cur);
double[] bestVec = Vec.copy(cur);
// If cur is the best vector yet found, remember it.
for(int i = 0; i < cur.length; i++) {
cur[i] += step[i];
if(step[i] > max[i]) {
step[i] = min[i];
}
else {
break;
}
}
return besterr;
/*
for(double y = ymin; y < ymax; y += ystep) {
for(double x = xmin; x < xmax; x+= xstep) {
double err = measure_SSE();
if(err < besterr) {
besterr = err;
bestVec = vec; // Basically x and y into a vector
}
}
}
*/
}
}