-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHwangRandomInstanceGenerator.py
36 lines (29 loc) · 1.16 KB
/
HwangRandomInstanceGenerator.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
#################
# Generate instances as used by Muter.2015 and described by Hwang.2005.
# All random numbers, excluding locations, are generated by uniform distribution.
# To be used with python 3.6 or higher.
#################
import numpy as np
import secrets as se
cap = 48
numInstances = 100
numOrdersInInstance = 20
lowB = 2
highB = 10
d = open("Hwang-random-cap" + str(cap) + "-all2.txt", "x") # generate file of filenames
for counter in range(numInstances): #number of instances
name = "Hwang-random-cap" + str(cap) + "-"+str(counter)+"-all2.txt"
d.write(name+"\n")
f = open(name, "x")
for orderCounter in range(numOrdersInInstance): #number of orders
numItems = round(np.random.uniform(low=lowB, high=highB))
head = "Order " + str(orderCounter) + " number of articles " + str(numItems) + "\n"
f.write(head)
for i in range(numItems):
cell = round(se.randbelow(44))
aisle = round(se.randbelow(19))
line = str(i)+" Aisle " + str(aisle) + " Location " + str(cell) + "\n"
print(cell, aisle)
f.write(line)
f.close()
d.close()