opensistemas-hub / osbrain

osBrain - A general-purpose multi-agent system module written in Python
https://osbrain.readthedocs.io/en/stable/
Apache License 2.0
175 stars 43 forks source link

How to implement broadcast? #319

Closed bangxiangyong closed 5 years ago

bangxiangyong commented 5 years ago

I'm trying to implement a contract net protocol: 1) where a coordinator publishes a request to many bidders 2) bidder replies the single coordinator with their own responses 3) coordinator collects all the responses from bidders into a list/array

How can I implement this and which communication type should I use? Thanks in advance.

Peque commented 5 years ago

Depends on your needs, but you probably want to use a server PUB and server PULL from the coordinator, then client SUB and client PUSH from the bidders. Those are basic communication patterns.

You should find all the information needed in the project's documentation. Please read the "About", the "Introduction and example" and the "Basic communication patterns" sections, in that order. It should be enough to start playing around with a simple architecture. :wink:

bangxiangyong commented 5 years ago

Thanks for the reply, I have tinkered around with the examples but wasn't sure which is the right combination of patterns to suit my need. I'll try with your suggestion above, sounds right to me.

Also, I just tried using SYNC-PUB-SUB, because it supports communication in both ways for one-to-many. But not sure of its drawback compared to other combinations such as coordinator sending multiple Request-Replies to its bidders.

Peque commented 5 years ago

It does not sound like you should be interested in SYNC-PUB-SUB for your application.

Whether or not you should be using REQ-REP instead of PUB-SUB + PUSH-PULL depends on your concerns. If bidders can come and go or if you want the system to keep running normally even if a bidder goes down, crashes or loses connection then you are probably interested more in a PUB-SUB communication pattern.