-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments and cleanup #133
base: master
Are you sure you want to change the base?
Comments and cleanup #133
Conversation
Also added LRU caching to DistributionTruncated.ppf for a speed boost.
…essary parameter assignments (they were immediately overwritten)
… for a general loop to initialise agent parameters.
…e now as a result, especially in insurancesimulation.py
… corrections/structure changes.
…ital_entry, count_underwritten_risks_by_category Removed redundant functions from metainsuranceorg: adjust_dividend, adjust_capacity_target.
…nction (get_newrisks_by_type) for organising new risks (start to cleaning up iterate function). Removed some imports from start.py.
…caching (since tuples are hashable). Tested, lead to a small performance increase. Also did misc cleanup etc.
…urance_non_proportional_by_category as they were almost the same.
…e to compiled bytecode. Done so simplify diffs with future commits.
the category each reinsurance firm is insuring on the edge labels.
…orks, including network visualisation.
… of run (i.e. doesnt need networkx). Added condition to isleconfig for allowing buying other firms.
…sted file is saved.
…which stops underwriting, or sells off firm. Included condition in isleconfig to enable/disable. Fixed bug causing non operational firms rolling over contracts. Simulation also keeps track of firms exiting due to regulations and being bought. Simulation also only iterates through operational firms, otherwise unnecessary looping/dissolutions. Adjusted firm pricing, might still need changing.
… if large enough damage. Called from simulation and added condition in isleconfig to enable.
centralbank.py
Outdated
elif avg_firm_cash >= 0.85 * avg_var: | ||
self.warnings[firm_id] += 1 | ||
elif avg_firm_cash < 0.85* avg_var: | ||
if self.warnings[firm_id] > 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Is this not the same as the case
avg_firm_cash >= 0.85 * avg_var
in line97
? Previousself.warnings[firm_id]
value 0 will be set to 1, previous value 1 to 2. 2 results in the company being dissolved. - According to the Comment above,
self.warnings[firm_id]
should always be set to 2 in this case. Is there a reason to wait one more period?
if avg_firm_cash >= 0.995 * avg_var: | ||
self.warnings[firm_id] = 0 | ||
elif avg_firm_cash >= 0.85 * avg_var: | ||
self.warnings[firm_id] += 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the Comment above, self.warnings[firm_id]
should always be set to 1 in this case and not further incremented. This would lead to the company being dissolved after 2 periods instead of just restricting its business. Is there a reason to do this?
centralbank.py
Outdated
def adjust_aid_budget(self, time): | ||
if time % 12 == 0: | ||
money_left = self.aid_budget | ||
self.aid_budget = 1000000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Like above:) Perhaps this should be a parameter in isleconfig.py
since its impact depends on the relation to other values fixed there.
centralbank.py
Outdated
@@ -13,6 +14,26 @@ def __init__(self): | |||
self.twelvemonth_CPI = 0 | |||
self.feedback_counter = 0 | |||
self.prices_list = [] | |||
self.economy_money = money_supply | |||
self.warnings = {} | |||
self.aid_budget = 1000000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps this should be a parameter in isleconfig.py
since its impact depends on the relation to other values fixed there.
@@ -13,6 +14,26 @@ def __init__(self): | |||
self.twelvemonth_CPI = 0 | |||
self.feedback_counter = 0 | |||
self.prices_list = [] | |||
self.economy_money = money_supply |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, the economy's money should not sit at the central bank. The money_supply
variable in InsuranceSimulation
is supposed to track the money of the rest of the economy, i.e. all the agents that are not modelled. The central bank is different.
- We may think about giving the central bank its own budget. But is this currently necessary?
- Currently, the central bank only needs money to pay aid. This is a cool idea, and it is fine that the central bank in its capacity as regulator decides on this. But the aid should technically be paid by the government (i.e. not the central bank). That is, the central bank could create an obligation for the
InsuranceSimulation
object (representing the government) for each aid payment it wants to effect. - We may allow the central bank to change the money supply of the economy. But this is not currently necessary.
self.warnings = {} | ||
self.aid_budget = 1000000 | ||
|
||
def update_money_supply(self, amount, reduce=True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method might need a description. But I would argue that the economy's money should be in the InsuranceSimulation
object, not in the central bank anyway. See my comment above.
@@ -110,12 +128,17 @@ def restore_logger_object(self, log): | |||
|
|||
"""Restore dict""" | |||
log = listify.delistify(log) | |||
|
|||
|
|||
self.network_data["unweighted_network_data"] = log["unweighted_network_data"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more thing: I think in order for the next four lines to work with ensembles, these keys have to be added to the requested_logs
dict in ensemble.py
, line 52 and following. This is because ensemble runs strictly only store the log items that are requested. I guess, we can just add these to the dict in ensemble.py
in case the save_network
switch is set and not execute these lines here if the save_network
switch is not set.
Thanks :)
…nd allows a 24 month grace period for new firms. Aid budget is now simulation parameter. Changed method of selling bankrupt firms in simulation, to just selling firms (helps logging). Now properly records and saves cumulative values in logger/simulation/ensemble(e.g. bankruptcies, bought firms). Network data should now properly save for ensemble runs.
# Conflicts: # calibration_conditions.py # calibrationscore.py # catbond.py # distribution_wrapper_test.py # distributionreinsurance.py # distributiontruncated.py # ensemble.py # genericagent.py # genericagentabce.py # insurancecontract.py # insurancefirm.py # insurancesimulation.py # isleconfig.py # listify.py # logger.py # metainsurancecontract.py # metainsuranceorg.py # metaplotter.py # metaplotter_pl_timescale.py # metaplotter_pl_timescale_additional_measures.py # plotter.py # plotter_pl_timescale.py # reinsurancecontract.py # reinsurancefirm.py # resume.py # riskmodel.py # setup.py # start.py # visualisation.py # visualization_network.py
# Conflicts: # calibration_conditions.py # calibrationscore.py # catbond.py # distribution_wrapper_test.py # distributionreinsurance.py # distributiontruncated.py # ensemble.py # genericagent.py # genericagentabce.py # insurancecontract.py # insurancefirm.py # insurancesimulation.py # isleconfig.py # listify.py # logger.py # metainsurancecontract.py # metainsuranceorg.py # metaplotter.py # metaplotter_pl_timescale.py # metaplotter_pl_timescale_additional_measures.py # plotter.py # plotter_pl_timescale.py # reinsurancecontract.py # reinsurancefirm.py # resume.py # riskmodel.py # setup.py # start.py # visualisation.py # visualization_network.py
…lso can now use event data. Only looks at given range of data (remove transient period). Basic chi squared test but really need more replications (100+)
…e excluded) safety margin from actual VaR calculation in regulator.
…added to visualisation.py. Other minor changes.
# Conflicts: # centralbank.py # metainsuranceorg.py # reinsurancecontract.py # start.py # visualisation.py
…insurance (loads of market exits but calculates reinsurance capital correctly)
… ask for risks). Fixed other issues causing data to no be saved as it should.
…operational condition for firm pay due to firm buyouts. Insurance claims made t+1 not t+2 for better profit tracking.
…. Added file on interactive visualisation using bokeh.
Added docstring to most functions, cleaned up some code that was not used. Removed all abce dependance (although still genericagentabce.py). Added continually updating network, also works with resume.py.
Some general setup parameters changed which may not be desired by default (e.g shownetwork = True, save_iter = 20) but they can be easily changed.