AgentWorldInterface

class negmas.situated.AgentWorldInterface(world: negmas.situated.World, agent: negmas.situated.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.

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_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_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: Optional[Union[str, List[str]]], query: Any, query_keys=False)Optional[Dict[str, Any]][source]

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

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

  • query – 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: str, key: str)Optional[Any][source]

Reads the value associated with given key from the bulletin board

Parameters
  • section – section name

  • key – key

Returns

Content of that key in the bulletin-board

bb_record(section: str, value: Any, key: Optional[str] = None)None[source]

Records data in the given section of the bulletin board

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

  • key – The key

  • value – The value

bb_remove(section: Optional[Union[str, List[str]]], *, query: Optional[Any] = None, key: Optional[str] = None, query_keys: bool = False, value: Optional[Any] = None)bool[source]

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

Parameters
  • section – The section

  • query – the query to use to select what to remove

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

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

  • value – Value to be removed

Returns

Success of failure

Return type

bool

execute(action: negmas.situated.Action, callback: Optional[Callable[[negmas.situated.Action, bool], Any]] = None)bool[source]

Executes an action in the world simulation

logdebug(msg: str)None[source]

Logs a WARNING message

Parameters

msg – The message to log

Returns:

logdebug_agent(msg: str)None[source]

Logs a WARNING message to the agent’s log

Parameters

msg – The message to log

Returns:

logerror(msg: str)None[source]

Logs a WARNING message

Parameters

msg – The message to log

Returns:

logerror_agent(msg: str)None[source]

Logs a WARNING message to the agent’s log

Parameters

msg – The message to log

Returns:

loginfo(msg: str)None[source]

Logs an INFO message

Parameters

msg – The message to log

Returns:

loginfo_agent(msg: str)None[source]

Logs an INFO message to the agent’s log

Parameters

msg – The message to log

Returns:

logwarning(msg: str)None[source]

Logs a WARNING message

Parameters

msg – The message to log

Returns:

logwarning_agent(msg: str)None[source]

Logs a WARNING message to the agent’s log

Parameters

msg – The message to log

Returns:

request_negotiation_about(issues: List[negmas.outcomes.Issue], partners: List[str], req_id: str, roles: Optional[List[str]] = None, annotation: Optional[Dict[str, Any]] = None, mechanism_name: Optional[str] = None, mechanism_params: Optional[Dict[str, Any]] = None, group: Optional[str] = None)bool[source]

Requests to start a negotiation with some other agents

Parameters
  • req_id

  • issues – Negotiation issues

  • annotation – 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. 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 – The roles of different partners. If None then each role for each partner will be None

  • mechanism_name – Name of the mechanism to use. It must be one of the mechanism_names that are supported by the

  • or None which means that the World should select the mechanism. If None (World) –

  • roles and my_role (then) –

  • also be None (must) –

  • mechanism_params – A dict of parameters used to initialize the mechanism object

  • group – 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.

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: Collection[negmas.outcomes.Issue], partners: Collection[Union[str, negmas.situated.Agent]], negotiator: negmas.negotiators.Negotiator, ufun: Optional[negmas.utilities.UtilityFunction] = None, caller_role: Optional[str] = None, roles: Optional[Collection[str]] = None, annotation: Optional[Dict[str, Any]] = None, mechanism_name: Optional[str] = None, mechanism_params: Optional[Dict[str, Any]] = None)Optional[Tuple[negmas.situated.Contract, negmas.common.AgentMechanismInterface]][source]

Runs a negotiation until completion

Parameters
  • partners – 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 – The negotiator to be used in the negotiation

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

  • caller_role – The role of the caller in the negotiation

  • issues – Negotiation issues

  • annotation – 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 – The roles of different partners. If None then each role for each partner will be None

  • mechanism_name – Name of the mechanism to use. It must be one of the mechanism_names that are supported by the

  • or None which means that the World should select the mechanism. If None (World) –

  • roles and my_role (then) –

  • also be None (must) –

  • mechanism_params – A dict of parameters used to initialize the mechanism object

Returns

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

run_negotiations(issues: Union[List[negmas.outcomes.Issue], List[List[negmas.outcomes.Issue]]], partners: List[List[Union[str, negmas.situated.Agent]]], negotiators: List[negmas.negotiators.Negotiator], ufuns: Optional[List[negmas.utilities.UtilityFunction]] = None, caller_roles: Optional[List[str]] = None, roles: Optional[List[Optional[List[str]]]] = None, annotations: Optional[List[Optional[Dict[str, Any]]]] = None, mechanism_names: Optional[Union[str, List[str]]] = None, mechanism_params: Optional[Union[Dict[str, Any], List[Dict[str, Any]]]] = None, all_or_none: bool = False)List[Tuple[negmas.situated.Contract, negmas.common.AgentMechanismInterface]][source]

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

Parameters
  • partners – 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 – Negotiation issues

  • negotiators – The negotiator to be used in the negotiation

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

  • caller_roles – The role of the caller in the negotiation

  • annotations – 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 – The roles of different partners. If None then each role for each partner will be None

  • mechanism_names – Name of the mechanism to use. It must be one of the mechanism_names that are supported by the

  • or None which means that the World should select the mechanism. If None (World) –

  • roles and my_role (then) –

  • also be None (must) –

  • mechanism_params – A dict of parameters used to initialize the mechanism object

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

Returns

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

Return type

A list of tuples each with two values