示例#1
0
 def __init__(self, name):
     self.position = [0, 0]
     self.docks = []
     self.unloading_warehouse = Warehouse(name="Unloading warehouse")
     self.loading_warehouse = Warehouse(name="Loading warehouse")
     self.fuel_magazine = FuelMagazine()
     self.size = 30
     self.name = name
示例#2
0
    def test_not_enough_inventory_for_multiple_items(self):
        # no warehouses
        self.assertEqual([],
                         InventoryAllocator().allocate_order(
                             {
                                 'item1': 10,
                                 'item2': 10
                             }, []))

        # warehouse object is null
        self.assertEqual([],
                         InventoryAllocator().allocate_order(
                             {
                                 'item1': 10,
                                 'item2': 10
                             }, [Warehouse()]))

        # warehouse exist, but does not have item
        self.assertEqual([],
                         InventoryAllocator().allocate_order(
                             {
                                 'item1': 10,
                                 'item2': 10
                             }, [Warehouse('wh1', {'item2': 10})]))

        # not enough quantity in a single warehouse
        self.assertEqual([],
                         InventoryAllocator().allocate_order(
                             {
                                 'item1': 10,
                                 'item2': 10
                             }, [Warehouse('wh1', {'item1': 5})]))

        # not enough quantity in a multiple warehouses
        self.assertEqual([],
                         InventoryAllocator().allocate_order(
                             {
                                 'item1': 10,
                                 'item2': 10
                             }, [
                                 Warehouse('wh1', {'item1': 5}),
                                 Warehouse('wh2', {'item1': 2}),
                                 Warehouse('wh3', {'item1': 2})
                             ]))

        # enough quantity in for an item, but not the rest of the order
        self.assertEqual([],
                         InventoryAllocator().allocate_order(
                             {
                                 'item1': 10,
                                 'item2': 10
                             }, [
                                 Warehouse('wh1', {'item1': 5}),
                                 Warehouse('wh2', {'item1': 5}),
                                 Warehouse('wh3', {'item1': 5})
                             ]))
示例#3
0
    def test_enough_inventory_for_single_item(self):
        # single warehouse with single item in inventory -- exact quantity
        self.assertEqual([{
            'wh1': {
                'item1': 10
            }
        }],
                         InventoryAllocator().allocate_order(
                             {'item1': 10}, [Warehouse('wh1', {'item1': 10})]))

        # single warehouse with single item in inventory -- over quantity
        self.assertEqual([{
            'wh1': {
                'item1': 10
            }
        }],
                         InventoryAllocator().allocate_order(
                             {'item1': 10}, [Warehouse('wh1', {'item1': 20})]))

        # multiple warehouses -- multiple items in inventory -- over quantity in first warehouse
        self.assertEqual([{
            'wh1': {
                'item1': 10
            }
        }],
                         InventoryAllocator().allocate_order({'item1': 10}, [
                             Warehouse('wh1', {'item1': 10}),
                             Warehouse('wh2', {'item1': 20})
                         ]))

        # multiple warehouses -- multiple items in inventory -- not enough quantity in first warehouse
        self.assertEqual([{
            'wh1': {
                'item1': 4
            }
        }, {
            'wh2': {
                'item1': 6
            }
        }],
                         InventoryAllocator().allocate_order({'item1': 10}, [
                             Warehouse('wh1', {'item1': 4}),
                             Warehouse('wh2', {'item1': 20})
                         ]))

        # multiple warehouses -- exact quantity needed
        self.assertEqual([{
            'wh1': {
                'item1': 4
            }
        }, {
            'wh2': {
                'item1': 6
            }
        }],
                         InventoryAllocator().allocate_order({'item1': 10}, [
                             Warehouse('wh1', {'item1': 4}),
                             Warehouse('wh2', {'item1': 6})
                         ]))
