mango_library.negotiation.core¶
This module implements some reacurring elements of neogtiation processes. Therfore a negotiation wrapper for some meta data is provided. Furthermore this module implements roles which can handle this meta data models and store them as central role data.
Role-Models:
* NegotiationModel: Stores information for all currently known negotiations
Messages:
* NeogtationMessage: Wrapper message for negotiation orientied content
Roles:
* NegotiationStarterRole: Starts a negotiation
* NegotiationParticipant: (abstract) Participates in a negotiation, stores the meta data
and wraps the real message in the negotiation wrapper message
- class mango_library.negotiation.core.Negotiation(coalition_id: uuid.UUID, negotiation_id: uuid.UUID, active: bool = True)¶
Modell for storing the data regarding a concrete negotiation
- property active: bool¶
Is seen as active
- Returns
True if active, False otherwise
- property coalition_id: uuid.UUID¶
Return the coalition id
- Returns
the UUID
- property negotiation_id: uuid.UUID¶
Return the negotiation id
- Returns
the UUID
- class mango_library.negotiation.core.NegotiationMessage(coalition_id: uuid.UUID, negotiation_id: uuid.UUID, message)¶
Message wrapper for negotiation messages.
- property coalition_id: uuid.UUID¶
Id of the coalition this negotiation belongs to
- Returns
UUID
- property messsage¶
Return the wrapped message
- Returns
wrapped message
- property negotiation_id: uuid.UUID¶
Id of the negotiation
- Returns
the id
- class mango_library.negotiation.core.NegotiationModel¶
Model for storing all metadata regarding negotiations
- add(negotiation_id: uuid.UUID, assignment: mango_library.negotiation.core.Negotiation)¶
Add a concrete negotiation
- Parameters
negotiation_id – the UUID of the negotiation
assignment – the assignment for the negotiation
- by_id(negotiation_id: uuid.UUID) → mango_library.negotiation.core.Negotiation¶
Get a negotiation by id
- Parameters
negotiation_id – id of the negotiation
- Returns
the negotiation
- exists(negotiation_id: uuid.UUID) → bool¶
Checks whether a negotiation exists
- Parameters
negotiation_id – id of the negotiation
- Returns
True if it exists, False otherwise
- class mango_library.negotiation.core.NegotiationParticipant¶
Abstract role for participating a negotiation. Handles the wrapper message and the internal agent model about the meta data of the negotiation.
- abstract handle(message, assignment: mango_library.coalition.core.CoalitionAssignment, negotiation: mango_library.negotiation.core.Negotiation, meta: Dict[str, Any])¶
Handle the message and execute the specific negotiation step.
- Parameters
message – the message
assignment – the assignment the negotiations is in
negotiation – the negotiation model
meta – meta data
- handle_msg(content: mango_library.negotiation.core.NegotiationMessage, meta: Dict[str, Any])¶
Handles any NegotiationMessages, updating the internal model of the agent.
- Parameters
content – the message
meta – meta
- is_applicable(content, meta)¶
Defines which messages can be handled by the role.
- Parameters
content – the content of the message
meta – the meta of the message
- Returns
True, when the message should be handled, False otherwise
- send(negotation: mango_library.negotiation.core.Negotiation, message, neighbor) → None¶
Send a negotiation message to the specified neighbor
- Parameters
negotation – the negotiation
message – the content you want to send
neighbor – the neighbor
- send_to_neighbors(assignment: mango_library.coalition.core.CoalitionAssignment, negotation: mango_library.negotiation.core.Negotiation, message)¶
Send a message to all neighbors
- Parameters
assignment – the coalition you want to use the neighbors of
negotation – the negotiation message
message – the message you want to send
- class mango_library.negotiation.core.NegotiationStarterRole(message_creator, coalition_model_matcher=None, coalition_uuid=None)¶
Starting role for a negotiation. Will use a specific negotiation message creator to start a negotiation within its coalition.
- setup()¶
Lifecycle hook in, which will be called on adding the role to agent. The role context is known from hereon.
- async start()¶
Start a negotiation. Send all neighbors a starting negotiation message.