-
Notifications
You must be signed in to change notification settings - Fork 0
/
Greedy_Checker.py
55 lines (43 loc) · 1.72 KB
/
Greedy_Checker.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
import os
import random
TotalCount = 40
genCount = 0
notCount = 0
mistCount = 0
resultList = []
numStatesList = []
numAlp = 2
randomSeed = 1
for count in range(0,TotalCount):
numStates = random.randint(50,170)
numStatesList.append(numStates)
for count in range(0,TotalCount):
numStates = numStatesList[count]
nilay_path = "./shortest " + str(numStates) + " " + str(numAlp) + " " + str(randomSeed) + " 1 1"
os.system(nilay_path)
print("\n\n--- Checker Starts Here with " + str(numStates) + " ---\n\n")
engin_path = "./greedychecker"
os.system(engin_path)
#file opening start
data_FileName = "GreedyData.txt"
data_File = open(data_FileName,"r")
result = data_File.read()
resultList.append(result[0:len(result)-1])
data_File.close()
for count in range(0,TotalCount):
if( resultList[count] == "1" ):
genCount = genCount + 1
print( str(numStatesList[count]) + " " + str(numAlp) + " " + str(randomSeed) + " --> Can be generated by Greedy Algorithm." )
elif( resultList[count] == "0" ):
notCount = notCount + 1
print( str(numStatesList[count]) + " " + str(numAlp) + " " + str(randomSeed) + " --> Cannot be generated by Greedy Algorithm." )
else:
mistCount = mistCount + 1
print( str(numStatesList[count]) + " " + str(numAlp) + " " + str(randomSeed) + "--> There was a mistake in the data! Error Code: " + str(resultList[count]))
#--- Error Codes ---
# -1 --> WE DON'T HAVE ANY SEQUENCE PART THAT IS BIGGER THAN 1!
# -2 --> EARLY FINISHED
print("******************")
print("Percentage of Generatable: %" + str(format( genCount/TotalCount*100, '.2f') ) )
print("Percentage of Non-Generatable: %" + str(format( notCount/TotalCount*100, '.2f') ) )
print("Percentage of Mistakes: %" + str(format( mistCount/TotalCount*100, '.2f') ) )