-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
98 lines (78 loc) · 2.97 KB
/
main.py
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
from numpy import average
from MTurk.SimMT import SimMT
from MTurk.RealMT import RealMT
from solve import solve
##########################################
# Configuration
##########################################
#Number of Tasks
numberOfProblems = 150
#What's your task called?
nameOfTask = "Named Entity Recognition"
#Toggle debugging output
debug = True
#Do you want to relearn the POMDP after every task? If yes, set to False.
fastLearning = False
#How many seconds do you want to spend learning POMDPs if not fastLearning?
timeLearning = 300
#How many seconds do you want to give workers to complete one task?
#For some reason, Amazon oddly starts the clock at 90 seconds, so if you want
#to give them 30 seconds, enter 120 seconds.
taskDuration = 150
f = open('simulation.info','r')
#How many worker pools would you like to have available?
#Typical value is 2, where the worker pools correspond to unstarred, and starred.
workerPools = int(f.readline().rstrip())
#value of a correct answer
VALUE = int(f.readline().rstrip())
#Payout per HIT, for 1each worker pool.
PRICE = [float(x) for x in f.readline().rstrip().split(",")]
#Prior on Gamma Averages for each worker pool.
GAMMA = [float(x) for x in f.readline().rstrip().split(",")]
SCALEFACTOR = int(f.readline().rstrip())
OFFSET = int(f.readline().rstrip())
f.close()
#Must be an absolute path to where ZMDP is
ZMDPPATH = '/Users/shreyarajpal/Desktop/MausamOld/AgentHuntUpdatedReleaseLiveExperiments/ModelLearning/zmdp-1.1.7/bin/darwin14/zmdp'
#Must be absolute path to where EM is
EMPATH = '/Users/shreyarajpal/Desktop/MausamOld/AgentHuntUpdatedReleaseLiveExperiments/EM/em'
#Address of your web server
URL = "http://<yourserverhere>/AgentHuntRelease1.0/client/client.php"
#AWS Access Key ID
AWSAKID = '<YOURAWSACCESSKEYIDHERE>'
#AWS Secret Access Key
AWSSAK = '<YOURAWSSECRETACCESSKEYHERE>'
#Sandbox
SANDBOX = True
#Simulation
SIMULATION = True
############################################
#End Configuration
############################################
numStates = 23 #(11 * 11 * 2 + 1 for terminal state)
if not SIMULATION:
mt = RealMT(numberOfProblems, AWSAKID, AWSSAK, sandbox = SANDBOX)
else:
mt = SimMT(numberOfProblems,workerPools,OFFSET)
(costs, answers) = solve(mt,
numStates,
numberOfProblems,
workerPools,
nameOfTask,
VALUE,
PRICE,
GAMMA,
SCALEFACTOR,
ZMDPPATH,
URL,
EMPATH,
fastLearning,
timeLearning,
taskDuration,
debug)
print "Average Cost:"
print average(costs)
print "Answers:"
print answers
for problemNumber in xrange(numberOfProblems):
print "The answer to problem %d is %d and it cost %f." % (problemNumber,answers[problemNumber],costs[problemNumber])