scml.scml2020.agent

Implements the world class for the SCML2020 world

Module Contents

Classes

SCML2020Agent

Base class for all SCML2020 agents (factory managers)

OneShotAdapter

An adapter allowing agents developed for SCML-OneShot to run in

class scml.scml2020.agent.SCML2020Agent(name: str | None = None, type_postfix: str = '', preferences: negmas.preferences.Preferences | None = None, ufun: negmas.preferences.UtilityFunction | None = None)[source]

Bases: negmas.Agent

Base class for all SCML2020 agents (factory managers)

property internal_state: Dict[str, Any][source]

Returns the internal state of the agent for debugging purposes

reset()[source]
is_clean() bool[source]
init()[source]

Called to initialize the agent after the world is initialized. the AWI is accessible at this point.

before_step()[source]
step_()[source]

Called at every time-step. This function is called directly by the world.

step()[source]

Called by the simulator at every simulation step

to_dict()[source]
_respond_to_negotiation_request(initiator: str, partners: List[str], issues: List[negmas.Issue], annotation: Dict[str, Any], mechanism: negmas.NegotiatorMechanismInterface, role: str | None, req_id: str | None) negmas.Negotiator | None[source]

Called by the mechanism to ask for joining a negotiation. The agent can refuse by returning a None

Parameters:
  • initiator – The ID of the agent that initiated the negotiation request

  • partners – The partner list (will include this agent)

  • issues – The list of issues

  • annotation – Any annotation specific to this negotiation.

  • mechanism – The mechanism that started the negotiation

  • role – The role of this agent in the negotiation

  • req_id – The req_id passed to the AWI when starting the negotiation (only to the initiator).

Returns:

None to refuse the negotiation or a Negotiator object appropriate to the given mechanism to accept it.

Remarks:

  • It is expected that world designers will introduce a better way to respond and override this function to call it

on_contract_breached(contract: negmas.Contract, breaches: List[negmas.Breach], resolution: negmas.Contract | None) None[source]

Called after complete processing of a contract that involved a breach.

Parameters:
  • contract – The contract

  • breaches – All breaches committed (even if they were resolved)

  • resolution – The resolution contract if re-negotiation was successful. None if not.

on_contract_executed(contract: negmas.Contract) None[source]

Called after successful contract execution for which the agent is one of the partners.

set_renegotiation_agenda(contract: negmas.Contract, breaches: List[negmas.Breach]) negmas.RenegotiationRequest | None[source]

Received by partners in ascending order of their total breach levels in order to set the renegotiation agenda when contract execution fails

Parameters:
  • contract – The contract being breached

  • breaches – All breaches on contract

Returns:

Renegotiation agenda (issues to negotiate about to avoid reporting the breaches).

respond_to_renegotiation_request(contract: negmas.Contract, breaches: List[negmas.Breach], agenda: negmas.RenegotiationRequest) negmas.Negotiator | None[source]

Called to respond to a renegotiation request

Parameters:
  • agenda

  • contract

  • breaches

Returns:

on_neg_request_rejected(req_id: str, by: List[str] | None)[source]

Called when a requested negotiation is rejected

Parameters:
  • req_id – The request ID passed to _request_negotiation

  • by – A list of agents that refused to participate or None if the failure was for another reason

on_neg_request_accepted(req_id: str, mechanism: negmas.NegotiatorMechanismInterface)[source]

Called when a requested negotiation is accepted

on_negotiation_failure(partners: List[str], annotation: Dict[str, Any], mechanism: negmas.NegotiatorMechanismInterface, state: negmas.MechanismState) None[source]

Called whenever a negotiation ends without agreement

on_negotiation_success(contract: negmas.Contract, mechanism: negmas.NegotiatorMechanismInterface) None[source]

Called whenever a negotiation ends with agreement

on_agent_bankrupt(agent: str, contracts: List[negmas.Contract], quantities: List[int], compensation_money: int) None[source]

Called whenever a contract is nullified (because the partner is bankrupt)

Parameters:
  • agent – The ID of the agent that went bankrupt.

  • contracts – All future contracts between this agent and the bankrupt agent.

  • quantities – The actual quantities that these contracts will be executed at.

  • compensation_money – The compensation money that is already added to the agent’s wallet (if ANY).

