ReactiveMiner

class scml.scml2019.ReactiveMiner(profiles=None, negotiator_type='negmas.sao.AspirationNegotiator', n_retrials=0, reactive=True, name=None)[source]

Bases: scml.scml2019.Miner

Raw Material Generator

Methods Summary

confirm_contract_execution(contract)

Called before executing any agreement

confirm_loan(loan, bankrupt_if_rejected)

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

confirm_partial_execution(contract, breaches)

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

init()

Called to initialize the agent after the world is initialized.

on_agent_bankrupt(agent_id)

Will be called whenever any agent goes bankrupt

on_cash_transfer(amount, cause)

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

on_contract_breached(contract, breaches, …)

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

on_contract_cancelled(contract, rejectors)

Called whenever at least a partner did not sign the contract

on_contract_executed(contract)

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

on_contract_nullified(contract, …)

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

on_contract_signed(contract)

Called whenever a contract is signed by all partners

on_inventory_change(product, quantity, cause)

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

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

on_new_cfp(cfp)

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

on_new_report(report)

Called whenever a financial report is published.

on_remove_cfp(cfp)

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

respond_to_negotiation_request(cfp, partner)

Called when a prospective partner requests a negotiation to start

respond_to_renegotiation_request(contract, …)

Called to respond to a renegotiation request

set_profiles(profiles)

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_contract(contract)

Called after the signing delay from contract conclusion to sign the contract.

step()

Called by the simulator at every simulation step

Methods Documentation

confirm_contract_execution(contract)[source]

Called before executing any agreement

Return type

bool

confirm_loan(loan, bankrupt_if_rejected)[source]

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

Return type

bool

confirm_partial_execution(contract, breaches)[source]

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

Parameters
  • contract (Contract) – The contract that was breached

  • breaches (List[Breach]) – A list of all the breaches committed.

Remarks:

  • Will not be called if both partners committed breaches.

Return type

bool

init()[source]

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

on_agent_bankrupt(agent_id)[source]

Will be called whenever any agent goes bankrupt

Parameters

agent_id (str) – The ID of the agent that went bankrupt

Remarks:

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

Return type

None

on_cash_transfer(amount, cause)[source]

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

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

  • cause (str) –

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

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_cancelled(contract, rejectors)[source]

Called whenever at least a partner did not sign the contract

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_contract_nullified(contract, bankrupt_partner, compensation)[source]

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

Return type

None

on_contract_signed(contract)[source]

Called whenever a contract is signed by all partners

Return type

None

on_inventory_change(product, quantity, cause)[source]

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

Parameters
  • product (int) – Product index.

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

  • cause (str) –

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

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

on_new_cfp(cfp)[source]

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

on_new_report(report)[source]

Called whenever a financial report is published.

Parameters

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

Remarks:

on_remove_cfp(cfp)[source]

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

respond_to_negotiation_request(cfp, partner)[source]

Called when a prospective partner requests a negotiation to start

Return type

Optional[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_profiles(profiles)[source]
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_contract(contract)[source]

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

Return type

Optional[str]

step()[source]

Called by the simulator at every simulation step