scml.oneshot.policy
Module Contents
Classes
A oneshot agent structured in three components, state encoder, policy (action) and action decoder. |
- class scml.oneshot.policy.OneShotPolicy(*args, **kwargs)[source]
Bases:
scml.oneshot.agent.OneShotSyncAgent
,abc.ABC
A oneshot agent structured in three components, state encoder, policy (action) and action decoder.
The agent is divided into three components:
State encoder (encode_state()) which takes the current state of all negotiation mechanisms, access the awi as needed, and generates a state which can be of any type to be passed to the next component.
Policy (act()) which takes the state generated from the state encoder and returns an action which may be encoded as any type to be passed to the next component. The policy (i.e. `act` () method) is not supposed to access the AWI or any other members of the class. It is preferred to be a pure function. This makes it easy to test the policy at predefined conditions (i.e. states) without having to construct a simulation.
Action decoder (decode_action()) which takes the action generated from the policy and generates the appropriate set of responses to all partners.
- Remarks:
The simplest form of state encoder which is implemented by default is to return the
state
member of the AWI.The simplest form of action encoding is to simply return the responses as a
dict[str, SAOResponse]
fromact
which is then passed as it is bydecode_action
. This is the default implementation ofdecode_action
- encode_state(mechanism_states: dict[str, negmas.sao.common.SAOState]) Any [source]
Called to generate a state to be passed to the act() method. The default is all of
awi
of typeOneShotState
- decode_action(action: Any) dict[str, negmas.sao.common.SAOResponse] [source]
Generates offers to all partners from an encoded action. Default is to return the action as it is assuming it is a
dict[str, SAOResponse]
- encode_action(responses: dict[str, negmas.sao.common.SAOResponse]) dict[str, negmas.sao.common.SAOResponse] [source]
Receives offers for all partners and generates the corresponding action. Used mostly for debugging and testing.
- counter_all(offers: dict[str, negmas.outcomes.Outcome | None], states: dict[str, negmas.sao.common.SAOState]) dict[str, negmas.sao.common.SAOResponse] [source]
Calculate a response to all offers from all negotiators (negotiator ID is the key).
- Parameters:
offers – Maps negotiator IDs to offers
states – Maps negotiator IDs to offers AT the time the offers were made.
- Returns:
A dictionary mapping negotiator ID to an
SAOResponse
. The response per agent consist of a tuple. In case of acceptance or ending the negotiation the second item of the tuple should be None. In case of rejection, the second item should be the counter offer.
- Remarks:
The response type CANNOT be WAIT.
If the system determines that a loop is formed, the agent may
receive this call for a subset of negotiations not all of them.