Skip to content

Refactor regulation policies#269

Draft
Femkemilene wants to merge 6 commits intomainfrom
refactor_regulation_policies
Draft

Refactor regulation policies#269
Femkemilene wants to merge 6 commits intomainfrom
refactor_regulation_policies

Conversation

@Femkemilene
Copy link
Contributor

Refactor regulatory policies. New code is more DRY and 30x faster than before.

There are two logical changes:

  • capacity now approaches MWKA more smoothly
  • The regulation correction only works when demand is growing, in line with E3ME

I've kept the code to compare outputs, but will of course tidy up after review. For testing:

  • MWKA is tested in baseline
  • In the baseline, there are regulatory policies in power and heat, but not in transport
  • Exogenous sales are off in S0 and S2, so need to be manually added for testing.

MWKA is reverted back to its old consistent behaviour, so that there's no guessing what the policy does (there were 3 complicated conditions, which broke the logic of using exogenous capacity for partial data).

Pim, feel free to delegate to someone else at CE!

And clean up the power sector policies
Logical intermediate names, and remove wrapper function in favour of more explicit calling of functions
And add comparisons in all three sectors
For easier comparison
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors regulatory policies across FTT modules to improve performance (30x faster) and code maintainability by centralizing common regulatory policy logic. The refactor also aligns regulation correction behavior with E3ME by only applying corrections when demand is growing, and makes capacity approach MWKA more smoothly.

  • Centralizes regulatory policy logic into a new shared module ftt_regulatory_policies.py
  • Updates Transport, Power, and Heat modules to use the new centralized functions
  • Adds performance timing and comparison checks between old and new implementations

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
settings.ini Disables most modules for testing, enabling only FTT-P
SourceCode/model_class.py Adds performance timing measurement starting from 2011
SourceCode/ftt_core/ftt_regulatory_policies.py New module containing centralized regulatory policy functions
SourceCode/Transport/ftt_tr_main.py Refactors to use new regulatory policy functions with comparison logic
SourceCode/Power/ftt_p_main.py Updates documentation and implements new regulatory policy approach
SourceCode/Power/fft_p_regulatory_policies.py Simplifies old policy implementation for comparison purposes
SourceCode/Heat/ftt_h_main.py Integrates new regulatory policy functions with comparison checks

@Femkemilene Femkemilene marked this pull request as draft August 8, 2025 10:23
@Femkemilene
Copy link
Contributor Author

Me and Pim have discussed and agree with the current simplified implementation. Testing still left to be done.

@Femkemilene
Copy link
Contributor Author

This is a good first pull request. A bit more context:

FTT has two types of policies, regulatory policies such as phase-outs, and price policies such as subsidies. In this bit of code, we're refactoring the regulatory policies so that all the different FTT models use the same code. An important element of reviewing is to say whether the code is understandable on sight.

I've kept in some of the code to compare with the old implementation. Once you're happy with the code, it's my job to clean everything up and to resolve the merge conflicts.

More explicit in mewl_dt naming (as this is still last timestep). No need for slow copying here.
@Femkemilene
Copy link
Contributor Author

@fciscoamsler: what's the latest on this one?

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

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants