Skip to content

Instantly share code, notes, and snippets.

@laem
Last active January 20, 2016 16:37
Show Gist options
  • Save laem/339203bc1a9bc77aff08 to your computer and use it in GitHub Desktop.
Save laem/339203bc1a9bc77aff08 to your computer and use it in GitHub Desktop.
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])
@benjello
Copy link

J'ai aussi tenté une inversion "directe" ici

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment