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