AgentWorldInterface

class negmas.situated.AgentWorldInterface(world, agent)[source]

Bases: object

Agent World Interface class

Attributes Summary

accepted_negotiation_requests

A list of negotiation requests sent to this agent that are already accepted by it.

current_step

Current simulation step

default_signing_delay

initialized

Was the agent initialized (i.e. was init_() called).

n_steps

Number of steps in a simulation

negotiation_requests

A list of the negotiation requests sent by this agent that are not yet accepted or rejected.

params

Returns the basic parameters of the world

relative_time

Relative time of the simulation going from 0 to 1

requested_negotiations

The negotiations currently requested by the agent.

running_mechanism_dicts

The negotiations currently requested by the agent as a mapping from mechanism ID to RunningNegotiationInfo

running_negotiations

The negotiations currently requested by the agent.

settings

state

Returns the private state of the agent in that world

unsigned_contracts

All contracts that are not yet signed.

Methods Summary

bb_query(section, query[, query_keys])

Returns all records in the given section/sections of the bulletin-board that satisfy the query

bb_read(section, key)

Reads the value associated with given key from the bulletin board

bb_record(section, value[, key])

Records data in the given section of the bulletin board

bb_remove(section, *[, query, key, ...])

Removes a value or a set of values from the bulletin Board

execute(action[, callback])

Executes an action in the world simulation

logdebug(msg)

Logs a WARNING message

logdebug_agent(msg)

Logs a WARNING message to the agent's log

logerror(msg)

Logs a WARNING message

logerror_agent(msg)

Logs a WARNING message to the agent's log

loginfo(msg)

Logs an INFO message

loginfo_agent(msg)

Logs an INFO message to the agent's log

logwarning(msg)

Logs a WARNING message

logwarning_agent(msg)

Logs a WARNING message to the agent's log

request_negotiation_about(issues, partners, ...)

Requests to start a negotiation with some other agents

run_negotiation(issues, partners, negotiator)

Runs a negotiation until completion

run_negotiations(issues, partners, negotiators)

Requests to run a set of negotiations simultaneously.

Attributes Documentation

accepted_negotiation_requests

A list of negotiation requests sent to this agent that are already accepted by it.

Remarks:
  • These negotiations did not start yet as they are still not accepted by all partners. Once that happens, they will be moved to running_negotiations

current_step

Current simulation step

default_signing_delay
initialized

Was the agent initialized (i.e. was init_() called)

n_steps

Number of steps in a simulation

negotiation_requests

A list of the negotiation requests sent by this agent that are not yet accepted or rejected.

Remarks:
  • These negotiations did not start yet as they are still not accepted by all partners. Once that happens, they will be moved to running_negotiations

params

Returns the basic parameters of the world

relative_time

Relative time of the simulation going from 0 to 1

requested_negotiations

The negotiations currently requested by the agent.

Returns:

A list of negotiation request information objects (NegotiationRequestInfo)

running_mechanism_dicts

The negotiations currently requested by the agent as a mapping from mechanism ID to RunningNegotiationInfo

Returns:

A list of negotiation information objects (RunningNegotiationInfo)

running_negotiations

The negotiations currently requested by the agent.

Returns:

A list of negotiation information objects (RunningNegotiationInfo)

settings
state

Returns the private state of the agent in that world

unsigned_contracts

All contracts that are not yet signed.

Methods Documentation

bb_query(section, query, query_keys=False)[source]

Returns all records in the given section/sections of the bulletin-board that satisfy the query

Parameters:
  • section (str | list[str] | None) – Either a section name, a list of sections or None specifying ALL public sections (see remarks)

  • query (Any) – The query which is USUALLY a dict with conditions on it when querying values and a RegExp when

  • keys (querying)

  • query_keys – Whether the query is to be applied to the keys or values.

Returns:

value pairs giving all records that satisfied the given requirements.

Return type:

  • A dictionary with key

Remarks:

  • A public section is a section with a name that does not start with an underscore

  • If a set of sections is given, and two records in different sections had the same key, only one of them will be returned

  • Key queries use regular expressions and match from the beginning using the standard re.match function

bb_read(section, key)[source]

Reads the value associated with given key from the bulletin board

Parameters:
  • section (str) – section name

  • key (str) – key

Return type:

Any | None

Returns:

Content of that key in the bulletin-board

bb_record(section, value, key=None)[source]

Records data in the given section of the bulletin board

Parameters:
  • section (str) – section name (can contain subsections separated by ‘/’)

  • key (str | None) – The key

  • value (Any) – The value

Return type:

None

bb_remove(section, *, query=None, key=None, query_keys=False, value=None)[source]

Removes a value or a set of values from the bulletin Board

Parameters:
  • section (list[str] | str | None) – The section

  • query (Any | None) – the query to use to select what to remove

  • key (str | None) – the key to remove (no need to give a full query)

  • query_keys (bool) – Whether to apply the query (if given) to keys or values

  • value (Any) – Value to be removed

Returns:

Success of failure

Return type:

bool

execute(action, callback=None)[source]

Executes an action in the world simulation

Return type:

bool

logdebug(msg)[source]

Logs a WARNING message

Parameters:

msg (str) – The message to log

Return type:

None

Returns:

logdebug_agent(msg)[source]

Logs a WARNING message to the agent’s log

Parameters:

msg (str) – The message to log

Return type:

None

Returns:

logerror(msg)[source]

Logs a WARNING message

Parameters:

msg (str) – The message to log

Return type:

None

Returns:

logerror_agent(msg)[source]

Logs a WARNING message to the agent’s log

Parameters:

