-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGreedClientSL.java
More file actions
39 lines (29 loc) · 946 Bytes
/
Copy pathGreedClientSL.java
File metadata and controls
39 lines (29 loc) · 946 Bytes
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
public class GreedClient {
public static void main(String[] args) {
System.out.println("Generating the probability array");
double[] p = {.9, .6};
System.out.println("Building the bandit");
GreedyBandit b = new GreedyBandit(p);
UCBPatron u = new UCBPatron(2);
System.out.println("UCBPatron");
System.out.println(u);
System.out.println("Initializing...");
u.init(b);
System.out.println(u);
GreedyPatron g = new GreedyPatron(2, .5);
System.out.println("GreedyPatron");
System.out.println(g);
for (int i = 0; i < 100000; i++) {
int choice = g.chooseArm();
int result = b.playMachine(choice);
g.updateRewards(result);
int choice2 = u.chooseArm();
int result2 = b.playMachine(choice2);
u.update(result2, choice2);
}
System.out.println("RESULTS FOR GreedyPatron");
System.out.println(g);
System.out.println("RESULTS FOR UCBPatron");
System.out.println(u);
}
}