Skip to content

Ac/port psi 1585 dual mip rounding#128

Closed
acostarelli wants to merge 5 commits into
mainfrom
ac/port-psi-1585-dual-mip-rounding
Closed

Ac/port psi 1585 dual mip rounding#128
acostarelli wants to merge 5 commits into
mainfrom
ac/port-psi-1585-dual-mip-rounding

Conversation

@acostarelli

Copy link
Copy Markdown
Member

Thanks for opening a PR to InfrastructureOptimizationModels.jl, please take note of the following when making a PR:

Check the contributor guidelines

Anthony Costarelli and others added 3 commits June 25, 2026 18:11
Gap analysis + actionable plan for porting PSI (PowerSimulations.jl)
generic optimization-core changes into IOM. Confirmed port: PR #1585
(dual-cache MIP-tolerance rounding); plus DLR IOM portion and minor
serialization residuals, with an already-ported "do not redo" list.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Round cached integer/binary primal values to the nearest integer before
re-fixing relaxed variables in process_duals. MIP solver tolerances leave
values like 0.9999997 instead of 1.0, making the fixed relaxation infeasible.
Landed into IOM's existing dual_processing structure (not PSI's VarRestoreInfo
refactor); the restore path already reuses var_cache, so rounding once also
covers the integer-restore path.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Record findings for the three plan items: #1585 ported (functional rounding
fix only, not PSI's struct refactor); DLR has no IOM work (param types live in
POM); #1539 residuals are stale write_result! refs with no action needed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

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.

Pull request overview

This PR ports the PSI #1585 fix into InfrastructureOptimizationModels.jl by rounding cached primal values for dense integer/binary variable containers before re-fixing them during process_duals, preventing LP infeasibility caused by MIP integrality tolerances (e.g., 0.9999997 vs 1.0).

Changes:

  • Added _round_cache_values! for DenseAxisArray caches and applied it immediately before JuMP.fix.(...) in process_duals.
  • Added a regression test ensuring MIP-tolerance values in the cache are snapped to exact integers.
  • Added an internal port-plan markdown document capturing PSI→IOM port status and rationale.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/core/dual_processing.jl Rounds cached integer/binary primal values before refixing during dual processing to avoid tolerance-induced infeasibility.
test/test_optimization_container.jl Adds a regression test validating cache rounding behavior for MIP-tolerance artifacts.
.claude/iom_port_plan.md Documents PSI port tracking and the rationale for the #1585 rounding-only port.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Performance Results
Main

Network: 10 nodes, 13 edges, 3 cost segments
Generators: 5, Demands: 5
Loss coefficients (a, b, c) per generator:
  n1: a=0.007287  b=0.005968  c=0.003850
  n2: a=0.001094  b=0.009002  c=0.007028
  n3: a=0.007897  b=0.008552  c=0.003001
  n4: a=0.008179  b=0.002530  c=0.009637
  n5: a=0.009778  b=0.009934  c=0.009099

Solver logs: /home/runner/work/InfrastructureOptimizationModels.jl/InfrastructureOptimizationModels.jl/main/test/performance/logs/solver_2026-06-26T22-04-13.log

==============================================================================================================================================
Bilinear Approximation Benchmarks
  Refinement = depth for all methods
==============================================================================================================================================
Method          R   Vars Constrs   Bins    Objective   Gap(%) MIPGap(%)     LowerBnd  rmse δbi   max δbi   rmse δq    max δq  build_t  solve_t
----------------------------------------------------------------------------------------------------------------------------------------------
NLP (Ipopt)     -     40     105      0     0.956760        -         -            -  0.00e+00  0.00e+00  0.00e+00  0.00e+00   0.0337   0.0047

NLP (Uno)       -     40     105      0     0.956760   0.0000         -            -  0.00e+00  0.00e+00  0.00e+00  0.00e+00   0.0013   0.0012

Bin2+sSOS       4    190     535      0     1.180700  23.4061    0.0000     1.180700  8.07e-02  1.41e-01  2.49e+01  5.48e+01   0.0056   1.8987
Bin2+sSOS       6    250     655      0     1.098175  14.7806    0.0000     1.098175  1.26e-01  2.86e-01  5.47e+00  9.07e+00   0.0061   7.9934
Bin2+sSOS       8    310     775      0     1.053069  10.0661    0.0088     1.052976  8.62e-02  2.43e-01  4.18e+01  9.32e+01   0.0060  28.4406

Bin2+mSOS       4    310     805    120     1.180700  23.4061    0.0000     1.180700  8.07e-02  1.41e-01  2.49e+01  5.48e+01   0.0025   1.8689
Bin2+mSOS       6    430    1045    180     1.098175  14.7806    0.0000     1.098175  1.26e-01  2.86e-01  5.47e+00  9.07e+00   0.0025   6.1870
Bin2+mSOS       8    550    1285    240     1.053069  10.0661    0.0080     1.052984  8.62e-02  2.43e-01  4.18e+01  9.32e+01   0.0028  20.2736