示例#4
0
def main():
    rospy.init_node('warehouse')

    if not rospy.has_param('~size'):
        raise rospy.ROSInitException('Parameter "size" must be set [length, height]')
    if not rospy.has_param('~offset'):
        raise rospy.ROSInitException('Parameter "offset" must be set [length, height]')
    if not rospy.has_param('~warehouse'):
        raise rospy.ROSInitException('Parameter "warehouse" muse be set "raws" or "goods"')
    if not rospy.has_param('~content'):
        raise rospy.ROSInitException('Items type must be specified in parameter "content"')

    warehouse_size = ast.literal_eval(rospy.get_param('~size'))
    global warehouse_offset
    warehouse_offset = ast.literal_eval(rospy.get_param('~offset'))

    global wh
    wh = Warehouse(warehouse_size)

    rospy.Service('~place', Place, handle_place)  # put item in cell
    rospy.Service('~order', Order, handle_order)  # get item from cell
    rospy.Service('~fill_all', FillAll, handle_fill_all)
    rospy.Service('~empty_all', EmptyAll, handle_empty_all)
    rospy.Service('~quantity_available', QuantityAvailable, handle_quantity_available)
    rospy.Service('~content', Content, handle_content)

    rospy.spin()
    def __init__(self,
                 rows,
                 cols,
                 edge_base_cost=1.,
                 occupancy_cost=0.,
                 n_agents=10,
                 n_tasks=100,
                 lam=1.,
                 seed=0):
        set_seed(s=seed)

        self._w = Warehouse(rows,
                            cols,
                            node_capacity=-1,
                            edge_base_cost=edge_base_cost,
                            occupancy_cost=occupancy_cost)
        self._w_manager = WarehouseManager(self._w, n_agents)
        nodes = self._w_manager.nodes()

        num_tasks_per_iteration = create_tasks_arrivals(n_tasks, lam)
        self._task_arrivals = []
        for x in num_tasks_per_iteration:
            self._task_arrivals.append([sample_nodes(nodes)] * x)

        self._processed_ticks = 0
        self._only_wip_ticks = 0
示例#6
0
 def __init__(self, pickle=False):
     if pickle == False:
         warehouse_zips = db.getDataFromString('exec dbo.facility')[:100]
         zip_data_class = ZipCodesData()
         self.distribution_centers(zip_data_class)
         self.warehouses = []
         self.warehouses.extend(self.dcs)
         self.ranking = Ranking()
         for i in warehouse_zips:
             self.warehouses.append(
                 Warehouse(i[0], i[1], i[2], i[3], i[4], i[5]))
         zips = db.getDataFromString('exec dbo.zipcode')
         self.zips = {}
         dc_cords = []
         for i in self.dcs:
             dc_cords.append(i.get_cordinates())
         for i in self.warehouses:
             dc_cords.append(i.get_cordinates())
         for i in zips:
             try:
                 int(i[0][:5])
                 zip = ('00000' + str(i[0][:5]))[-5:]
             except:
                 zip = i[0]
             cords = zip_data_class.get_cordinates(zip)
             state = zip_data_class.get_state(zip)
             self.zips[zip] = ZipCode(zip, cords, state)
             self.zips[zip].get_serviceable_array(dc_cords)
     else:
         self.pickle_load()
示例#7
0
 def test_give_unit_of_type(self):
     warehouse = Warehouse()
     unit = Unit('company', 'model1')
     warehouse.add_unit(unit)
     given_unit = warehouse.give_unit_of_type(Unit)
     self.assertEqual(unit, given_unit)
     self.assertRaises(NoUnitsLeft, warehouse.give_unit_of_type, Unit)
示例#8
0
    def __init__(self, config_file):
        with open(config_file, 'r') as f:
            self.rows, self.cols, self.num_drones, self.num_turns, self.max_payload = get_line(f.readline())
            self.num_product_types = get_line_first(f.readline())
            weights = get_line(f.readline())
            self.products = []
            for idx in range(self.num_product_types):
                self.products.append(Product(idx, weights[idx]))

            self.num_warehouses = get_line_first(f.readline())
            self.warehouses = []
            for warehouse_idx in range(self.num_warehouses):
                loc = tuple(get_line(f.readline()))
                warehouse = Warehouse(warehouse_idx, loc)
                for prod_idx, prod_quant in enumerate(get_line(f.readline())):
                    prod = self.products[prod_idx]
                    warehouse.add_product(prod, prod_quant)
                self.warehouses.append(warehouse)

            self.num_orders = get_line_first(f.readline())
            self.orders = []
            for order_idx in range(self.num_orders):
                loc = tuple(get_line(f.readline()))
                order = Order(order_idx, loc)
                f.readline() #just skip cause we know it from the next line
                for prod_id in get_line(f.readline()):
                    prod = self.products[prod_id]
                    order.add_product(prod)
                self.orders.append(order)

            self.drones = [Drone(drone_idx, self.warehouses[0].location, self.max_payload) \
                           for drone_idx in range(self.num_drones)]
示例#9
0
 def test_init_board(self):
     warehouse = Warehouse(True)
     warehouse.board_width = 10
     warehouse.board_height = 5
     warehouse.init_board()
     self.assertEqual(10, len(warehouse.new_board[0]), 'Passed')
     self.assertEqual(5, len(warehouse.new_board), 'Passed')
示例#10
0
    def __init__(self, path):
        self.path = path
        input_data = self._get_input(path)
        self.deadline = input_data["deadline"]
        self.rows = input_data["rows"]
        self.columns = input_data["columns"]

        self.num_products = input_data["num_products"]
        self.num_drones = input_data["num_drones"]
        self.num_orders = input_data["num_orders"]
        self.num_warehouses = input_data["num_warehouses"]
        self.max_load = input_data["max_load"]

        self.products = [
            Product(weight) for weight in input_data["product_weights"]
        ]
        self.warehouses = [
            Warehouse(wh["row"], wh["column"], wh["stock"])
            for wh in input_data["warehouses"]
        ]
        self.drones = [
            Drone(i, self.warehouses, input_data["max_load"])
            for i in range(input_data["num_drones"])
        ]
        self.orders = [
            Order(i, order["row"], order["column"], order["product_ids"])
            for i, order in enumerate(input_data["orders"])
        ]
示例#11
0
 def distribution_centers(self, zipcodes):
     """created self.dcs object"""
     dcs = [['Sainte-Croix', 'G0S 2H0'], ['Coaticook', 'J1A 1Z5'], ['Juarez', '31000']\
     , ['Nashville', '37011'], ['Salt Lake', '84044']]
     self.dcs = []
     for i in dcs:
         cords = zipcodes.get_cordinates(i[1])
         self.dcs.append(Warehouse(i[0], i[1], 2, 4, cords[0], cords[1]))
 def setUp(self) -> None:
     super().setUp()
     self.warehouse = Warehouse(":memory:", create_tables=True)
     self.warehouse.create_product(Product("W1", "Вино", "Бутылка"))
     self.warehouse.create_product(Product("P1", "Пармезан", "Килограмм"))
     self.warehouse.create_product(Product("C1", "Колбаса", "Килограмм"))
     customer = self.warehouse.create_customer("Виталий Брагилевский")
     self.cid = customer.id
示例#13
0
def load():
	"""
        opens a load dialogue window to load a file and creates a WHreader and a Warehouse object
    """
	filename = filedialog.askopenfilename(parent=win)
	global read_setting
	read_setting = WHreader(filename)	#read in the content of the file
	global whouse_object # create an actual warehouse object with the content of the file
	whouse_object = Warehouse(WHreader(filename).stock, WHreader(filename).psus)
