-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample_input.py
More file actions
46 lines (44 loc) · 1.5 KB
/
Copy pathexample_input.py
File metadata and controls
46 lines (44 loc) · 1.5 KB
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@author: Xinquan Chen
@contact:XinquanChen0117@163.com
@file: example_input.py
@time: 2022-05-05 20:47
"""
import numpy as np
def experimental_data_reshape(filename):
f = open(filename, 'r', encoding='utf-8')
workpieceCount = 1
processCount = 1
result = []
workpieceNameSet = []
for line in f.readlines()[1:]:
if line == '\n':
workpieceCount += 1
processCount = 1
continue
processInfo = {}
line_list = []
line = line.split()
for element in line:
line_list.append(int(element))
timeSet = line_list[1::2]
machineSet = list(map(lambda x: '#m-' + str(x), line_list[0::2]))
workpieceName = '#w-' + str(workpieceCount)
processName = '#p-1' + str(workpieceCount) + str(processCount)
processCount += 1
processInfo['order'] = '#o-1'
processInfo['workpiece'] = workpieceName
processInfo['number'] = 1
processInfo['process'] = processName
processInfo['machine'] = machineSet
processInfo['time'] = timeSet
result.append(processInfo)
workpieceNameSet.append(workpieceName)
workpieceNameSet = list(set(workpieceNameSet))
wpstMatrix = np.full((len(workpieceNameSet),len(workpieceNameSet)), 0)
return result, workpieceNameSet, wpstMatrix
if __name__ == '__main__':
result, workpieceNameSet, wpstMatrix = experimental_data_reshape('./expData/Kacem1.txt')
print(result)