-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpilot.py
113 lines (68 loc) · 2.69 KB
/
pilot.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
LowerBoundInputs = 1
UpperBoundInputs = 10
LowerBoundGates = 1
UpperBoundGates = 2
GateTypes = [{"LowerBoundPos":0,"UpperBoundPos":2,
"LowerBoundNeg":0,"UpperBoundNeg":0,
"UpperBoundOcc":1},
{"LowerBoundPos":0,"UpperBoundPos":0,
"LowerBoundNeg":0,"UpperBoundNeg":1,
"UpperBoundOcc":2}]
EfficiencyConstraint = False
OptimizationStrategy = 1
BreakSymmetries = True
UniquenessConstraint = True
import classifier
if __name__=="__main__":
if 1:
# creates an image for each answer
FnameCSV = "toy.csv"
print
print "Example for pilot:"
parameters = {
"FnameCSV":FnameCSV,
"LowerBoundInputs":LowerBoundInputs,
"UpperBoundInputs":UpperBoundInputs,
"LowerBoundGates":LowerBoundGates,
"UpperBoundGates":UpperBoundGates,
"GateTypes":GateTypes,
"EfficiencyConstraint":EfficiencyConstraint,
"OptimizationStrategy":OptimizationStrategy,
"BreakSymmetries":BreakSymmetries,
"Silent":True,
"UniquenessConstraint": UniquenessConstraint}
answers = classifier.pilot(parameters)
for i,x in enumerate(answers):
FnamePDF = "toy_%i.pdf"%i
classifier.gateinputs2pdf(FnamePDF, x, Silent=True)
print " created", FnamePDF
print " answers:", len(answers)
if 0:
# slices
FnameCSV = "casestudies/C2_corrected.csv"
print
print "Example for slices (fixed number of inputs and gates):"
print " Format: (Inputs, Gates, Answers)"
hit = False
for x in range(1,UpperBoundInputs+1):
if hit: break
for y in range(1, min(x+1,UpperBoundGates+1) ):
if hit: break
parameters = {
"FnameCSV":FnameCSV,
# slice:
"LowerBoundInputs": x,
"UpperBoundInputs": x,
"LowerBoundGates": y,
"UpperBoundGates": y,
"GateTypes":GateTypes,
"EfficiencyConstraint":EfficiencyConstraint,
"OptimizationStrategy":OptimizationStrategy,
"BreakSymmetries":BreakSymmetries,
"Silent":True}
answers = classifier.pilot(parameters)
print "", x, y, len(answers)
if answers: hit = True
print "Answers:"
for i,x in enumerate(answers):
print " %i:"%i, x