SCML2019Agent

class scml.scml2019.SCML2019Agent(name=None, ufun=None)[source]

Bases: negmas.situated.situated.Agent

The base for all SCM Agents

Attributes Summary

awi

Returns the Agent-SCML2020World-Interface through which the agent does all of its actions in the world.

Methods Summary

can_expect_agreement(cfp, margin)

Checks if it is possible in principle to get an agreement on this CFP by the time it becomes executable

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_()

The initialization function called by the world directly.

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_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_inventory_change(product, quantity, cause)

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

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

request_negotiation(cfp[, negotiator, ufun])

Requests a negotiation from the AWI while keeping track of available negotiation requests

respond_to_negotiation_request(cfp, partner)

Called when a prospective partner requests a negotiation to start

Attributes Documentation

awi

Returns the Agent-SCML2020World-Interface through which the agent does all of its actions in the world.

A single excption is request_negotiation for which it is recommended to actually call the helper method on the agent itself instead of directly calling the AWI version.

Return type

SCMLAWI

Methods Documentation

can_expect_agreement(cfp, margin)[source]

Checks if it is possible in principle to get an agreement on this CFP by the time it becomes executable

Parameters
  • margin (int) –

  • cfp (CFP) –

Returns:

abstract confirm_contract_execution(contract)[source]

Called before executing any agreement

Return type

bool

abstract 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

abstract 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]

The initialization function called by the world directly.

It does the following actions by default:

  1. copies some of the static world settings to the agent to make them available without calling the AWI.

  2. prepares production related properties like producing, consuming, line_profiles, compiled_profiles, etc.

  3. registers interest in all products that the agent can produce or consume in its factory.

  4. finally it calls any custom initialization logic implemented in `init`()

See also

init, step

abstract 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

abstract 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

abstract 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

abstract on_contract_executed(contract)[source]

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

Return type

None

abstract 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

abstract 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

abstract on_new_cfp(cfp)[source]

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

abstract 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:

abstract on_remove_cfp(cfp)[source]

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

request_negotiation(cfp, negotiator=None, ufun=None)[source]

Requests a negotiation from the AWI while keeping track of available negotiation requests

Parameters
Return type

bool

Returns

Whether the negotiation request was successful indicating that the partner accepted the negotiation

abstract respond_to_negotiation_request(cfp, partner)[source]

Called when a prospective partner requests a negotiation to start

Return type

Optional[Negotiator]