ItemDisplayAgent
This commit is contained in:
parent
153f16bcc0
commit
23950ba5b5
12
GameModel.py
12
GameModel.py
@ -9,6 +9,7 @@ from mesa.time import RandomActivation
|
||||
from AgentBase import AgentBase
|
||||
from ForkliftAgent import ForkliftAgent
|
||||
from InitialStateFactory import InitialStateFactory
|
||||
from ItemDisplayAgent import ItemDisplayAgent
|
||||
from PatchAgent import PatchAgent
|
||||
from PatchType import PatchType
|
||||
from PictureVisualizationAgent import PictureVisualizationAgent
|
||||
@ -36,7 +37,9 @@ class Phase(Enum):
|
||||
|
||||
class GameModel(Model):
|
||||
|
||||
def __init__(self, width, height, graph: GridWithWeights, items: int, orders: int, classificator):
|
||||
def __init__(self, width, height, graph: GridWithWeights, items: int, orders: int, classificator,
|
||||
item_display_pos: List[GridLocation]):
|
||||
|
||||
# self.num_agents = 5
|
||||
self.first = True
|
||||
self.item_recognised = False
|
||||
@ -68,6 +71,7 @@ class GameModel(Model):
|
||||
|
||||
self.schedule.add(self.forklift_agent)
|
||||
self.agents.append(self.forklift_agent)
|
||||
self.display_agents: List[ItemDisplayAgent] = []
|
||||
|
||||
# INITIALIZATION #
|
||||
print("############## INITIALIZATION ##############")
|
||||
@ -162,6 +166,12 @@ class GameModel(Model):
|
||||
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.display_agents.append(agent)
|
||||
self.grid.place_agent(agent, p)
|
||||
|
||||
def step(self):
|
||||
self.schedule.step()
|
||||
self.grid.remove_agent(self.forklift_agent)
|
||||
|
10
ItemDisplayAgent.py
Normal file
10
ItemDisplayAgent.py
Normal file
@ -0,0 +1,10 @@
|
||||
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)
|
@ -11,3 +11,4 @@ class PatchType(enum.Enum):
|
||||
packingRefrigerator = 7
|
||||
packingDoor = 8
|
||||
divider = 9
|
||||
itemDisplay = 10
|
||||
|
68
main.py
68
main.py
@ -3,6 +3,7 @@ import random
|
||||
|
||||
from mesa.visualization.ModularVisualization import ModularServer
|
||||
from mesa.visualization.modules import CanvasGrid
|
||||
from tensorflow import keras
|
||||
|
||||
from ForkliftAgent import ForkliftAgent
|
||||
from GameModel import GameModel
|
||||
@ -94,6 +95,8 @@ if __name__ == '__main__':
|
||||
|
||||
grid = CanvasGrid(agent_portrayal, gridWidth, gridHeight, scale * gridWidth, scale * gridHeight)
|
||||
|
||||
display_items = [(6, 11), (7, 11), (8, 11), (9, 11)]
|
||||
|
||||
readyText = DisplayAttributeElement("phase")
|
||||
# current_item = DisplayPictureElement("current_item_recognition")
|
||||
provided_itesm = DisplayItemListAttributeElement("provided_items")
|
||||
@ -107,69 +110,8 @@ if __name__ == '__main__':
|
||||
[grid, readyText, provided_itesm, recognised_items, ordersText,
|
||||
fulfilled_orders],
|
||||
"Automatyczny Wózek Widłowy",
|
||||
dict(width=gridHeight, height=gridWidth, graph=diagram, items=50, orders=20, classificator=model))
|
||||
|
||||
# def order_rule(order: Order):
|
||||
# return order.id
|
||||
#
|
||||
#
|
||||
# punish_low = 500
|
||||
# punish_med = 300
|
||||
# def sum_wrong(member: [Order]) -> int:
|
||||
# last_high = 0
|
||||
# last_med = 0
|
||||
#
|
||||
# sum_high = 0
|
||||
# sum_med = 0
|
||||
# sum_low = 0
|
||||
#
|
||||
# counter = 0
|
||||
#
|
||||
# for i in range(len(member)):
|
||||
# o: Order = member[i]
|
||||
# if o.priority == Priority.HIGH :
|
||||
# sum_high += 1
|
||||
# last_high = i
|
||||
# elif o.priority == Priority.MEDIUM:
|
||||
# sum_med += 1
|
||||
# last_med = i
|
||||
# else:
|
||||
# sum_low += 1
|
||||
#
|
||||
# for i in range(last_high):
|
||||
# o: Order = member[i]
|
||||
# if o.priority == Priority.MEDIUM:
|
||||
# counter += punish_med
|
||||
# elif o.priority == Priority.LOW:
|
||||
# counter += punish_low
|
||||
#
|
||||
# for i in range(last_med):
|
||||
# o: Order = member[i]
|
||||
# if o.priority == Priority.LOW:
|
||||
# counter += punish_low
|
||||
#
|
||||
# print("sum: high:", sum_high, "med:", sum_med, "low:", sum_low)
|
||||
# print("last_high:", last_high, "last_med:", last_med, "sum:", counter)
|
||||
# return counter
|
||||
#
|
||||
# orders = InitialStateFactory.generate_order_list_XD(20)
|
||||
# test: GeneticOrder = GeneticOrder(orders)
|
||||
# punish_low = test.punish_low
|
||||
# punish_med = test.punish_med
|
||||
#
|
||||
# print("SIEMA before: ")
|
||||
# sum_wrong(orders)
|
||||
# for i in orders:
|
||||
# print("id:", i.id, "priority:", i.priority, "sum/time:", i.sum/i.time)
|
||||
# # print("id:", i.id, "priority:", i.priority)
|
||||
#
|
||||
# newOrders = test.get_orders_sorted(orders)
|
||||
#
|
||||
# print("NAURA after:")
|
||||
# sum_wrong(newOrders)
|
||||
# for i in newOrders:
|
||||
# print("id:", i.id, "priority:", i.priority, "sum/time:", i.sum/i.time)
|
||||
# # print("id:", i.id, "priority:", i.priority)
|
||||
dict(width=gridHeight, height=gridWidth, graph=diagram, items=50, orders=3,
|
||||
classificator=model,item_display_pos=display_items))
|
||||
|
||||
server.port = 8888
|
||||
server.launch()
|
||||
|
Loading…
Reference in New Issue
Block a user