You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to broadcast between agents, I want them to message each other constantly, but I'm not getting the agent to reply back.
I saw another similar issue (#74) , but I couldn't understand what should be done to solve it (sorry, I'm new to working with multi-agent systems).
To clarify, my project is to implement a framework so that allows the instantiation of strategies for Vehicle Routing Problem. The next step would be to implement contract net protocol, if you have any material that can help me I would appreciate it.
classPackage():
def__init__(self, id, volume, weight, location):
self.id=idself.volume=volumeself.weigth=weightself.location=locationclassDistributionCenter(Agent):
classDistributionBehaviour(CyclicBehaviour):
asyncdefon_start(self):
ic("-------------Testando Distribution-------------------")
#precisa do run, por padrão, ao começar um CyclicBehaviour ele procura o start (ñ necessario) e depois obrigatoriamente entre no runasyncdefrun(self):
msg=Message(to="Deliveryman********") # Instantiate the messagemsg.set_metadata("performative", "inform") # Set the "inform" FIPA performativepacote=Package(11111,234,89,12321412)
msg.body=json.dumps(Ex.para_dict(pacote)) # Set the message content (precisa ser em string)#ic(msg.prepare())awaitself.send(msg)
# stop agent from behaviourawaitself.agent.stop()
asyncdefreceive(self):
msg=awaitself.receive(timeout=10)
ifmsg:
ic("to aqui")
ic("Message received with content: {}".format(msg.body))
else:
print("Did not received any message after 10 seconds")
asyncdefon_end(self):
ic("Termiando Distribution")
#Necessario inicializar o Behaviour aqui asyncdefsetup(self):
ic("Agent starting . . .")
b=self.DistributionBehaviour()
template=Template()
template.set_metadata("performative", "inform")
self.add_behaviour(b, template)
classDeliveryman(Agent):
classDeliverymanBehaviour(CyclicBehaviour):
asyncdefon_start(self):
ic("--------------Testando Deliveryman----------------")
asyncdefrun(self):
ic("RecvBehav running")
msg=awaitself.receive(timeout=10) # wait for a message for 10 secondsifmsg:
msg_test=json.loads(msg.body)
ic("Message received with content: {}".format(msg_test))
else:
print("Did not received any message after 10 seconds")
msgD=Message(to="Distribution*******")
msgD.set_metadata("perfomative","inform")
msgD.body="Mensagem Recebida"awaitself.send(msgD)
# stop agent from behaviourawaitself.agent.stop()
asyncdefon_end(self):
ic("Finishing Deliverman")
asyncdefsetup(self):
ic("ReceiverAgent started")
b=self.DeliverymanBehaviour()
template=Template()
template.set_metadata("performative", "inform")
self.add_behaviour(b, template)
if__name__=="__main__":
DL=Deliveryman("Deliveryman****", "*******")
future=DL.start()
future.result()
#receiverDC=DistributionCenter("Distribution***","********")
DC.start()
#print(EC)Ex.Interrupt(DC, DL)
Here the output:
The text was updated successfully, but these errors were encountered:
@jhppires I think separating the listening and sending behaviours is optimal. I like sending behaviours to be oneshot and listening behaviours to be cyclic. when a message is received, fire off a one shot reply
Description
I'm trying to broadcast between agents, I want them to message each other constantly, but I'm not getting the agent to reply back.
I saw another similar issue (#74) , but I couldn't understand what should be done to solve it (sorry, I'm new to working with multi-agent systems).
To clarify, my project is to implement a framework so that allows the instantiation of strategies for Vehicle Routing Problem. The next step would be to implement contract net protocol, if you have any material that can help me I would appreciate it.
I will leave my email, for any reason: [email protected]
What I Did
Here is my code:
Here the output:
![image](https://user-images.githubusercontent.com/30126258/149007465-a581d5f3-8f06-4f5a-994f-6c74e8010732.png)
The text was updated successfully, but these errors were encountered: