This repository has been archived on 2019-08-09. You can view files and clone it, but cannot push or open issues or pull requests.
hashcode2016/read.py

82 lines
1.5 KiB
Python
Raw Normal View History

2016-02-11 19:24:11 +01:00
#Read the input file
2016-02-11 19:55:30 +01:00
X = 0 # Nb rows
Y = 0 # Nb columns
D = 0 # Nb drones
T = 0 # Deadline
M = 0 # Maximum load
P = 0 # Nb products
W = 0 # Nb warehouses
C = 0 # Nb customers
Dp = []; # Positions of drones
# (x, y)
Di = []; # Items of drones
# {product number: qt}
Dd = []; # Turn avaibility of drone
# int
Pw = []; # Weight of products
# int
Wp = []; # Positions of warehouses
# (x, y)
Wi = []; # Items of warehouses
# {product number: qt}
Cp = []; # Positions of customers
# (x, y)
Ci = []; # Needs of customers
# {product number: qt}
2016-02-11 19:24:11 +01:00
def Read_input_file(file):
f = open(file, 'r')
line = f.readline()
2016-02-11 19:24:11 +01:00
info = line.split(' ')
GRILLE = (int(info[0]), int(info[1]))
D = int(info[2])
T = int(info[3])
M = int(info[4])
line = f.readline()
2016-02-11 19:24:11 +01:00
P = int(line)
line = f.readline()
2016-02-11 19:24:11 +01:00
info = line.split(' ')
for i in range(0, P):
2016-02-11 19:55:30 +01:00
Pw.append(int(info[i]))
2016-02-11 19:24:11 +01:00
line = f.readline()
2016-02-11 19:24:11 +01:00
W = int(line)
for i in range(0, W):
line = f.readline()
2016-02-11 19:24:11 +01:00
info = line.split(' ')
2016-02-11 19:55:30 +01:00
Wp.append((int(info[0]), int(info[1])))
line = f.readline()
2016-02-11 19:24:11 +01:00
info = line.split(' ')
2016-02-11 19:36:20 +01:00
productQ = {}
2016-02-11 19:55:30 +01:00
for j in range(0, info.size()):
productQ.append(int(info[j]))
Wi.append(productsQ)
2016-02-11 19:36:20 +01:00
line = f.readline()
2016-02-11 19:36:20 +01:00
nbC = int(line)
for i in range(0, nbC):
line = f.readline()
2016-02-11 19:36:20 +01:00
info = line.split(' ')
2016-02-11 19:55:30 +01:00
Cp.append((int(info[0]), int(info[1])))
line = f.readline()
2016-02-11 19:36:20 +01:00
nbP = int(line)
line = f.readline()
2016-02-11 19:36:20 +01:00
info = line.split(' ')
orderQ = {}
for j in range(0, nbP):
2016-02-11 19:55:30 +01:00
orderQ.append(int(info[j]))
Ci.append(orderQ)
2016-02-11 19:24:11 +01:00
return