Extended run preparation

This commit is contained in:
Geoffrey Frogeye 2016-02-12 17:44:38 +01:00
parent 01a7f8405d
commit ab2d199d04

121
reborn.py Executable file
View file

@ -0,0 +1,121 @@
#!/usr/bin/env python3
import sys
class Product:
ALL = []
def __init__(self, weight):
self.ALL.append(self)
self.weight = weight
def weight(pid):
return __class__.ALL[pid].weight
def get(pid):
return __class__.ALL[pid]
def len():
return len(__class__.ALL)
class Warehouse:
ALL = []
def __init__(self, pos, items):
self.ALL.append(self)
self.pos = pos
self.items = items
def get(pid):
return __class__.ALL[pid]
def len():
return len(__class__.ALL)
class Client:
ALL = []
def __init__(self, pos, needs):
self.ALL.append(self)
self.pos = pos
self.items = needs
def get(pid):
return __class__.ALL[pid]
def len():
return len(__class__.ALL)
class Drone:
ALL = []
PAYLOAD = 0
def __init__(self):
self.ALL.append(self)
self.pos = Warehouse.get(0).pos
self.items = []
self.avail = 0
self.tasks = []
def get(pid):
return __class__.ALL[pid]
def len():
return len(__class__.ALL)
X = 0 # Nb rows
Y = 0 # Nb columns
T = 0 # Deadline
def readFile(filename):
global X, Y, T
with open(filename, 'r') as f:
# Parameters
X, Y, D, T, Drone.PAYLOAD = [int(i) for i in f.readline().split(' ')]
# Products
P = int(f.readline())
weights = f.readline().split(' ')
assert(len(weights) == P)
for w in weights:
Product(w)
# Warehouses
for i in range(0, int(f.readline())):
pos = [int(i) for i in f.readline().split(' ')]
qtItems = [int(i) for i in f.readline().split(' ')]
assert(len(qtItems) == P)
items = []
for p in range(P):
for i in range(qtItems[p]):
items.append(p)
Warehouse(pos, items)
# Clients
for i in range(0, int(f.readline())):
pos = [int(i) for i in f.readline().split(' ')]
N = int(f.readline())
needs = [int(i) for i in f.readline().split(' ')]
assert(len(needs) == N)
Client(pos, needs)
# Create drones
for d in range(D):
Drone()
readFile(sys.argv[1])