AgentWorldInterface
- class negmas.situated.AgentWorldInterface(world: World, agent: Agent)[source]
Bases:
objectAgent World Interface class
Attributes Summary
A list of negotiation requests sent to this agent that are already accepted by it.
Current simulation step
Was the agent initialized (i.e. was init_() called).
Number of steps in a simulation
A list of the negotiation requests sent by this agent that are not yet accepted or rejected.
Returns the basic parameters of the world
Relative time of the simulation going from 0 to 1
The negotiations currently requested by the agent.
The negotiations currently requested by the agent as a mapping from mechanism ID to
RunningNegotiationInfoThe negotiations currently requested by the agent.
Returns the private state of the agent in that world
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: str | list[str] | None, query: Any, query_keys=False) dict[str, Any] | None[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) Any | None[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: str | None = 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: list[str] | str | None, *, query: Any | None = None, key: str | None = None, query_keys: bool = False, value: 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:
- execute(action: Action, callback: Callable[[Action, bool], Any] | None = 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_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[Issue] | tuple[Issue, ...], partners: list[str], req_id: str, roles: list[str] | None = None, annotation: dict[str, Any] | None = None, mechanism_name: str | None = None, mechanism_params: dict[str, Any] | None = None, group: str | None = 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
partnerswhen asking them to join the negotiationpartners – 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/
Agentor 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 ifroleswas 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
None (must also be)
my_role (then roles and)
None
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
negotiationsproperty.
- 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:
The function will create a request ID that will be used in callbacks
on_neg_request_acceptedand
- run_negotiation(issues: list[Issue], partners: list[str | Agent], negotiator: Negotiator, preferences: Preferences | None = None, caller_role: str | None = None, roles: list[str] | None = None, annotation: dict[str, Any] | None = None, mechanism_name: str | None = None, mechanism_params: dict[str, Any] | None = None) tuple[Contract, NegotiatorMechanismInterface] | None[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/
Agentor 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 ifroleswas passed as None.negotiator – The negotiator to be used in the negotiation
preferences – The preferences. 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
partnerswhen asking them to join the negotiationpartners – 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
None (must also be)
my_role (then roles and)
None
mechanism_params – A dict of parameters used to initialize the mechanism object
- 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: list[Issue] | list[list[Issue]], partners: list[list[str | Agent]], negotiators: list[Negotiator], preferences: list[Preferences] | None = None, caller_roles: list[str] | None = None, roles: list[list[str] | None] | None = None, annotations: list[dict[str, Any] | None] | None = None, mechanism_names: str | list[str] | None = None, mechanism_params: dict[str, Any] | list[dict[str, Any]] | None = None, all_or_none: bool = False) list[tuple[Contract, NegotiatorMechanismInterface]][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/
Agentor 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 ifroleswas 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
partnerswhen asking them to join the negotiationpartners – 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
None (must also be)
my_role (then roles and)
None
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 nmi (The mechanism info [None if the corresponding partner refused to negotiation])
- Return type:
A list of tuples each with two values