ResearchMy master’s thesis
State estimation: from a few meters, work out the voltage everywhere on a power grid.
Watch a day on the line
Of the 33 buses, 10 have a meter (the squares). The classic method and the neural network each guess the voltage at the rest. Play the day: who stays closer to the truth? Tap a bus to see its voltage.
Voltage along the main line · 19:00
- True voltage
- Classic method
- Neural network
- meter
The numbers
| Bus | True voltage | Classic method | Neural network |
|---|---|---|---|
| 0 | 230.0 V | 229.6 V | … |
| 1 | 229.1 V | 228.7 V | … |
| 2 | 224.8 V | 224.5 V | … |
| 3 | 222.9 V | 222.4 V | … |
| 4 | 221.0 V | 220.5 V | … |
| 5 | 216.5 V | 215.7 V | … |
| 6 | 215.6 V | 214.7 V | … |
| 7 | 214.1 V | 213.3 V | … |
| 8 | 212.2 V | 211.7 V | … |
| 9 | 210.5 V | 210.2 V | … |
| 10 | 210.3 V | 209.9 V | … |
| 11 | 209.8 V | 209.6 V | … |
| 12 | 208.1 V | 208.0 V | … |
| 13 | 207.4 V | 207.5 V | … |
| 14 | 206.9 V | 207.2 V | … |
| 15 | 206.4 V | 206.8 V | … |
| 16 | 205.8 V | 206.2 V | … |
| 17 | 205.6 V | 206.1 V | … |
The day’s shape is assumed: every load follows the same residential day, low at night and highest at 19:00. The meters, their noise and both estimators are the game’s own.
4 streets are under 207 V at 19:00, circled in red. The classic method’s estimate puts 3 of them under 207 V, the neural network’s ….
19:00 · average of 33 buses
- meter (10 of 33)
- meter that also reads the angle
- under 207 V
The question
A distribution feeder carries power from a substation to homes and businesses, and its operator has to keep the voltage at every point within limits. Only a few points have a meter. State estimation works out the rest from the meters’ readings, a forecast of every load and the physics of the lines. The standard method is weighted least squares (WLS): the voltages that best fit every reading, each weighted by how far it can be trusted.
My master’s thesis (UPC Barcelona, 2026) asked whether a graph neural network (GNN), which learns from examples, or one also trained on the physics (a PINN, physics-informed) could estimate better, and with how few meters each one still works.
How it works
The state and the readings
The state of the feeder is every bus's voltage, its size and its angle. The substation's angle is the reference, zero by definition, so 33 buses have 65 numbers to find:
Every reading is a function of that state plus an error. A meter reads its bus's and the active and reactive power injected there, and ; a PMU reads the angle too. A bus with no meter gets its load forecast in place of a reading, with a far larger error: ±50% on its load, against ±0.5% on a smart meter's voltage. The errors are independent, each with its own variance:
For a voltage reading, is the state itself. For the powers it is the network's physics, from the bus admittance matrix , with and the sums over bus and the buses it shares a line with:
A power flow runs these equations forward: given the loads, what will the voltages be. State estimation runs them backwards, from readings that each disagree a little: what are the voltages now. With 10 meters that is 76 readings, forecasts included, for 65 unknowns: more than enough, and none of them exact.
Weighted least squares
Weighted least squares takes the state whose readings come closest to the measured ones, each miss divided by its reading's standard deviation, so that a miss of one counts the same for a PMU's ±0.1% as for a forecast's ±50%:
Why squares: when each error is Gaussian, the likelihood of the readings is a product of bells, its logarithm is plus a constant, and the state that makes smallest is the most likely one. With one unknown read twice, 's minimum is the two readings' mean, each weighted by one over its variance, and it is more certain than either reading:
Move how far the second meter can be trusted, and watch the estimate slide between the two.
On the feeder, is made of sines and cosines of the angles, so has no minimum in closed form. Where it is lowest its slope is zero, with the Jacobian of the readings:
Gauss-Newton replaces by its tangent at the current guess, steps to the minimum of that straight-line model by the normal equations, and repeats from there:
The gain matrix is 65 by 65 here, and it can be solved only if the readings fix every part of the state: that is observability. I start from a flat start, every 1 and every angle 0, and stop when no part of the step is above ; on the test samples that takes 5 or 6 steps. Take them one at a time on the game's moment:
The fit also says when a reading is wrong. If every error is as its variance says, at the estimate follows a chi-square distribution with degrees of freedom, readings minus states, and a above its 99% point means something in the readings is off. To find which, each residual is divided by its own standard deviation:
The reading with the largest above 3 is taken out and the state estimated again, until none is above it. The game's third chapter, Catch the liar, sets this test against your own eye.
The graph neural network
A graph neural network reads the feeder as it is drawn, buses as nodes and lines as edges. At every bus it takes 17 numbers: the four readings (, angle, , , zero where there is none), four flags for which of them are there, their four variances, and the kind of sensor, one of five (none, SCADA, smart meter, PMU, forecast).
A layer gives each bus 64 new numbers by mixing in its neighbours': each neighbour's vector through a matrix made from the line between them, its resistance and reactance, averaged over the neighbours, plus the bus's own vector through a matrix of its own:
The network has two layers, 17 → 64 → 64, and a linear read-out of both layers' outputs gives each bus's and angle:
Each layer reaches one line further, so with two layers a bus's readings reach the buses up to two lines away, and no farther. That is why every bus carries its own forecast as an input: a bus far from any meter still has something of its own to start from. Pick a bus and see where its readings reach.
The game's network learned its matrices from 3,000 solved examples with 0 to 33 meters, scored on its and angle against the truth. It answers in one pass, with no iteration and nothing to invert, so it answers with no meter at all, where WLS can't.
The physics term
A physics-informed network (PINN) is trained on two things at once: how far its voltages are from the true ones, and how far they break Ohm's law on the lines. A weight sets how much the second counts:
Here are the complex voltages, is the line's impedance, and the current it carries, which on a radial feeder is the sum of the currents drawn at every bus beyond it:
At the true state the term is zero, and away from it it isn't, so it pulls the network towards voltages the lines allow. The loads it uses are the readings where there is a meter and the forecasts where there isn't. I chose on validation samples, from four weights:
The data
- The feeder
- The IEEE 33-bus test feeder: 33 buses on 32 lines at 12.66 kV, with 3.7 MW of load. At its base load the voltage falls to 91.3% of nominal at bus 17, the far end.
- The meters
- Each test sample has 10 meters at random buses, 2 of them PMUs. A meter reads its bus’s voltage and power: a PMU to ±0.1% (and the angle), a smart meter to ±0.5%, a SCADA meter to ±1%, each with a bias of up to ±1%.
- The scenarios
- Every load is its base value × (1 + 0.5 × a normal draw), each on its own. A bus without a meter gets a forecast: its base load, 50% uncertain. Every number below is over the 400 test samples, which played no part in any choice.
Voltages are shown as a share of the nominal 12.66 kV, and errors as the mean distance from the true voltage, over every bus of every sample: 0.32% is 0.0032 p.u.
What I found
WLS is the most accurate, the networks close behind
With 10 meters, answering the average voltage profile with no model at all is off by 0.64% on average. Both networks do far better, at 0.43%.
The PINN equals the GNN: at the physics weight chosen on validation (α = 0.1), the physics term changes the error by 1%, and more weight on it makes the estimate worse (why, and what I’d try instead, is under What I’d do next).
WLS is lower still, at 0.32%.
|V| error at 10 meters, 400 test samples
- WLS
- the networks
- no model
- No model: the average voltage profile0.64%
- GNN0.43%
- PINN, physics-informed0.43%
- GNN for 0 to 33 meters (the game’s)0.44%
- WLS0.32%
The thin line through the bars is the no-model baseline.
The numbers
| Estimator | |V| error |
|---|---|
| No model: the average voltage profile | 0.64% |
| GNN | 0.43% |
| PINN, physics-informed | 0.43% |
| GNN for 0 to 33 meters (the game’s) | 0.44% |
| WLS | 0.32% |
Where on the feeder each one misses, bus by bus, with 10 meters: pick an estimator.
Fewer or more meters
A grid’s operator rarely has the meters a model was trained on, so the GNN here (the game’s) was trained on samples with 0 to 33 meters: one network for any number of them.
WLS has the lowest error at every count from 3 meters to 33. The GNN degrades as gracefully but stays behind, at 1.3 to 2.1 times WLS’s error.
Two exceptions. With one meter, the substation’s alone, WLS is behind even the no-model baseline (0.74% against 0.61%): that one voltage reading sets the level of the whole estimate. With none, WLS has no answer at all.
The game shows two more. A wrong voltage reading is caught by WLS’s bad-data test in 126 of 126 trials, a wrong P or Q reading in 0 of 274. And without load forecasts WLS needs at least 22 meters: of the 1,673,828 placements of 22 that could work, 4,096 do.
|V| error by number of meters, new samples for each count
- WLS
- GNN
- No model
Meters on the feeder
The numbers
| Meters | WLS | GNN | No model |
|---|---|---|---|
| 0 | no estimate | 0.63% | 0.63% |
| 1 | 0.74% | 0.60% | 0.61% |
| 3 | 0.48% | 0.64% | 0.71% |
| 5 | 0.42% | 0.53% | 0.62% |
| 10 | 0.30% | 0.42% | 0.59% |
| 15 | 0.25% | 0.37% | 0.61% |
| 20 | 0.21% | 0.32% | 0.58% |
| 33 | 0.12% | 0.24% | 0.61% |
What I built
In Python: the IEEE 33-bus feeder and its power flow, WLS with GridCal and with a Gauss-Newton of my own, and the GNN and the PINN in PyTorch Geometric. Then the page, in TypeScript.
1. The networks
The graph neural network and the PINN of How it works, in PyTorch Geometric. Standardised outputs and a decaying learning rate, so the training settles; 3 seeds of each, the error their mean.
2. A WLS of my own
Gauss-Newton in plain numpy, written to port line for line. It lands on GridCal’s answer wherever GridCal reaches the minimum, and goes lower on the 10 of the 400 test samples where GridCal stops short.
3. Every bus, every sample
Each estimator scored on every bus of 400 test samples that played no part in any choice, against a model-free baseline, then again with 0 to 33 meters.
4. Observability and bad data
Tested all 1,673,828 placements of 22 meters that could fix the state without forecasts, and WLS’s chi-square and largest-residual tests on the test samples with one reading made wrong in each.
5. A GNN for any number of meters
The same network on 4,000 samples with 0 to 33 meters each; of 3 seeds, the one with the lowest validation error.
6. This page
The power flow, WLS with its tests and the GNN’s forward pass, ported to TypeScript and checked against the Python case by case. The game runs in your browser, with no server.
The result in plain words
WLS is the most accurate on this data: 0.32% average error with 10 meters, against 0.43% for the GNN, and the lowest at every count from 3 meters up. The GNN is close behind, degrades as gracefully as WLS when meters are taken away, and is ahead with a single meter. The PINN equals the GNN.
That is what this data should give. Its load errors are independent and Gaussian, which is exactly what WLS assumes, so there is little left for a learned model to find. Where real loads move together, a learned model has something WLS can’t express, and that is the test I’d run next.
What I’d do next
A physics term weighted like WLS
The PINN’s physics term trusts a 50%-uncertain load forecast as much as a meter, so more weight on it makes the estimate worse: the validation error goes from 0.43% with none to 0.61% at α = 10. Weighted by each reading’s variance, the term becomes the WLS objective itself: the hybrid the thesis proposed in its chapter 7.
Loads that move together
Here every load varies on its own, which is exactly what WLS assumes. Real loads rise and fall together through the day. WLS’s forecasts can’t express that, but a learned model can learn it: that is where a GNN could beat WLS, and the test I’d run next.
Questions people ask
What is state estimation in a power system?
Working out the voltage at every bus of a grid, its size and its angle, from the readings of the few points that have a meter, forecasts of the loads elsewhere and the network's model. On the IEEE 33-bus feeder that is 65 numbers from 10 meters. It is what an operator's other tools start from: a voltage out of limits, an overloaded line or a meter gone wrong are all read off the estimate.
How is state estimation different from a power flow?
A power flow takes exactly as many inputs as there are unknowns (the loads, the generation, the substation's voltage) and solves for the rest: what will happen. State estimation takes readings that each carry an error, usually more of them than there are unknowns, and finds the state that fits them all best: what is happening. A power flow trusts every input; state estimation weighs them, and can tell when one is wrong.
What is the weighted least squares method of state estimation?
The standard method: the state that makes the sum of squared misses between the readings and the model smallest, each miss divided by its reading's variance, so a precise meter counts for more than a rough forecast. Because the readings depend on the voltages nonlinearly, it is solved by Gauss-Newton from a flat start, which settles here in 5 or 6 steps. With 10 meters it is off by 0.32% on average on this feeder, the lowest of the estimators on the page. How it works says more.
Why is state estimation harder on a distribution network?
A transmission grid has meters at most of its substations; a distribution feeder has them at a few points, so most buses are known only by a forecast of their load. Its lines have resistance close to their reactance, so active power and voltage are tied together, and its loads swing widely. On this feeder, without forecasts, WLS needs at least 22 meters of 33 before it can answer at all.
What is a pseudo-measurement?
A forecast standing in for a reading where there is no meter: a bus's expected load, given a large variance so the estimate leans on it only where nothing better is known. Here every unmetered bus gets its base load, ±50%. Without them WLS needs 22 meters; with them it answers from 1.
How many meters does state estimation need?
With load forecasts, WLS answers from a single meter that reads a voltage, and its error falls as meters are added: 0.74% with 1, 0.42% with 5, 0.12% with all 33. Without forecasts it needs at least 22 of the 33 buses metered, and of the 1,673,828 placements of 22 that could work, 4,096 do. A graph neural network answers with any number, none included. The game's second chapter lets you place them.
Can a graph neural network estimate the state of a grid?
Yes. With 10 meters the game's network is off by 0.44% on average, against 0.64% for the average voltage profile with no model at all, and WLS's 0.32%. One trained network serves any number of meters, from none to 33, and answers in a single pass. It runs in this page, in your browser.
What is a physics-informed graph neural network?
A graph neural network whose training also penalises breaking the physics, here Ohm's law on every line, beside the error against the true voltages. A weight α sets how much the physics counts; at the α chosen on validation (0.1) it changes the error by 1%, and the PINN equals the GNN at 0.43%. The physics term says how it works.
What is the IEEE 33-bus system?
A radial distribution feeder of 33 buses on 32 lines at 12.66 kV, with 3.7 MW of load, published by Baran and Wu in 1989 and used ever since as a test case for distribution studies. At its base load the voltage falls to 91.3% of nominal at bus 17, the far end. The game draws it as a tree from the substation.
Further reading
- B. Sanchez-Lengeling, E. Reif, A. Pearce, A. Wiltschko, A Gentle Introduction to Graph Neural Networks (opens in a new tab)distill.pub
Graphs, then message passing, with figures where hovering a node shows what it gathers from its neighbours, layer by layer.
- A. Daigavane, B. Ravindran, G. Aggarwal, Understanding Convolutions on Graphs (opens in a new tab)distill.pub
From an image's convolution to a graph's, then GCN, GAT, GraphSAGE and GIN side by side: click a node to see its update.
- Optimal Fusion of Two Sensors (SY6301) (opens in a new tab)usafa-ece.github.io
Two sensors of one quantity weighted by their variances: drag the weight and watch the fused spread narrow. Weighted least squares with one unknown.
- Q.-H. Ngo et al., Physics-informed Graphical Neural Network for Power System State Estimation (opens in a new tab)arxiv.org
Physics-informed graph networks for state estimation, a paper my thesis cites, free to read on arXiv.
- BambooGrid (opens in a new tab)github.com
A network editor in the browser on pandapower: place measurements, run weighted least squares, and see the residuals, the reading flagged as bad and the critical measurements.
- tellegen (opens in a new tab)tellegen.dev
Power flow and DC optimal power flow on real grid cases, in the browser through WebAssembly, with a live preview as you edit.
References
- A. Abur, A. G. Expósito, Power System State Estimation: Theory and Implementation, CRC Press, 2004
- F. F. Wu, “Power system state estimation: a survey”, International Journal of Electrical Power & Energy Systems, 12(2), 1990, doi:10.1016/0142-0615(90)90003-T
- H. Wang, N. N. Schulz, “A revised branch current-based distribution system state estimation algorithm and meter placement impact”, IEEE Transactions on Power Systems, 19(1), 2004
- R. Gelagaev, P. Vermeyen, J. Driesen, “State Estimation in Distribution Grids”, 13th International Conference on Harmonics and Quality of Power, IEEE, 2008, doi:10.1109/ICHQP.2008.4562896
- M. Ćalović, A. Sarić, Eksploatacija elektroenergetskih sistema u uslovima slobodnog tržišta, Elektrotehnički fakultet, Beograd, and Fakultet tehničkih nauka, Čačak, 2025
- M. E. Baran, F. F. Wu, “Network reconfiguration in distribution systems for loss reduction and load balancing”, IEEE Transactions on Power Delivery, 4(2), 1989, doi:10.1109/61.25627
- R. D. Zimmerman, “AC Power Flows, Generalized OPF Costs and their Derivatives using Complex Matrix Notation”, MATPOWER Technical Note 2, 2010
- O. Kundacina, M. Cosovic, D. Vukobratovic, “State Estimation in Electric Power Systems Leveraging Graph Neural Networks”, 17th International Conference on Probabilistic Methods Applied to Power Systems (PMAPS), IEEE, 2022, doi:10.1109/PMAPS53380.2022.9810559
- Q.-H. Ngo, B. L. H. Nguyen, T. V. Vu, J. Zhang, T. Ngo, “Physics-informed graphical neural network for power system state estimation”, Applied Energy, 358, 2024, doi:10.1016/j.apenergy.2023.122602
- J. Gilmer, S. S. Schoenholz, P. F. Riley, O. Vinyals, G. E. Dahl, “Neural Message Passing for Quantum Chemistry”, Proceedings of the 34th International Conference on Machine Learning, PMLR 70, 2017
- Z. Wu, S. Pan, F. Chen, G. Long, C. Zhang, P. S. Yu, “A Comprehensive Survey on Graph Neural Networks”, IEEE Transactions on Neural Networks and Learning Systems, 32(1), 2021, doi:10.1109/TNNLS.2020.2978386
- M. Raissi, P. Perdikaris, G. E. Karniadakis, “Physics-informed neural networks: A deep learning framework for solving forward and inverse problems involving nonlinear partial differential equations”, Journal of Computational Physics, 378, 2019, doi:10.1016/j.jcp.2018.10.045
- D. Katsikis, A. Muradova, G. Stavroulakis, “A Gentle Introduction to Physics-Informed Neural Networks, with Applications in Static Rod and Beam Problems”, Journal of Advances in Applied & Computational Mathematics, 2022
- S. J. D. Prince, Understanding Deep Learning, 2023
Links
- The thesis (PDF) (opens in a new tab) · Advanced State Estimation in Distribution Networks Using Graph and Physics-Informed Neural Networks
- The thesis’s code (opens in a new tab) · as handed in with it
- The thesis’s folder in my Classroom · the code with its dataset and the trained models, the defence slides and the GridCal tutorials
- My father’s lecture on state estimation · Statička estimacija stanja, in Serbian: the weighted least squares estimator this page sets my models beside, from its criterion of mean-square deviations to the detection of bad measurements