-
Notifications
You must be signed in to change notification settings - Fork 0
/
cutstock_util.py
70 lines (63 loc) · 1.64 KB
/
cutstock_util.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
def getCutCount():
cutCount = 0
fout1 = open('WidthDemand.csv', 'r')
for eachline in fout1:
cutCount += 1
fout1.close()
return cutCount
def getPatCount():
patCount = 0
fout2 = open('Waste.csv', 'r')
for eachline in fout2:
patCount += 1
fout2.close()
return patCount
def getPriceSheetData():
return 28
def getSheetsAvail():
return 2000
def getCuts():
cutcount = getCutCount()
Cuts = list(range(cutcount))
for i in range(cutcount):
nstr = str(i+1)
Cuts[i] = 'w' + nstr
return Cuts
def getPatterns():
patcount = getPatCount()
Patterns = list(range(patcount))
for j in range(patcount):
pstr = str(j+1)
Patterns[j] = 'P' + pstr
return Patterns
def getCutDemand():
i = 0
cutcount = getCutCount()
CutDemand = list(range(cutcount))
fout1 = open('WidthDemand.csv', 'r')
for eachline in fout1.readlines():
str = eachline.rstrip("\n")
CutDemand[i] = int(str)
i += 1
fout1.close()
return CutDemand
def getCutsInPattern():
cutcount = getCutCount()
patcount = getPatCount()
CutsInPattern = [[0 for col in range(patcount)] for row in range(cutcount)]
fout2 = open('Patterns.csv', 'r')
for eachline in fout2.readlines():
str = eachline
lstr = str.split(",")
pstr = lstr[0]
wstr = lstr[1]
cstr = lstr[2]
pstr = pstr.replace("P","")
wstr = wstr.replace("w","")
cstr = cstr.rstrip("\n")
p = int(pstr)
w = int(wstr)
c = int(cstr)
CutsInPattern[w-1][p-1] = c
fout2.close()
return CutsInPattern