Skip to content

Commit

Permalink
Market exit log implemented.
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan Sabuco committed Nov 30, 2018
1 parent 23651d5 commit dfba6bb
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 24 deletions.
23 changes: 15 additions & 8 deletions ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down Expand Up @@ -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")





Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions insurancesimulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
36 changes: 20 additions & 16 deletions logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'] = []

Expand Down Expand Up @@ -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 = []
Expand All @@ -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'])
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit dfba6bb

Please sign in to comment.