Bin2+Saw        4    310    1075    120     0.985859   3.0414    0.0055     0.985805  1.15e-01  2.48e-01  2.65e+02  5.18e+02   0.0033  12.2704
Bin2+Saw        6    430    1495    180     0.958677   0.2004    0.0077     0.958603  7.52e-02  1.68e-01  8.94e+01  1.71e+02   0.0041  14.3037
Bin2+Saw        8    550    1915    240     0.956996   0.0247    0.0072     0.956927  7.52e-02  1.68e-01  1.37e+02  2.09e+02   0.0047  53.1372

HybS+sSOS       4    310    1165      0     0.812261  15.1030    0.0000     0.812261  5.52e-01  1.00e+00  2.04e+02  2.97e+02   0.0074   2.8866
HybS+sSOS       6    410    1545      0     0.891208   6.8515    0.0000     0.891208  5.49e-01  1.00e+00  3.69e+02  7.09e+02   0.0083   5.2100
HybS+sSOS       8    510    1925      0     0.934789   2.2965    0.0087     0.934707  5.48e-01  1.00e+00  3.47e+02  5.22e+02   0.0085  16.4745

HybS+mSOS       4    390    1345     80     0.812261  15.1030    0.0046     0.812224  5.52e-01  1.00e+00  2.04e+02  2.97e+02   0.0036   3.0182
HybS+mSOS       6    530    1805    120     0.891208   6.8515    0.0000     0.891208  5.49e-01  1.00e+00  3.69e+02  7.09e+02   0.0041   6.5945
HybS+mSOS       8    670    2265    160     0.934789   2.2965    0.0047     0.934744  5.48e-01  1.00e+00  3.47e+02  5.22e+02   0.0047  17.0129

HybS+Saw        4    390    1525     80     0.951869   0.5113    0.0084     0.951789  5.48e-01  1.00e+00  2.16e+03  4.23e+03   0.0040  11.2332
HybS+Saw        6    530    2105    120     0.956386   0.0391    0.0099     0.956291  5.48e-01  1.00e+00  4.57e+02  7.57e+02   0.0049  35.3388
HybS+Saw        8    670    2685    160     0.956734   0.0027    0.0078     0.956659  5.48e-01  1.00e+00  6.08e+00  1.07e+01   0.0059 104.4023

DNMDT           4    395    1640     80     0.954878   0.1967    0.0004     0.954874  1.39e-03  3.13e-03  4.70e-04  1.05e-03   0.0035   4.3230
DNMDT           6    550    2315    120     0.956636   0.0130    0.0098     0.956541  6.75e-05  1.57e-04  4.26e+03  9.54e+03   0.0043  18.4696
DNMDT           8    705    2990    160     0.956754   0.0007    0.0096     0.956662  4.62e-06  1.14e-05  9.42e+01  1.49e+02   0.0042  57.6012

==============================================================================================================================================

This branch

Network: 10 nodes, 13 edges, 3 cost segments
Generators: 5, Demands: 5
Loss coefficients (a, b, c) per generator:
  n1: a=0.007287  b=0.005968  c=0.003850
  n2: a=0.001094  b=0.009002  c=0.007028
  n3: a=0.007897  b=0.008552  c=0.003001
  n4: a=0.008179  b=0.002530  c=0.009637
  n5: a=0.009778  b=0.009934  c=0.009099

Solver logs: /home/runner/work/InfrastructureOptimizationModels.jl/InfrastructureOptimizationModels.jl/branch/test/performance/logs/solver_2026-06-26T22-12-42.log

==============================================================================================================================================
Bilinear Approximation Benchmarks
  Refinement = depth for all methods
==============================================================================================================================================
Method          R   Vars Constrs   Bins    Objective   Gap(%) MIPGap(%)     LowerBnd  rmse δbi   max δbi   rmse δq    max δq  build_t  solve_t
----------------------------------------------------------------------------------------------------------------------------------------------
NLP (Ipopt)     -     40     105      0     0.956760        -         -            -  0.00e+00  0.00e+00  0.00e+00  0.00e+00   0.0321   0.0049

NLP (Uno)       -     40     105      0     0.956760   0.0000         -            -  0.00e+00  0.00e+00  0.00e+00  0.00e+00   0.0014   0.0012

Bin2+sSOS       4    190     535      0     1.180700  23.4061    0.0000     1.180700  8.07e-02  1.41e-01  2.49e+01  5.48e+01   0.0058   1.8869
Bin2+sSOS       6    250     655      0     1.098175  14.7806    0.0000     1.098175  1.26e-01  2.86e-01  5.47e+00  9.07e+00   0.0063   7.9157
Bin2+sSOS       8    310     775      0     1.053069  10.0661    0.0088     1.052976  8.62e-02  2.43e-01  4.18e+01  9.32e+01   0.0061  28.0934

