From dfba6bb1542c30813f651d83d5f0f21fc250efa9 Mon Sep 17 00:00:00 2001 From: Juan Sabuco Date: Fri, 30 Nov 2018 02:32:51 +0000 Subject: [PATCH] Market exit log implemented. --- ensemble.py | 23 +++++++++++++++-------- insurancesimulation.py | 1 + logger.py | 36 ++++++++++++++++++++---------------- 3 files changed, 36 insertions(+), 24 deletions(-) diff --git a/ensemble.py b/ensemble.py index 95ea6cb..ca80b54 100644 --- a/ensemble.py +++ b/ensemble.py @@ -90,14 +90,15 @@ def rake(hostname): wfile_11 = open(os.getcwd() + "/data/" + str(nums[str(counter)]) + "_premium.dat", "w") wfile_12 = open(os.getcwd() + "/data/" + str(nums[str(counter)]) + "_reinpremium.dat", "w") wfile_13 = open(os.getcwd() + "/data/" + str(nums[str(counter)]) + "_cumulative_bankruptcies.dat", "w") - wfile_14 = open(os.getcwd() + "/data/" + str(nums[str(counter)]) + "_cumulative_unrecovered_claims.dat", "w") - wfile_15 = open(os.getcwd() + "/data/" + str(nums[str(counter)]) + "_cumulative_claims.dat", "w") - wfile_16 = open(os.getcwd() + "/data/record_" + str(nums[str(counter)]) + "_insurance_firms_cash.dat", "w") - wfile_17 = open(os.getcwd() + "/data/record_" + str(nums[str(counter)]) + "_reinsurance_firms_cash.dat", "w") - wfile_18 = open(os.getcwd() + "/data/" + str(nums[str(counter)]) + "_market_diffvar.dat", "w") - wfile_19 = open(os.getcwd() + "/data/" + str(counter) + "_rc_schedule.dat", "w") - wfile_20 = open(os.getcwd() + "/data/" + str(counter) + "_rc_damage.dat", "w") - + wfile_14 = open(os.getcwd() + "/data/" + str(nums[str(counter)]) + "_cumulative_market_exits", "w") + wfile_15 = open(os.getcwd() + "/data/" + str(nums[str(counter)]) + "_cumulative_unrecovered_claims.dat", "w") + wfile_16 = open(os.getcwd() + "/data/" + str(nums[str(counter)]) + "_cumulative_claims.dat", "w") + wfile_17 = open(os.getcwd() + "/data/record_" + str(nums[str(counter)]) + "_insurance_firms_cash.dat", "w") + wfile_18 = open(os.getcwd() + "/data/record_" + str(nums[str(counter)]) + "_reinsurance_firms_cash.dat", "w") + wfile_19 = open(os.getcwd() + "/data/" + str(nums[str(counter)]) + "_market_diffvar.dat", "w") + wfile_20 = open(os.getcwd() + "/data/" + str(counter) + "_rc_schedule.dat", "w") + wfile_21 = open(os.getcwd() + "/data/" + str(counter) + "_rc_damage.dat", "w") + wfile_22 = open(os.getcwd() + "/data/" + str(counter) + "_no_riskmodels.dat", "w") """Here the results of the simulations (typically run in the cloud) are collected""" @@ -136,6 +137,10 @@ def rake(hostname): wfile_18.write(str(result[i][18]) + "\n") wfile_19.write(str(result[i][19]) + "\n") wfile_20.write(str(result[i][20]) + "\n") + wfile_21.write(str(result[i][21]) + "\n") + wfile_22.write(str(result[i][22]) + "\n") + + @@ -162,6 +167,8 @@ def rake(hostname): wfile_18.close() wfile_19.close() wfile_20.close() + wfile_21.close() + wfile_22.close() counter =counter + 1 diff --git a/insurancesimulation.py b/insurancesimulation.py index 7bbfabd..7857f10 100644 --- a/insurancesimulation.py +++ b/insurancesimulation.py @@ -398,6 +398,7 @@ def save_data(self): current_log['market_premium'] = self.market_premium current_log['market_reinpremium'] = self.reinsurance_market_premium current_log['cumulative_bankruptcies'] = self.cumulative_bankruptcies + current_log['cumulative_market_exits'] = self.cumulative_market_exits current_log['cumulative_unrecovered_claims'] = self.cumulative_unrecovered_claims current_log['cumulative_claims'] = self.cumulative_claims #Log the cumulative claims received so far. diff --git a/logger.py b/logger.py index cb32b63..e83b271 100644 --- a/logger.py +++ b/logger.py @@ -31,6 +31,7 @@ def __init__(self, no_riskmodels=None, rc_event_schedule_initial=None, rc_event_ self.history_logs['total_contracts'] = [] self.history_logs['total_operational'] = [] self.history_logs['cumulative_bankruptcies'] = [] # TODO: should we not have that for both insurance firms and reinsurance firms? + self.history_logs['cumulative_market_exits'] = [] # TODO: should we not have that for both insurance firms and reinsurance firms? self.history_logs['cumulative_claims'] = [] #Here are stored the total cumulative claims received by the whole insurance sector until a certain time. self.history_logs['cumulative_unrecovered_claims'] = [] @@ -89,14 +90,15 @@ def obtain_log(self): #This function allows to return in a list all the data g [11]: 'market_premium' [12]: 'market_reinpremium' [13]: 'cumulative_bankruptcies' - [14]: 'cumulative_unrecovered_claims' - [15]: 'cumulative_claims' - [16]: 'insurance_firms_cash' - [17]: 'reinsurance_firms_cash' - [18]: 'market_diffvar' - [19]: rc_event_schedule_initial - [20]: rc_event_damage_initial - [21]: number_riskmodels + [14]: 'cumulative_market_exits' + [15]: 'cumulative_unrecovered_claims' + [16]: 'cumulative_claims' + [17]: 'insurance_firms_cash' + [18]: 'reinsurance_firms_cash' + [19]: 'market_diffvar' + [20]: rc_event_schedule_initial + [21]: rc_event_damage_initial + [22]: number_riskmodels """ log = [] @@ -115,6 +117,7 @@ def obtain_log(self): #This function allows to return in a list all the data g log.append(self.history_logs['market_premium']) log.append(self.history_logs['market_reinpremium']) log.append(self.history_logs['cumulative_bankruptcies']) + log.append(self.history_logs['cumulative_market_exits']) log.append(self.history_logs['cumulative_unrecovered_claims']) log.append(self.history_logs['cumulative_claims']) log.append(self.history_logs['insurance_firms_cash']) @@ -169,14 +172,15 @@ def restore_logger_object(self, log): self.history_logs['market_premium'] = log [11] self.history_logs['market_reinpremium'] = log [12] self.history_logs['cumulative_bankruptcies'] = log [13] - self.history_logs['cumulative_unrecovered_claims'] = log [14] - self.history_logs['cumulative_claims'] = log [15] - self.history_logs['insurance_firms_cash'] = log [16] - self.history_logs['reinsurance_firms_cash'] = log [17] - self.history_logs['market_diffvar'] = log [18] - self.rc_event_schedule_initial = log[19] - self.rc_event_damage_initial = log[20] - self.number_riskmodels = log[21] + self.history_logs['cumulative_market_exits'] = log[14] + self.history_logs['cumulative_unrecovered_claims'] = log [15] + self.history_logs['cumulative_claims'] = log [16] + self.history_logs['insurance_firms_cash'] = log [17] + self.history_logs['reinsurance_firms_cash'] = log [18] + self.history_logs['market_diffvar'] = log [19] + self.rc_event_schedule_initial = log[20] + self.rc_event_damage_initial = log[21] + self.number_riskmodels = log[22] def save_log(self, background_run):