AgentWorldInterface
- class negmas.situated.AgentWorldInterface(world, agent)[source]
Bases:
object
Agent 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
RunningNegotiationInfo
The 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, 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 whenkeys (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_record(section, value, key=None)[source]
Records data in the given section of the bulletin board
- 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:
- Returns:
Success of failure
- Return type:
- 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 issuesannotation (
dict
[str
,Any
] |None
) – Extra information to be passed to thepartners
when asking them to join the negotiationpartners (
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 ifroles
was passed as None.roles (
list
[str
] |None
) – The roles of different partners. If None then each role for each partner will be Nonemechanism_name (
str
|None
) – Name of the mechanism to use. It must be one of the mechanism_names that are supported by theNone (must also be)
my_role (then roles and)
None
mechanism_params (
dict
[str
,Any
] |None
) – A dict of parameters used to initialize the mechanism objectgroup (
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 itsnegotiations
property.
- Return type:
- 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_accepted
and
- 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 ifroles
was passed as None.negotiator (
Negotiator
) – The negotiator to be used in the negotiationpreferences (
Preferences
|None
) – The preferences. Only needed if the negotiator does not already know itcaller_role (
str
|None
) – The role of the caller in the negotiationannotation (
dict
[str
,Any
] |None
) – Extra information to be passed to thepartners
when asking them to join the negotiationpartners – 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 Nonemechanism_name (
str
|None
) – Name of the mechanism to use. It must be one of the mechanism_names that are supported by theNone (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:
- 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 ifroles
was passed as None.issues (
list
[Issue
] |list
[list
[Issue
]]) – Negotiation issuesnegotiators (
list
[Negotiator
]) – The negotiator to be used in the negotiationufuns – 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 negotiationannotations (
list
[dict
[str
,Any
] |None
] |None
) – Extra information to be passed to thepartners
when asking them to join the negotiationpartners – 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 Nonemechanism_names (
str
|list
[str
] |None
) – Name of the mechanism to use. It must be one of the mechanism_names that are supported by theNone (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 objectall_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