示例#14
0
 def test_add_item(self):
     warehouse = Warehouse(True)
     test_list = [123, 'apples', 5, 6, 6]
     warehouse.add_item(test_list)
     self.assertEqual('apples', warehouse.new_item_list[0].name, 'Passed')
     self.assertEqual(123, warehouse.new_item_list[0].item_id, 'Passed')
     self.assertEqual(5, warehouse.new_item_list[0].quantity, 'Passed')
     self.assertEqual(6, warehouse.new_item_list[0].length, 'Passed')
     self.assertEqual(6, warehouse.new_item_list[0].width, 'Passed')
    def test_warehouse_create(self):
        self.assertEqual(test_1.name, "test 1")
        self.assertEqual(test_1.inventory, {"apples": 5})

        self.assertEqual(test_2.name, "test 2")
        self.assertEqual(test_2.inventory, {
            "banana": 5,
            "apples": 10,
            "pears": 7
        })

        self.assertEqual(test_3.name, "test 3")
        self.assertEqual(test_3.inventory, {})

        with self.assertRaises(TypeError):
            Warehouse("invalid warehouse", 5)
        with self.assertRaises(TypeError):
            Warehouse("invalid warehouse", "string")
    def test_subtract_inventory(self):
        sub_test_1 = Warehouse("test 1", {"apples": 5})
        sub_test_1.subtract_inventory("apples", 5)
        self.assertEqual(sub_test_1.find_order("apples"), 0)

        sub_test_2 = Warehouse("test 2", {
            "banana": 5,
            "apples": 10,
            "pears": 7
        })
        sub_test_2.subtract_inventory("banana", 3)
        self.assertEqual(sub_test_2.find_order("banana"), 2)
        sub_test_2.subtract_inventory("apples", 15)
        self.assertEqual(sub_test_2.find_order("apples"), 0)
        self.assertEqual(sub_test_2.subtract_inventory("Not found", 5), None)

        with self.assertRaises(ValueError):
            sub_test_2.subtract_inventory("banana", -5)
示例#17
0
 def test_fill_board(self):
     warehouse = Warehouse(True)
     warehouse.board_width = 10
     warehouse.board_height = 10
     warehouse.init_board()
     test_item = [123, 'apples', 1, 6, 6]
     warehouse.add_item(test_item)
     warehouse.fill_board(0, warehouse.new_item_list[0], 1)
     self.assertEqual('1', warehouse.new_board[0][0], 'Passed')
示例#18
0
 def test_packing(self):
     warehouse = Warehouse(True)
     warehouse.board_width = 10
     warehouse.board_height = 10
     warehouse.init_board()
     test_item = [123, 'apples', 1, 6, 6]
     warehouse.add_item(test_item)
     self.assertEqual(0, len(warehouse.complete_list), 'Passed')
     warehouse.packing(warehouse.new_item_list)
     self.assertEqual(1, len(warehouse.complete_list), 'Passed')
示例#19
0
def parse(inFileName):

    with open(inFileName, "r") as inFile:

        header = inFile.readline()
        rows, columns, nr_drones, nr_turns, max_payload = list(
            map(int,
                header.strip().split(" ")))

        # read product types
        nr_products = int(inFile.readline())
        products = list(map(int, inFile.readline().strip().split(" ")))
        assert len(products) == nr_products

        # read warehouses
        nr_warehouses = int(inFile.readline())
        warehouses = []
        for i in range(nr_warehouses):
            pos = tuple(map(int, inFile.readline().strip().split(" ")))
            items = list(map(int, inFile.readline().strip().split(" ")))
            assert len(items) == nr_products
            warehouses.append(Warehouse(i, pos, items))

        assert len(warehouses) == nr_warehouses

        # read orders
        nr_orders = int(inFile.readline())
        orders = []
        lines = inFile.readlines()
        for i, (pos, nr_items,
                items) in enumerate(zip(lines[::3], lines[1::3], lines[2::3])):
            pos = tuple(map(int, pos.split(" ")))
            items = list(map(int, items.strip().split(" ")))
            assert int(nr_items) == len(items)
            orders.append(Order(id=i, pos=pos, items=items))

        assert len(orders) == nr_orders

        # init drones to simulate
        drones = []
        first_warehouse = warehouses[0]
        for i in range(nr_drones):
            drone = Drone(pos=first_warehouse.pos,
                          id=i,
                          max_payload=max_payload)
            drones.append(drone)

        return State(rows=rows,
                     columns=columns,
                     nr_turns=nr_turns,
                     max_payload=max_payload,
                     products=products,
                     warehouses=warehouses,
                     orders=orders,
                     drones=drones)
示例#20
0
 def test_check_available_area(self):
     warehouse = Warehouse(True)
     test_list = [123, 'apples', 1, 6, 6]
     warehouse.add_item(test_list)
     test_list_2 = [456, 'oranges', 2, 2, 2]
     warehouse.add_item(test_list_2)
     test_true = warehouse.check_available_area(warehouse.new_item_list, 44)
     test_false = warehouse.check_available_area(warehouse.new_item_list,
                                                 10)
     self.assertEqual(True, test_true, 'Passed')
     self.assertEqual(False, test_false, 'Passed')
示例#21
0
 def test_create_rect(self):
     warehouse = Warehouse(test_flag=True)
     visualize = VisualizeWarehouse(test_flag=True)
     visualize.screen_buffer = 10
     visualize.width_segment = 40
     visualize.height_segment = 40
     test_board = [['0', '0', '1', '1', '0'], ['0', '0', '1', '1', '0'],
                   ['0', '0', '1', '1', '0']]
     test_item = [123, 'apples', 1, 6, 6]
     warehouse.add_item(test_item)
     result = visualize.create_item_rect(test_board,
                                         warehouse.new_item_list)
     self.assertEqual(1, len(visualize.rectangle_list), 'Passed')
示例#22
0
def populate_warehouses(warehouse_locations, warehouse_stock):
   """
   create the warehouses
   :param warehouses_locations
   :param warehouses_stock
   return list of warehouses
   """
   id_ = -1
   items = []
   for l, s in zip(warehouse_locations, warehouse_stock):
      id_ += 1
      items.append(Warehouse(id_, l , s))
   return items
示例#23
0
	def parse_warehouses(self, warehouseList):
		result = []
		if not isinstance(warehouseList, list):
			raise TypeError("Input must be a list of dictionaries")
		for wh in warehouseList:
			if not isinstance(wh, dict):
				raise TypeError("List must contain dictionaries with name of warehouse mapped to its inventory")
			if not "name" in wh:
				raise ValueError("warehouse input must contain a name")
			if not "inventory" in wh:
				raise ValueError("warehouse input must contain an inventory")
			result.append(Warehouse(wh.get("name"), wh.get("inventory")))
		return result
    def setUp(self):
        """ Create some objects: one Warehouse, one Shelf, three of each
            Container type (Bin, Box, Bag), and three each of four different
            sizes of Item.
        """
        self.warehouse = Warehouse()
        self.shelf = Shelf()
        self.bin1, self.bin2, self.bin3 = [Bin() for _ in range(3)]
        self.box1, self.box2, self.box3 = [Box() for _ in range(3)]
        self.bag1, self.bag2, self.bag3 = [Bag() for _ in range(3)]

        self.itemS1, self.itemS2, self.itemS3 = [Item(1) for _ in range(3)]
        self.itemM1, self.itemM2, self.itemM3 = [Item(6) for _ in range(3)]
        self.itemL1, self.itemL2, self.itemL3 = [Item(10) for _ in range(3)]
        self.itemXL1, self.itemXL2, self.itemXL3 = [Item(15) for _ in range(3)]
def run_warehouse():
    warehouse = Warehouse()
    while True:
        warehouse.show_menu()
        key = input('Enter your command: ')
        if key == 'q':
            break
        elif key == '1':
            warehouse.show_inventory()
        elif key == '2':
            warehouse.modify_inventory()
        elif key == '3':
            warehouse.show_orders_need_ship()
        elif key == '4':
            warehouse.show_all_orders()
        elif key == '5':
            warehouse.create_shipment()
示例#26
0
def main():
    #Initial grid
    width = 10
    height = 10
    grid = Grid(width, height)

    #Initial warehouse
    robots_path = r'../warehouse/robots.json'
    goods_path = r'../warehouse/goods.json'
    requests_path = r'../requests/requests.json'
    goals = set([(0, 0), (0, 3), (0, 6), (0, 9)])
    warehouse = Warehouse(grid, goals)
    warehouse.load_robots(robots_path)
    warehouse.load_goods(goods_path)
    warehouse.load_requests(requests_path)

    warehouse.maintain()
