def phone_call_outcome(self, current_ad): # digital by this point so just can you convince them to reply? outcome_test = self.rep.rnd.uniform(0, 100) conversion_dict = self.input_data['conversion_rate'][str(h.current_day(self))] if outcome_test <= conversion_dict[h.return_time_key(conversion_dict, self.env.now)]: yield self.env.timeout(current_ad.input_data['call_times']['success'] / 60) self.rep.output_data['Call_success'].append(call_success(self.rep.reps, self.district.input_data["LA"], self.digital, self.hh_type, self.env.now, self.hh_id)) self.resp_planned = True self.rep.adviser_store.put(current_ad) self.rep.env.process(self.respond(self.delay)) else: yield self.env.timeout(current_ad.input_data['call_times']['failed'] / 60) self.rep.output_data['Call_failed'].append(call_failed(self.rep.reps, self.district.input_data["LA"], self.digital, self.hh_type, self.env.now, self.hh_id)) self.rep.adviser_store.put(current_ad)
def household_test(self, household, input_type): # tests if hh is in or is converted to a return! test_value = self.rnd.uniform(0, 100) dict_value = household.input_data[input_type][str(h.current_day(self))] if test_value <= dict_value[h.return_time_key(dict_value, self.env.now)]: return True else: return False
def optimal_time(self, household): # determines if the current time is the best time to visit a hh that has asked for a visit # get times avail d = household.input_data['contact_rate'][str(h.current_day(household))] # if current time is not best time don't visit if d[h.return_time_key(d, self.env.now)] != d[max(d, key=d.get)]: return False else: # visit return True
def phone_call_outcome(self, current_ad): # digital by this point so just can you convince them to reply? outcome_test = self.rnd.uniform(0, 100) conversion_dict = self.input_data['success_rate'][str(h.current_day(self))] if outcome_test <= conversion_dict[h.return_time_key(conversion_dict, self.env.now)]: yield self.env.timeout(current_ad.input_data['call_times']['success'] / 60) if oo.record_call_success: self.rep.output_data['Call_success'].append(oo.generic_output(self.rep.reps, self.district.district, self.la, self.lsoa, self.digital, self.hh_type, self.hh_id, self.env.now)) self.resp_planned = True self.rep.adviser_store.put(current_ad) self.rep.env.process(self.household_returns(self.calc_delay())) else: yield self.env.timeout(current_ad.input_data['call_times']['failed'] / 60) if oo.record_call_failed: self.rep.output_data['Call_failed'].append(oo.generic_output(self.rep.reps, self.district.district, self.la, self.lsoa, self.digital, self.hh_type, self.hh_id, self.env.now)) self.rep.adviser_store.put(current_ad)