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