Skip to content

test unit invariance of objective function coefficient - #142

Merged
jd-lara merged 1 commit into
mainfrom
test/cost-curve-unit-invariance
Jul 28, 2026
Merged

test unit invariance of objective function coefficient#142
jd-lara merged 1 commit into
mainfrom
test/cost-curve-unit-invariance

Conversation

@luke-kiernan

Copy link
Copy Markdown
Collaborator

What the title says: put the same physical data in different unit systems and check that we get the same objective function coefficient in each case.

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

Adds regression tests to ensure objective-function coefficients derived from linear and quadratic cost curves are invariant to the unit system used to express the same underlying physical costs (natural units vs system-base vs device-base), strengthening correctness around unit conversions in objective construction.

Changes:

  • Add unit-system invariance test coverage for CostCurve{LinearCurve} objective coefficients.
  • Add unit-system invariance test coverage for CostCurve{QuadraticCurve} linear and quadratic objective coefficients.

Reviewed changes

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

File Description
test/test_linear_curve.jl Adds a testset verifying linear-cost objective coefficients match across NATURAL_UNITS, SYSTEM_BASE, and DEVICE_BASE representations of the same physical rate.
test/test_quadratic_curve.jl Adds a testset verifying both linear and quadratic objective coefficients match across NATURAL_UNITS, SYSTEM_BASE, and DEVICE_BASE representations of the same physical quadratic cost.

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

@github-actions

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-07-21T19-38-15.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.0253   0.0039

NLP (Uno)       -     40     105      0     0.956760   0.0000         -            -  0.00e+00  0.00e+00  0.00e+00  0.00e+00   0.0011   0.0010

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.0049   1.4221
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.0052   6.0257
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.0057  21.4280

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.3931
Bin2+mSOS       6    430    1045    180     1.098175  14.7806    0.0092     1.098074  1.26e-01  2.86e-01  5.47e+00  9.07e+00   0.0025   5.9888
Bin2+mSOS       8    550    1285    240     1.053069  10.0661    0.0045     1.053021  8.62e-02  2.43e-01  4.18e+01  9.32e+01   0.0026  14.4101

Bin2+Saw        4    310    1075    120     0.985823   3.0376    0.0000     0.985823  1.08e-01  2.49e-01  1.11e+02  2.44e+02   0.0032   4.6955
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.0031  10.7444
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.0037  40.5603

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.0064   2.1499
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.0065   3.9635
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.0072  12.5145

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.0030   2.3382
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.0034   5.0127
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.0038  12.9876

HybS+Saw        4    390    1525     80     0.951869   0.5113    0.0021     0.951849  5.48e-01  1.00e+00  2.16e+03  4.23e+03   0.0033  10.9093
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.0039  26.8631

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-07-21T19-43-51.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.0249   0.0037

NLP (Uno)       -     40     105      0     0.956760   0.0000         -            -  0.00e+00  0.00e+00  0.00e+00  0.00e+00   0.0011   0.0010

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.0051   1.4134
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.0053   6.0046
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.0055  21.3921

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.0020   1.3875
Bin2+mSOS       6    430    1045    180     1.098175  14.7806    0.0092     1.098074  1.26e-01  2.86e-01  5.47e+00  9.07e+00   0.0021   5.9744
Bin2+mSOS       8    550    1285    240     1.053069  10.0661    0.0045     1.053021  8.62e-02  2.43e-01  4.18e+01  9.32e+01   0.0022  14.3725

Bin2+Saw        4    310    1075    120     0.985823   3.0376    0.0000     0.985823  1.08e-01  2.49e-01  1.11e+02  2.44e+02   0.0027   4.6542
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.0032  10.6184
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.0037  40.2537

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.0064   2.1384
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.0068   3.9458
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.0070  12.4340

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.0028   2.3279
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.0033   4.9988
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.0037  12.9418

HybS+Saw        4    390    1525     80     0.951869   0.5113    0.0021     0.951849  5.48e-01  1.00e+00  2.16e+03  4.23e+03   0.0032  10.8696
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.0039  26.8115

@jd-lara
jd-lara merged commit 1b1d624 into main Jul 28, 2026
6 of 7 checks passed
@luke-kiernan
luke-kiernan deleted the test/cost-curve-unit-invariance branch July 29, 2026 13:16
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