示例#27
0
def load_data():
    ipt_file = open(input_file + ".in", "r")
    lines = ipt_file.read().split("\n")
    init_info = lines[0].split(" ")

    rows = int(init_info[0])
    cols = int(init_info[1])
    n_drones = int(init_info[2])
    turns = int(init_info[3])
    max_weight = int(init_info[4])
    
    #Init drones
    drones = [0]*n_drones
    for i in range(n_drones):
        drones[i] = Drone(i)

    #Items
    #n_items = int(lines[1])
    _items = lines[2].split(" ")
    items = [0]*len(_items)
    for i in range(len(_items)):
        items[i] = int(_items[i])

    #Warehouses    
    n_wh = int(lines[3])
    warehouses = [0]*n_wh
    for i in range(n_wh):
        wh_pos = lines[4 + i*2].split(" ")
        wh_items = lines[5 + i*2].split(" ")
        warehouses[i] = Warehouse(i, int(wh_pos[0]), int(wh_pos[1]))
        warehouses[i].items = [0]*len(wh_items)
        for j in range(len(wh_items)):
            warehouses[i].items[j] = int(wh_items[j])
        
    #Orders
    init_idx = 4 + n_wh*2
    n_orders = int(lines[init_idx])
    orders = [0]*n_orders
    for i in range(n_orders):
        orders_pos = lines[init_idx+1 + i*3].split(" ")
        orders_items = lines[init_idx+1 + (i*3)+2].split(" ")
        orders[i] = Order(orders_pos[0], orders_pos[1])
        orders[i].items = [0]*len(orders_items)
        for j in range(len(orders_items)): #convertim a int
            orders[i].items[j] = int(orders_items[j])
示例#28
0
 def __init__(self, threads):
     self.pool = ThreadPoolExecutor(threads)
     self.queue = queue.Queue()
     self.warehouse = Warehouse(19999)
     self.robots = []
     self.tasks = []
     self.app = Flask("Warehouse")
     self.socketio = SocketIO(self.app, pingTimeout=60, pingInterval=60)
     self.socketio.on_event("addTask", self.handleAddTask)
     self.socketio.on_event("addRobot", self.handleAddRobot)
     self.loop = threading.Thread(target=self._dispatcher)
     self.freeRobots = threading.Semaphore(value=0)
     self.mutex = threading.Lock()
     self.app.add_url_rule("/<path:path>",
                           "sendFile",
                           self.sendFile,
                           methods=["GET"])
     self.app.add_url_rule("/",
                           "sendHomePage",
                           self.sendHomePage,
                           methods=["GET"])
     self.app.add_url_rule("/getTasks", "sendTasksHTTP", self.sendTasksHTTP)
     self.app.add_url_rule("/getRobotsPos", "sendRobotsPos",
                           self.sendRobotsPos)
 def __init__(self, file):
     self.warehouse = Warehouse(file)
from warehouse import Warehouse, train
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

e_decays = [0.001, 0.01, 1]

env = Warehouse(2, 2, 2, True)  # create warehouse
# n_shelve_units, unit_width, n_pick_pts
env.render()
n_episodes = 1000

for e_decay in e_decays:
    _, r = train(env,
                 n_episodes=n_episodes,
                 n_steps=100,
                 l_rate=0.5,
                 d_rate=0.99,
                 max_e_rate=1,
                 min_e_rate=0.001,
                 e_d_rate=e_decay)
    plt.plot(range(n_episodes),
             pd.DataFrame(r).rolling(100).mean().to_numpy(),
             label=str(e_decay))

plt.grid()
plt.legend(title="Exploration decay rate:")
plt.xlabel("Episode")
plt.ylabel("Reward")
plt.savefig("../../basic_e_sens.pdf")
plt.show()