Compare commits
No commits in common. "master" and "jer_test" have entirely different histories.
2
.gitignore
vendored
@ -50,7 +50,7 @@ MANIFEST
|
|||||||
pip-log.txt
|
pip-log.txt
|
||||||
pip-delete-this-directory.txt
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
# Unit pathfinding / coverage reports
|
# Unit test / coverage reports
|
||||||
htmlcov/
|
htmlcov/
|
||||||
.tox/
|
.tox/
|
||||||
.nox/
|
.nox/
|
||||||
|
14
AgentBase.py
@ -1,14 +0,0 @@
|
|||||||
from mesa import Agent, Model
|
|
||||||
|
|
||||||
from util.AgentIdFactory import AgentIdFactory
|
|
||||||
|
|
||||||
|
|
||||||
class AgentBase(Agent):
|
|
||||||
|
|
||||||
def __init__(self, model: Model):
|
|
||||||
unique_id = AgentIdFactory.get_next_id()
|
|
||||||
super().__init__(unique_id, model)
|
|
||||||
self.creation_log()
|
|
||||||
|
|
||||||
def creation_log(self):
|
|
||||||
pass
|
|
171
ForkliftAgent.py
@ -1,147 +1,54 @@
|
|||||||
from copy import deepcopy
|
from typing import Tuple
|
||||||
from typing import Tuple, List
|
|
||||||
|
|
||||||
from AgentBase import AgentBase
|
from mesa import Agent
|
||||||
from PatchAgent import PatchAgent
|
|
||||||
from PatchType import PatchType
|
from data.Direction import Direction
|
||||||
from data.GameConstants import GameConstants
|
|
||||||
from data.Item import Item
|
|
||||||
from data.Order import Order
|
|
||||||
from data.enum.Direction import Direction
|
|
||||||
from data.enum.ItemType import ItemType
|
|
||||||
from decision.Action import Action
|
|
||||||
from decision.ActionType import ActionType
|
|
||||||
from pathfinding.PathFinderState import PathFinderState
|
|
||||||
from pathfinding.PathfinderOnStates import PathFinderOnStates
|
|
||||||
from util.PathDefinitions import GridLocation, GridWithWeights
|
|
||||||
|
|
||||||
|
|
||||||
class ForkliftAgent(AgentBase):
|
class ForkliftAgent(Agent):
|
||||||
|
|
||||||
def __init__(self, model, game_constants: GameConstants, client_delivery: PatchAgent, drop_off: PatchAgent,
|
def __init__(self, unique_id, model):
|
||||||
graph: GridWithWeights):
|
super().__init__(unique_id, model)
|
||||||
super().__init__(model)
|
self.movement_queue = [Tuple[int, int]]
|
||||||
self.action_queue: List[Action] = []
|
|
||||||
self.current_position = Tuple[int, int]
|
self.current_position = Tuple[int, int]
|
||||||
self.current_rotation = Direction.right
|
self.current_rotation = Direction.right
|
||||||
self.orderList = []
|
print("Created forklift Agent with ID: {}".format(unique_id))
|
||||||
self.fulfilled_orders: List[Order] = []
|
|
||||||
self.client_delivery: PatchAgent = client_delivery
|
|
||||||
self.drop_off: PatchAgent = drop_off
|
|
||||||
self.graph = graph
|
|
||||||
self.game_constants = game_constants
|
|
||||||
self.item_station_completed = False
|
|
||||||
self.current_order_delivered_items: List[Item] = []
|
|
||||||
self.ready_for_execution = False
|
|
||||||
self.last_delviered_item = None
|
|
||||||
|
|
||||||
self.current_item: Item = None
|
def assign_new_movement_task(self, movement_list):
|
||||||
self.current_order = None
|
self.movement_queue = []
|
||||||
self.base: GridLocation = None
|
|
||||||
self.goal: GridLocation = None
|
|
||||||
|
|
||||||
def set_base(self, drop_off: PatchAgent):
|
for m in movement_list:
|
||||||
self.drop_off = drop_off
|
self.movement_queue.append(m)
|
||||||
self.base = self.drop_off.location
|
|
||||||
self.goal = self.base
|
|
||||||
|
|
||||||
def queue_movement_actions(self, movement_actions: List[Action]):
|
print("Assigned new movement queue to forklift agent")
|
||||||
self.action_queue.extend(movement_actions)
|
|
||||||
|
def get_proper_rotation(self, next_pos: Tuple[int, int]) -> Direction:
|
||||||
|
|
||||||
|
if next_pos[0] < self.current_position[0]:
|
||||||
|
return Direction.left
|
||||||
|
elif next_pos[0] > self.current_position[0]:
|
||||||
|
return Direction.right
|
||||||
|
elif next_pos[1] > self.current_position[1]:
|
||||||
|
return Direction.top
|
||||||
|
elif next_pos[1] < self.current_position[1]:
|
||||||
|
return Direction.down
|
||||||
|
elif next_pos == self.current_position:
|
||||||
|
return self.current_rotation
|
||||||
|
|
||||||
def move(self):
|
def move(self):
|
||||||
if len(self.action_queue) > 0:
|
if len(self.movement_queue) > 0:
|
||||||
action = self.action_queue.pop(0)
|
next_pos = self.movement_queue.pop(0)
|
||||||
action_type = action.action_type
|
|
||||||
|
|
||||||
if action_type == ActionType.ROTATE_UP:
|
dir = self.get_proper_rotation(next_pos)
|
||||||
# print("rotate {} --> {}".format(self.current_rotation, action_type))
|
|
||||||
self.current_rotation = Direction.top
|
|
||||||
|
|
||||||
elif action_type == ActionType.ROTATE_RIGHT:
|
if dir == self.current_rotation:
|
||||||
# print("rotate {} --> {}".format(self.current_rotation, action_type))
|
print("move {} --> {}".format(self.current_position, next_pos))
|
||||||
self.current_rotation = Direction.right
|
self.current_position = next_pos
|
||||||
|
else:
|
||||||
elif action_type == ActionType.ROTATE_DOWN:
|
print("rotate {} --> {}".format(self.current_rotation, dir))
|
||||||
# print("rotate {} --> {}".format(self.current_rotation, action_type))
|
self.current_rotation = dir
|
||||||
self.current_rotation = Direction.down
|
self.movement_queue.insert(0, next_pos)
|
||||||
|
|
||||||
elif action_type == ActionType.ROTATE_LEFT:
|
|
||||||
# print("rotate {} --> {}".format(self.current_rotation, action_type))
|
|
||||||
self.current_rotation = Direction.left
|
|
||||||
|
|
||||||
elif action_type == ActionType.MOVE:
|
|
||||||
if self.current_rotation == Direction.top:
|
|
||||||
# print("move {} --> {}".format(self.current_position, action_type))
|
|
||||||
self.current_position = (self.current_position[0], self.current_position[1] + 1)
|
|
||||||
|
|
||||||
elif self.current_rotation == Direction.down:
|
|
||||||
# print("move {} --> {}".format(self.current_position, action_type))
|
|
||||||
self.current_position = (self.current_position[0], self.current_position[1] - 1)
|
|
||||||
|
|
||||||
elif self.current_rotation == Direction.right:
|
|
||||||
# print("move {} --> {}".format(self.current_position, action_type))
|
|
||||||
self.current_position = (self.current_position[0] + 1, self.current_position[1])
|
|
||||||
|
|
||||||
elif self.current_rotation == Direction.left:
|
|
||||||
# print("move {} --> {}".format(self.current_position, action_type))
|
|
||||||
self.current_position = (self.current_position[0] - 1, self.current_position[1])
|
|
||||||
|
|
||||||
def step(self) -> None:
|
def step(self) -> None:
|
||||||
if len(self.action_queue) > 0:
|
print("forklift step")
|
||||||
self.move()
|
self.move()
|
||||||
elif self.ready_for_execution:
|
|
||||||
if self.current_position != self.goal:
|
|
||||||
pathFinder = PathFinderOnStates(
|
|
||||||
self.game_constants,
|
|
||||||
self.goal,
|
|
||||||
PathFinderState(self.current_position,
|
|
||||||
self.current_rotation,
|
|
||||||
0,
|
|
||||||
Action(
|
|
||||||
desired_item=None,
|
|
||||||
action_type=ActionType.PICK_ITEM
|
|
||||||
),
|
|
||||||
[])
|
|
||||||
)
|
|
||||||
actions = pathFinder.get_action_list()
|
|
||||||
self.queue_movement_actions(actions)
|
|
||||||
else:
|
|
||||||
if self.current_order is not None and self.goal == self.base:
|
|
||||||
self.current_item = self.current_order.items.pop(0)
|
|
||||||
packing_station: GridLocation = None
|
|
||||||
stations = dict(self.graph.packingStations)
|
|
||||||
|
|
||||||
if self.current_item.real_type == ItemType.SHELF:
|
|
||||||
packing_station = stations[PatchType.packingShelf]
|
|
||||||
elif self.current_item.real_type == ItemType.REFRIGERATOR:
|
|
||||||
packing_station = stations[PatchType.packingRefrigerator]
|
|
||||||
elif self.current_item.real_type == ItemType.DOOR:
|
|
||||||
packing_station = stations[PatchType.packingDoor]
|
|
||||||
|
|
||||||
self.goal = packing_station
|
|
||||||
|
|
||||||
elif self.goal in [i[1] for i in self.graph.packingStations]:
|
|
||||||
self.goal = self.client_delivery.location
|
|
||||||
|
|
||||||
elif self.goal == self.client_delivery.location:
|
|
||||||
if self.current_order is not None and len(self.current_order.items) == 0:
|
|
||||||
|
|
||||||
self.current_order_delivered_items.append(self.current_item)
|
|
||||||
self.current_order.items = deepcopy(self.current_order_delivered_items)
|
|
||||||
self.fulfilled_orders.append(self.current_order)
|
|
||||||
|
|
||||||
self.current_item = None
|
|
||||||
self.current_order = None
|
|
||||||
|
|
||||||
self.goal = self.base
|
|
||||||
else:
|
|
||||||
self.current_order_delivered_items.append(self.current_item)
|
|
||||||
self.goal = self.base
|
|
||||||
self.current_item = None
|
|
||||||
|
|
||||||
elif self.goal == self.base and self.current_order is None:
|
|
||||||
self.current_order_delivered_items.clear()
|
|
||||||
self.current_order = self.orderList.pop(0)
|
|
||||||
|
|
||||||
def creation_log(self):
|
|
||||||
print("Created Forklift Agent [id: {}]".format(self.unique_id))
|
|
||||||
|
293
GameModel.py
@ -1,301 +1,66 @@
|
|||||||
import copy
|
|
||||||
from enum import Enum
|
|
||||||
from typing import List, Tuple
|
|
||||||
|
|
||||||
from mesa import Model
|
from mesa import Model
|
||||||
from mesa.space import MultiGrid
|
from mesa.space import MultiGrid
|
||||||
from mesa.time import RandomActivation
|
from mesa.time import RandomActivation
|
||||||
|
|
||||||
from AgentBase import AgentBase
|
|
||||||
from ForkliftAgent import ForkliftAgent
|
from ForkliftAgent import ForkliftAgent
|
||||||
from InitialStateFactory import InitialStateFactory
|
|
||||||
from ItemDisplayAgent import ItemDisplayAgent
|
|
||||||
from PatchAgent import PatchAgent
|
from PatchAgent import PatchAgent
|
||||||
from PatchType import PatchType
|
from PatchType import PatchType
|
||||||
from PictureVisualizationAgent import PictureVisualizationAgent
|
from util.PathDefinitions import inverse_y
|
||||||
from data.GameConstants import GameConstants
|
from util.PathVisualiser import draw_grid, reconstruct_path
|
||||||
from data.Item import Item
|
from util.Pathfinder import a_star_search
|
||||||
from data.Order import Order
|
|
||||||
from data.enum.ItemType import ItemType
|
|
||||||
from decision.Action import Action
|
|
||||||
from decision.ActionType import ActionType
|
|
||||||
from genetic_order.GeneticOrder import GeneticOrder
|
|
||||||
from imageClasification.Classificator import image_classification
|
|
||||||
from pathfinding.PathfinderOnStates import PathFinderOnStates, PathFinderState
|
|
||||||
from tree.DecisionTree import DecisionTree
|
|
||||||
from util.PathByEnum import PathByEnum
|
|
||||||
from util.PathDefinitions import GridLocation, GridWithWeights
|
|
||||||
|
|
||||||
|
|
||||||
class Phase(Enum):
|
|
||||||
INIT = 1
|
|
||||||
ITEM_RECOGNITION = 2
|
|
||||||
CLIENT_SORTING = 3
|
|
||||||
PLAN_MOVEMENT = 4
|
|
||||||
EXECUTION = 5
|
|
||||||
|
|
||||||
|
|
||||||
class GameModel(Model):
|
class GameModel(Model):
|
||||||
|
|
||||||
def __init__(self, width, height, graph: GridWithWeights, items: int, orders: int, classificator,
|
def __init__(self, width, height, graph):
|
||||||
item_display_pos: List[GridLocation]):
|
|
||||||
|
|
||||||
# self.num_agents = 5
|
# self.num_agents = 5
|
||||||
self.first = True
|
|
||||||
self.item_recognised = False
|
|
||||||
self.running = True
|
self.running = True
|
||||||
self.grid = MultiGrid(height, width, True)
|
self.grid = MultiGrid(height, width, True)
|
||||||
self.schedule = RandomActivation(self)
|
self.schedule = RandomActivation(self)
|
||||||
self.current_item_recognition = None
|
self.agents = []
|
||||||
self.current_item = None
|
|
||||||
|
|
||||||
self.client_delivery: PatchAgent = None
|
|
||||||
self.drop_off: PatchAgent = None
|
|
||||||
self.graph = graph
|
|
||||||
self.cut_orders : List[Order] = []
|
|
||||||
|
|
||||||
self.game_constants = GameConstants(
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
graph.walls,
|
|
||||||
graph.puddles
|
|
||||||
)
|
|
||||||
|
|
||||||
self.agents = [AgentBase]
|
|
||||||
|
|
||||||
self.forklift_agent = ForkliftAgent(
|
|
||||||
self,
|
|
||||||
self.game_constants,
|
|
||||||
self.client_delivery,
|
|
||||||
self.drop_off,
|
|
||||||
self.graph
|
|
||||||
)
|
|
||||||
|
|
||||||
|
self.forklift_agent = ForkliftAgent(0, self)
|
||||||
self.schedule.add(self.forklift_agent)
|
self.schedule.add(self.forklift_agent)
|
||||||
self.agents.append(self.forklift_agent)
|
self.agents.append(self.forklift_agent)
|
||||||
self.item_display_agents: List[ItemDisplayAgent] = []
|
|
||||||
|
|
||||||
# INITIALIZATION #
|
|
||||||
print("############## INITIALIZATION ##############")
|
|
||||||
self.phase = Phase.INIT
|
|
||||||
self.initialize_grid(graph, item_display_pos)
|
|
||||||
self.orderList: List[Order] = InitialStateFactory.generate_order_list(orders)
|
|
||||||
self.fulfilled_orders: List[Order] = []
|
|
||||||
self.forklift_agent.fulfilled_orders = self.fulfilled_orders
|
|
||||||
self.forklift_agent.set_base(self.drop_off)
|
|
||||||
self.classificator = classificator
|
|
||||||
|
|
||||||
print("############## RECOGNISE ITEMS ##############")
|
|
||||||
self.phase = Phase.ITEM_RECOGNITION
|
|
||||||
self.provided_items = InitialStateFactory.generate_item_list(items)
|
|
||||||
self.items_for_recognization = copy.deepcopy(self.provided_items)
|
|
||||||
self.recognised_items: List[Item] = []
|
|
||||||
|
|
||||||
self.current_order_delivered_items = self.forklift_agent.current_order_delivered_items
|
|
||||||
|
|
||||||
print("Relocate forklift agent to loading area for item recognition")
|
|
||||||
|
|
||||||
pathFinder = PathFinderOnStates(
|
|
||||||
self.game_constants,
|
|
||||||
self.drop_off.location,
|
|
||||||
PathFinderState(self.forklift_agent.current_position, self.forklift_agent.current_rotation, 0,
|
|
||||||
Action(ActionType.NONE), [])
|
|
||||||
)
|
|
||||||
|
|
||||||
actions = pathFinder.get_action_list()
|
|
||||||
print("PATHFINDING")
|
|
||||||
print(actions)
|
|
||||||
self.forklift_agent.queue_movement_actions(actions)
|
|
||||||
self.current_order = self.forklift_agent.current_order
|
|
||||||
|
|
||||||
def initialize_grid(self, graph: GridWithWeights, item_display_pos):
|
|
||||||
print("INITIALIZING GRID")
|
|
||||||
# Add the agent to a random grid cell
|
# Add the agent to a random grid cell
|
||||||
x = 5
|
x = 5
|
||||||
y = 5
|
y = 5
|
||||||
self.grid.place_agent(self.forklift_agent, (x, y))
|
self.grid.place_agent(self.forklift_agent, (x, y))
|
||||||
self.forklift_agent.current_position = (x, y)
|
self.forklift_agent.current_position = (x, y)
|
||||||
|
|
||||||
self.picture_visualization = PictureVisualizationAgent(
|
start, goal = (x, y), (2, 1)
|
||||||
self,
|
came_from, cost_so_far = a_star_search(graph, start, goal)
|
||||||
(1, 11),
|
draw_grid(graph, point_to=came_from, start=start, goal=goal)
|
||||||
)
|
|
||||||
self.schedule.add(self.picture_visualization)
|
|
||||||
self.grid.place_agent(self.picture_visualization, self.picture_visualization.location)
|
|
||||||
self.agents.append(self.picture_visualization)
|
|
||||||
|
|
||||||
self.place_logistics()
|
path = map(lambda t: (t[0], inverse_y(height, t[1])),
|
||||||
self.place_dividers()
|
reconstruct_path(came_from=came_from, start=start, goal=goal))
|
||||||
self.place_walls_agents(graph.walls)
|
|
||||||
self.place_puddles(graph.puddles)
|
|
||||||
self.place_packing_stations(graph.packingStations)
|
|
||||||
self.place_order_items_display(item_display_pos)
|
|
||||||
|
|
||||||
def place_dividers(self):
|
print("cam from: {}".format(came_from))
|
||||||
for i in range(0, 10):
|
print("costerino: {}".format(cost_so_far))
|
||||||
for j in range(10, 13):
|
draw_grid(graph, path=reconstruct_path(came_from, start=start, goal=goal))
|
||||||
agent = PatchAgent(self, (i, j), PatchType.divider)
|
|
||||||
self.agents.append(agent)
|
|
||||||
self.grid.place_agent(agent, (i, j))
|
|
||||||
|
|
||||||
def place_logistics(self):
|
self.forklift_agent.assign_new_movement_task(path)
|
||||||
agent = PatchAgent(self, (self.grid.width - 1, int(self.grid.height / 2)), PatchType.pickUp)
|
|
||||||
self.schedule.add(agent)
|
agent = PatchAgent(1, self, PatchType.pickUp)
|
||||||
self.grid.place_agent(agent, agent.location)
|
# self.schedule.add(agent)
|
||||||
|
self.grid.place_agent(agent, (self.grid.width - 1, self.grid.height - 1))
|
||||||
self.agents.append(agent)
|
self.agents.append(agent)
|
||||||
self.client_delivery = agent
|
|
||||||
self.forklift_agent.client_delivery = self.client_delivery
|
|
||||||
|
|
||||||
agent = PatchAgent(self, (0, int(self.grid.height / 2)), PatchType.dropOff)
|
agent = PatchAgent(2, self, PatchType.dropOff)
|
||||||
self.grid.place_agent(agent, agent.location)
|
# self.schedule.add(agent)
|
||||||
|
self.grid.place_agent(agent, (0, self.grid.height - 1))
|
||||||
self.agents.append(agent)
|
self.agents.append(agent)
|
||||||
self.drop_off = agent
|
|
||||||
self.forklift_agent.drop_off = self.drop_off
|
|
||||||
|
|
||||||
def place_walls_agents(self, walls: List[GridLocation]):
|
for i in range(3):
|
||||||
for w in walls:
|
a = PatchAgent(i + 3, self, PatchType.item)
|
||||||
agent = PatchAgent(self, w, PatchType.wall)
|
self.agents.append(a)
|
||||||
self.agents.append(agent)
|
self.grid.place_agent(a, (i, 0))
|
||||||
self.grid.place_agent(agent, w)
|
|
||||||
|
|
||||||
def place_puddles(self, puddles: List[GridLocation]):
|
|
||||||
for p in puddles:
|
|
||||||
agent = PatchAgent(self, p, PatchType.diffTerrain)
|
|
||||||
self.agents.append(agent)
|
|
||||||
self.grid.place_agent(agent, p)
|
|
||||||
|
|
||||||
def place_packing_stations(self, packing_stations: List[Tuple[PatchType, GridLocation]]):
|
|
||||||
for p in packing_stations:
|
|
||||||
agent = PatchAgent(self, p[1], p[0])
|
|
||||||
self.agents.append(agent)
|
|
||||||
self.grid.place_agent(agent, p[1])
|
|
||||||
|
|
||||||
def place_order_items_display(self, item_positions: List[GridLocation]):
|
|
||||||
for p in item_positions:
|
|
||||||
agent = ItemDisplayAgent(self, p)
|
|
||||||
self.item_display_agents.append(agent)
|
|
||||||
self.grid.place_agent(agent, p)
|
|
||||||
|
|
||||||
def update_item_display(self):
|
|
||||||
self.current_item = self.forklift_agent.current_item
|
|
||||||
for i in range(4):
|
|
||||||
self.item_display_agents[i].image = None
|
|
||||||
if len(self.forklift_agent.current_order_delivered_items) > i:
|
|
||||||
self.item_display_agents[i].image = self.forklift_agent.current_order_delivered_items[i].image
|
|
||||||
|
|
||||||
def step(self):
|
def step(self):
|
||||||
self.schedule.step()
|
self.schedule.step()
|
||||||
|
|
||||||
|
print("update multiGrid")
|
||||||
|
|
||||||
self.grid.remove_agent(self.forklift_agent)
|
self.grid.remove_agent(self.forklift_agent)
|
||||||
self.grid.place_agent(self.forklift_agent, self.forklift_agent.current_position)
|
self.grid.place_agent(self.forklift_agent, self.forklift_agent.current_position)
|
||||||
self.update_item_display()
|
|
||||||
|
|
||||||
if self.phase == Phase.ITEM_RECOGNITION:
|
|
||||||
if not self.item_recognised and self.forklift_agent.current_position == self.drop_off.location:
|
|
||||||
|
|
||||||
if len(self.items_for_recognization) == 0:
|
|
||||||
print("FINISHED ITEM RECOGNITION")
|
|
||||||
self.item_recognised = True
|
|
||||||
self.phase = Phase.CLIENT_SORTING
|
|
||||||
self.forklift_agent.ready_for_execution = True
|
|
||||||
else:
|
|
||||||
print("BEGIN ITEM RECOGNITION, left: {}".format(len(self.items_for_recognization)))
|
|
||||||
item_to_recognise = self.items_for_recognization.pop()
|
|
||||||
self.picture_visualization.img = PathByEnum.get_random_path(item_to_recognise.real_type)
|
|
||||||
recognised = self.recognise_item(item_to_recognise)
|
|
||||||
self.recognised_items.append(recognised)
|
|
||||||
|
|
||||||
if self.phase == Phase.CLIENT_SORTING:
|
|
||||||
orders: [Order] = self.orderList
|
|
||||||
tree: DecisionTree = DecisionTree()
|
|
||||||
|
|
||||||
# CLIENT RECOGNITION
|
|
||||||
orders_with_prio = tree.get_data_good(orders)
|
|
||||||
|
|
||||||
# print("before:" )
|
|
||||||
# for i in range(len(orders_with_prio)):
|
|
||||||
# print("ORDER {}, PRIO: {}".format(orders_with_prio[i].id, orders_with_prio[i].priority))
|
|
||||||
|
|
||||||
# GENERICS SORTING
|
|
||||||
genericOrder: GeneticOrder = GeneticOrder(orders_with_prio)
|
|
||||||
new_orders = genericOrder.get_orders_sorted(orders)
|
|
||||||
|
|
||||||
# print("after:" )
|
|
||||||
# for i in range(len(new_orders)):
|
|
||||||
# print("ORDER {}, PRIO: {}".format(new_orders[i].id, new_orders[i].priority))
|
|
||||||
|
|
||||||
self.orderList = new_orders
|
|
||||||
self.count_recognised_items()
|
|
||||||
|
|
||||||
self.sort_orders()
|
|
||||||
|
|
||||||
self.forklift_agent.orderList = self.orderList
|
|
||||||
|
|
||||||
print("FINISHED CLIENT ORDER SORTING")
|
|
||||||
self.phase = Phase.EXECUTION
|
|
||||||
|
|
||||||
if self.phase == Phase.EXECUTION:
|
|
||||||
self.current_order = self.forklift_agent.current_order
|
|
||||||
pass
|
|
||||||
# print("Execution")
|
|
||||||
|
|
||||||
def sort_orders(self):
|
|
||||||
orders_to_fill: [Order] = []
|
|
||||||
cut_orders: [Order] = []
|
|
||||||
|
|
||||||
for i in range(len(self.orderList)):
|
|
||||||
o: Order = self.orderList[i]
|
|
||||||
refrige = self.count_item_type(o, ItemType.REFRIGERATOR)
|
|
||||||
shelf = self.count_item_type(o, ItemType.SHELF)
|
|
||||||
door = self.count_item_type(o, ItemType.DOOR)
|
|
||||||
|
|
||||||
if self.count_shelf - shelf >= 0 and self.count_refrige - refrige >= 0 and self.count_door - door >= 0:
|
|
||||||
self.count_shelf -= shelf
|
|
||||||
self.count_door -= door
|
|
||||||
self.count_refrige -= refrige
|
|
||||||
orders_to_fill.append(o)
|
|
||||||
else:
|
|
||||||
cut_orders.append(o)
|
|
||||||
|
|
||||||
self.cut_orders = cut_orders
|
|
||||||
self.orderList = orders_to_fill
|
|
||||||
self.forklift_agent.orderList = orders_to_fill
|
|
||||||
|
|
||||||
def count_item_type(self, o: Order, itemType: ItemType) -> int:
|
|
||||||
res = 0
|
|
||||||
for i in range(len(o.items)):
|
|
||||||
it: Item = o.items[i]
|
|
||||||
if it.guessed_type == itemType:
|
|
||||||
res += 1
|
|
||||||
|
|
||||||
return res
|
|
||||||
|
|
||||||
def count_recognised_items(self):
|
|
||||||
count_refrige: int = 0
|
|
||||||
count_door: int = 0
|
|
||||||
count_shelf: int = 0
|
|
||||||
|
|
||||||
for i in range(len(self.recognised_items)):
|
|
||||||
item: Item = self.recognised_items[i]
|
|
||||||
if item.guessed_type == ItemType.DOOR:
|
|
||||||
count_door += 1
|
|
||||||
elif item.guessed_type == ItemType.SHELF:
|
|
||||||
count_shelf += 1
|
|
||||||
else:
|
|
||||||
count_refrige += 1
|
|
||||||
|
|
||||||
self.count_door = count_door
|
|
||||||
self.count_shelf = count_shelf
|
|
||||||
self.count_refrige = count_refrige
|
|
||||||
|
|
||||||
def recognise_item(self, item: Item):
|
|
||||||
val = image_classification(self.picture_visualization.img, self.classificator)
|
|
||||||
print("VAL: {}".format(val))
|
|
||||||
|
|
||||||
if val == ItemType.DOOR:
|
|
||||||
item.guessed_type = ItemType.DOOR
|
|
||||||
elif val == ItemType.REFRIGERATOR:
|
|
||||||
item.guessed_type = ItemType.REFRIGERATOR
|
|
||||||
elif val == ItemType.SHELF:
|
|
||||||
item.guessed_type = ItemType.SHELF
|
|
||||||
|
|
||||||
return item
|
|
||||||
|
@ -1,89 +0,0 @@
|
|||||||
import random
|
|
||||||
|
|
||||||
from data.Item import Item
|
|
||||||
from data.Order import Order
|
|
||||||
from data.enum.ItemType import ItemType
|
|
||||||
from data.enum.Priority import Priority
|
|
||||||
from util.ClientParamsFactory import ClientParamsFactory
|
|
||||||
from util.PathByEnum import PathByEnum
|
|
||||||
|
|
||||||
|
|
||||||
class InitialStateFactory:
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def generate_item_list(output_list_size: int):
|
|
||||||
item_list: [Item] = []
|
|
||||||
for i in range(output_list_size):
|
|
||||||
item_list.append(InitialStateFactory.__generate_item())
|
|
||||||
|
|
||||||
return item_list
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def generate_order_list(output_order_list_size: int):
|
|
||||||
order_list: [Order] = []
|
|
||||||
for i in range(output_order_list_size):
|
|
||||||
order_list.append(InitialStateFactory.__generate_order())
|
|
||||||
|
|
||||||
return order_list
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def generate_order_list_XD(output_order_list_size: int):
|
|
||||||
order_list: [Order] = []
|
|
||||||
for i in range(output_order_list_size):
|
|
||||||
order_list.append(InitialStateFactory.__generate_order_XD())
|
|
||||||
|
|
||||||
return order_list
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def __generate_order_XD() -> Order:
|
|
||||||
order_size = random.randint(1, 4)
|
|
||||||
|
|
||||||
items: [Item] = []
|
|
||||||
for i in range(order_size):
|
|
||||||
items.append(InitialStateFactory.__generate_item())
|
|
||||||
|
|
||||||
time_base = random.randint(8, 20)
|
|
||||||
final_time = time_base * order_size
|
|
||||||
|
|
||||||
client_params = ClientParamsFactory.get_client_params()
|
|
||||||
|
|
||||||
x = random.randint(0, 3)
|
|
||||||
type = Priority.LOW
|
|
||||||
if x == 0:
|
|
||||||
type = Priority.MEDIUM
|
|
||||||
elif x == 1:
|
|
||||||
type = Priority.HIGH
|
|
||||||
|
|
||||||
x = random.randint(20, 300)
|
|
||||||
|
|
||||||
return Order(final_time, items, type, x, client_params)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def __generate_order() -> Order:
|
|
||||||
order_size = random.randint(1, 4)
|
|
||||||
|
|
||||||
items: [Item] = []
|
|
||||||
for i in range(order_size):
|
|
||||||
items.append(InitialStateFactory.__generate_item())
|
|
||||||
|
|
||||||
time_base = random.randint(8, 20)
|
|
||||||
final_time = time_base * order_size
|
|
||||||
|
|
||||||
client_params = ClientParamsFactory.get_client_params()
|
|
||||||
|
|
||||||
return Order(final_time, items, Priority.LOW, 0, client_params)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def generate_input_sequence(self, input_sequence_size):
|
|
||||||
sequence: [Item] = []
|
|
||||||
for i in range(0, input_sequence_size):
|
|
||||||
sequence.append(self.__generate_item())
|
|
||||||
|
|
||||||
return sequence
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def __generate_item() -> Item:
|
|
||||||
randomly_picked_type = random.choice(list(ItemType))
|
|
||||||
item = Item(randomly_picked_type, PathByEnum.get_random_path(randomly_picked_type))
|
|
||||||
item.guessed_type = item.real_type
|
|
||||||
return item
|
|
@ -1,10 +0,0 @@
|
|||||||
from PatchAgent import PatchAgent
|
|
||||||
from PatchType import PatchType
|
|
||||||
from util.PathDefinitions import GridLocation
|
|
||||||
|
|
||||||
|
|
||||||
class ItemDisplayAgent(PatchAgent):
|
|
||||||
|
|
||||||
def __init__(self, model, location: GridLocation):
|
|
||||||
self.image = None
|
|
||||||
super().__init__(model, location, patch_type=PatchType.itemDisplay)
|
|
@ -1,14 +1,11 @@
|
|||||||
from AgentBase import AgentBase
|
from mesa import Agent, Model
|
||||||
|
|
||||||
from PatchType import PatchType
|
from PatchType import PatchType
|
||||||
from util.PathDefinitions import GridLocation
|
|
||||||
|
|
||||||
|
|
||||||
class PatchAgent(AgentBase):
|
class PatchAgent(Agent):
|
||||||
|
|
||||||
def __init__(self, model, location: GridLocation, patch_type: PatchType):
|
def __init__(self, unique_id, model, type: PatchType):
|
||||||
self.location = location
|
super().__init__(unique_id, model)
|
||||||
self.patch_type = patch_type
|
self.type = type
|
||||||
super().__init__(model)
|
print("Created Patch Agent with ID: {}".format(unique_id))
|
||||||
|
|
||||||
def creation_log(self):
|
|
||||||
print("Created Patch Agent [id: {} ,type: {}]".format(self.unique_id, self.patch_type))
|
|
@ -4,11 +4,4 @@ import enum
|
|||||||
class PatchType(enum.Enum):
|
class PatchType(enum.Enum):
|
||||||
dropOff = 1
|
dropOff = 1
|
||||||
pickUp = 2
|
pickUp = 2
|
||||||
item = 3
|
item = 3
|
||||||
wall = 4
|
|
||||||
diffTerrain = 5
|
|
||||||
packingShelf = 6
|
|
||||||
packingRefrigerator = 7
|
|
||||||
packingDoor = 8
|
|
||||||
divider = 9
|
|
||||||
itemDisplay = 10
|
|
@ -1,13 +0,0 @@
|
|||||||
from AgentBase import AgentBase
|
|
||||||
from util.PathDefinitions import GridLocation
|
|
||||||
|
|
||||||
|
|
||||||
class PictureVisualizationAgent(AgentBase):
|
|
||||||
|
|
||||||
def __init__(self, model, location: GridLocation):
|
|
||||||
self.location = location
|
|
||||||
self.img = ""
|
|
||||||
super().__init__(model)
|
|
||||||
|
|
||||||
def creation_log(self):
|
|
||||||
print("Created Patch Agent [id: {} ,img: {}]".format(self.unique_id, self.img))
|
|
8
data/CATEGORY.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
from enum import Enum
|
||||||
|
|
||||||
|
|
||||||
|
class CATEGORY(Enum):
|
||||||
|
PIZZA = 1
|
||||||
|
PASTA = 2
|
||||||
|
EGG = 3
|
||||||
|
UNKNOWN = 4
|
@ -1,21 +0,0 @@
|
|||||||
from data.enum.CompanySize import CompanySize
|
|
||||||
|
|
||||||
|
|
||||||
class ClientParams:
|
|
||||||
def __init__(self,
|
|
||||||
payment_delay: int,
|
|
||||||
net_worth: int,
|
|
||||||
infuelnce_rate: int,
|
|
||||||
payed: bool,
|
|
||||||
is_skarbowka: bool,
|
|
||||||
membership: bool,
|
|
||||||
is_hat: bool,
|
|
||||||
company_size: CompanySize) -> None:
|
|
||||||
self.payment_delay = payment_delay
|
|
||||||
self.payed = payed
|
|
||||||
self.net_worth = net_worth
|
|
||||||
self.is_skarbowka = is_skarbowka
|
|
||||||
self.infuence_rate = infuelnce_rate
|
|
||||||
self.membership = membership
|
|
||||||
self.company_size = company_size
|
|
||||||
self.is_hat = is_hat
|
|
37
data/Game.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
from data import Direction
|
||||||
|
from data.CATEGORY import CATEGORY
|
||||||
|
from data.Item import Item
|
||||||
|
from data.Order import Order
|
||||||
|
from typing import Dict
|
||||||
|
|
||||||
|
class Game:
|
||||||
|
def __init__(self, id: int, agentPos: (int, int), agentDirection: Direction, deliveryPos: (int, int), orderPos: (int,int), stockPilePos: Dict,
|
||||||
|
deliveryItem: Item, carriedItem: Item, orderStock: Dict, orderList: [Order]):
|
||||||
|
self.agentDirection = agentDirection
|
||||||
|
self.id = id
|
||||||
|
self.agentPos = agentPos
|
||||||
|
self.deliveryPos = deliveryPos
|
||||||
|
self.orderPos = orderPos
|
||||||
|
self.stockPilePos = stockPilePos
|
||||||
|
self.deliveryItem = deliveryItem
|
||||||
|
self.carriedItem = carriedItem
|
||||||
|
self.orderStock = orderStock
|
||||||
|
self.orderList = orderList
|
||||||
|
|
||||||
|
def getCopy(self):
|
||||||
|
newGame = Game(self)
|
||||||
|
return newGame
|
||||||
|
# def move(self, x: int, y: int):
|
||||||
|
# self.agentPos = (x, y)
|
||||||
|
#
|
||||||
|
# def pickUp(self, item: Item):
|
||||||
|
# self.deliveryItem = item
|
||||||
|
#
|
||||||
|
# def drop(self, item: Item):
|
||||||
|
# self.deliveryItem = -1
|
||||||
|
#
|
||||||
|
# def identify(item: Item, category: CATEGORY):
|
||||||
|
# item.category = category
|
||||||
|
#
|
||||||
|
# def finishOrder(order: Order):
|
||||||
|
# order.id = -1
|
@ -1,20 +0,0 @@
|
|||||||
from typing import Dict
|
|
||||||
|
|
||||||
from data.Item import Item
|
|
||||||
from data.Order import Order
|
|
||||||
from data.enum.ItemType import ItemType
|
|
||||||
from util.PathDefinitions import GridLocation
|
|
||||||
|
|
||||||
|
|
||||||
class GameConstants:
|
|
||||||
def __init__(
|
|
||||||
self,
|
|
||||||
grid_width: int,
|
|
||||||
grid_height: int,
|
|
||||||
walls: [GridLocation],
|
|
||||||
diffTerrain: [GridLocation]
|
|
||||||
):
|
|
||||||
self.grid_width = grid_width
|
|
||||||
self.grid_height = grid_height
|
|
||||||
self.walls = walls
|
|
||||||
self.diffTerrain = diffTerrain
|
|
18
data/Item.py
@ -1,16 +1,8 @@
|
|||||||
from itertools import count
|
from data.CATEGORY import CATEGORY
|
||||||
|
|
||||||
from data.enum.ItemType import ItemType
|
|
||||||
|
|
||||||
|
|
||||||
class Item:
|
class Item:
|
||||||
id_counter = count(start=0)
|
def __init__(self, id: int, category: CATEGORY, price: int):
|
||||||
|
self.id = id
|
||||||
def __init__(self, item_type: ItemType, image):
|
self.category = category
|
||||||
self.id = next(self.id_counter)
|
self.price = price
|
||||||
self.real_type = item_type
|
|
||||||
self.image = image
|
|
||||||
self.guessed_type = None
|
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
|
||||||
return "|real: {} -- guessed: {}| \n".format(self.real_type, self.guessed_type)
|
|
7
data/JOB.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
from enum import Enum
|
||||||
|
|
||||||
|
|
||||||
|
class JOB(Enum):
|
||||||
|
FISHERMAN = 1
|
||||||
|
FIREFIGHTER = 2
|
||||||
|
POLICEMAN = 3
|
@ -1,26 +1,8 @@
|
|||||||
from itertools import count
|
from data.JOB import JOB
|
||||||
from typing import List
|
|
||||||
|
|
||||||
from data.ClientParams import ClientParams
|
|
||||||
from data.Item import Item
|
|
||||||
from data.enum.Priority import Priority
|
|
||||||
|
|
||||||
|
|
||||||
class Order:
|
class Order:
|
||||||
id_counter = count(start=0)
|
def __init__(self, id: int, money: int, job: JOB):
|
||||||
|
self.id = id
|
||||||
def __init__(self, time: int, items: [Item], priority: Priority, sum: int, client_params: ClientParams):
|
self.money = money
|
||||||
self.id = next(self.id_counter)
|
self.job = job
|
||||||
self.time = time
|
|
||||||
self.items: List[Item] = items
|
|
||||||
self.client_params = client_params
|
|
||||||
self.priority = priority
|
|
||||||
self.sum = sum
|
|
||||||
|
|
||||||
# def sum_items(self, items: [Item]):
|
|
||||||
# result = 0
|
|
||||||
# for i in range(len(items)):
|
|
||||||
# result += items[i]
|
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
|
||||||
return "items: {} priority: {}".format(self.items, self.priority)
|
|
@ -1,9 +1,9 @@
|
|||||||
from data.enum.ItemType import ItemType
|
from data.CATEGORY import CATEGORY
|
||||||
from data.Item import Item
|
from data.Item import Item
|
||||||
|
|
||||||
|
|
||||||
class StockPile:
|
class StockPile:
|
||||||
def __init__(self, id: ItemType, pos: (int, int), itemList: [Item], ):
|
def __init__(self, id: int, category: CATEGORY, itemList: [Item]):
|
||||||
self.id = id
|
self.id = id
|
||||||
self.pos = pos
|
self.category = category
|
||||||
self.itemList = itemList
|
self.itemList = itemList
|
@ -1,240 +0,0 @@
|
|||||||
DELAY,PAYED,NET-WORTH,INFLUENCE,SKARBOWKA,MEMBER,HAT,SIZE,PRIORITY
|
|
||||||
13,TRUE,13,20,FALSE,FALSE,TRUE,CompanySize.BIG,MEDIUM
|
|
||||||
3,FALSE,93,31,FALSE,TRUE,FALSE,CompanySize.SMALL,LOW
|
|
||||||
2,TRUE,8,93,FALSE,FALSE,FALSE,CompanySize.SMALL,MEDIUM
|
|
||||||
8,TRUE,43,77,TRUE,TRUE,TRUE,CompanySize.SMALL,HIGH
|
|
||||||
5,FALSE,79,71,FALSE,TRUE,TRUE,CompanySize.BIG,LOW
|
|
||||||
2,TRUE,14,46,FALSE,FALSE,FALSE,CompanySize.NORMAL,LOW
|
|
||||||
0,FALSE,18,16,TRUE,FALSE,TRUE,CompanySize.GIGANTISHE,HIGH
|
|
||||||
9,TRUE,33,79,FALSE,FALSE,TRUE,CompanySize.HUGE,HIGH
|
|
||||||
2,TRUE,38,48,FALSE,TRUE,TRUE,CompanySize.HUGE,HIGH
|
|
||||||
0,TRUE,79,66,FALSE,FALSE,FALSE,CompanySize.SMALL,MEDIUM
|
|
||||||
6,FALSE,21,33,FALSE,FALSE,FALSE,CompanySize.NORMAL,LOW
|
|
||||||
1,TRUE,79,43,FALSE,TRUE,TRUE,CompanySize.HUGE,HIGH
|
|
||||||
0,TRUE,42,60,TRUE,TRUE,TRUE,CompanySize.SMALL,HIGH
|
|
||||||
1,FALSE,59,25,TRUE,TRUE,TRUE,CompanySize.GIGANTISHE,HIGH
|
|
||||||
3,TRUE,88,50,FALSE,FALSE,TRUE,CompanySize.HUGE,HIGH
|
|
||||||
6,FALSE,0,4,FALSE,TRUE,TRUE,CompanySize.NO,LOW
|
|
||||||
13,FALSE,67,9,FALSE,TRUE,FALSE,CompanySize.NORMAL,LOW
|
|
||||||
10,TRUE,53,38,FALSE,TRUE,FALSE,CompanySize.NORMAL,MEDIUM
|
|
||||||
5,TRUE,26,64,FALSE,TRUE,TRUE,CompanySize.SMALL,MEDIUM
|
|
||||||
9,TRUE,32,79,FALSE,TRUE,FALSE,CompanySize.GIGANTISHE,MEDIUM
|
|
||||||
13,TRUE,95,94,FALSE,TRUE,FALSE,CompanySize.GIGANTISHE,HIGH
|
|
||||||
10,TRUE,0,58,FALSE,FALSE,FALSE,CompanySize.GIGANTISHE,MEDIUM
|
|
||||||
6,TRUE,86,91,FALSE,TRUE,TRUE,CompanySize.BIG,HIGH
|
|
||||||
8,TRUE,52,5,FALSE,FALSE,FALSE,CompanySize.GIGANTISHE,MEDIUM
|
|
||||||
8,TRUE,1,46,FALSE,FALSE,FALSE,CompanySize.HUGE,MEDIUM
|
|
||||||
6,TRUE,80,10,FALSE,TRUE,TRUE,CompanySize.NORMAL,HIGH
|
|
||||||
4,FALSE,29,53,FALSE,TRUE,TRUE,CompanySize.BIG,LOW
|
|
||||||
3,TRUE,49,35,TRUE,FALSE,TRUE,CompanySize.NORMAL,HIGH
|
|
||||||
4,TRUE,38,1,FALSE,TRUE,FALSE,CompanySize.BIG,MEDIUM
|
|
||||||
8,FALSE,88,96,FALSE,FALSE,FALSE,CompanySize.NO,LOW
|
|
||||||
6,TRUE,64,27,FALSE,FALSE,FALSE,CompanySize.HUGE,MEDIUM
|
|
||||||
5,TRUE,87,50,FALSE,FALSE,FALSE,CompanySize.BIG,MEDIUM
|
|
||||||
1,FALSE,87,29,TRUE,TRUE,TRUE,CompanySize.SMALL,HIGH
|
|
||||||
3,FALSE,63,52,FALSE,FALSE,FALSE,CompanySize.BIG,LOW
|
|
||||||
14,FALSE,74,33,FALSE,FALSE,FALSE,CompanySize.HUGE,LOW
|
|
||||||
10,TRUE,81,22,FALSE,FALSE,FALSE,CompanySize.NORMAL,LOW
|
|
||||||
14,TRUE,78,85,TRUE,TRUE,FALSE,CompanySize.HUGE,HIGH
|
|
||||||
0,TRUE,76,91,FALSE,TRUE,TRUE,CompanySize.GIGANTISHE,HIGH
|
|
||||||
8,TRUE,54,11,FALSE,FALSE,TRUE,CompanySize.BIG,MEDIUM
|
|
||||||
8,TRUE,52,92,FALSE,TRUE,FALSE,CompanySize.GIGANTISHE,MEDIUM
|
|
||||||
0,TRUE,86,29,FALSE,TRUE,FALSE,CompanySize.SMALL,LOW
|
|
||||||
9,TRUE,15,94,TRUE,FALSE,TRUE,CompanySize.HUGE,HIGH
|
|
||||||
14,FALSE,90,84,FALSE,TRUE,TRUE,CompanySize.NO,LOW
|
|
||||||
3,TRUE,68,30,FALSE,TRUE,TRUE,CompanySize.GIGANTISHE,HIGH
|
|
||||||
9,TRUE,14,39,FALSE,TRUE,TRUE,CompanySize.BIG,MEDIUM
|
|
||||||
5,TRUE,19,40,FALSE,FALSE,FALSE,CompanySize.NO,LOW
|
|
||||||
1,TRUE,17,71,FALSE,TRUE,FALSE,CompanySize.HUGE,MEDIUM
|
|
||||||
0,FALSE,41,97,FALSE,FALSE,TRUE,CompanySize.HUGE,LOW
|
|
||||||
2,FALSE,22,3,FALSE,TRUE,FALSE,CompanySize.NO,LOW
|
|
||||||
8,TRUE,14,64,FALSE,FALSE,TRUE,CompanySize.NORMAL,MEDIUM
|
|
||||||
4,TRUE,10,46,FALSE,FALSE,TRUE,CompanySize.NO,LOW
|
|
||||||
6,TRUE,39,75,FALSE,FALSE,FALSE,CompanySize.BIG,LOW
|
|
||||||
6,TRUE,96,68,FALSE,FALSE,TRUE,CompanySize.HUGE,HIGH
|
|
||||||
5,TRUE,60,10,TRUE,FALSE,TRUE,CompanySize.HUGE,HIGH
|
|
||||||
13,TRUE,6,73,FALSE,TRUE,FALSE,CompanySize.SMALL,LOW
|
|
||||||
2,FALSE,21,10,FALSE,TRUE,TRUE,CompanySize.GIGANTISHE,LOW
|
|
||||||
4,FALSE,34,59,FALSE,FALSE,TRUE,CompanySize.SMALL,LOW
|
|
||||||
11,TRUE,5,57,TRUE,FALSE,FALSE,CompanySize.HUGE,HIGH
|
|
||||||
5,TRUE,84,34,FALSE,FALSE,TRUE,CompanySize.GIGANTISHE,MEDIUM
|
|
||||||
7,TRUE,23,23,FALSE,TRUE,TRUE,CompanySize.HUGE,MEDIUM
|
|
||||||
1,TRUE,10,38,TRUE,TRUE,FALSE,CompanySize.SMALL,HIGH
|
|
||||||
3,TRUE,36,89,TRUE,TRUE,TRUE,CompanySize.BIG,HIGH
|
|
||||||
1,TRUE,12,33,FALSE,TRUE,TRUE,CompanySize.BIG,MEDIUM
|
|
||||||
4,FALSE,21,72,FALSE,FALSE,FALSE,CompanySize.NO,LOW
|
|
||||||
2,FALSE,34,44,FALSE,FALSE,FALSE,CompanySize.GIGANTISHE,LOW
|
|
||||||
8,TRUE,25,29,FALSE,TRUE,TRUE,CompanySize.HUGE,MEDIUM
|
|
||||||
2,TRUE,96,94,FALSE,FALSE,FALSE,CompanySize.NORMAL,MEDIUM
|
|
||||||
13,TRUE,91,0,FALSE,FALSE,TRUE,CompanySize.NO,LOW
|
|
||||||
13,TRUE,26,24,FALSE,FALSE,TRUE,CompanySize.BIG,MEDIUM
|
|
||||||
3,FALSE,96,43,TRUE,TRUE,FALSE,CompanySize.BIG,HIGH
|
|
||||||
12,TRUE,48,97,FALSE,FALSE,TRUE,CompanySize.SMALL,HIGH
|
|
||||||
10,TRUE,23,5,FALSE,TRUE,FALSE,CompanySize.NO,LOW
|
|
||||||
4,FALSE,77,98,FALSE,FALSE,TRUE,CompanySize.GIGANTISHE,LOW
|
|
||||||
4,FALSE,95,39,FALSE,FALSE,FALSE,CompanySize.HUGE,LOW
|
|
||||||
1,TRUE,33,40,FALSE,TRUE,TRUE,CompanySize.GIGANTISHE,MEDIUM
|
|
||||||
9,TRUE,2,11,FALSE,FALSE,FALSE,CompanySize.BIG,LOW
|
|
||||||
6,TRUE,90,62,TRUE,TRUE,FALSE,CompanySize.HUGE,HIGH
|
|
||||||
13,TRUE,53,62,FALSE,FALSE,FALSE,CompanySize.NORMAL,MEDIUM
|
|
||||||
9,TRUE,3,15,FALSE,TRUE,FALSE,CompanySize.NORMAL,LOW
|
|
||||||
7,TRUE,5,2,FALSE,TRUE,FALSE,CompanySize.NORMAL,LOW
|
|
||||||
6,TRUE,14,59,FALSE,FALSE,FALSE,CompanySize.BIG,MEDIUM
|
|
||||||
10,TRUE,93,58,FALSE,FALSE,FALSE,CompanySize.NORMAL,MEDIUM
|
|
||||||
8,TRUE,95,23,FALSE,TRUE,TRUE,CompanySize.SMALL,MEDIUM
|
|
||||||
14,TRUE,6,37,FALSE,TRUE,TRUE,CompanySize.HUGE,MEDIUM
|
|
||||||
9,TRUE,71,3,FALSE,TRUE,TRUE,CompanySize.GIGANTISHE,HIGH
|
|
||||||
8,TRUE,4,5,FALSE,FALSE,FALSE,CompanySize.SMALL,LOW
|
|
||||||
0,FALSE,32,8,FALSE,TRUE,FALSE,CompanySize.NORMAL,LOW
|
|
||||||
8,TRUE,20,43,FALSE,TRUE,TRUE,CompanySize.HUGE,MEDIUM
|
|
||||||
13,TRUE,50,44,FALSE,TRUE,TRUE,CompanySize.HUGE,MEDIUM
|
|
||||||
11,TRUE,59,93,FALSE,FALSE,FALSE,CompanySize.NO,MEDIUM
|
|
||||||
4,TRUE,65,34,FALSE,TRUE,TRUE,CompanySize.GIGANTISHE,LOW
|
|
||||||
12,FALSE,47,100,FALSE,TRUE,TRUE,CompanySize.GIGANTISHE,LOW
|
|
||||||
10,TRUE,65,97,FALSE,FALSE,TRUE,CompanySize.NORMAL,MEDIUM
|
|
||||||
9,FALSE,81,42,FALSE,FALSE,FALSE,CompanySize.GIGANTISHE,LOW
|
|
||||||
13,FALSE,28,21,FALSE,FALSE,FALSE,CompanySize.NO,LOW
|
|
||||||
9,FALSE,93,93,FALSE,FALSE,FALSE,CompanySize.BIG,LOW
|
|
||||||
7,TRUE,64,26,TRUE,TRUE,TRUE,CompanySize.HUGE,HIGH
|
|
||||||
10,FALSE,28,72,FALSE,TRUE,FALSE,CompanySize.HUGE,LOW
|
|
||||||
0,FALSE,34,50,FALSE,TRUE,TRUE,CompanySize.HUGE,LOW
|
|
||||||
9,FALSE,36,44,FALSE,FALSE,FALSE,CompanySize.HUGE,LOW
|
|
||||||
11,TRUE,63,1,FALSE,TRUE,TRUE,CompanySize.HUGE,MEDIUM
|
|
||||||
8,FALSE,38,34,FALSE,TRUE,FALSE,CompanySize.SMALL,LOW
|
|
||||||
3,TRUE,57,7,FALSE,FALSE,TRUE,CompanySize.HUGE,MEDIUM
|
|
||||||
14,FALSE,12,23,TRUE,FALSE,TRUE,CompanySize.NO,HIGH
|
|
||||||
4,TRUE,16,98,FALSE,TRUE,FALSE,CompanySize.GIGANTISHE,HIGH
|
|
||||||
5,TRUE,39,69,FALSE,FALSE,FALSE,CompanySize.NO,LOW
|
|
||||||
0,TRUE,82,77,TRUE,FALSE,FALSE,CompanySize.GIGANTISHE,HIGH
|
|
||||||
11,TRUE,84,64,FALSE,TRUE,TRUE,CompanySize.GIGANTISHE,HIGH
|
|
||||||
12,TRUE,71,77,TRUE,TRUE,FALSE,CompanySize.BIG,HIGH
|
|
||||||
8,TRUE,42,54,FALSE,TRUE,TRUE,CompanySize.GIGANTISHE,HIGH
|
|
||||||
1,TRUE,23,93,FALSE,FALSE,FALSE,CompanySize.NO,MEDIUM
|
|
||||||
1,TRUE,38,40,FALSE,TRUE,TRUE,CompanySize.NORMAL,MEDIUM
|
|
||||||
1,FALSE,33,11,FALSE,TRUE,TRUE,CompanySize.BIG,LOW
|
|
||||||
0,TRUE,5,56,FALSE,TRUE,TRUE,CompanySize.NO,MEDIUM
|
|
||||||
13,TRUE,49,71,FALSE,FALSE,TRUE,CompanySize.NO,MEDIUM
|
|
||||||
9,TRUE,64,29,FALSE,FALSE,TRUE,CompanySize.BIG,MEDIUM
|
|
||||||
8,TRUE,44,95,FALSE,TRUE,FALSE,CompanySize.BIG,MEDIUM
|
|
||||||
0,TRUE,40,3,FALSE,FALSE,FALSE,CompanySize.SMALL,LOW
|
|
||||||
2,TRUE,49,39,FALSE,TRUE,TRUE,CompanySize.NO,LOW
|
|
||||||
10,TRUE,4,94,FALSE,TRUE,TRUE,CompanySize.BIG,MEDIUM
|
|
||||||
0,TRUE,90,86,FALSE,TRUE,FALSE,CompanySize.SMALL,MEDIUM
|
|
||||||
14,TRUE,61,74,FALSE,FALSE,FALSE,CompanySize.GIGANTISHE,MEDIUM
|
|
||||||
3,TRUE,86,27,FALSE,FALSE,TRUE,CompanySize.NORMAL,MEDIUM
|
|
||||||
0,FALSE,47,19,FALSE,TRUE,FALSE,CompanySize.SMALL,LOW
|
|
||||||
7,FALSE,60,30,FALSE,TRUE,FALSE,CompanySize.NORMAL,LOW
|
|
||||||
13,TRUE,96,89,FALSE,FALSE,FALSE,CompanySize.NO,MEDIUM
|
|
||||||
7,TRUE,83,73,FALSE,TRUE,TRUE,CompanySize.HUGE,HIGH
|
|
||||||
7,TRUE,21,30,FALSE,FALSE,TRUE,CompanySize.NO,LOW
|
|
||||||
10,TRUE,26,41,FALSE,TRUE,TRUE,CompanySize.NO,LOW
|
|
||||||
13,FALSE,73,16,FALSE,TRUE,FALSE,CompanySize.NO,LOW
|
|
||||||
12,TRUE,30,54,TRUE,TRUE,TRUE,CompanySize.GIGANTISHE,HIGH
|
|
||||||
12,FALSE,9,52,FALSE,FALSE,FALSE,CompanySize.NORMAL,LOW
|
|
||||||
12,TRUE,28,10,FALSE,FALSE,FALSE,CompanySize.SMALL,LOW
|
|
||||||
2,FALSE,23,34,FALSE,TRUE,FALSE,CompanySize.NORMAL,LOW
|
|
||||||
6,TRUE,50,85,FALSE,TRUE,FALSE,CompanySize.NO,MEDIUM
|
|
||||||
10,TRUE,86,74,FALSE,TRUE,TRUE,CompanySize.SMALL,MEDIUM
|
|
||||||
10,TRUE,4,39,FALSE,FALSE,TRUE,CompanySize.GIGANTISHE,HIGH
|
|
||||||
3,TRUE,11,66,FALSE,TRUE,FALSE,CompanySize.NORMAL,MEDIUM
|
|
||||||
6,FALSE,31,1,FALSE,FALSE,TRUE,CompanySize.NO,LOW
|
|
||||||
8,TRUE,77,29,FALSE,FALSE,TRUE,CompanySize.BIG,MEDIUM
|
|
||||||
0,TRUE,85,91,FALSE,FALSE,FALSE,CompanySize.NO,MEDIUM
|
|
||||||
0,FALSE,51,68,FALSE,FALSE,FALSE,CompanySize.NORMAL,LOW
|
|
||||||
6,TRUE,54,32,FALSE,FALSE,TRUE,CompanySize.BIG,MEDIUM
|
|
||||||
8,FALSE,2,78,FALSE,FALSE,FALSE,CompanySize.HUGE,LOW
|
|
||||||
0,FALSE,92,47,FALSE,TRUE,FALSE,CompanySize.NORMAL,LOW
|
|
||||||
0,TRUE,9,34,TRUE,FALSE,TRUE,CompanySize.GIGANTISHE,HIGH
|
|
||||||
11,TRUE,3,40,FALSE,TRUE,TRUE,CompanySize.HUGE,HIGH
|
|
||||||
5,TRUE,6,58,FALSE,TRUE,TRUE,CompanySize.HUGE,HIGH
|
|
||||||
5,TRUE,27,61,FALSE,FALSE,TRUE,CompanySize.NO,LOW
|
|
||||||
2,TRUE,70,98,FALSE,TRUE,FALSE,CompanySize.NO,MEDIUM
|
|
||||||
6,TRUE,2,11,FALSE,FALSE,FALSE,CompanySize.HUGE,MEDIUM
|
|
||||||
3,TRUE,64,14,FALSE,TRUE,FALSE,CompanySize.NORMAL,MEDIUM
|
|
||||||
5,TRUE,63,84,FALSE,TRUE,TRUE,CompanySize.SMALL,HIGH
|
|
||||||
5,TRUE,72,32,FALSE,FALSE,TRUE,CompanySize.NORMAL,MEDIUM
|
|
||||||
8,TRUE,48,7,TRUE,TRUE,FALSE,CompanySize.GIGANTISHE,HIGH
|
|
||||||
11,FALSE,4,96,TRUE,FALSE,FALSE,CompanySize.NORMAL,HIGH
|
|
||||||
8,TRUE,60,76,FALSE,FALSE,FALSE,CompanySize.SMALL,LOW
|
|
||||||
4,TRUE,17,24,FALSE,FALSE,TRUE,CompanySize.GIGANTISHE,MEDIUM
|
|
||||||
9,TRUE,59,88,FALSE,TRUE,FALSE,CompanySize.NORMAL,HIGH
|
|
||||||
10,TRUE,95,79,FALSE,TRUE,FALSE,CompanySize.SMALL,MEDIUM
|
|
||||||
2,TRUE,59,20,FALSE,TRUE,FALSE,CompanySize.NO,LOW
|
|
||||||
7,TRUE,75,61,FALSE,FALSE,FALSE,CompanySize.GIGANTISHE,HIGH
|
|
||||||
1,TRUE,10,89,TRUE,FALSE,TRUE,CompanySize.GIGANTISHE,HIGH
|
|
||||||
6,TRUE,69,78,TRUE,TRUE,TRUE,CompanySize.NO,HIGH
|
|
||||||
5,TRUE,98,43,FALSE,TRUE,TRUE,CompanySize.GIGANTISHE,HIGH
|
|
||||||
4,TRUE,14,1,FALSE,TRUE,FALSE,CompanySize.SMALL,LOW
|
|
||||||
3,FALSE,56,85,FALSE,TRUE,TRUE,CompanySize.GIGANTISHE,LOW
|
|
||||||
0,TRUE,22,0,FALSE,FALSE,FALSE,CompanySize.BIG,MEDIUM
|
|
||||||
2,TRUE,28,61,FALSE,FALSE,FALSE,CompanySize.BIG,HIGH
|
|
||||||
14,TRUE,99,34,FALSE,FALSE,FALSE,CompanySize.GIGANTISHE,HIGH
|
|
||||||
3,TRUE,90,96,FALSE,TRUE,TRUE,CompanySize.BIG,HIGH
|
|
||||||
1,TRUE,25,98,FALSE,FALSE,TRUE,CompanySize.HUGE,HIGH
|
|
||||||
5,TRUE,16,49,FALSE,TRUE,TRUE,CompanySize.NORMAL,MEDIUM
|
|
||||||
0,TRUE,40,97,FALSE,TRUE,FALSE,CompanySize.SMALL,MEDIUM
|
|
||||||
0,TRUE,31,17,FALSE,TRUE,TRUE,CompanySize.NORMAL,MEDIUM
|
|
||||||
1,TRUE,43,4,FALSE,FALSE,TRUE,CompanySize.NORMAL,MEDIUM
|
|
||||||
5,TRUE,69,65,FALSE,TRUE,FALSE,CompanySize.SMALL,LOW
|
|
||||||
2,TRUE,45,9,FALSE,FALSE,TRUE,CompanySize.NORMAL,MEDIUM
|
|
||||||
5,FALSE,24,41,FALSE,FALSE,FALSE,CompanySize.BIG,LOW
|
|
||||||
0,TRUE,0,25,FALSE,TRUE,FALSE,CompanySize.BIG,MEDIUM
|
|
||||||
13,TRUE,41,91,TRUE,FALSE,TRUE,CompanySize.NORMAL,HIGH
|
|
||||||
5,TRUE,15,10,FALSE,TRUE,TRUE,CompanySize.GIGANTISHE,MEDIUM
|
|
||||||
5,TRUE,91,94,FALSE,TRUE,TRUE,CompanySize.HUGE,HIGH
|
|
||||||
9,TRUE,83,98,FALSE,TRUE,FALSE,CompanySize.HUGE,HIGH
|
|
||||||
12,TRUE,58,56,FALSE,FALSE,FALSE,CompanySize.BIG,MEDIUM
|
|
||||||
8,TRUE,78,39,FALSE,TRUE,FALSE,CompanySize.BIG,HIGH
|
|
||||||
12,TRUE,8,80,FALSE,TRUE,FALSE,CompanySize.NORMAL,MEDIUM
|
|
||||||
3,TRUE,80,52,FALSE,FALSE,TRUE,CompanySize.NORMAL,MEDIUM
|
|
||||||
12,TRUE,23,47,FALSE,TRUE,FALSE,CompanySize.BIG,MEDIUM
|
|
||||||
6,FALSE,21,94,TRUE,TRUE,FALSE,CompanySize.GIGANTISHE,HIGH
|
|
||||||
3,TRUE,32,58,FALSE,FALSE,FALSE,CompanySize.HUGE,MEDIUM
|
|
||||||
3,TRUE,74,26,FALSE,TRUE,FALSE,CompanySize.BIG,MEDIUM
|
|
||||||
0,TRUE,7,2,FALSE,TRUE,TRUE,CompanySize.BIG,MEDIUM
|
|
||||||
7,TRUE,90,32,FALSE,FALSE,FALSE,CompanySize.NO,LOW
|
|
||||||
8,TRUE,81,21,TRUE,FALSE,TRUE,CompanySize.NORMAL,HIGH
|
|
||||||
14,TRUE,84,54,FALSE,FALSE,FALSE,CompanySize.GIGANTISHE,HIGH
|
|
||||||
5,TRUE,99,96,FALSE,FALSE,TRUE,CompanySize.NO,MEDIUM
|
|
||||||
14,TRUE,93,12,TRUE,TRUE,FALSE,CompanySize.HUGE,HIGH
|
|
||||||
5,TRUE,17,34,FALSE,FALSE,FALSE,CompanySize.SMALL,LOW
|
|
||||||
3,TRUE,78,76,FALSE,TRUE,TRUE,CompanySize.GIGANTISHE,HIGH
|
|
||||||
9,FALSE,37,65,FALSE,TRUE,FALSE,CompanySize.GIGANTISHE,LOW
|
|
||||||
12,FALSE,61,84,FALSE,FALSE,FALSE,CompanySize.NO,LOW
|
|
||||||
11,FALSE,72,6,FALSE,FALSE,TRUE,CompanySize.GIGANTISHE,LOW
|
|
||||||
1,TRUE,54,38,FALSE,FALSE,TRUE,CompanySize.GIGANTISHE,MEDIUM
|
|
||||||
9,FALSE,35,72,FALSE,TRUE,FALSE,CompanySize.NORMAL,LOW
|
|
||||||
6,TRUE,77,86,FALSE,FALSE,FALSE,CompanySize.NO,MEDIUM
|
|
||||||
7,TRUE,52,75,FALSE,FALSE,FALSE,CompanySize.NORMAL,MEDIUM
|
|
||||||
5,TRUE,50,14,FALSE,FALSE,TRUE,CompanySize.GIGANTISHE,HIGH
|
|
||||||
13,FALSE,88,14,FALSE,FALSE,TRUE,CompanySize.BIG,LOW
|
|
||||||
13,FALSE,81,15,FALSE,FALSE,TRUE,CompanySize.GIGANTISHE,LOW
|
|
||||||
9,FALSE,99,73,FALSE,FALSE,FALSE,CompanySize.BIG,LOW
|
|
||||||
9,FALSE,18,50,FALSE,TRUE,FALSE,CompanySize.NO,LOW
|
|
||||||
9,FALSE,51,2,FALSE,FALSE,TRUE,CompanySize.NO,LOW
|
|
||||||
6,TRUE,30,68,FALSE,TRUE,FALSE,CompanySize.BIG,MEDIUM
|
|
||||||
7,FALSE,24,12,FALSE,TRUE,TRUE,CompanySize.GIGANTISHE,LOW
|
|
||||||
7,FALSE,22,3,FALSE,TRUE,TRUE,CompanySize.NORMAL,LOW
|
|
||||||
5,TRUE,95,61,FALSE,FALSE,FALSE,CompanySize.HUGE,LOW
|
|
||||||
12,FALSE,68,33,FALSE,FALSE,TRUE,CompanySize.NORMAL,LOW
|
|
||||||
7,TRUE,12,25,FALSE,TRUE,TRUE,CompanySize.NORMAL,LOW
|
|
||||||
8,FALSE,63,4,FALSE,FALSE,TRUE,CompanySize.GIGANTISHE,LOW
|
|
||||||
8,TRUE,82,18,FALSE,FALSE,TRUE,CompanySize.HUGE,HIGH
|
|
||||||
5,TRUE,56,85,FALSE,FALSE,FALSE,CompanySize.HUGE,MEDIUM
|
|
||||||
7,FALSE,96,29,FALSE,FALSE,TRUE,CompanySize.GIGANTISHE,LOW
|
|
||||||
9,FALSE,24,46,FALSE,TRUE,TRUE,CompanySize.BIG,LOW
|
|
||||||
9,FALSE,38,35,FALSE,TRUE,TRUE,CompanySize.NO,LOW
|
|
||||||
5,TRUE,52,89,FALSE,FALSE,FALSE,CompanySize.HUGE,MEDIUM
|
|
||||||
12,FALSE,94,52,FALSE,FALSE,FALSE,CompanySize.BIG,LOW
|
|
||||||
7,TRUE,36,27,FALSE,TRUE,TRUE,CompanySize.GIGANTISHE,MEDIUM
|
|
||||||
7,FALSE,78,76,FALSE,FALSE,FALSE,CompanySize.HUGE,LOW
|
|
||||||
8,FALSE,83,93,TRUE,FALSE,FALSE,CompanySize.NO,HIGH
|
|
||||||
9,FALSE,47,66,FALSE,TRUE,FALSE,CompanySize.HUGE,LOW
|
|
||||||
11,FALSE,39,78,FALSE,TRUE,FALSE,CompanySize.GIGANTISHE,LOW
|
|
||||||
9,FALSE,8,41,FALSE,TRUE,TRUE,CompanySize.NORMAL,LOW
|
|
||||||
10,FALSE,86,97,TRUE,FALSE,FALSE,CompanySize.HUGE,HIGH
|
|
||||||
7,TRUE,85,98,TRUE,FALSE,FALSE,CompanySize.GIGANTISHE,HIGH
|
|
||||||
11,FALSE,9,25,FALSE,TRUE,TRUE,CompanySize.NORMAL,LOW
|
|
||||||
3,TRUE,11,57,FALSE,TRUE,FALSE,CompanySize.BIG,LOW
|
|
||||||
13,FALSE,72,4,FALSE,FALSE,TRUE,CompanySize.NO,LOW
|
|
||||||
8,TRUE,24,28,FALSE,TRUE,TRUE,CompanySize.NO,LOW
|
|
|
@ -1,10 +0,0 @@
|
|||||||
from enum import Enum
|
|
||||||
|
|
||||||
|
|
||||||
class CompanySize(Enum):
|
|
||||||
BIG = 1
|
|
||||||
NORMAL = 2
|
|
||||||
SMALL = 3
|
|
||||||
NO = 4
|
|
||||||
HUGE = 5
|
|
||||||
GIGANTISHE = 6
|
|
@ -1,7 +0,0 @@
|
|||||||
from enum import Enum
|
|
||||||
|
|
||||||
|
|
||||||
class GeneticMutationType(Enum):
|
|
||||||
MUTATION = 1
|
|
||||||
CROSS = 2
|
|
||||||
REVERSE = 3
|
|
@ -1,7 +0,0 @@
|
|||||||
from enum import Enum
|
|
||||||
|
|
||||||
|
|
||||||
class ItemType(Enum):
|
|
||||||
DOOR = "door"
|
|
||||||
SHELF = "shelf"
|
|
||||||
REFRIGERATOR = "refrigerator"
|
|
@ -1,7 +0,0 @@
|
|||||||
from enum import Enum
|
|
||||||
|
|
||||||
|
|
||||||
class Priority(Enum):
|
|
||||||
HIGH = 1
|
|
||||||
MEDIUM = 2
|
|
||||||
LOW = 3
|
|
@ -1,9 +0,0 @@
|
|||||||
from data.Item import Item
|
|
||||||
from decision.ActionType import ActionType
|
|
||||||
|
|
||||||
|
|
||||||
class Action:
|
|
||||||
|
|
||||||
def __init__(self, action_type: ActionType, desired_item: Item = None):
|
|
||||||
self.desired_item = desired_item
|
|
||||||
self.action_type = action_type
|
|
@ -1,13 +0,0 @@
|
|||||||
from enum import Enum
|
|
||||||
|
|
||||||
|
|
||||||
class ActionType(Enum):
|
|
||||||
MOVE = 1
|
|
||||||
ROTATE_RIGHT = 2
|
|
||||||
ROTATE_DOWN = 3
|
|
||||||
ROTATE_LEFT = 4
|
|
||||||
ROTATE_UP = 5
|
|
||||||
PICK_ITEM = 6
|
|
||||||
DROP_ITEM = 7
|
|
||||||
SPECIAL = 8
|
|
||||||
NONE = 9
|
|
@ -1,23 +0,0 @@
|
|||||||
from data.enum.Direction import Direction
|
|
||||||
from data.Item import Item
|
|
||||||
from data.Order import Order
|
|
||||||
from data.enum.Priority import Priority
|
|
||||||
from decision.ActionType import ActionType
|
|
||||||
from util.PathDefinitions import GridLocation
|
|
||||||
|
|
||||||
|
|
||||||
class State:
|
|
||||||
def __init__(self,
|
|
||||||
action_taken: ActionType,
|
|
||||||
forklift_position: GridLocation,
|
|
||||||
forklift_rotation: Direction,
|
|
||||||
pending_orders: [Priority, [Order]],
|
|
||||||
filled_orders: [Order],
|
|
||||||
input_items: [Item]
|
|
||||||
):
|
|
||||||
self.action_taken = action_taken
|
|
||||||
self.forklift_position = forklift_position
|
|
||||||
self.forklift_rotation = forklift_rotation
|
|
||||||
self.pending_orders = pending_orders
|
|
||||||
self.filled_orders = filled_orders
|
|
||||||
self.input_items = input_items
|
|
@ -1,9 +0,0 @@
|
|||||||
from data.GameConstants import GameConstants
|
|
||||||
|
|
||||||
|
|
||||||
class ForkliftActions:
|
|
||||||
|
|
||||||
def __init__(self, game: GameConstants,
|
|
||||||
) -> None:
|
|
||||||
self.game = game
|
|
||||||
|
|
@ -1,218 +0,0 @@
|
|||||||
import itertools
|
|
||||||
import random
|
|
||||||
|
|
||||||
from data.Order import Order
|
|
||||||
from data.enum.GeneticMutationType import GeneticMutationType
|
|
||||||
from data.enum.Priority import Priority
|
|
||||||
|
|
||||||
|
|
||||||
class GeneticOrder:
|
|
||||||
mutation_chance = 10
|
|
||||||
reverse_chance = 60
|
|
||||||
cross_chance = 5
|
|
||||||
|
|
||||||
best_fit_special = 50
|
|
||||||
best_fit_super_special = 20
|
|
||||||
|
|
||||||
population_size = 200
|
|
||||||
number_of_populations = 1000
|
|
||||||
|
|
||||||
punish_low = 500
|
|
||||||
punish_med = 300
|
|
||||||
|
|
||||||
punish_sum = 50
|
|
||||||
|
|
||||||
def __init__(self, orders: [Order]) -> None:
|
|
||||||
self.orders = orders
|
|
||||||
|
|
||||||
def get_mutation_type(self) -> GeneticMutationType:
|
|
||||||
x = random.randint(0, self.mutation_chance + self.cross_chance + self.reverse_chance)
|
|
||||||
|
|
||||||
if x < self.mutation_chance:
|
|
||||||
return GeneticMutationType.MUTATION
|
|
||||||
|
|
||||||
if x > self.mutation_chance + self.cross_chance:
|
|
||||||
return GeneticMutationType.REVERSE
|
|
||||||
|
|
||||||
return GeneticMutationType.CROSS
|
|
||||||
|
|
||||||
def mutation(self, population: [int]) -> [int]:
|
|
||||||
x = random.randint(0, len(population) - 1)
|
|
||||||
y = random.randint(0, len(population) - 1)
|
|
||||||
while x == y:
|
|
||||||
y = random.randint(0, len(population) - 1)
|
|
||||||
|
|
||||||
result = population
|
|
||||||
|
|
||||||
pom = population[x]
|
|
||||||
result[x] = population[y]
|
|
||||||
result[y] = pom
|
|
||||||
|
|
||||||
if (result[x] == result[y]):
|
|
||||||
print("PIZDA I CHUJ")
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
def cross(self, population: [int]) -> [int]:
|
|
||||||
x = random.randint(1, len(population) - 1)
|
|
||||||
|
|
||||||
result = []
|
|
||||||
|
|
||||||
for i in range(len(population)):
|
|
||||||
result.append(population[(i + x) % len(population)])
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
def reverse(self, population: [int]) -> [int]:
|
|
||||||
x = random.randint(0, len(population))
|
|
||||||
y = random.randint(0, len(population) - 1)
|
|
||||||
while y - x > 2 or x >= y:
|
|
||||||
x = random.randint(0, len(population))
|
|
||||||
y = random.randint(0, len(population) - 1)
|
|
||||||
|
|
||||||
result = []
|
|
||||||
# print("X: ", x, " y: ", y)
|
|
||||||
|
|
||||||
for i in range(len(population)):
|
|
||||||
if x <= i <= y:
|
|
||||||
new_i = i - x
|
|
||||||
# print("len:", len(population), " new_i: ", new_i)
|
|
||||||
result.append(population[y - new_i])
|
|
||||||
else:
|
|
||||||
result.append(population[i])
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
def generate_first_population(self, k: int) -> [[int]]:
|
|
||||||
result = []
|
|
||||||
|
|
||||||
s = range(len(self.orders))
|
|
||||||
p = itertools.permutations(s)
|
|
||||||
while len(result) < k:
|
|
||||||
n = p.__next__()
|
|
||||||
if n not in result:
|
|
||||||
result.append(n)
|
|
||||||
|
|
||||||
return [list(x) for x in result]
|
|
||||||
|
|
||||||
# result = itertools.permutations(range(len(self.orders)))
|
|
||||||
#
|
|
||||||
# return [list(x) for x in result]
|
|
||||||
|
|
||||||
def correct_sum(self, last_prio: Priority, last_sum: float, o: Order) -> bool:
|
|
||||||
if o.priority == last_prio:
|
|
||||||
return last_sum > o.sum / o.time
|
|
||||||
return True
|
|
||||||
|
|
||||||
def sum_wrong(self, member: [int]) -> int:
|
|
||||||
last_high = 0
|
|
||||||
last_med = 0
|
|
||||||
last_prio = Priority.HIGH
|
|
||||||
last_sum = 0
|
|
||||||
counter = 0
|
|
||||||
|
|
||||||
for i in range(len(member)):
|
|
||||||
o: Order = self.orders[member[i]]
|
|
||||||
if o.priority == Priority.HIGH:
|
|
||||||
last_high = i
|
|
||||||
elif o.priority == Priority.MEDIUM:
|
|
||||||
last_med = i
|
|
||||||
|
|
||||||
if not self.correct_sum(last_prio, last_sum, o):
|
|
||||||
counter += int(last_sum - (o.sum / o.time))
|
|
||||||
last_prio = o.priority
|
|
||||||
last_sum = o.sum / o.time
|
|
||||||
|
|
||||||
for i in range(last_high):
|
|
||||||
o: Order = self.orders[member[i]]
|
|
||||||
if o.priority == Priority.MEDIUM:
|
|
||||||
counter += self.punish_med
|
|
||||||
elif o.priority == Priority.LOW:
|
|
||||||
counter += self.punish_low
|
|
||||||
|
|
||||||
for i in range(last_med):
|
|
||||||
o: Order = self.orders[member[i]]
|
|
||||||
if o.priority == Priority.LOW:
|
|
||||||
counter += self.punish_low
|
|
||||||
|
|
||||||
return counter
|
|
||||||
|
|
||||||
def evaluate(self, member: [int]) -> int:
|
|
||||||
# result = 0
|
|
||||||
# for i in range(len(self.orders) - 1):
|
|
||||||
# x: Order = self.orders[member[i]]
|
|
||||||
# y: Order = self.orders[member[i + 1]]
|
|
||||||
#
|
|
||||||
# if ((x.priority == Priority.MEDIUM or x.priority == Priority.LOW) and y.priority == Priority.HIGH) or (x.priority == Priority.LOW and y.priority == Priority.MEDIUM):
|
|
||||||
# result += 30
|
|
||||||
#
|
|
||||||
# if x.sum / x.time < y.sum / y.time:
|
|
||||||
# result += int(y.sum / y.time)
|
|
||||||
|
|
||||||
# return result
|
|
||||||
|
|
||||||
return self.sum_wrong(member)
|
|
||||||
|
|
||||||
def mutate_population(self, order_population: [[int]]) -> [[int]]:
|
|
||||||
result = []
|
|
||||||
|
|
||||||
for i in range(len(order_population)):
|
|
||||||
member: [int] = order_population[i]
|
|
||||||
operation: GeneticMutationType = self.get_mutation_type()
|
|
||||||
|
|
||||||
if operation == GeneticMutationType.MUTATION:
|
|
||||||
member = self.mutation(member)
|
|
||||||
elif operation == GeneticMutationType.REVERSE:
|
|
||||||
member = self.reverse(member)
|
|
||||||
else:
|
|
||||||
member = self.cross(member)
|
|
||||||
|
|
||||||
result.append(member)
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
def get_next_population(self, population: [[int]]) -> [[int]]:
|
|
||||||
result = []
|
|
||||||
|
|
||||||
for i in range(len(population) - self.best_fit_special - self.best_fit_super_special):
|
|
||||||
result.append(population[i])
|
|
||||||
|
|
||||||
for i in range(self.best_fit_special):
|
|
||||||
x = random.randint(0, self.best_fit_special)
|
|
||||||
result.append(population[x])
|
|
||||||
|
|
||||||
for i in range(self.best_fit_super_special):
|
|
||||||
x = random.randint(0, self.best_fit_super_special)
|
|
||||||
result.append(population[x])
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
def get_orders_sorted(self, orders: [Order]) -> [Order]:
|
|
||||||
self.orders = orders
|
|
||||||
|
|
||||||
population: [[int]] = self.generate_first_population(self.population_size)
|
|
||||||
# print(population)
|
|
||||||
|
|
||||||
population.sort(key=self.evaluate)
|
|
||||||
best_fit: [int] = population[0]
|
|
||||||
|
|
||||||
for i in range(self.number_of_populations):
|
|
||||||
# print("population: ", i)
|
|
||||||
population = self.mutate_population(population)
|
|
||||||
population.sort(key=self.evaluate)
|
|
||||||
|
|
||||||
if self.evaluate(best_fit) > self.evaluate(population[0]):
|
|
||||||
best_fit = population[0]
|
|
||||||
|
|
||||||
# population = self.get_next_population(population).sort(key=self.evaluate)
|
|
||||||
|
|
||||||
if self.evaluate(best_fit) < self.evaluate(population[0]):
|
|
||||||
population[0] = best_fit
|
|
||||||
|
|
||||||
best: [int] = population[0]
|
|
||||||
result: [Order] = []
|
|
||||||
|
|
||||||
for i in range(len(best)):
|
|
||||||
result.append(self.orders[best[i]])
|
|
||||||
|
|
||||||
return result
|
|
@ -1,22 +0,0 @@
|
|||||||
import numpy as np
|
|
||||||
import tensorflow as tf
|
|
||||||
from tensorflow import keras
|
|
||||||
|
|
||||||
|
|
||||||
# loaded_model = keras.models.load_model("my_model")
|
|
||||||
|
|
||||||
def image_classification(path, model):
|
|
||||||
class_names = ['door', 'refrigerator', 'shelf']
|
|
||||||
|
|
||||||
img = tf.keras.utils.load_img(
|
|
||||||
path, target_size=(180, 180)
|
|
||||||
)
|
|
||||||
img_array = tf.keras.utils.img_to_array(img)
|
|
||||||
img_array = tf.expand_dims(img_array, 0) # Create a batch
|
|
||||||
|
|
||||||
predictions = model.predict(img_array)
|
|
||||||
score = tf.nn.softmax(predictions[0])
|
|
||||||
# print(class_names[np.argmax(score)])
|
|
||||||
return class_names[np.argmax(score)]
|
|
||||||
|
|
||||||
|
|
Before Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 8.6 KiB |
Before Width: | Height: | Size: 7.4 KiB |
Before Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 9.8 KiB |
Before Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 9.3 KiB |
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 6.5 KiB |
Before Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 7.5 KiB |
Before Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 7.1 KiB |
Before Width: | Height: | Size: 4.1 KiB |
Before Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 9.2 KiB |
Before Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 8.6 KiB |
Before Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 6.4 KiB |
Before Width: | Height: | Size: 8.5 KiB |
Before Width: | Height: | Size: 8.4 KiB |
Before Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 6.0 KiB |
Before Width: | Height: | Size: 7.0 KiB |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 6.9 KiB |
Before Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 5.6 KiB |
Before Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 7.9 KiB |
Before Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 6.8 KiB |
Before Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 7.8 KiB |
Before Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 8.5 KiB |
Before Width: | Height: | Size: 5.8 KiB |
Before Width: | Height: | Size: 8.4 KiB |
Before Width: | Height: | Size: 6.4 KiB |
Before Width: | Height: | Size: 6.8 KiB |
Before Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 6.0 KiB |
Before Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 7.1 KiB |
Before Width: | Height: | Size: 5.8 KiB |
Before Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 6.8 KiB |
Before Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 5.7 KiB |