scml.scml2020.services.controllers

Classes

StepController

A controller for managing a set of negotiations about selling or buying (but not both) starting/ending at some

SyncController

Will try to get the best deal which is defined as being nearest to the agent needs and with lowest price

Module Contents

class scml.scml2020.services.controllers.StepController(*args, target_quantity: int, is_seller: bool, step: int, urange: Tuple[int, int], product: int, partners: List[str], negotiator_type: negmas.sao.SAONegotiator, horizon: int, awi: negmas.AgentWorldInterface, parent_name: str, negotiations_concluded_callback: Callable[[int, bool], None], negotiator_params: Dict[str, Any] = None, max_retries: int = 2, **kwargs)[source]

Bases: negmas.sao.SAOController, negmas.events.Notifier

A controller for managing a set of negotiations about selling or buying (but not both) starting/ending at some specific time-step.

Parameters:
  • target_quantity – The quantity to be secured

  • is_seller – Is this a seller or a buyer

  • parent_name – Name of the parent

  • horizon – How many steps in the future to allow negotiations for selling to go for.

  • step – The simulation step that this controller is responsible about

  • urange – The range of unit prices used for negotiation

  • product – The product that this controller negotiates about

  • partners – A list of partners to negotiate with

  • negotiator_type – The type of the single negotiator used for all negotiations.

  • negotiator_params – The parameters of the negotiator used for all negotiations

  • max_retries – How many times can the controller try negotiating with each partner.

  • negotiations_concluded_callback – A method to be called with the step of this controller and whether is it a seller when all negotiations are concluded

  • *args – Position arguments passed to the base Controller constructor

  • **kwargs – Keyword arguments passed to the base Controller constructor

Remarks:

  • It uses whatever negotiator type on all of its negotiations and it assumes that the ufun will never change

  • Once it accumulates the required quantity, it ends all remaining negotiations

  • It assumes that all ufuns are identical so there is no need to keep a separate negotiator for each one and it instantiates a single negotiator that dynamically changes the AMI but always uses the same ufun.

join(negotiator_id: str, nmi: negmas.common.NegotiatorMechanismInterface, state: negmas.MechanismState, *, preferences: negmas.Preferences | None = None, ufun: negmas.UtilityFunction | None = None, role: str = 'agent') bool[source]

Called by the mechanism when the agent is about to enter a negotiation. It can prevent the agent from entering

Parameters:
  • negotiator_id – The negotiator ID

  • nmi (AgentMechanismInterface) – The negotiation.

  • state (TState) – The current state of the negotiation

  • preferences (Preferences) – The preferences.

  • ufun (BaseUtilityFunction) – The ufun function to use before any discounting (overrides preferences)

  • role (str) – role of the agent.

Returns:

bool indicating whether or not the agent accepts to enter.If False is returned it will not enter the negotiation.

propose(negotiator_id: str, state: negmas.MechanismState) negmas.Outcome | None[source]
respond(negotiator_id: str, state: negmas.MechanismState, source: str = '') negmas.ResponseType[source]
__str__()[source]

Return str(self).

create_negotiator(negotiator_type: str | Type[negmas.ControlledNegotiator] = None, name: str = None, cntxt: Any = None, **kwargs) negmas.ControlledNegotiator[source]

Creates a negotiator passing it the context

Parameters:
  • negotiator_type – Type of the negotiator to be created

  • name – negotiator name

  • cntxt – The context to be associated with this negotiator.

  • **kwargs – any key-value pairs to be passed to the negotiator constructor

Returns:

The negotiator to be controlled. None for failure

time_range(step, is_seller)[source]
on_negotiation_end(negotiator_id: str, state: negmas.MechanismState) None[source]

A call back called at each negotiation end

Parameters:
  • negotiator_id – The negotiator ID

  • stateTState or one of its descendants giving the state at which the negotiation ended.

class scml.scml2020.services.controllers.SyncController(*args, is_seller: bool, parent: scml.scml2020.components.trading.PredictionBasedTradingStrategy, price_weight=0.7, utility_threshold=0.9, time_threshold=0.9, **kwargs)[source]

Bases: negmas.sao.SAOSyncController

Will try to get the best deal which is defined as being nearest to the agent needs and with lowest price

utility(offer: Tuple[int, int, int], max_price: int) float[source]

A simple utility function

Remarks:
  • If the time is invalid or there is no need to get any more agreements at the given time, return -1000

  • Otherwise use the price-weight to calculate a linear combination of the price and the how much of the needs is satisfied by this contract

is_valid(negotiator_id: str, offer: negmas.Outcome) bool[source]
counter_all(offers: Dict[str, negmas.Outcome], states: Dict[str, negmas.sao.SAOState]) Dict[str, negmas.sao.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.

Remarks:
  • The response type CANNOT be WAIT.

best_proposal(nid: str) Tuple[negmas.Outcome | None, float][source]

Finds the best proposal for the given negotiation

Parameters:

nid – Negotiator ID

Returns:

The outcome with highest utility and the corresponding utility

first_proposals() Dict[str, negmas.Outcome][source]

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