Skip to content

Commit

Permalink
Reduce simulation time (#984)
Browse files Browse the repository at this point in the history
* Reduce simulation time

* Fix bugs in benefits!

* delete irrelevant tests

---------

Co-authored-by: Vahid Ahmadi <[email protected]>
  • Loading branch information
nikhilwoodruff and vahid-ahmadi authored Oct 24, 2024
1 parent 1600947 commit 4c54b86
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 49 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.13.1] - 2024-10-24 13:24:27

### Fixed

- Bug causing capital gains responses to be calculated for every reform simulation.

## [2.13.0] - 2024-10-24 11:42:25

### Fixed
Expand Down Expand Up @@ -1561,6 +1567,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0



[2.13.1]: https://github.com/PolicyEngine/openfisca-uk/compare/2.13.0...2.13.1
[2.13.0]: https://github.com/PolicyEngine/openfisca-uk/compare/2.12.0...2.13.0
[2.12.0]: https://github.com/PolicyEngine/openfisca-uk/compare/2.11.0...2.12.0
[2.11.0]: https://github.com/PolicyEngine/openfisca-uk/compare/2.10.0...2.11.0
Expand Down
5 changes: 5 additions & 0 deletions changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1310,3 +1310,8 @@
- Bug causing household app crashes.
- Metadat for OBR parameters.
date: 2024-10-24 11:42:25
- bump: patch
changes:
fixed:
- Bug causing capital gains responses to be calculated for every reform simulation.
date: 2024-10-24 13:24:27
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
- name: Single person eligible for housing benefit
# Source: https://www.entitledto.co.uk/benefits-calculator/Results/ComprehensiveCalc?cid=6ea29422-0999-4439-8047-b43ac444acb9&paymentPeriod=Weekly&calcScenario=CurrentSystem
period: 2023
absolute_error_margin: 15
input:
age: 28
weekly_hours: 26
benunit_rent: 80*52
is_single_person: true
tenure_type: RENT_FROM_COUNCIL
housing_benefit_reported: true
employment_income: 2000
output:
housing_benefit: 80*52

- name: Single person not eligible for housing benefit
# Source: https://www.entitledto.co.uk/benefits-calculator/Results/ComprehensiveCalc?cid=995817cb-b6f2-4350-825f-14f3e5a71265&paymentPeriod=Weekly&calcScenario=UniversalCredit
period: 2023
Expand All @@ -28,31 +13,4 @@
output:
housing_benefit: 0

- name: Lone parent with small earnings
# Source: https://www.entitledto.co.uk/benefits-calculator/Results/ComprehensiveCalc?cid=6b6f49eb-8054-47d8-90d5-0f74e23b89cb&paymentPeriod=Weekly&calcScenario=CurrentSystem
period: 2023
absolute_error_margin: 15
input:
age: 26
benunit_rent: 80*52
is_lone_parent: true
tenure_type: RENT_FROM_COUNCIL
housing_benefit_reported: true
employment_income: 0
output:
housing_benefit: 80*52

- name: Single person over pension age
# Source: https://www.entitledto.co.uk/benefits-calculator/Results/ComprehensiveCalc?cid=0e7190d3-6662-4653-b9d8-1836077df2b1&paymentPeriod=Weekly&calcScenario=CurrentSystem
period: 2023
input:
age: 68
gender: MALE
benunit_rent: 80*52
tenure_type: RENT_FROM_COUNCIL
housing_benefit_reported: true
is_single_person: true
private_pension_income: 100*52
output:
housing_benefit: 80*52

2 changes: 1 addition & 1 deletion policyengine_uk/variables/gov/dwp/attendance_allowance.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class aa_category(Variable):
default_value = LowerOrHigher.NONE

def formula(person, period, parameters):
aa = parameters(period).gov.dwp.attendance_allowance
aa = parameters(period).baseline.gov.dwp.attendance_allowance
SAFETY_MARGIN = 0.1 # Survey reported values could be slightly below eligible values when they should be above due to data manipulation
reported_weekly_aa = (
person("attendance_allowance_reported", period) / WEEKS_IN_YEAR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ def formula(benunit, period, parameters):
already_claiming = (
add(benunit, period, ["housing_benefit_reported"]) > 0
)
claiming_uc = benunit("would_claim_uc", period)
lha_eligible = benunit("LHA_eligible", period)
return already_claiming & (social | lha_eligible)
return already_claiming & (social | lha_eligible) & ~claiming_uc
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ def formula(person, period, parameters):
if simulation.baseline is None:
return 0

if (
parameters(
period
).gov.simulation.capital_gains_responses.elasticity
== 0
):
return 0

capital_gains = person("capital_gains_before_response", period)
tax_rate_change = person("relative_capital_gains_mtr_change", period)
elasticity = person("capital_gains_elasticity", period)
Expand Down
8 changes: 4 additions & 4 deletions policyengine_uk/variables/input/disability.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class dla_sc_category(Variable):
default_value = LowerMiddleOrHigher.NONE

def formula(person, period, parameters):
dla_sc = parameters(period).gov.dwp.dla.self_care
dla_sc = parameters(period).baseline.gov.dwp.dla.self_care
SAFETY_MARGIN = 0.1 # Survey reported values could be slightly below eligible values when they should be above due to data manipulation
reported_weekly_dla_sc = (
person("dla_sc_reported", period) / WEEKS_IN_YEAR
Expand Down Expand Up @@ -51,7 +51,7 @@ class dla_m_category(Variable):
default_value = LowerOrHigher.NONE

def formula(person, period, parameters):
dla_m = parameters(period).gov.dwp.dla.mobility
dla_m = parameters(period).baseline.gov.dwp.dla.mobility
SAFETY_MARGIN = 0.1 # Survey reported values could be slightly below eligible values when they should be above due to data manipulation
reported_weekly_dla_m = (
person("dla_m_reported", period) / WEEKS_IN_YEAR
Expand Down Expand Up @@ -80,7 +80,7 @@ class pip_m_category(Variable):
default_value = PIPCategory.NONE

def formula(person, period, parameters):
pip_m = parameters(period).gov.dwp.pip.mobility
pip_m = parameters(period).baseline.gov.dwp.pip.mobility
SAFETY_MARGIN = 0.1 # Survey reported values could be slightly below eligible values when they should be above due to data manipulation
reported_weekly_pip_m = (
person("pip_m_reported", period) / WEEKS_IN_YEAR
Expand Down Expand Up @@ -109,7 +109,7 @@ class pip_dl_category(Variable):
default_value = PIPCategory.NONE

def formula(person, period, parameters):
pip_dl = parameters(period).gov.dwp.pip.daily_living
pip_dl = parameters(period).baseline.gov.dwp.pip.daily_living
SAFETY_MARGIN = 0.1 # Survey reported values could be slightly below eligible values when they should be above due to data manipulation
reported_weekly_pip_dl = (
person("pip_dl_reported", period) / WEEKS_IN_YEAR
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setup(
name="PolicyEngine-UK",
version="2.13.0",
version="2.13.1",
author="PolicyEngine",
author_email="[email protected]",
classifiers=[
Expand Down

0 comments on commit 4c54b86

Please sign in to comment.