Remarks:

  • compensation_money will be nonzero iff immediate_compensation is enabled for this world

on_failures(failures: List[scml.scml2020.common.Failure]) None[source]

Called whenever there are failures either in production or in execution of guaranteed transactions

Parameters:

failures – A list of Failure s.

respond_to_negotiation_request(initiator: str, issues: List[negmas.Issue], annotation: Dict[str, Any], mechanism: negmas.NegotiatorMechanismInterface) negmas.Negotiator | None[source]

Called whenever another agent requests a negotiation with this agent.

Parameters:
  • initiator – The ID of the agent that requested this negotiation

  • issues – Negotiation issues

  • annotation – Annotation attached with this negotiation

  • mechanism – The NegotiatorMechanismInterface interface to the mechanism to be used for this negotiation.

Returns:

None to reject the negotiation, otherwise a negotiator

confirm_production(commands: numpy.ndarray, balance: int, inventory) numpy.ndarray[source]

Called just before production starts at every time-step allowing the agent to change what is to be produced in its factory

Parameters:
  • commands – an n_lines vector giving the process to be run at every line (NO_COMMAND indicates nothing to be processed

  • balance – The current balance of the factory

  • inventory – an n_products vector giving the number of items available in the inventory of every product type.

Returns:

an n_lines vector giving the process to be run at every line (NO_COMMAND indicates nothing to be processed

Remarks:

  • Not called in SCML2020 competition.

  • The inventory will contain zero items of all products that the factory does not buy or sell

  • The default behavior is to just retrun commands confirming production of everything.

sign_all_contracts(contracts: List[negmas.Contract]) List[str | None][source]

Signs all contracts

class scml.scml2020.agent.OneShotAdapter(oneshot_type: str | scml.oneshot.agent.OneShotAgent, oneshot_params: Dict[str, Any], obj: scml.oneshot.agent.OneShotAgent | None = None, name=None, type_postfix='', ufun=None)[source]

Bases: scml.scml2020.components.signing.SignAll, scml.scml2020.components.production.DemandDrivenProductionStrategy, scml.scml2020.components.trading.MarketAwareTradePredictionStrategy, SCML2020Agent, negmas.situated.Adapter, scml.oneshot.mixins.OneShotUFunCreatorMixin

An adapter allowing agents developed for SCML-OneShot to run in SCML2020World simulations.

property price_multiplier[source]
property is_perishable: bool[source]

Are all products perishable (original design of OneShot)

property current_disposal_cost: float[source]

Cost of storing one unit (penalizes buying too much/ selling too little)

property current_storage_cost: float[source]

Cost of storing one unit (penalizes buying too much/ selling too little)

property current_shortfall_penalty: float[source]

Cost of failure to deliver one unit (penalizes buying too little / selling too much)

property allow_zero_quantity: bool[source]

Does negotiations allow zero quantity?

init()[source]

Called to initialize the agent after the world is initialized. the AWI is accessible at this point.

_make_issues(product)[source]
before_step()[source]
step()[source]

Called by the simulator at every simulation step

make_ufun(add_exogenous: bool)[source]
to_dict()[source]
respond_to_negotiation_request(initiator, issues, annotation, mechanism)[source]

Called whenever another agent requests a negotiation with this agent.

Parameters:
  • initiator – The ID of the agent that requested this negotiation

  • issues – Negotiation issues

  • annotation – Annotation attached with this negotiation

  • mechanism – The NegotiatorMechanismInterface interface to the mechanism to be used for this negotiation.

Returns:

None to reject the negotiation, otherwise a negotiator

get_disposal_cost() float[source]
get_shortfall_penalty_mean()[source]
get_disposal_cost_mean()[source]
get_shortfall_penalty_dev()[source]
get_disposal_cost_dev()[source]
get_storage_cost_mean()[source]
get_storage_cost_dev()[source]
get_profile()[source]
get_shortfall_penalty()[source]
get_current_balance()[source]
get_exogenous_output() Tuple[int, int][source]
get_exogenous_input() Tuple[int, int][source]