A oneshot agent structured in three components, state encoder, policy (action) and action decoder.

Module Contents

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:

  1. 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.

  2. 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.

  3. Action decoder (decode_action()) which takes the action generated from the policy and generates the appropriate set of responses to all partners.

  • 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] from act which is then passed as it is by decode_action . This is the default implementation of decode_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 type OneShotState

abstract act(state: Any) Any[source]

The main policy. Generates an action given a state

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.


A policy is a callable that receives a state and generates an action

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).

  • offers – Maps negotiator IDs to offers

  • states – Maps negotiator IDs to offers AT the time the offers were made.


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.

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

first_proposals() dict[str, negmas.outcomes.Outcome | None][source]

Gets a set of proposals to use for initializing the negotiation.


A dictionary mapping each negotiator (in self.negotiators dict) to an outcome to be used as the first proposal if the agent is to start a negotiation.