@@ -31,14 +31,20 @@ def init(self, simulation_parameters, agent_parameters):
31
31
self .acceptance_threshold_friction = agent_parameters ['acceptance_threshold_friction' ] # 0.9 #1.0 to switch off
32
32
self .interest_rate = agent_parameters ["interest_rate" ]
33
33
self .reinsurance_limit = agent_parameters ["reinsurance_limit" ]
34
+ self .simulation_no_risk_categories = simulation_parameters ["no_categories" ]
35
+ self .simulation_reinsurance_type = simulation_parameters ["simulation_reinsurance_type" ]
36
+ self .categories_reinsured = [False for i in range (self .simulation_no_risk_categories )]
37
+ if self .simulation_reinsurance_type == 'non-proportional' :
38
+ self .np_reinsurance_deductible = simulation_parameters ["default_non-proportional_reinsurance_deductible" ]
39
+ self .np_reinsurance_excess = simulation_parameters ["default_non-proportional_reinsurance_excess" ]
34
40
self .obligations = []
35
41
self .underwritten_contracts = []
36
42
#self.reinsurance_contracts = []
37
43
self .operational = True
38
44
self .is_insurer = True
39
45
self .is_reinsurer = False
40
46
41
- def iterate (self , time ):
47
+ def iterate (self , time ): # TODO: split function so that only the sequence of events remains here and everything else is in separate methods
42
48
"""obtain investments yield"""
43
49
self .obtain_yield (time )
44
50
@@ -71,12 +77,24 @@ def iterate(self, time):
71
77
except :
72
78
print ("Something wrong; agent {0:d} receives too few new contracts {1:d} <= {2:d}" .format (self .id , contracts_offered , 2 * contracts_dissolved ))
73
79
#print(self.id, " has ", len(self.underwritten_contracts), " & receives ", contracts_offered, " & lost ", contracts_dissolved)
80
+
81
+ new_nonproportional_risks = [risk for risk in new_risks if risk .get ("insurancetype" )== 'excess-of-loss' ]
82
+ new_risks = [risk for risk in new_risks if risk .get ("insurancetype" ) in ['proportional' , None ]]
74
83
75
-
76
- """make underwriting decisions, category-wise"""
77
84
underwritten_risks = [{"excess" : contract .value , "category" : contract .category , \
78
85
"risk_factor" : contract .risk_factor , "deductible" : contract .deductible , \
86
+ "excess" : contract .excess , "insurancetype" : contract .insurancetype , \
79
87
"runtime" : contract .runtime } for contract in self .underwritten_contracts if contract .reinsurance_share != 1.0 ]
88
+
89
+ """deal with non-proportional risks first as they must evaluate each request separatly, then with proportional ones"""
90
+ for risk in new_nonproportional_risks :
91
+ #accept = self.riskmodel.evaluate(underwritten_risks, self.cash, risk) # TODO: change riskmodel.evaluate() to accept new risk to be evaluated and to account for existing non-proportional risks correctly
92
+ #if accept:
93
+ # contract = ReinsuranceContract(...)
94
+ # self.underwritten_contracts.append(contract)
95
+ pass # TODO: write this nonproportional risk acceptance decision section based on commented code in the lines above this
96
+
97
+ """make underwriting decisions, category-wise"""
80
98
# TODO: Enable reinsurance shares other tan 0.0 and 1.0
81
99
expected_profit , acceptable_by_category = self .riskmodel .evaluate (underwritten_risks , self .cash )
82
100
@@ -171,9 +189,41 @@ def receive(self, amount):
171
189
def obtain_yield (self , time ):
172
190
amount = self .cash * self .interest_rate
173
191
self .simulation .receive_obligation (amount , self , time )
192
+
193
+ def ask_reinsurance (self ):
194
+ if self .simulation_reinsurance_type == 'proportional' :
195
+ self .ask_reinsurance_proportional ()
196
+ elif self .simulation_reinsurance_type == 'non-proportional' :
197
+ self .ask_reinsurance_non_proportional ()
198
+ else :
199
+ assert False , "Undefined reinsurance type"
200
+
201
+ def ask_reinsurance_non_proportional (self ):
202
+ for categ_id in range (len (self .simulation_no_risk_categories )):
203
+ # with probability 5% if not reinsured ... # TODO: find a more generic way to decide whether to request reinsurance for category in this period
204
+ if (not self .categories_reinsured [categ_id ]) and np .random () < 0.05 :
205
+ total_value = 0
206
+ avg_risk_factor = 0
207
+ number_risks = 0
208
+ periodized_total_premium = 0
209
+ for contract in self .underwritten_contracts :
210
+ if contract .category == categ_id :
211
+ total_value += contract .value
212
+ avg_risk_factor += contract .risk_factor
213
+ number_risks += 1
214
+ periodized_total_premium += contract .periodized_premium
215
+ avg_risk_factor /= number_risks
216
+ risk = {"value" : total_value , "category" : categ_id , "owner" : self ,
217
+ #"identifier": uuid.uuid1(),
218
+ "insurancetype" : 'excess-of-loss' , "number_risks" : number_risks ,
219
+ "deductible" : self .np_reinsurance_deductible , "excess" : np_reinsurance_excess ,
220
+ "periodized_total_premium" : periodized_total_premium , "runtime" : 12 ,
221
+ "expiration" : time + 12 , "risk_factor" : avg_risk_factor }
222
+
223
+ self .simulation .append_reinrisks (risk )
174
224
175
225
@nb .jit
176
- def ask_reinsurance (self ):
226
+ def ask_reinsurance_proportional (self ):
177
227
nonreinsured = []
178
228
for contract in self .underwritten_contracts :
179
229
if contract .reincontract == None :
0 commit comments