JavaFactoryManager

class scml.scml2019.JavaFactoryManager(java_object=None, java_class_name=None, python_shadow=None, auto_load_java=False, name=None, simulator_type=<class 'scml.scml2019.simulators.FastFactorySimulator'>)[source]

Bases: scml.scml2019.FactoryManager, negmas.java.JavaCallerMixin

Allows factory managers implemented in Java (using jnegmas) to participate in SCML worlds.

Objects of this class is used to represent a java object to the python environment. This means that they MUST have the same interface as a python class (first class in the inheritance list). The JavaCallerMixin is used to enable it to connect to the java object it is representing.

Attributes Summary

awi

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

type_name

Overrides type name to give the internal java type name

Methods Summary

confirmContractExecution(contract)

confirmLoan(loan, bankruptIfRejected)

confirmPartialExecution(contract, breaches)

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.

do_nothing_manager()

getCompiledProfiles()

getConsuming()

getContracts()

getID()

getLineProfiles()

getName()

getNegotiationRequests()

getProcesses()

getProducing()

getProducts()

getRequestedNegotiations()

getRunningNegotiations()

greedy_manager()

init()

Called to initialize the agent after the world is initialized.

initPython()

onAgentBankrupt(agentId)

onCashTransfer(amount, cause)

rtype

None

onContractBreached(contract, breaches, …)

rtype

None

onContractCancelled(contract, rejectors)

onContractExecuted(contract)

rtype

None

onContractNullified(contract, …)

onContractSigned(contract)

onInventoryChange(product, quantity, cause)

rtype

None

onNegRequestAccepted(req_id, mechanism)

onNegRequestRejected(req_id, rejectors)

onNegotiationFailure(partners, annotation, …)

onNegotiationSuccess(contract, mechanism)

onNewCFP(cfp)

onNewReport(report)

onProductionFailure(failures)

onProductionSuccess(reports)

rtype

None

onRemoveCFP(cfp)

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_production_failure(failures)

Called with a list of ProductionFailure records on production failure.

on_production_success(reports)

Called with a list of ProductionReport records on production success

on_remove_cfp(cfp)

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

requestNegotiation(cfp[, negotiator, ufun])

rtype

bool

respondToNegotiationRequest(cfp, partner)

respondToRenegotiationRequest(contract, …)

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

setID(value)

setName(value)

setRenegotiationAgenda(contract, breaches)

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

signContract(contract)

sign_contract(contract)

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

step()

Called by the simulator at every simulation step

stepPython()

Attributes Documentation

awi
type_name

Overrides type name to give the internal java type name

Methods Documentation

confirmContractExecution(contract)[source]
confirmLoan(loan, bankruptIfRejected)[source]
confirmPartialExecution(contract, breaches)[source]
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

classmethod do_nothing_manager()[source]
getCompiledProfiles()[source]
getConsuming()[source]
getContracts()[source]
getID()[source]
getLineProfiles()[source]
getName()[source]
getNegotiationRequests()[source]
getProcesses()[source]
getProducing()[source]
getProducts()[source]
getRequestedNegotiations()[source]
getRunningNegotiations()[source]
classmethod greedy_manager()[source]
init()[source]

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

initPython()[source]
onAgentBankrupt(agentId)[source]
onCashTransfer(amount, cause)[source]
Return type

None

onContractBreached(contract, breaches, resolution)[source]
Return type

None

onContractCancelled(contract, rejectors)[source]
onContractExecuted(contract)[source]
Return type

None

onContractNullified(contract, bankruptPartner, compensation)[source]
onContractSigned(contract)[source]
onInventoryChange(product, quantity, cause)[source]
Return type

None

onNegRequestAccepted(req_id, mechanism)[source]
onNegRequestRejected(req_id, rejectors)[source]
onNegotiationFailure(partners, annotation, mechanism, state)[source]
onNegotiationSuccess(contract, mechanism)[source]
onNewCFP(cfp)[source]
onNewReport(report)[source]
onProductionFailure(failures)[source]
onProductionSuccess(reports)[source]
Return type

None

onRemoveCFP(cfp)[source]
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_production_failure(failures)[source]

Called with a list of ProductionFailure records on production failure.

Return type

None

on_production_success(reports)[source]

Called with a list of ProductionReport records on production success

Return type

None

on_remove_cfp(cfp)[source]

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

requestNegotiation(cfp, negotiator=None, ufun=None)[source]
Return type

bool

respondToNegotiationRequest(cfp, partner)[source]
respondToRenegotiationRequest(contract, breaches, agenda)[source]
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]

setID(value)[source]
setName(value)[source]
setRenegotiationAgenda(contract, breaches)[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).

signContract(contract)[source]
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

stepPython()[source]