Use append() method for lists

This commit is contained in:
JLo'w 2016-02-11 19:55:30 +01:00
parent 93881fd341
commit 4ee070a305

45
read.py
View file

@ -1,5 +1,34 @@
#Read the input file
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}
def Read_input_file(file):
f = open(file, 'r')
@ -17,7 +46,7 @@ def Read_input_file(file):
line = f.readline()
info = line.split(' ')
for i in range(0, P):
Pw[i] = int(info[i])
Pw.append(int(info[i]))
line = f.readline()
W = int(line)
@ -25,13 +54,13 @@ def Read_input_file(file):
for i in range(0, W):
line = f.readline()
info = line.split(' ')
Wp[i] = (int(info[0]), int(info[1]))
Wp.append((int(info[0]), int(info[1])))
line = f.readline()
info = line.split(' ')
productQ = {}
for j in range(1, info.size())+1:
productQ[j] = int(info[j])
Wi[i] = productsQ
for j in range(0, info.size()):
productQ.append(int(info[j]))
Wi.append(productsQ)
line = f.readline()
nbC = int(line)
@ -39,14 +68,14 @@ def Read_input_file(file):
for i in range(0, nbC):
line = f.readline()
info = line.split(' ')
Cp[i] = (int(info[0]), int(info[1]))
Cp.append((int(info[0]), int(info[1])))
line = f.readline()
nbP = int(line)
line = f.readline()
info = line.split(' ')
orderQ = {}
for j in range(0, nbP):
orderQ[j] = int(info[j])
Ci[i] = orderQ
orderQ.append(int(info[j]))
Ci.append(orderQ)
return