Repository navigation
Adding capacity and emission axes options for MGA solution space - #423
Draft
matteo-nicoli wants to merge 2 commits into
Draft
matteo-nicoli wants to merge 2 commits into
matteo-nicoli wants to merge 2 commits into
Conversation
Non-annual demand technologies have both time-sliced and annual output flow variables for the same activity. The activity vector manager mapped both, so their activity was counted twice in the category values (the hull points) and in the objective of every MGA solve. Map annual flow variables only for annual technologies. Add a test that checks the activity of each category against the output flows written for the solved model.
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
MGA hull expansion could only diversify the activity of technology categories; the other documented axes were placeholders. Following the MGA development guide, add one vector manager per axis, each selected by the manager factory: - TECH_CATEGORY_ACTIVITY (default): TechActivityVectorManager, output flows - TECH_CATEGORY_CAPACITY: TechCapacityVectorManager, net available capacity - TECH_CATEGORY_EMISSION: TechEmissionVectorManager, activity-related emissions of the commodities listed in the new `axis_emission_commodities` option The capacity and emission managers subclass the activity manager and only change which variables make up a category's value. The placeholder TECH_CAPACITY and EMISSION_ACTIVITY axes are removed. Categories with no variables for the axis are excluded, and at least two categories are required to build the hull. Technologies without a category are left out of every axis. Grouping them into an extra DEFAULT dimension mixed unrelated quantities, typically dummy, transfer and pass-through technologies whose capacity carries no cost, so on the capacity axis any direction that increased their capacity was unbounded. They still take whatever values the solver finds, but MGA does not push them. The number left out is logged, and the documentation says which technologies need a category. The sample config lists the three axes and the axis_emission_commodities option, with aligned comments in the [MGA] section.
matteo-nicoli
force-pushed
the
feature/mga-category-axes
branch
from
November 24, 2026 21:09
0651bf4 to
3f86a44
Compare
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MGA hull expansion could only diversify the activity of technology categories: the other documented axes were placeholders. This PR fixes the activity axis and adds capacity and emission axes, so the modeler can choose what to diversify. Two commits:
output_flow_out.axistech_category_activity(default)tech_category_capacity(new)tech_category_emission(new)axis_emission_commoditiesChanges
TechCapacityVectorManagerandTechEmissionVectorManager, thin subclasses of the activity manager that only change which variables make up a category's value and, for emissions, their weights (the emission rates). The placeholder axesTECH_CAPACITYandEMISSION_ACTIVITYare removed.DEFAULTdimension: it summed dummy imports, transfers and pass-throughs, which pushes the exploration towards differences nobody asked for, and on the capacity axis any direction pushing their free capacity up is unbounded. They are still mapped and written for every solution, and the run logs how many are left out.mga.rstgains a section on categories and axes (which technologies need a category, and which are best left without one); the MGA README, design notes and sample config are updated.This PR changes some of the same lines of
tech_activity_vector_manager.pyas the MGA PR: whichever of the two is merged later needs a small conflict resolution.On a fully categorized model, the activity axis behaves as after commit 1. Without the search-direction fix of the MGA PR, the new axes work, but the emission axis does not reliably cover its own space (see below): the two PRs are best used together.
Tests
test_mga_axes.py: category activity againstoutput_flow_out(fails without commit 1); capacity and emission values against the model results andoutput_emission; error cases (missing or unknown emission commodity, too few categories); uncategorized technologies left out of the activity and capacity axes; full MGA runs on the capacity and emission axes.The full test suite passes locally (338 tests, with gurobipy 13 to match the local licence; the 3 CLI smoke tests time out on this machine, where
temoatakes about 10 s to start, onunstabletoo). On Linux, with Python 3.12 and 3.14, it fails only the tests that fail onunstablethere too (those that need a Gurobi licence, and with Python 3.12 fivetemoa tutorialCLI tests).Sanity checks on Utopia
These checks were run on
main(a96d46e), before the branch was moved ontounstable; the MGA code they exercise is the same on both.The new axes are correct
MGA's initial solves minimize and maximize each category. Each result was compared with an independent optimization, written directly from the model's variables rather than through the vector manager:
["co2"]["co2", "nox"]What each axis explores
Three case studies built from Utopia by recategorizing its technologies (transport: diesel, gasoline and electric vehicles; power chains: each plant with its fuel import; transport with synthetic vintage-dependent NOx factors). Each axis was run 3 times at 3% and 10% cost slack, 100 hull-expansion solves each, and every solution was measured in the capacity, activity and emission spaces. The share is the volume of the hull of an axis's solutions over the hull of all solutions found by all axes.
DEFAULTdimension.No solve failed in any run, every solution stayed within its cost relaxation, and emission values matched
output_emissionto 7e-15.