-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
58 lines (45 loc) · 1.69 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
from utils import *
from datetime import datetime
#Arguments check
(appId,DLimit,K,tables,labellingsP,timestamp) = checkArgs()
if(timestamp):
print('Starting execution.')
print('Retrieving application information.')
start = datetime.now()
(StartingLabelling,DLimit,K)=checkApp(appId,K,DLimit)
if(timestamp):
print('Starting to create labelling probabilities at:'+str(datetime.now()-start)+'\n')
(labellings,Already) = queryLabellings(appId,StartingLabelling,K)
if(timestamp):
if(not Already):
print('Labelling created at: '+str(datetime.now()-start)+'\n')
else:
print('Labelling created before.\n')
print('Search for all eligible partitionings.')
partitionings = queryAllPartitionings(appId,StartingLabelling,DLimit)
if(timestamp):
print(str(len(partitionings))+' partitionings determined at: '+str(datetime.now()-start)+'\n')
print('Determining cost for every partitioning.')
for p in partitionings:
labs = []
parts = []
costs = []
probs =[]
impossible=0.0
for labelling, prob in labellings:
fcs = queryFutureCost(appId,p,labelling,DLimit)
if(fcs is None):
#probability that labelling is not satisfiable
impossible+=prob
continue
for (part,cost) in fcs:
labs.append(labelling)
if(labellingsP):
parts.append(part)
else:
parts.append(Partitioning(part))
costs.append(cost)
probs.append(prob)
(sumProb,expectedCost)=buildResults(labs,parts,costs,probs)
printResults(p,sumProb,expectedCost,tables,labellingsP,timestamp,start)
print('Impossible prob: '+str(impossible))