PolicyEngine / PolicyEngine/policyengine-core

Speed up branch calculations by reimplementing `neutralize`

Open
#300 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
22
Forks
30
Avg merge
14h 33m
Merged PRs (30d)
7

Description

Currently, when a simulation branches, we can choose to either:

  • Clone the tax-benefit system (policy) to make it fully independent from the original TBS (at a cost of the TBS initialisation, often a few seconds)
  • Leave attached to the original TBS

For labour and capital gains responses, we need to create branches to measure marginal tax rates. In those branches, we have to neutralise the behavioural response variables (in order to avoid an infinite loop). Neutralisation is a change to the tax benefit policy, not the simulation data, so we need to clone the TBS. But we could implement an alternative neutralisation as a change to data not policy, by saying that instead of:

  • Neutralise(variable) -> adjust the simulation logic to always return 0
  • Neutralise(variable) -> set the simulation input data to include an array of zeros (size of entity population)

Then the LSR and CG branches wouldn't need to clone the TBS.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing branch creation for labour and capital gains responses and the current neutralisation path described in the issue. Compare policy cloning with changing simulation input data; done means branches avoid cloning the tax-benefit system while still neutralising behavioural response variables and preventing infinite loops.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.