Last active
January 20, 2016 16:37
-
-
Save laem/339203bc1a9bc77aff08 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
from scipy.optimize import fsolve | |
def calculate_net_from(brut): | |
print brut[0] | |
scenario = tax_benefit_system.new_scenario() | |
scenario.init_single_entity( | |
period = "2015-11", | |
parent1 = dict( | |
age = 30, | |
salaire_de_base = brut[0], | |
contrat_de_travail_debut='2015-10-01', | |
allegement_fillon_mode_recouvrement='anticipe_regularisation_fin_de_periode' | |
) | |
) | |
simulation = scenario.new_simulation() | |
return simulation.calculate('salaire_net', '2015-11')[0] | |
def func(net): | |
def innerfunc(x): | |
return calculate_net_from(x)- net | |
return innerfunc | |
def solve(net_voulu): | |
print fsolve( | |
func(net_voulu), | |
net_voulu*1.5, # on entend souvent cette méthode... | |
xtol = 1/10 # précision | |
)[0], "<------ solution" | |
solve(net_voulu = 3000) | |
print calculate_net_from([3144]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
C'est exactement cela l'idée