SCML2020Agent

class scml.scml2020.SCML2020Agent(name=None, type_postfix='', ufun=None)[source]

Bases: negmas.situated.situated.Agent

Base class for all SCML2020 agents (factory managers)

Attributes Summary

internal_state

Returns the internal state of the agent for debugging purposes

Methods Summary

before_step()

confirm_production(commands, balance, inventory)

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

init()

Called to initialize the agent after the world is initialized.

on_agent_bankrupt(agent, contracts, …)

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

on_contract_breached(contract, breaches, …)

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

on_contract_executed(contract)

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

on_failures(failures)

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

on_neg_request_accepted(req_id, mechanism)

Called when a requested negotiation is accepted

on_neg_request_rejected(req_id, by)

Called when a requested negotiation is rejected

on_negotiation_failure(partners, annotation, …)

Called whenever a negotiation ends without agreement

on_negotiation_success(contract, mechanism)

Called whenever a negotiation ends with agreement

respond_to_negotiation_request(initiator, …)

Called whenever another agent requests a negotiation with this agent.

respond_to_renegotiation_request(contract, …)

Called to respond to a renegotiation request

set_renegotiation_agenda(contract, breaches)

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

sign_all_contracts(contracts)

Signs all contracts

step()

Called by the simulator at every simulation step

step_()

Called at every time-step.

to_dict()

Attributes Documentation

internal_state

Returns the internal state of the agent for debugging purposes

Return type

Dict[str, Any]

Methods Documentation

before_step()[source]
confirm_production(commands, balance, inventory)[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 (ndarray) – an n_lines vector giving the process to be run at every line (NO_COMMAND indicates nothing to be processed

  • balance (int) – The current balance of the factory

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

Return type

ndarray

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.

init()[source]

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

on_agent_bankrupt(agent, contracts, quantities, compensation_money)[source]

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

Parameters
  • agent (str) – The ID of the agent that went bankrupt.

  • contracts (List[Contract]) – All future contracts between this agent and the bankrupt agent.

  • quantities (List[int]) – The actual quantities that these contracts will be executed at.

  • compensation_money (int) – 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

Return type

None

on_contract_breached(contract, breaches, resolution)[source]

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

Parameters
  • contract (Contract) – The contract

  • breaches (List[Breach]) – All breaches committed (even if they were resolved)

  • resolution (Optional[Contract]) – The resolution contract if re-negotiation was successful. None if not.

Return type

None

on_contract_executed(contract)[source]

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

Return type

None

on_failures(failures)[source]

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

Parameters

failures (List[ForwardRef]) – A list of Failure s.

Return type

None

on_neg_request_accepted(req_id, mechanism)[source]

Called when a requested negotiation is accepted

on_neg_request_rejected(req_id, by)[source]

Called when a requested negotiation is rejected

Parameters
  • req_id (str) – The request ID passed to _request_negotiation

  • by (Optional[List[str]]) – A list of agents that refused to participate or None if the failure was for another reason

on_negotiation_failure(partners, annotation, mechanism, state)[source]

Called whenever a negotiation ends without agreement

Return type

None

on_negotiation_success(contract, mechanism)[source]

Called whenever a negotiation ends with agreement

Return type

None

respond_to_negotiation_request(initiator, issues, annotation, mechanism)[source]

Called whenever another agent requests a negotiation with this agent.

Parameters
  • initiator (str) – The ID of the agent that requested this negotiation

  • issues (List[Issue]) – Negotiation issues

  • annotation (Dict[str, Any]) – Annotation attached with this negotiation

  • mechanism (AgentMechanismInterface) – The AgentMechanismInterface interface to the mechanism to be used for this negotiation.

Return type

Optional[Negotiator]

Returns

None to reject the negotiation, otherwise a negotiator

respond_to_renegotiation_request(contract, breaches, agenda)[source]

Called to respond to a renegotiation request

Parameters
  • agenda (RenegotiationRequest) –

  • contract (Contract) –

  • breaches (List[Breach]) –

Returns:

Return type

Optional[Negotiator]

set_renegotiation_agenda(contract, breaches)[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 (Contract) – The contract being breached

  • breaches (List[Breach]) – All breaches on contract

Return type

Optional[RenegotiationRequest]

Returns

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

sign_all_contracts(contracts)[source]

Signs all contracts

Return type

List[Optional[str]]

step()[source]

Called by the simulator at every simulation step

step_()[source]

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

to_dict()[source]