Skip to content

Create ComponentPairKey for service models - #171

Merged
jd-lara merged 5 commits into
mainfrom
ac/service-containers
Sep 24, 2026
Merged

jd-lara merged 5 commits into
mainfrom
ac/service-containers

Conversation

@acostarelli

Copy link
Copy Markdown
Member

Service model variables need to be keyed on the service type and device type due to possible naming conflicts.

@github-actions

Copy link
Copy Markdown
Contributor

Performance Results
Main


This branch


@rodrigomha

Copy link
Copy Markdown
Contributor

Can you make a minimum example that showcases how our approach was failing before

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Unresolved critical and moderate findings remain in variable creation, key encoding, and tolerance dispatch tests.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 High severity · 1 Medium severity

Open (3)
What changed in this PR

Adds ComponentPairKey so service variables are keyed by device and service types, avoiding naming conflicts.

Changes:

  • Adds and exports composite key handling.
  • Refactors service-variable containers by device/service pairs.
  • Updates mocks and related tests.
File Summary
test/​verify_mocks.jl Updates mock construction.
test/​test_tolerance_dispatch.jl Moderate (3): Refixed variables need force for each sample at lines 95 and 149.
test/​test_quadratic_approximations.jl Removes an unused alias.
test/​test_optimization_container_keys.jl Tests composite keys and service-variable separation.
test/​mocks/​mock_services.jl Adds parameterized service mocks.
src/​InfrastructureOptimizationModels.jl Exports ComponentPairKey.
src/​core/​optimization_container_keys.jl Critical (1): Pair encoding can collide with generic parametric component encoding.
src/​common_models/​add_variable.jl Critical (1): Inserts the Vector type instead of an empty vector. Moderate (1): Unconditionally creates containers instead of reusing existing ones.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/common_models/add_variable.jl Outdated
Comment thread src/core/optimization_container_keys.jl Outdated
JuMP.@objective(setup.jump_model, Min, expr["g", 1])
JuMP.set_optimizer(setup.jump_model, HiGHS.Optimizer)
JuMP.set_silent(setup.jump_model)
JuMP.fix(x, x0)
@rodrigomha

Copy link
Copy Markdown
Contributor

@luke-kiernan Does generating a container for each component-type service-type fix the stability issue we had before when we were looping through different StaticInjection. I don't remember if this can fix the stability issue.

@codecov

codecov Bot commented Sep 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.61538% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/operation/decision_model_store.jl 0.00% 5 Missing ⚠️
src/core/optimization_container_keys.jl 91.66% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@jd-lara
jd-lara merged commit 97f3aa5 into main Sep 24, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants