ML-OPF-Bench: Benchmarking Machine Learning for Optimal Power Flow
Organizations: Dartmouth College · Hong Kong University of Science and Technology (Guangzhou) · University of Alberta
Abstract
Machine Learning (ML) methods promise a fast solution process for Optimal Power Flow (OPF). While inconsistent test cases, implementations, and evaluation metrics across existing studies make it challenging to determine which algorithmic advances are most critical for real-world deployment. To this end, we propose ML-OPF-Bench, a unified benchmark for AC- and DC-OPF that evaluates representative ML algorithms under a consistent pipeline, stress-tests them across system sizes, distribution shifts, and resource budgets, and ranks them with a multi-objective framework. We find that prediction accuracy alone is not a reliable indicator of operational feasibility. Under heavily loaded, congested conditions, even the strongest in-distribution performers lose their advantage, while feasibility is maintained largely by post-processing that enforces the target constraints rather than by the underlying pure ML predictor. Data scaling shows that prediction accuracy and constraint violations follow different trajectories, whereas compute scaling shows that returns diminish and that larger models do not consistently perform better. These results expose critical trade-offs among ML methods' speed, accuracy, and feasibility, and offer practical guidance for future ML-OPF design. We open-source the benchmark as an extensible Python package for integrating new learning-based OPF algorithms and evaluating them under the same standard as the existing baselines.
Figures & tables
| Paradigm | Method | Training Objective | Constraint Handling |
| Pure Data-Driven | LR [ 10 ] | Least squares | No explicit constraint penalties |
| DNN [ 13 ; 29 ; 28 ] | MSE | No explicit constraint penalties | |
| GNN [ 27 ] | MSE | Graph features; no constraint penalties | |
| Physics-Informed | Constraint Penalty (CP) [ 29 ; 28 ] | MSE + violation penalties | Fixed-weight penalties in loss |
| Multiplier Updates (MU) [ 13 ] | MSE + weighted violations | Adaptive multipliers on violations | |
| KKT Embedded (KKT) [ 25 ; 26 ] | Primal/dual + KKT residuals | Optimality residuals in loss |
| Notation | Definition |
|---|---|
| Set of generators/non-slack generators | |
| Set of buses | |
| Set of transmission lines | |
| Number of generators/buses/lines/loads | |
| Number of evaluation samples | |
| Active/reactive power generation |
| (1a) | ||||
| subject to: | ||||
| (1b) | ||||
| (1c) | ||||
| (1d) | ||||
| Test Case | (AC) | (DC) | Batch | ||||
|---|---|---|---|---|---|---|---|
| 30-bus | 30 | 6 | 21 | 41 | 64/32 | 32/16 | 32 |
| 118-bus | 118 | 54 | 99 | 186 | 256/128 | 128/64 | 64 |
| 300-bus | 300 | 69 | 191 | 411 | 512/256 | 256/128 | 128 |
| 30-bus | 118-bus | 300-bus | |||||||||||
| Category | Method | MAE Pg | Viol total | Cost gap | Infer | MAE Pg | Viol total | Cost gap | Infer | MAE Pg | Viol total | Cost gap | Infer |
| Data-Driven | LR | 0.000 | 0.000 | 0.000 | 0.119 | 1.013 | 0.076 | -0.004 | 0.121 | 2.413 | 0.490 | -0.003 | 0.128 |
| DNN | 0.162 | 0.000 | 0.040 | 0.454 | 0.711 | 0.030 | 0.001 | 0.439 | 1.789 | 0.991 | -0.152 | 0.456 | |
| GNN | 1.369 | 0.003 | -0.034 | 2.950 | 1.073 | 0.021 | -0.003 | 2.906 | 3.171 | 1.347 | 0.015 | 3.008 | |
| Physics-Informed | CP | 1.118 | 0.003 | -0.109 | 0.448 | 0.364 | 0.005 | 0.011 | 0.451 | 1.170 | 0.550 | 0.019 | 0.481 |
| MU | 1.134 | 0.003 | -0.079 | 0.463 | 0.377 | 0.004 | 0.014 | 0.483 | 1.925 | 0.185 | 0.928 | 0.473 | |
| 30-bus | 118-bus | 300-bus | ||||||||||||||
| Category | Method | MAE Pg | MAE V | Viol total | Cost gap | Infer | MAE Pg | MAE V | Viol total | Cost gap | Infer | MAE Pg | MAE V | Viol total | Cost gap | Infer |
| Data-Driven | LR | 0.040 | 0.005 | 0.001 | 0.000 | 9.720 | 0.518 | 0.066 | 0.093 | -0.002 | 17.921 | 4.565 | 0.248 | 0.572 | -0.028 | 26.831 |
| DNN | 0.240 | 0.015 | 0.006 | 0.018 | 9.621 | 0.306 | 0.041 | 0.076 | -0.012 | 11.060 | 3.995 | 0.216 | 0.451 | 0.701 | 17.967 | |
| GNN | 3.245 | 3.576 | 0.553 | 0.514 | 22.332 | 0.958 | 3.702 | 1.295 | 0.403 | 33.259 | 6.566 | 3.924 | 4.791 | 0.062 | 68.736 | |
| Physics-Informed | CP | 1.970 | 0.253 | 0.014 | -0.086 | 9.666 | 1.088 | 0.122 | 0.078 | -0.426 | 11.267 | 10.718 | 0.797 | 0.686 | 1.011 | 17.868 |
| MU | 0.569 | 0.032 | 0.005 | -0.121 | 9.973 | 1.341 | 0.074 | 0.118 | 0.078 | 11.663 | 8.067 | 0.595 | 2.692 | 0.029 | 18.957 | |
| Rank | Method | 30-bus | 118-bus | 300-bus | Mean | Marginal (%) |
| DC-OPF | ||||||
| 1 | LR | 1 | 1 | 1 | 1.00 | 73.33 |
| 2 | KKT | 2 | 2 | 1 | 1.67 | 60.00 |
| 3 | CP | 3 | 1 | 1 | 1.67 | 57.50 |
| 4 | NGT | 3 | 1 | 1 | 1.67 | 56.25 |
| 5 | E-NGT | 2 | 2 | 1 | 1.67 | 55.83 |
| Form | Method | Metric | ||||||
|---|---|---|---|---|---|---|---|---|
| AC | DNN | MAE (%) | 0.349 | -0.555 | 0.974 | 0.995 | -0.568 | 0.996 |
| AC | KKT | MAE (%) | 0.719 | -0.584 | 0.966 | 0.939 | -0.508 | 0.965 |
| AC | LR | MAE (%) | 0.534 | -0.048 | 0.826 | 0.837 | -0.051 | 0.839 |
| AC | MU | MAE (%) | 0.960 | -0.487 | 0.786 | 0.480 | -0.328 | 0.648 |
| AC | DNN | Viol | 0.009 | -0.356 | 0.742 | 0.692 | -0.280 | 0.754 |
| AC | KKT | Viol | 0.011 | -0.613 | 0.920 | 0.914 | -0.508 | 0.965 |
| Form | Depth | Width | Parameters | Stop epoch | Best epoch | TFLOPs | Train (s) |
|---|---|---|---|---|---|---|---|
| AC | 2 | 64 | 23851 | 214 | 194 | 0.365 | 58.41 |
| AC | 2 | 128 | 55787 | 250 | 230 | 1.023 | 65.71 |
| AC | 2 | 256 | 144235 | 171 | 151 | 1.870 | 47.60 |
| AC | 2 | 512 | 419435 | 228 | 208 | 7.509 | 62.11 |
| AC | 3 | 64 | 28011 | 333 | 313 | 0.684 | 107.31 |
| AC | 3 | 128 | 72299 | 250 | 230 | 1.370 | 78.25 |
| Form | Budget (TFLOPs) | Actual (TFLOPs) | Depth width | Checkpoint epoch | MAE (%) |
|---|---|---|---|---|---|
| AC | 0.077 | 0.077 | 45 | 0.896 | |
| AC | 0.254 | 0.252 | 148 | 0.493 | |
| AC | 0.835 | 0.831 | 121 | 0.360 | |
| AC | 2.748 | 1.868 | 252 | 0.206 | |
| AC | 9.037 | 1.868 | 252 | 0.206 | |
| DC | 0.072 | 0.072 | 45 | 0.843 |
| Case | Scenario | Method | MAE | Viol | Viol | Viol line | Gap (%) | Infer (ms) | Train (s) | Epoch/steps |
|---|---|---|---|---|---|---|---|---|---|---|
| 30 | TYP | AS | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 4.442 | 12.73 | 33 |
| 30 | TYP | CP | 1.118 | 0.000 | 0.000 | 0.003 | -0.109 | 0.448 | 33.50 | 72 |
| 30 | TYP | DNN | 0.162 | 0.000 | 0.000 | 0.000 | 0.040 | 0.454 | 14.53 | 51 |
| 30 | TYP | E-NGT | 0.225 | 0.000 | 0.000 | 0.001 | -0.069 | 0.379 | 2732.66 | 2500 |
| 30 | TYP | GNN | 1.369 | 0.000 | 0.000 | 0.003 | -0.034 | 2.950 | 164.73 | 118 |
| 30 | TYP | KKT | 0.058 | 0.000 | 0.000 | 0.000 | -0.015 | 0.438 | 85.84 | 63 |
| Case | Scenario | Method | MAE | MAE | Viol | Viol | Viol | Viol | Viol line | Gap (%) | PF (%) | Infer (ms) | Train (s) | Epoch/steps |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 30 | TYP | AS | 20.187 | 0.068 | 0.000 | 0.000 | 0.042 | 0.000 | 0.000 | 6.654 | 100.00 | 11.005 | 13.58 | 28 |
| 30 | TYP | CP | 1.970 | 0.253 | 0.001 | 0.000 | 0.000 | 0.009 | 0.005 | -0.086 | 100.00 | 9.666 | 10240.01 | 272 |
| 30 | TYP | DNN | 0.240 | 0.015 | 0.001 | 0.000 | 0.004 | 0.000 | 0.000 | 0.018 | 100.00 | 9.621 | 18.35 | 62 |
| 30 | TYP | E-NGT | 32.507 | 0.105 | 0.104 | 0.000 | 0.004 | 0.000 | 0.007 | -5.565 | 100.00 | 10.903 | 6952.06 | 2500 |
| 30 | TYP | FR | 0.000 | 0.001 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 100.00 | 232.519 | 10240.01 | 272 |
| 30 | TYP | GNN | 3.245 | 3.576 | 0.002 | 0.000 | 0.490 | 0.000 | 0.061 | 0.514 | 100.00 | 22.332 | 85.57 | 66 |
| Size | Scenario | Method | MAE | Viol | Viol | Viol line | Gap (%) | Infer (ms) | Train (s) | Epoch/steps |
|---|---|---|---|---|---|---|---|---|---|---|
| 1000 | TYP | DNN | 1.790 | 0.001 | 0.000 | 0.043 | -0.002 | 0.437 | 0.86 | 48 |
| 1000 | TYP | KKT | 1.378 | 0.022 | 0.000 | 0.039 | -0.035 | 0.456 | 15.36 | 218 |
| 1000 | TYP | LR | 1.008 | 0.074 | 0.000 | 0.004 | -0.003 | 0.118 | 0.01 | – |
| 1000 | TYP | MU | 1.740 | 0.000 | 0.000 | 0.033 | 0.039 | 0.458 | 2.62 | 80 |
| 1000 | TYP | QP | 2.187 | 0.000 | 0.000 | 0.000 | 0.566 | 5.042 | 1.79 | 61 |
| 5000 | TYP | DNN | 1.014 | 0.035 | 0.000 | 0.014 | 0.007 | 0.442 | 8.68 | 123 |
| Size | Scenario | Method | MAE | MAE | Viol | Viol | Viol | Viol | Viol line | Gap (%) | PF (%) | Infer (ms) | Train (s) | Epoch/steps |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1000 | TYP | DNN | 1.286 | 0.120 | 0.018 | 0.000 | 0.098 | 0.002 | 0.013 | 0.018 | 100.00 | 11.178 | 5.67 | 363 |
| 1000 | TYP | KKT | 2.443 | 0.205 | 0.039 | 0.000 | 0.194 | 0.002 | 0.027 | 0.011 | 100.00 | 11.399 | 112.63 | 309 |
| 1000 | TYP | LR | 0.615 | 0.081 | 0.031 | 0.000 | 0.096 | 0.001 | 0.003 | -0.002 | 100.00 | 17.832 | 0.82 | – |
| 1000 | TYP | MU | 2.082 | 0.147 | 0.013 | 0.000 | 0.086 | 0.002 | 0.034 | 0.006 | 100.00 | 11.843 | 22.69 | 80 |
| 1000 | TYP | QC | 2.988 | 0.233 | 0.000 | 0.000 | 0.029 | 0.000 | 0.049 | 0.141 | 100.00 | 21.419 | 2.62 | 104 |
| 5000 | TYP | DNN | 0.535 | 0.056 | 0.017 | 0.000 | 0.074 | 0.001 | 0.006 | -0.002 | 100.00 | 11.228 | 13.08 | 175 |
| Formulation | Case | Solver time (ms) |
|---|---|---|
| DC | 30 | 14.88 |
| DC | 118 | 419.91 |
| DC | 300 | 3325.96 |
| AC | 30 | 67.32 |
| AC | 118 | 432.57 |
| AC | 300 | 14093.14 |
| System | Method | Samples | MAE (%) | MAE (%) | Direct MAE (%) | PF MAE (%) | Direct MAE θ ( ∘ ) | PF MAE θ ( ∘ ) |
|---|---|---|---|---|---|---|---|---|
| 30-bus | MU | 1000 | 0.569 | 0.032 | 0.407 | 2.550 | 0.029 | 0.016 |
| KKT | 1000 | 0.624 | 0.027 | 0.587 | 2.536 | 0.035 | 0.007 | |
| 118-bus | MU | 1000 | 1.341 | 0.074 | 3.620 | 5.058 | 0.241 | 0.269 |
| KKT | 1000 | 0.669 | 0.107 | 3.100 | 8.359 | 0.185 | 0.254 | |
| 300-bus | MU | 985 | 8.067 | 0.595 | 7.665 | 13.664 | 12.282 | 15.973 |
| KKT | 1000 | 4.150 | 0.522 | 4.383 | 10.563 | 2.849 | 4.925 |