InsuranceFraudFactoryManager¶
-
class
scml.scml2019.
InsuranceFraudFactoryManager
(optimism=0.0, negotiator_type=<class 'scml.scml2019.factory_managers.iffm.AspirationNego2'>, negotiator_params=None, sign_only_guaranteed_contracts=False, *args, **kwargs)[source]¶ Bases:
scml.scml2019.factory_managers.iffm.NonDemandDrivenAgent
Attributes Summary
A list of negotiation requests sent to this agent that are already accepted by it.
Returns the Agent-SCML2020World-Interface through which the agent does all of its actions in the world.
The unique ID of this entity
Was the agent initialized (i.e.
A convenient name of the entity (intended primarily for printing/logging/debugging).
A list of the negotiation requests sent by this agent that are not yet accepted or rejected.
The negotiations currently requested by the agent.
The negotiations currently requested by the agent.
Returns a short name of the type of this entity
Returns the name of the type of this entity
All contracts that are not yet signed.
The unique ID of this entity
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
can_produce
(cfp[, …])Whether or not we can produce the required item in time
can_secure_needs
(schedule, step)Finds if it is possible in principle to arrange these needs at the given time.
checkpoint
(path[, file_name, info, …])Saves a checkpoint of the current object at the given path.
checkpoint_info
(file_name)Returns the information associated with a dump of the object saved in the given file
confirm_contract_execution
(contract)Called at the delivery time specified in the contract to confirm that the agent wants to execute it.
confirm_loan
(loan, bankrupt_if_rejected)Will be called whenever the agent needs to pay for something (e.g.
confirm_partial_execution
(contract, breaches)Will be called whenever a contract cannot be fully executed due to breaches by the other partner.
create
(*args, **kwargs)Creates an object and returns a proxy to it.
create_negotiation_request
(issues, partners, …)Creates a new
NegotiationRequestInfo
record and returns its IDfrom_checkpoint
(file_name[, return_info])Creates an object from a saved checkpoint
from_config
(config[, section, …])Creates an object of this class given the configuration info
init
()Called once after the agent-world interface is initialized
init_
()The initialization function called by the world directly.
notify
(notifiable, notification)on_agent_bankrupt
(agent_id)Will be called whenever any agent goes bankrupt
on_cash_transfer
(amount, cause)Called whenever there is a cash transfer to or from the agent
on_contract_breached
(contract, breaches, …)Called after full processing of contracts that were breached.
on_contract_cancelled
(contract, rejectors)Called whenever at least a partner did not sign the contract
on_contract_cancelled_
(contract, rejectors)Called whenever at least a partner did not sign the contract
on_contract_executed
(contract)Called whenever a contract is fully executed without any breaches
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_contract_signed_
(contract)Called whenever a contract is signed by all partners
on_contracts_finalized
(signed, cancelled, …)Called for all contracts in a single step to inform the agent about which were finally signed and which were rejected by any agents (including itself)
on_event
(event, sender)on_inventory_change
(product, quantity, cause)Will be called whenever there is a change in inventory for a cause other than production (e.g.
on_neg_request_accepted
(req_id, mechanism)Called when a requested negotiation is accepted.
on_neg_request_accepted_
(req_id, mechanism)Called when a requested negotiation is accepted
on_neg_request_rejected
(req_id, by)Called when a negotiation request sent by this agent is rejected.
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_failure_
(partners, …)Called whenever a negotiation ends without agreement
on_negotiation_success
(contract, mechanism)Called whenever a negotiation ends with 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)Will be called whenever a failure happens in one of the agent’s factory’s production lines
on_production_success
(reports)Will be called whenever some production succeeds in the factory owned by the manager
on_remove_cfp
(cfp)Called when a new CFP for a product for which the agent registered interest is removed
read_config
(config[, section])Reads the configuration from a file or a dict and prepares it for parsing
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 whenever someone (partner) is requesting a negotiation with the agent about a Call-For-Proposals (cfp) that was earlier published by this agent to the bulletin-board
respond_to_negotiation_request_
(initiator, …)Called when a negotiation request is received
respond_to_renegotiation_request
(contract, …)Will be called whenever a renegotiation agenda is set by one agent after a breach asking the other agent to join the re-negotiation.
set_renegotiation_agenda
(contract, breaches)Will be called when a contract fails to be concluded due to any kind of breach to allow partners to start a re-negotiation that may lead to a new contract that nullifies these breaches.
sign_all_contracts
(contracts)Called to sign all contracts concluded in a single step by this agent
sign_contract
(contract)Called after the signing delay from contract conclusion to sign the contract.
step
()Called at every production step by the world
step_
()Called at every time-step.
total_utility
([contracts])Calculates the total utility for the agent of a collection of contracts
Attributes Documentation
-
accepted_negotiation_requests
¶ A list of negotiation requests sent to this agent that are already accepted by it.
- Remarks:
These negotiations did not start yet as they are still not accepted by all partners. Once that happens, they will be moved to
running_negotiations
- Return type
List
[NegotiationInfo
]
-
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
-
id
¶ The unique ID of this entity
-
initialized
¶ Was the agent initialized (i.e. was init_() called)
- Return type
bool
-
name
¶ A convenient name of the entity (intended primarily for printing/logging/debugging).
-
negotiation_requests
¶ A list of the negotiation requests sent by this agent that are not yet accepted or rejected.
- Remarks:
These negotiations did not start yet as they are still not accepted by all partners. Once that happens, they will be moved to
running_negotiations
- Return type
List
[NegotiationInfo
]
-
requested_negotiations
¶ The negotiations currently requested by the agent.
- Return type
List
[NegotiationRequestInfo
]- Returns
A list of negotiation request information objects (
NegotiationRequestInfo
)
-
running_negotiations
¶ The negotiations currently requested by the agent.
- Return type
List
[RunningNegotiationInfo
]- Returns
A list of negotiation information objects (
RunningNegotiationInfo
)
-
short_type_name
¶ Returns a short name of the type of this entity
-
type_name
¶ Returns the name of the type of this entity
-
unsigned_contracts
¶ All contracts that are not yet signed.
- Return type
List
[Contract
]
-
uuid
¶ The unique ID of this entity
Methods Documentation
-
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
- Parameters
margin (
int
) –cfp (
CFP
) –
Returns:
-
can_produce
(cfp, assume_no_further_negotiations=False)¶ Whether or not we can produce the required item in time
- Return type
bool
-
can_secure_needs
(schedule, step)¶ Finds if it is possible in principle to arrange these needs at the given time.
- Parameters
schedule (
ScheduleInfo
) –step (
int
) –
Returns:
-
checkpoint
(path, file_name=None, info=None, exist_ok=False, single_checkpoint=True, step_attribs=('current_step', '_current_step', '_Entity__current_step', '_step'))¶ Saves a checkpoint of the current object at the given path.
- Parameters
path (
Union
[Path
,str
]) – Full path to a directory to store the checkpointfile_name (
Optional
[str
]) – Name of the file to dump into. If not given, a unique name is createdinfo (
Optional
[Dict
[str
,Any
]]) – Information to save with the checkpoint (must be json serializable)exist_ok (
bool
) – If true, override existing dumpsingle_checkpoint (
bool
) – If true, keep a single checkpoint for the last stepstep_attribs (
Tuple
[str
]) – Attributes to represent the time-step of the object. Any of the given attributes will be used in the file name generated if single_checkpoint is False. If single_checkpoint is True, the filename will not contain time-step information
- Return type
Path
- Returns
full path to the file used to save the checkpoint
-
classmethod
checkpoint_info
(file_name)¶ Returns the information associated with a dump of the object saved in the given file
- Parameters
file_name (
Union
[str
,Path
]) – Name of the object
Returns:
- Return type
Dict
[str
,Any
]
-
confirm_contract_execution
(contract)¶ Called at the delivery time specified in the contract to confirm that the agent wants to execute it.
Returning False is equivalent to committing a
refusal-to-execute
breach of maximum level (1.0).- Return type
bool
-
confirm_loan
(loan, bankrupt_if_rejected)¶ Will be called whenever the agent needs to pay for something (e.g. loan interest, products it bought) but does not have enough money in its wallet.
- Parameters
loan (
Loan
) – The loan informationbankrupt_if_rejected (
bool
) – If this is true, rejecting the loan will declare the agent bankrupt.
Remarks:
will NEVER be called in ANAC 2019 League. The bank is disabled and no loans are allowed.
- Return type
bool
-
confirm_partial_execution
(contract, breaches)¶ Will be called whenever a contract cannot be fully executed due to breaches by the other partner.
Will not be called if both partners committed breaches.
- Return type
bool
-
classmethod
create
(*args, **kwargs)¶ Creates an object and returns a proxy to it.
-
create_negotiation_request
(issues, partners, annotation, negotiator, extra)¶ Creates a new
NegotiationRequestInfo
record and returns its ID- Parameters
issues (
List
[Issue
]) – negotiation issuespartners (
List
[str
]) – partnersannotation (
Optional
[Dict
[str
,Any
]]) – annotationnegotiator (
Optional
[Negotiator
]) – the negotiator to useextra (
Optional
[Dict
[str
,Any
]]) – any extra information
- Return type
str
- Returns
A unique identifier for this negotiation info structure
-
classmethod
from_checkpoint
(file_name, return_info=False)¶ Creates an object from a saved checkpoint
- Parameters
file_name (
Union
[str
,Path
]) –return_info – If True, tbe information saved when the file was dumped are returned
- Return type
Union
[NamedObject
,Tuple
[NamedObject
,Dict
[str
,Any
]]]- Returns
Either the object or the object and dump-info as a dict (if return_info was true)
Remarks:
- If info is returned, it is guaranteed to have the following members:
time: Dump time
type: Type of the dumped object
id: ID
name: name
-
classmethod
from_config
(config, section=None, ignore_children=True, try_parsing_children=True, scope=None)¶ Creates an object of this class given the configuration info
- Parameters
config (
Union
[str
,dict
]) – Either a file name or a dictionarysection (
Optional
[str
]) – A section in the file or a key in the dictionary to use for loading paramsignore_children (
bool
) – If true then children will be ignored and there will be a single returntry_parsing_children (
bool
) – If true the children will first be parsed asConfigReader
classes if they are nottypes (e.g. int, str, float, Iterable[int|str|float] (simple) –
scope – The scope at which to evaluate any child classes. This MUST be passed as scope=globals() if you are
any children that are to be parsed. (having) –
- Returns
An object of cls if ignore_children is True or a tuple with an object of cls and a dictionary with children that were not parsed.
Remarks:
This function will return an object of its class after passing the key-value pairs found in the config to the init function.
Requiring passing scope=globals() to this function is to get around the fact that in python eval() will be called with a globals dictionary based on the module in which the function is defined not called. This means that in general when eval() is called to create the children, it will not have access to the class definitions of these children (except if they happen to be imported in this file). To avoid this problem causing an undefined_name exception, the caller must pass her globals() as the scope.
-
init_
()¶ The initialization function called by the world directly.
It does the following actions by default:
copies some of the static world settings to the agent to make them available without calling the AWI.
prepares production related properties like producing, consuming, line_profiles, compiled_profiles, etc.
registers interest in all products that the agent can produce or consume in its factory.
finally it calls any custom initialization logic implemented in `init`()
-
notify
(notifiable, notification)¶
-
on_agent_bankrupt
(agent_id)¶ 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:
Failing to pay one installments of a loan they bought and refusing (or being unable to) get another loan to pay it.
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).
The first bankruptcy case above will never happen in ANAC 2019 league as the bank is disabled.
The second bankruptcy case above may still happen in ANAC 2019 league.
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
andrespond_to_negotiation_request
callbacks by pulling the bulletin-board using the helper functionis_bankrupt
of their AWI.
- Return type
None
-
on_cash_transfer
(amount, cause)[source]¶ Called whenever there is a cash transfer to or from the agent
- Return type
None
-
on_contract_breached
(contract, breaches, resolution)¶ Called after full processing of contracts that were breached.
- Parameters
contract (
Contract
) – The contract breachedbreaches (
List
[Breach
]) – A list of all breaches committedresolution (
Optional
[Contract
]) – If not None, the resolution contract resulting from re-negotiation (if any).
Remarks:
Even if renegotiation resulted in an agreement, this callback will be called.
- Return type
None
-
on_contract_cancelled
(contract, rejectors)¶ Called whenever at least a partner did not sign the contract
- Return type
None
-
on_contract_cancelled_
(contract, rejectors)¶ Called whenever at least a partner did not sign the contract
- Return type
None
-
on_contract_executed
(contract)[source]¶ Called whenever a contract is fully executed without any breaches
- Return type
None
-
on_contract_nullified
(contract, bankrupt_partner, compensation)¶ 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_contract_signed_
(contract)¶ Called whenever a contract is signed by all partners
- Return type
None
-
on_contracts_finalized
(signed, cancelled, rejectors)¶ Called for all contracts in a single step to inform the agent about which were finally signed and which were rejected by any agents (including itself)
- Parameters
signed (
List
[Contract
]) – A list of signed contracts. These are bindingcancelled (
List
[Contract
]) – A list of cancelled contracts. These are not bindingrejectors (
List
[List
[str
]]) – A list of lists where each of the internal lists gives the rejectors of one of the cancelled contracts. Notice that it is possible that this list is empty which means that the contract other than being rejected by any agents (if that was possible in the specific world).
Remarks:
The default implementation is to call
on_contract_signed
for singed contracts andon_contract_cancelled
for cancelled contracts- Return type
None
-
on_event
(event, sender)¶
-
on_inventory_change
(product, quantity, cause)¶ Will be called whenever there is a change in inventory for a cause other than production (e.g. contract execution).
- Return type
None
-
on_neg_request_accepted
(req_id, mechanism)¶ Called when a requested negotiation is accepted. The
req_id
is a unique identifier for this negotiation request.
-
on_neg_request_accepted_
(req_id, mechanism)¶ Called when a requested negotiation is accepted
-
on_neg_request_rejected
(req_id, by)¶ Called when a negotiation request sent by this agent is rejected. The
req_id
is a unique identifier for this negotiation request.Remarks:
You MUST call super() here before doing anything else.
-
on_neg_request_rejected_
(req_id, by)¶ Called when a requested negotiation is rejected
- Parameters
req_id (
str
) – The request ID passed to _request_negotiationby (
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)¶ Called whenever a negotiation ends without agreement
- Return type
None
-
on_negotiation_failure_
(partners, annotation, mechanism, state)¶ Called whenever a negotiation ends without agreement
- Return type
None
-
on_negotiation_success
(contract, mechanism)¶ Called whenever a negotiation ends with agreement
- Return type
None
-
on_negotiation_success_
(contract, mechanism)¶ 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
- Return type
None
-
on_new_report
(report)¶ Called whenever a financial report is published.
- Parameters
report (
FinancialReport
) – The financial report giving details of the standing of an agent at some time (seeFinancialReport
)
Remarks:
Agents must opt-in to receive these calls by calling
receive_financial_reports
on their AWI
-
on_production_failure
(failures)¶ Will be called whenever a failure happens in one of the agent’s factory’s production lines
- Return type
None
-
on_production_success
(reports)¶ Will be called whenever some production succeeds in the factory owned by the manager
- Return type
None
-
on_remove_cfp
(cfp)¶ Called when a new CFP for a product for which the agent registered interest is removed
- Return type
None
-
classmethod
read_config
(config, section=None)¶ Reads the configuration from a file or a dict and prepares it for parsing
- Parameters
config (
Union
[str
,dict
]) – Either a file name or a dictionarysection (
Optional
[str
]) – A section in the file or a key in the dictionary to use for loading params
- Return type
Dict
[str
,Any
]- Returns
A dict ready to be parsed by from_config
Remarks:
-
request_negotiation
(cfp, negotiator=None, ufun=None)¶ Requests a negotiation from the AWI while keeping track of available negotiation requests
- Parameters
cfp (
CFP
) –negotiator (
Optional
[Negotiator
]) –ufun (
Optional
[UtilityFunction
]) –
- Return type
bool
- Returns
Whether the negotiation request was successful indicating that the partner accepted the negotiation
-
respond_to_negotiation_request
(cfp, partner)[source]¶ Called whenever someone (partner) is requesting a negotiation with the agent about a Call-For-Proposals (cfp) that was earlier published by this agent to the bulletin-board
Returning
None
means rejecting to enter this negotiation- Return type
Optional
[Negotiator
]
-
respond_to_negotiation_request_
(initiator, partners, issues, annotation, mechanism, role, req_id)¶ Called when a negotiation request is received
- Return type
Optional
[Negotiator
]
-
respond_to_renegotiation_request
(contract, breaches, agenda)¶ Will be called whenever a renegotiation agenda is set by one agent after a breach asking the other agent to join the re-negotiation.
Returning None means that you refuse to renegotiate.
- Return type
Optional
[Negotiator
]
-
set_renegotiation_agenda
(contract, breaches)¶ Will be called when a contract fails to be concluded due to any kind of breach to allow partners to start a re-negotiation that may lead to a new contract that nullifies these breaches. It is always called on agents in descending order of their total breach levels on this contract.
Returning
None
will mean that you pass your opportunity to set the renegotiation agenda.- Return type
Optional
[RenegotiationRequest
]
-
sign_all_contracts
(contracts)¶ Called to sign all contracts concluded in a single step by this agent
- Remarks:
default implementation calls
sign_contract
for each contract returning the results
- Return type
List
[Optional
[str
]]
-
sign_contract
(contract)[source]¶ Called after the signing delay from contract conclusion to sign the contract. Contracts become binding only after they are signed.
Remarks:
Return
None
if you decided not to sign the contract. Return your ID (self.id) otherwise.
- Return type
Optional
[str
]
-
step_
()¶ Called at every time-step. This function is called directly by the world.
-
total_utility
(contracts=())¶ Calculates the total utility for the agent of a collection of contracts
- Return type
float
-