scml.scml2019.bank ================== .. py:module:: scml.scml2019.bank .. autoapi-nested-parse:: Implements all builtin banks. Classes ------- .. autoapisummary:: scml.scml2019.bank.Bank scml.scml2019.bank.DefaultBank Module Contents --------------- .. py:class:: Bank(*args, **kwargs) Bases: :py:obj:`negmas.situated.Agent`, :py:obj:`abc.ABC` Base class for all banks .. py:attribute:: _world :value: None .. py:method:: _respond_to_negotiation_request(initiator: str, partners: list[str], issues: list[negmas.Issue], annotation: dict[str, Any], mechanism: negmas.NegotiatorMechanismInterface, role: Optional[str], req_id: Optional[str]) -> Optional[negmas.Negotiator] Called by the mechanism to ask for joining a negotiation. The agent can refuse by returning a None :param initiator: The ID of the agent that initiated the negotiation request :param partners: The partner list (will include this agent) :param issues: The list of issues :param annotation: Any annotation specific to this negotiation. :param mechanism: The mechanism that started the negotiation :param role: The role of this agent in the negotiation :param req_id: The req_id passed to the AWI when starting the negotiation (only to the initiator). :returns: None to refuse the negotiation or a `Negotiator` object appropriate to the given mechanism to accept it. Remarks: - It is expected that world designers will introduce a better way to respond and override this function to call it .. py:method:: on_neg_request_rejected(req_id: str, by: Optional[list[str]]) Called when a requested negotiation is rejected :param req_id: The request ID passed to _request_negotiation :param by: A list of agents that refused to participate or None if the failure was for another reason .. py:method:: on_neg_request_accepted(req_id: str, mechanism: negmas.NegotiatorMechanismInterface) Called when a requested negotiation is accepted .. py:method:: on_negotiation_failure(partners: list[str], annotation: dict[str, Any], mechanism: negmas.NegotiatorMechanismInterface, state: negmas.MechanismState) -> None Called whenever a negotiation ends without agreement .. py:method:: on_negotiation_success(contract: negmas.situated.Contract, mechanism: negmas.NegotiatorMechanismInterface) -> None Called whenever a negotiation ends with agreement .. py:method:: on_contract_signed(contract: negmas.situated.Contract) -> None Called whenever a contract is signed by all partners .. py:method:: on_contract_cancelled(contract: negmas.situated.Contract, rejectors: list[str]) -> None Called whenever at least a partner did not sign the contract .. py:method:: sign_contract(contract: negmas.situated.Contract) -> Optional[str] Called after the signing delay from contract conclusion to sign the contract. Contracts become binding only after they are signed. .. py:method:: respond_to_negotiation_request(initiator: str, partners: list[str], issues: list[negmas.Issue], annotation: dict[str, Any], mechanism: negmas.Mechanism, role: Optional[str], req_id: str) -> Optional[negmas.Negotiator] .. py:method:: on_contract_executed(contract: negmas.situated.Contract) -> None Called after successful contract execution for which the agent is one of the partners. .. py:method:: on_contract_breached(contract: negmas.situated.Contract, breaches: list[negmas.situated.Breach], resolution: Optional[negmas.situated.Contract]) -> None Called after complete processing of a contract that involved a breach. :param contract: The contract :param breaches: All breaches committed (even if they were resolved) :param resolution: The resolution contract if re-negotiation was successful. None if not. .. py:class:: DefaultBank(minimum_balance: float, interest_rate: float, interest_max: float, balance_at_max_interest: float, installment_interest: float, time_increment: float, a2f: dict[str, scml.scml2019.common.Factory], disabled: bool = False, name: str | None = None) Bases: :py:obj:`Bank` Represents a bank in the world .. py:method:: init() Called to initialize the agent **after** the world is initialized. the AWI is accessible at this point. .. py:method:: respond_to_negotiation_request(initiator: str, partners: list[str], issues: list[negmas.Issue], annotation: dict[str, Any], mechanism: negmas.Mechanism, role: Optional[str], req_id: str) -> Optional[negmas.Negotiator] .. py:attribute:: storage :type: dict[int, int] .. py:attribute:: wallet :type: float :value: 0.0 .. py:attribute:: disabled :value: False .. py:attribute:: loans :type: dict[scml.scml2019.agent.SCML2019Agent, list[scml.scml2019.common.Loan]] .. py:attribute:: minimum_balance .. py:attribute:: interest_rate .. py:attribute:: interest_max .. py:attribute:: installment_interest .. py:attribute:: time_increment .. py:attribute:: balance_at_max_interest .. py:attribute:: _credit_rating :type: dict[str, float] .. py:attribute:: a2f .. py:method:: set_renegotiation_agenda(contract: negmas.situated.Contract, breaches: list[negmas.situated.Breach]) -> Optional[negmas.situated.RenegotiationRequest] Received by partners in ascending order of their total breach levels in order to set the renegotiation agenda when contract execution fails :param contract: The contract being breached :param breaches: All breaches on `contract` :returns: Renegotiation agenda (issues to negotiate about to avoid reporting the breaches). .. py:method:: respond_to_renegotiation_request(contract: negmas.situated.Contract, breaches: list[negmas.situated.Breach], agenda: negmas.situated.RenegotiationRequest) -> Optional[negmas.Negotiator] Called to respond to a renegotiation request :param agenda: :param contract: :param breaches: Returns: .. py:method:: _evaluate_loan(agent: scml.scml2019.agent.SCML2019Agent, amount: float, n_installments: int, starts_at: int, installment_loan=False) -> Optional[scml.scml2019.common.Loan] Evaluates the interest that will be imposed on the agent to buy_loan that amount .. py:method:: evaluate_loan(agent: scml.scml2019.agent.SCML2019Agent, amount: float, start_at: int, n_installments: int) -> Optional[scml.scml2019.common.Loan] Evaluates the interest that will be imposed on the agent to buy_loan that amount .. py:method:: _buy_loan(agent: scml.scml2019.agent.SCML2019Agent, loan: scml.scml2019.common.Loan, beneficiary: negmas.situated.Agent, contract: Optional[negmas.situated.Contract], bankrupt_if_rejected=False) -> Optional[scml.scml2019.common.Loan] .. py:method:: buy_loan(agent: scml.scml2019.agent.SCML2019Agent, amount: float, n_installments: int, beneficiary: negmas.situated.Agent, contract: Optional[negmas.situated.Contract], force: bool = False) -> Optional[scml.scml2019.common.Loan] Gives a loan of amount to agent at the interest calculated using `evaluate_loan` .. py:method:: step() Takes payments from agents .. py:method:: _reduce_credit_rating(agent: negmas.situated.Agent, unavailable: float) Updates the credit rating when the agent fails to pay an installment .. py:method:: credit_rating(agent_id: str) -> float