Merge stuff
This commit is contained in:
parent
8a58caa99e
commit
0fefade86b
34
main.py
34
main.py
|
@ -18,26 +18,26 @@ C = 0 # Nb customers
|
|||
|
||||
t = -1 # Turn
|
||||
|
||||
Dp = []; # Positions of drones
|
||||
Dp = [] # Positions of drones
|
||||
# (x, y)
|
||||
Di = []; # Items of drones
|
||||
Di = [] # Items of drones
|
||||
# {product number: qt}
|
||||
Dd = []; # Turn avaibility of drone
|
||||
Dd = [] # Turn avaibility of drone
|
||||
# int
|
||||
Da = []; # Avaibles drones
|
||||
Da = [] # Avaibles drones
|
||||
# int
|
||||
|
||||
Pw = []; # Weight of products
|
||||
Pw = [] # Weight of products
|
||||
# int
|
||||
|
||||
Wp = []; # Positions of warehouses
|
||||
Wp = [] # Positions of warehouses
|
||||
# (x, y)
|
||||
Wi = []; # Items of warehouses
|
||||
Wi = [] # Items of warehouses
|
||||
# {product number: qt}
|
||||
|
||||
Cp = []; # Positions of customers
|
||||
Cp = [] # Positions of customers
|
||||
# (x, y)
|
||||
Ci = []; # Needs of customers
|
||||
Ci = [] # Needs of customers
|
||||
# {product number: qt}
|
||||
|
||||
# Reading raw data
|
||||
|
@ -99,7 +99,6 @@ for d in range(D):
|
|||
Dp.append(Wp[0])
|
||||
Di.append(dict((p, 0) for p in range(P)))
|
||||
Dd.append(0)
|
||||
Out = '' # Drones commands
|
||||
|
||||
# Debug
|
||||
|
||||
|
@ -139,7 +138,7 @@ def load(d, w, p, q):
|
|||
Di[d][p] += +q
|
||||
assert(Wp[w][p] >= 0)
|
||||
assert(weight(d) <= M)
|
||||
assert(Dd[d] <= T);
|
||||
assert(Dd[d] <= T)
|
||||
print("Drone", d, "loads", q, "of", p, "from warehouse", w, "→", Dd[d])
|
||||
|
||||
def unload(d, w, p, q):
|
||||
|
@ -149,7 +148,7 @@ def unload(d, w, p, q):
|
|||
Dd[d] += distance(Dp[d], Wp[w])
|
||||
Wi[w][p] += +q
|
||||
Di[d][p] += -q
|
||||
assert(Dd[d] <= T);
|
||||
assert(Dd[d] <= T)
|
||||
print("Drone", d, "unloads", q, "of", p, "from warehouse", w, "→", Dd[d])
|
||||
|
||||
def deliver(d, c, p, q):
|
||||
|
@ -160,7 +159,7 @@ def deliver(d, c, p, q):
|
|||
Ci[w][p] += +q
|
||||
Di[d][p] += -q
|
||||
Dd[d] += 1
|
||||
assert(Dd[d] <= T);
|
||||
assert(Dd[d] <= T)
|
||||
print("Drone", d, "delivers", q, "of", p, "to client", w, "→", Dd[d])
|
||||
|
||||
def wait(d, w=1):
|
||||
|
@ -183,11 +182,10 @@ def newTurn():
|
|||
def end():
|
||||
print("--- End!")
|
||||
|
||||
Out = '' # Drones commands
|
||||
# IA
|
||||
|
||||
#Out file
|
||||
|
||||
|
||||
f = open(sys.argv[1] + '_out', 'w')
|
||||
# Output
|
||||
f = open(sys.argv[1] + 'o', 'w')
|
||||
f.write(len(Out)/10 + '\n' + Out)
|
||||
f.close()
|
||||
f.close()
|
||||
|
|
Reference in a new issue