Bin2+mSOS       4    310     805    120     1.180700  23.4061    0.0000     1.180700  8.07e-02  1.41e-01  2.49e+01  5.48e+01   0.0024   1.8382
Bin2+mSOS       6    430    1045    180     1.098175  14.7806    0.0000     1.098175  1.26e-01  2.86e-01  5.47e+00  9.07e+00   0.0025   6.0490
Bin2+mSOS       8    550    1285    240     1.053069  10.0661    0.0080     1.052984  8.62e-02  2.43e-01  4.18e+01  9.32e+01   0.0026  19.9891

Bin2+Saw        4    310    1075    120     0.985859   3.0414    0.0055     0.985805  1.15e-01  2.48e-01  2.65e+02  5.18e+02   0.0033  12.1018
Bin2+Saw        6    430    1495    180     0.958677   0.2004    0.0077     0.958603  7.52e-02  1.68e-01  8.94e+01  1.71e+02   0.0040  14.1072
Bin2+Saw        8    550    1915    240     0.956996   0.0247    0.0072     0.956927  7.52e-02  1.68e-01  1.37e+02  2.09e+02   0.0046  52.3203

HybS+sSOS       4    310    1165      0     0.812261  15.1030    0.0000     0.812261  5.52e-01  1.00e+00  2.04e+02  2.97e+02   0.0071   2.8452
HybS+sSOS       6    410    1545      0     0.891208   6.8515    0.0000     0.891208  5.49e-01  1.00e+00  3.69e+02  7.09e+02   0.0075   5.0696
HybS+sSOS       8    510    1925      0     0.934789   2.2965    0.0087     0.934707  5.48e-01  1.00e+00  3.47e+02  5.22e+02   0.0082  16.2511

HybS+mSOS       4    390    1345     80     0.812261  15.1030    0.0046     0.812224  5.52e-01  1.00e+00  2.04e+02  2.97e+02   0.0035   2.9746
HybS+mSOS       6    530    1805    120     0.891208   6.8515    0.0000     0.891208  5.49e-01  1.00e+00  3.69e+02  7.09e+02   0.0041   6.4869
HybS+mSOS       8    670    2265    160     0.934789   2.2965    0.0047     0.934744  5.48e-01  1.00e+00  3.47e+02  5.22e+02   0.0046  16.7130

HybS+Saw        4    390    1525     80     0.951869   0.5113    0.0084     0.951789  5.48e-01  1.00e+00  2.16e+03  4.23e+03   0.0040  10.9460
HybS+Saw        6    530    2105    120     0.956386   0.0391    0.0099     0.956291  5.48e-01  1.00e+00  4.57e+02  7.57e+02   0.0049  34.7411
HybS+Saw        8    670    2685    160     0.956734   0.0027    0.0078     0.956659  5.48e-01  1.00e+00  6.08e+00  1.07e+01   0.0059 104.2125

DNMDT           4    395    1640     80     0.954878   0.1967    0.0004     0.954874  1.39e-03  3.13e-03  4.70e-04  1.05e-03   0.0032   4.3327
DNMDT           6    550    2315    120     0.956636   0.0130    0.0098     0.956541  6.75e-05  1.57e-04  4.26e+03  9.54e+03   0.0038  18.6354
DNMDT           8    705    2990    160     0.956754   0.0007    0.0096     0.956662  4.62e-06  1.14e-05  9.42e+01  1.49e+02   0.0042  58.1839

==============================================================================================================================================

Comment thread test/test_optimization_container.jl Outdated
Comment thread .claude/iom_port_plan.md Outdated
Anthony Costarelli and others added 2 commits June 26, 2026 17:52
…re method

Comment 1: inline the integer-cache rounding in process_duals instead of a
dedicated _round_cache_values! helper, and drop the trivial unit test that only
exercised round.(). Rounding cached integer primals before re-fixing is the
canonical JuMP pattern for computing MILP duals.

Comment 2: add the missing write_output! method for 1-D UnitRange-indexed
(time-only) results in DecisionModelStore, which previously MethodError'd since
initialize_storage! allocates that shape for component-less results. Mirrors
PSI's write_result! (the #1506 system-slack fix) and the existing 1-D
Vector{String} method. Add a store write/read round-trip test and correct the
port-plan note.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
`const PSI = InfrastructureOptimizationModels` was a misleading alias — this is
IOM, not PowerSimulations. Replace all 272 `PSI.` references with the correct
`IOM.` alias (already defined in the test harness) and drop the redundant
`PSI` definitions/guards in mock_components.jl and the three test files.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

2 participants