smia.behaviours.specific_handle_behaviours.handle_negotiation_behaviour module

class smia.behaviours.specific_handle_behaviours.handle_negotiation_behaviour.HandleNegotiationBehaviour(agent_object, received_acl_msg)[source]

Bases: CyclicBehaviour

This class implements the behaviour that handle a particular negotiation.

neg_value_event = None
myagent = None

the SPADE agent object of the SMIA agent.

targets_processed = {}

targets that their values have been processed

neg_value = None

value of the negotiation

async on_start()[source]

This method implements the initialization process of this behaviour.

async run()[source]

This method implements the logic of the behaviour.

async get_neg_value_with_criteria()[source]

This method gets the negotiation value based on a given criteria.

Returns:

value of the negotiation

Return type:

int

async send_propose_acl_msgs(targets=None)[source]

This method sends the FIPA-ACL messages with the PROPOSE performative in order to offer the negotiation value. If no targets are set, only a message is sent to distribute the communication load.

Parameters:

targets (list, optional) – the targets to whom the proposal message should be sent.

async request_remaining_neg_acl_msgs()[source]

This method sends the FIPA-ACL messages with a request for the PROPOSE message in order to obtain their negotiation value.

async handle_neg_values_tie(received_agent_id, received_neg_value)[source]

This method handles the situations where negotiation values tie. A seeded randomization process will be performed which will slightly modify the tied trading values and obtain a random winner. This method will be executed in all SMIA instances where the tie occurs, but since the ACL message thread is used as seed, they will all return the same result.

Parameters:
  • received_agent_id (str) – identifier of the received SMIA agent proposal with the tie.

  • received_neg_value (float) – received tie negotiation value

async exit_negotiation(is_winner, resolved_timestamp=None)[source]

This method is executed when the trade has ended, either as a winner or a loser. In any case, all the information of the negotiation is added to the global variable with all the information of all the negotiations

of the agent. The thread is used to differentiate the information of each negotiation, since this is the identifier of each one of them.

Parameters:
  • is_winner (bool) – it determines whether the SMIA has been the winner of the negotiation.

  • resolved_timestamp (int) – timestamp when the negotiation is resolved.