Sienna-Platform / Sienna-Platform/PowerOperationsModels.jl
Build-loop type-stability: branch-divergent PTDF balance values and AbstractArray staging dict
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 2
- Forks
- 1
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 26
Description
Summary
Two build-loop type-stability findings from a time-series-chain audit. Both compound the container type-erasure documented in Sienna-Platform/InfrastructureOptimizationModels.jl#155 — fixing them without that one helps little, so they're documented here for when that issue is addressed.
Findings
-
Branch-divergent per-timestep values in the PTDF balance expression builders.
src/common_models/add_to_expression.jl:1533-1578(branch at 1565-1572) and_add_load_ts_parameter_to_balance!(:224-256, branch at 246-255):param/multare either a JuMP scalar fromget_parameter_column_refs(...)[t]or a literalFloat64, chosen by a runtimehas_tsflag resolved per device but not per type. In isolation a fine 2-way union; through the erased containers of IOM#155 it collapses toAny, soadd_proportional_to_jump_expression!(concrete dispatch arms inadd_jump_expressions.jl:24-43) redispatches dynamically 2 × devices × timesteps. Fix direction: resolvehas_tsinto aVal{true}/Val{false}split (or two typed helpers called once per device) so the timestep body is monomorphic. -
Dict{String, AbstractArray}staging in the time-series parameter build.src/common_models/add_parameters.jl:179(initial_values = Dict{String, AbstractArray}()) erases the concreteVector{Float64}the accessors return; the values re-emerge as::AbstractArray, theunwrap_for_param.(...)broadcast widens toAnyeltype, andIOM._set_parameter_at!(5 concrete dispatch arms) redispatches per step in the loop at:257-259. Mirror pattern in_add_objective_function_parameters!(~:727-782). Bounded today — runs once perbuild!, and noupdate_container_parameter_values!implementation exists yet on this branch to re-execute it per step — but it becomes hot the moment that update path is ported. Fix: type the dict to the concrete family (Dict{String, Vector{Float64}}), a signature-only change.
Found during a type-stability audit (Julia 1.12.5, faithful minimal reproductions; _set_parameter_at! and the multiplier dispatch tables themselves verified clean — the callers hand them Any).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the cited branches in src/common_models/add_to_expression.jl and the concrete dispatch arms in add_jump_expressions.jl, then inspect src/common_models/add_parameters.jl:179 and the mirrored objective-parameter code around lines 727-782. Use the stated Julia 1.12.5 minimal reproductions to verify the callers no longer hand Any values to the dispatch tables; done means the timestep paths remain type-stable without changing their behavior, alongside the container-type work tracked in IOM#155.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- performance
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100