def compute_and_save_opt_pension(criterium, disable_api = False): if disable_api: csv_file = DIR + 'opt_pension_no_api.csv' else: csv_file = DIR + 'opt_pension_new.csv' nb_enf_max = 4 nb_enf_max_14 = 0 rev_smic_max = 4 rev_smic_step = .5 temps_garde_range = ['classique', 'alternee_pension_non_decl', 'alternee_pension_decl'] first = True disabled = None if disable_api: disabled = ['api'] for uc_parameters in [ {'alpha' : 0, 'beta' : .5, 'gamma' : 1}, {'alpha' : 0.4, 'beta' : .7, 'gamma' : 1.4}]: for nb_enf in range(1,nb_enf_max+1): for ea in range(0,nb_enf_max_14+1): e = nb_enf - ea for temps_garde in temps_garde_range: for rev_smic_chef in arange(0,rev_smic_max, rev_smic_step): for rev_smic_part in arange(0,rev_smic_max, rev_smic_step): opt_pension = compute_optimal_pension(e, ea, rev_smic_chef, rev_smic_part, temps_garde, uc_parameters = uc_parameters, criterium = criterium, disabled=disabled) asf = get_asf(nb_enf, year=YEAR) if opt_pension >= asf: if disabled is not None: disabled = disabled + ['asf'] else: disabled = ['asf'] df = get_results_df(e, ea, rev_smic_chef, rev_smic_part, temps_garde, uc_parameters = uc_parameters, pension = opt_pension, disabled = disabled) else: df = get_results_df(e, ea, rev_smic_chef, rev_smic_part, temps_garde, uc_parameters = uc_parameters, pension = 0, disabled = disabled) print df if first: df_final = df first = False else: df_final = concat([df_final, df], axis=0) df_final.to_csv(csv_file)
def optimal_pension(criterium, disable_api = False): e = 2 ea = 0 rev_smic_chef = 3.5 rev_smic_part = 0 temps_garde ="alternee_pension_non_decl" # 'classique', 'alternee_pension_decl uc_parameters = {'alpha' : 0.4, 'beta' : .7, 'gamma' : 1.4} disabled = [] if disable_api: disabled += ['api'] if criterium == "unaf": print get_unaf(e,ea) opt_pension_nv = compute_optimal_pension(e, ea, rev_smic_chef, rev_smic_part, temps_garde, uc_parameters = uc_parameters, criterium = "nivvie", disabled=disabled) print "nivvie : ", opt_pension_nv opt_pension_unaf = compute_optimal_pension(e, ea, rev_smic_chef, rev_smic_part, temps_garde, uc_parameters = uc_parameters, criterium = "unaf", disabled=disabled) print "unaf : ", opt_pension_unaf opt_pension = max(opt_pension_nv, opt_pension_unaf) else: opt_pension = compute_optimal_pension(e, ea, rev_smic_chef, rev_smic_part, temps_garde, uc_parameters = uc_parameters, criterium=criterium, disabled=disabled) asf = get_asf(e+ea, year=YEAR) print 'opt_pension :', opt_pension print 'asf :', asf if opt_pension >= asf: df = get_results_df(e, ea, rev_smic_chef, rev_smic_part, temps_garde, uc_parameters = uc_parameters, pension = opt_pension, disabled = disabled + ['asf'] ) else: df = get_results_df(e, ea, rev_smic_chef, rev_smic_part, temps_garde, uc_parameters = uc_parameters, pension = 0, disabled=disabled) print df.to_string() return df