Base class of all miners


Raw Material Generator

Module Contents

class scml.scml2019.miners.MiningProfile[source]
cv: float = 0.05[source]
alpha_t: float = 1.0[source]
alpha_q: float = 1.0[source]
alpha_u: float = 1.0[source]
beta_t: float = 1.0[source]
beta_q: float = 100.0[source]
beta_u: float = 100.0[source]
tau_t: float[source]
tau_q: float = 0.25[source]
tau_u: float = 1.0[source]
classmethod random()[source]
class scml.scml2019.miners.Miner(name: str | None = None, ufun: negmas.UtilityFunction | None = None)[source]

Bases: scml.scml2019.agent.SCML2019Agent, abc.ABC

Base class of all miners

class scml.scml2019.miners.ReactiveMiner(profiles: dict[int, MiningProfile] | None = None, negotiator_type=DEFAULT_NEGOTIATOR, n_retrials=0, reactive=True, name=None)[source]

Bases: Miner

Raw Material Generator

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

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

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

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

  • 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_inventory_change(product: int, quantity: int, cause: str) None[source]

Received whenever something moves in or out of the factory’s storage

  • product – Product index.

  • quantity – Negative value for products moving out and positive value for products moving in

  • cause

    The cause of the change. Possibilities include:

    • contract: Contract execution

    • insurance: Received from insurance company

    • bankruptcy: Liquidated due to bankruptcy

    • transport: Arrival of goods (when transportation delay in the system is > 0).

on_cash_transfer(amount: float, cause: str) None[source]

Received whenever money is transferred to the factory or from it.

  • amount – Amount of money (negative for transfers out of the factory, positive for transfers to it).

  • cause

    The cause of the change. Possibilities include:

    • contract: Contract execution

    • insurance: Received from insurance company

    • bankruptcy: Liquidated due to bankruptcy

    • transfer: Arrival of transferred money (when transfer delay in the system is > 0).

on_new_report(report: scml.scml2019.common.FinancialReport)[source]

Called whenever a financial report is published.


report – The financial report giving details of the standing of an agent at some time (see FinancialReport)


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

Called when a requested negotiation is rejected

  • 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.common.NegotiatorMechanismInterface)[source]

Called when a requested negotiation is accepted

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

Called whenever a negotiation ends with agreement

on_contract_signed(contract: negmas.situated.Contract) None[source]

Called whenever a contract is signed by all partners

on_contract_cancelled(contract: negmas.situated.Contract, rejectors: list[str]) None[source]

Called whenever at least a partner did not sign the contract

sign_contract(contract: negmas.situated.Contract) str | None[source]

Called after the signing delay from contract conclusion to sign the contract. Contracts become binding only after they are signed.

on_contract_nullified(contract: negmas.situated.Contract, bankrupt_partner: str, compensation: float) None[source]

Will be called whenever a contract the agent is involved in is nullified because another partner went bankrupt

on_agent_bankrupt(agent_id: str) None[source]

Will be called whenever any agent goes bankrupt


agent_id – The ID of the agent that went bankrupt


  • Agents can go bankrupt in two cases:

    1. Failing to pay one installments of a loan they bought and refusing (or being unable to) get another loan to pay it.

    2. Failing to pay a penalty on a sell contract they failed to honor (and refusing or being unable to get a loan to pay for it).

  • All built-in agents ignore this call and they use the bankruptcy list ONLY to decide whether or not to negotiate in their on_new_cfp and respond_to_negotiation_request callbacks by pulling the bulletin-board using the helper function is_bankrupt of their AWI.

confirm_partial_execution(contract: negmas.situated.Contract, breaches: list[negmas.situated.Breach]) bool[source]

Will be called whenever a contract cannot be fully executed due to breaches by the other partner.

  • contract – The contract that was breached

  • breaches – A list of all the breaches committed.


  • Will not be called if both partners committed breaches.

on_remove_cfp(cfp: scml.scml2019.common.CFP)[source]

Called when a new CFP for a product for which the agent registered interest is removed


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

on_negotiation_failure(partners: list[str], annotation: dict[str, Any], mechanism: negmas.common.NegotiatorMechanismInterface, state: negmas.common.MechanismState) None[source]

Called whenever a negotiation ends without agreement

set_profiles(profiles: dict[int, MiningProfile])[source]
_process_cfp(cfp: scml.scml2019.common.CFP)[source]
on_new_cfp(cfp: scml.scml2019.common.CFP)[source]

Called when a new CFP for a product for which the agent registered interest is published


Called by the simulator at every simulation step

confirm_contract_execution(contract: negmas.situated.Contract) bool[source]

Called before executing any agreement

respond_to_negotiation_request(cfp: scml.scml2019.common.CFP, partner: str) negmas.negotiators.Negotiator | None[source]

Called when a prospective partner requests a negotiation to start

set_renegotiation_agenda(contract: negmas.situated.Contract, breaches: list[negmas.situated.Breach]) negmas.situated.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

  • contract – The contract being breached

  • breaches – All breaches on contract


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

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

Called to respond to a renegotiation request

  • agenda

  • contract

  • breaches


confirm_loan(loan: scml.scml2019.common.Loan, bankrupt_if_rejected: bool) bool[source]

called by the world manager to confirm a loan if needed by the buyer of a contract that is about to be breached