msg (str) – The message to log

Return type:

None

Returns:

loginfo(msg)[source]

Logs an INFO message

Parameters:

msg (str) – The message to log

Return type:

None

Returns:

loginfo_agent(msg)[source]

Logs an INFO message to the agent’s log

Parameters:

msg (str) – The message to log

Return type:

None

Returns:

logwarning(msg)[source]

Logs a WARNING message

Parameters:

msg (str) – The message to log

Return type:

None

Returns:

logwarning_agent(msg)[source]

Logs a WARNING message to the agent’s log

Parameters:

msg (str) – The message to log

Return type:

None

Returns:

request_negotiation_about(issues, partners, req_id, roles=None, annotation=None, mechanism_name=None, mechanism_params=None, group=None)[source]

Requests to start a negotiation with some other agents

Parameters:
  • req_id (str)

  • issues (list[Issue] | tuple[Issue, ...]) – Negotiation issues

  • annotation (dict[str, Any] | None) – Extra information to be passed to the partners when asking them to join the negotiation

  • partners (list[str]) – A list of partners to participate in the negotiation. Note that the caller itself may not be in this list which makes it possible for an agent to request a negotaition that it does not participate in. If that is not to be allowed in some world, override this method and explicitly check for these kinds of negotiations and return False. If partners is passed as a single string/Agent or as a list containing a single string/Agent, then he caller will be added at the beginning of the list. This will only be done if roles was passed as None.

  • roles (list[str] | None) – The roles of different partners. If None then each role for each partner will be None

  • mechanism_name (str | None) – Name of the mechanism to use. It must be one of the mechanism_names that are supported by the

  • None (must also be)

  • my_role (then roles and)

  • None

  • mechanism_params (dict[str, Any] | None) – A dict of parameters used to initialize the mechanism object

  • group (str | None) – An opational identifier for the group to which this negotiation belongs. It is not used by the system but is logged for debugging purposes. Moreover, the agent have access to it through its negotiations property.

Return type:

bool

Returns:

List[“Agent”] the list of partners who rejected the negotiation if any. If None then the negotiation was accepted. If empty then the negotiation was not started from the world manager

Remarks:

on_neg_request_rejected

run_negotiation(issues, partners, negotiator, preferences=None, caller_role=None, roles=None, annotation=None, mechanism_name=None, mechanism_params=None)[source]

Runs a negotiation until completion

Parameters:
  • partners (list[str | Agent]) – A list of partners to participate in the negotiation. Note that the caller itself may not be in this list which makes it possible for an agent to request a negotaition that it does not participate in. If that is not to be allowed in some world, override this method and explicitly check for these kinds of negotiations and return False. If partners is passed as a single string/Agent or as a list containing a single string/Agent, then he caller will be added at the beginning of the list. This will only be done if roles was passed as None.

  • negotiator (Negotiator) – The negotiator to be used in the negotiation

  • preferences (Preferences | None) – The preferences. Only needed if the negotiator does not already know it

  • caller_role (str | None) – The role of the caller in the negotiation

  • issues (list[Issue]) – Negotiation issues

  • annotation (dict[str, Any] | None) – Extra information to be passed to the partners when asking them to join the negotiation

  • partners – A list of partners to participate in the negotiation

  • roles (list[str] | None) – The roles of different partners. If None then each role for each partner will be None

  • mechanism_name (str | None) – Name of the mechanism to use. It must be one of the mechanism_names that are supported by the

  • None (must also be)

  • my_role (then roles and)

  • None

  • mechanism_params (dict[str, Any] | None) – A dict of parameters used to initialize the mechanism object

Return type:

tuple[Contract, NegotiatorMechanismInterface] | None

Returns:

A Tuple of a contract and the nmi of the mechanism used to get it in case of success. None otherwise

run_negotiations(issues, partners, negotiators, preferences=None, caller_roles=None, roles=None, annotations=None, mechanism_names=None, mechanism_params=None, all_or_none=False)[source]

Requests to run a set of negotiations simultaneously. Returns after all negotiations are run to completion

Parameters:
  • partners (list[list[str | Agent]]) – A list of partners to participate in the negotiation. Note that the caller itself may not be in this list which makes it possible for an agent to request a negotaition that it does not participate in. If that is not to be allowed in some world, override this method and explicitly check for these kinds of negotiations and return False. If partners is passed as a single string/Agent or as a list containing a single string/Agent, then he caller will be added at the beginning of the list. This will only be done if roles was passed as None.

  • issues (list[Issue] | list[list[Issue]]) – Negotiation issues

  • negotiators (list[Negotiator]) – The negotiator to be used in the negotiation

  • ufuns – The utility function. Only needed if the negotiator does not already know it

  • caller_roles (list[str] | None) – The role of the caller in the negotiation

  • annotations (list[dict[str, Any] | None] | None) – Extra information to be passed to the partners when asking them to join the negotiation

  • partners – A list of partners to participate in the negotiation

  • roles (list[list[str] | None] | None) – The roles of different partners. If None then each role for each partner will be None

  • mechanism_names (str | list[str] | None) – Name of the mechanism to use. It must be one of the mechanism_names that are supported by the

  • None (must also be)

  • my_role (then roles and)

  • None

  • mechanism_params (dict[str, Any] | list[dict[str, Any]] | None) – A dict of parameters used to initialize the mechanism object

  • all_or_none (bool) – If true, either no negotiations will be started execpt if all partners accepted

Returns:

contract (None for failure) and nmi (The mechanism info [None if the corresponding partner refused to negotiation])

Return type:

A list of tuples each with two values