Methodology =========== The proposed methodology addresses operational constraints in distribution grids through a hierarchical, sequential greedy algorithm. The approach prioritizes low-cost operational measures before resorting to capital-intensive grid reinforcement. The algorithm iteratively analyzes the network state via power flow calculations, identifies constraint violations, and applies corrective strategies based on a predefined priority order. Problem Formulation ------------------- The grid operation is constrained by voltage magnitude limits and thermal loading limits of network branches (lines and transformers). Let :math:`V_i` be the voltage magnitude at bus :math:`i`, and :math:`S_{ij}` be the apparent power flow on branch :math:`ij`. The constraints are defined as: .. math:: V_{min} \le V_i \le V_{max} \quad \forall i \in \mathcal{N} \\ |I_{ij}| \le I_{max, ij} \quad \forall ij \in \mathcal{L} \\ |S_{t}| \le S_{max, t} \quad \forall t \in \mathcal{T} where :math:`\mathcal{N}`, :math:`\mathcal{L}`, and :math:`\mathcal{T}` represent the sets of buses, lines, and transformers, respectively. Grid Enhancement Algorithm -------------------------- The core algorithm follows a sequential greedy heuristic. In each pass, a power flow simulation is executed to detect violations. Violations are grouped by type (e.g., over-voltage, line loading) and addressed according to a priority queue. The default priority addresses thermal violations first, followed by voltage violations. Within each violation type, strategies are applied in order of increasing cost level, each on the violations the previous ones left. With a cost model, this chain of strategies is also tried from each later strategy, and each chain is rated by finishing the run from it in the order of the cost levels: the chain whose run ends with the fewest violations, then the cheapest, is kept (a rollout, or pilot method). The run that rates a chain is followed as long as each pass improves its best state (fewer violations, or a lower cost), and given up after a pass that does not, which keeps the work proportional to the number of passes. Since the chain in the order of the cost levels is among those rated, the result is no worse than that order alone as long as no rating is given up. Where one was, and a chain other than that of the cost levels was kept, the run is also made in the order of the cost levels, and the better of the two runs is returned: the result is never worse than that order alone. A turn can bring about violations of a type whose turn has passed: a flexibility call for the over-voltages, for instance, can overload a line that no flexible asset relieves, after the turn of the line overloads. Such a type is given its turn once more in the pass, before the next type of the order (#66): its group is all its violations, its chain is chosen as at its turn, and its actions are recorded and charged as any, the history entry of the turn saying "again". A type is given another turn when a violation of it is there that was not as its last turn of the pass ended, whatever strategy brought it about, the operation actions chosen again after a planning change included (below); one that was there, which its strategies left, waits for the next pass as before. Of several such types, the first in the order goes first, and each gets one more turn at most per pass, whatever the turns bring about: a pass gives at most twice as many turns as there are types (8 with the 4 default types), and ``max_iterations`` still counts passes. The rollouts that rate a chain finish the pass as the run would, turns given again included, so that a chain is not rated by a violation that the run resolves in the same pass. Until #66 such a violation waited for the next pass, and a run of one pass ended with it. On the 700 random LV feeders with flexible loads and generators of the reviews of #63 (384 runs with violations, priced or not, with and without lookahead, 1 to 3 passes), against the pass of the order alone: one run ends with fewer violations, 1 against 3 (the run of one pass in `Active Power Flexibility Management`_), and none with more, also with every run unpriced; with five assets a step, two runs end with fewer violations, one of them resolved. A priced run with lookahead is resolved for 8,143.69 € against 36,643.10 € (8,336.25 € with five assets a step). With line and transformer upgrades only, no flexibility, two runs of one pass, where a line upgrade overloaded the transformer after its turn, end resolved instead of with that overload, for the transformer upgrade (38,459.13 € against 27,626.33 €, and 88,533.19 € against 78,472.79 €). In every set, the only runs that get dearer are those that no longer leave a violation. The other runs that move by the turns given again take the same actions in fewer passes, or in another order, or, unpriced, end as before with one more flexibility step. 4 turns were given again in 4 runs, 8 in 7 runs with five assets a step (at most 2 in a run), 14 in 13 runs without flexibility, each applying something; the runs make 0.5 % and 0.8 % more power flows with flexibility (the rollouts that give turns again included), 0.4 % fewer unpriced and 0.1 % fewer without flexibility; on 600 smaller feeders that all resolve, no turn is given again and nothing moves. On 6 feeders of the case study, with and without flexibility, none is given, and their runs are those before to the bit; on the full study, measured at f5ca8a6 against the milestone with #60, the 300 runs are identical to those before in cost, actions, passes and power flows. If a planning strategy (e.g., line upgrade) is applied, previously applied operational actions are reverted, and the optimization process restarts for the operational stage to account for the modified network topology. A tap change is reverted to the position the unit had before it, not by its number of steps: a transformer upgrade since the change may have moved the position into the tap range of the new type, from which the same number of steps leads elsewhere (a unit taken from 0 to -2, then brought to -1 by a type of range -1 to 1, went to +1, and the operation stage paid for two tap changes where one from 0 does). A position outside the range the unit has now is not reached: the unit goes as far towards it as the range allows, with a warning. The algorithm tracks the best partial solution found to ensure robustness against convergence failures: the state with the fewest violations, then the cheapest, then the one with the least severe violations, their excesses being taken relative to the limit for a loading and to the width of the allowed voltage band for a voltage. The states compared are the initial state and those the strategies leave when they return, not the steps inside a strategy: a flexibility call is rated by the state it ends in, even where it went through a cheaper state with as many violations (see "Passes and partial solutions" in the usage guide). Two costs are equal when they differ by no more than the price of the power that the power flow leaves unresolved at a bus (see `Precision of the Power Flow`_), at the dearer of the prices of flexibility, once for every flexibility step of the state, the largest over the states of the run. Each step is sized on a power flow that leaves that power unresolved, so that its cost is uncertain by as much, and two states with the same powers reached by different steps can differ in cost by up to the sum: in one run of the case study, two chains of strategies reached states 8.7e-8 € apart (1.5e-13 relative). After the Newton step that ends each power flow, the power left unresolved is the rounding floor of the power balance at the solution: the mismatch of bus :math:`i` sums :math:`n_i + 2` products (the terms of its row of the admittance matrix, the product with :math:`V_i` and the injection), which floating point computes within :math:`\gamma_{n_i+2} = (n_i+2)u / (1 - (n_i+2)u)` of the sum of their magnitudes, :math:`u` being the unit roundoff. It is a smooth function of the state, the same for a state reached warm or cold, where the mismatch measured after the step is a sample of rounding noise that differed between them by a factor of up to 2.7; and it bounds that mismatch, which was at most 0.42 of it on 30 feeders, warm and cold, and up to voltage collapse. It is 1.4e-11 to 3.5e-9 MVA on the MV/LV feeders at the load of the case study, whatever the tolerance, and on the runs of 90 feeders at 30 % of flexibility the tie ranges from 1.3e-6 to 8.9e-3 € (median 1.5e-4 €), under the cent it used to be, and 1,000 times smaller with prices in k€. Where the engine takes no step, the power left unresolved is the solver's tolerance times the base power, and the tie its price for every flexibility step: 0.01 € a step at 1e-8, 100 MVA and 10,000 €/MW. Without a price of flexibility, or with an engine that does not tell its mismatch, the costs are compared exactly. A state cheaper than the best one by more than the tie wins. A state that wins a tie on its severity does not move the cost that the next states are compared with, the cost of the state it tied with: a series of states, each a little dearer than the one before and less severe, cannot raise the cost kept by more than one tie. The total cost of a state is the exact sum of the costs of its actions, whatever was applied and undone before them, so that the same actions cost the same. The priority order can name a violation type at a level of network, ``"mv"`` or ``"lv"``, A turn for an over-voltage at the ``"lv"`` level takes the LV over-voltages alone. The level of a violation comes from the engine: that of the bus, and the LV side of a transformer, so that an MV/LV unit is in the LV network it feeds. The top-down order takes the MV network first, then the LV networks. The planning profiles fix the order, the choice of the strategies and the strategies a run registers (see :doc:`profiles`); none is a claim about the cost of its plan. Precision of the Power Flow --------------------------- The Newton-Raphson solver stops as soon as the power mismatch of every bus is under its tolerance: ``tolerance`` of the engine's settings, which pandapower compares in per unit of the base power of the network (``sn_mva``), 1e-6 MVA for the default 1e-8 on the 100 MVA base of the MV/LV feeders. Where it stops depends on where it started: after a last step that took the mismatch far under the tolerance, or just under. The voltages and loadings it gives differ from the exact solution by the response of the network to that mismatch. On the runs with flexibility of 30 feeders of the case study, at every power flow of the run, warm-started runs (from the previous solution) and cold ones (from a flat start) of the same network differed by up to 5.2e-6 p.u. of voltage and 3.5e-3 % of loading, and cold runs differed from a solution 1,000 times tighter by as much: a cold run does not end far inside its tolerance either (its final mismatch ranged up to 1e-8, median 9e-10). That is more than the margin by which a flexibility step aims inside a limit (1e-6 of the limit), and more than some of the excesses the runs meet (on 90 runs with flexibility, 14 of 250,000 voltage violations met were under 1e-6 p.u.). Every run of the power flow therefore ends with one more Newton step, computed from the mismatch the solver left and the Jacobian at its solution, which squares the error: warm and cold runs then agree to about 1e-10 p.u. of voltage and 1e-7 % of loading, whatever the start (measured on 5 feeders: 6e-11 p.u. and 3.4e-8 % at most). The voltages, currents and loadings of the results, and the internal voltages at which the sensitivities are taken, are those after the step; the powers and losses are the solver's, within its error. The decisions taken on these values agree with them: the violations, the target and the size of a flexibility step, which also depends on the sensitivities (at the solver's own solution they differed between warm and cold runs by about 1e-6 relative), the cycle rule, the sizing of a thermal upgrade. A value at its limit is not a violation, in the check and in the strategies, which only see the violations it reports. No band is added to the limits: the error left after the step is far under any margin the strategies use. The step is not taken, and the results are the solver's, with another algorithm than Newton-Raphson (the step uses the data it leaves), with a distributed slack, FACTS devices or line temperatures in the power flow, which the Jacobian of the engine does not model. With loads of constant current or constant impedance, the Jacobian of the step adds the derivative of those loads with the voltage, so that the step squares the error with them too: with 30 % of each in every load of a feeder, warm and cold runs agree to 7.5e-13 p.u., where a Jacobian of constant-power loads left them 5.5e-8 apart. The sensitivities keep the loads at constant power (see the note below). Until this was done, warm-started runs were solved to a tolerance 100 times tighter than cold ones, as a cold run was thought to end far inside its tolerance. With the step, warm runs use the configured tolerance. On 90 feeders of the case study, with 30 % of flexibility and without, runs that start every power flow warm and runs that start every one cold take the same decisions; along the runs with flexibility, over 9,339 violation checks, their violations agree to 4.5e-11 p.u. and 2.5e-8 % and their costs to 3.1e-6 €. They make 13 to 14 % fewer Newton iterations than with the tighter tolerance, and take the same decisions, at the same total cost to the cent, as before the step; the step, one more factorisation of the Jacobian per power flow, makes them take 1.4 to 1.5 % (with flexibility) and 3.8 to 5.4 % (without) more CPU time, in two measurements. A warm start begins from the voltages of the previous solution, which is a good start after a change that moves them a little: a power, an impedance, the tap of a ratio changer, a unit in parallel. A change of the angle that a transformer or an external grid applies does not move them a little: it rotates the voltages of every bus beyond it by the change of angle, 30 to 180 degrees for a change of vector group, so that the new solution is the previous one rotated. A change of what connects the network can do the same, by moving buses behind a source of another angle. Started that far from the new solution, Newton-Raphson can converge to another solution of the power flow equations, which it then gives as converged: a 1.6 MVA unit loaded at 75 % was solved at 0.05 p.u. after a change of its shift by 90 or 180 degrees (it failed at 120 and 150), and a three-winding transformer after a change of 60 degrees. The same happened when the supply of a bus moved from a unit at 0 degrees to a standby one at 150, put in service or switched in at its terminal; when a feeder moved from a substation at 0 degrees to one at 150, by lines put in and out of service, by line switches or by bus-bus switches; and when an ideal phase shifter of 5 degrees a step moved 10 steps (50 degrees) at once (from 1 to 9 steps the warm start was right; beyond 10 it was wrong or failed, irregularly). A run therefore starts from scratch (pandapower's ``init="auto"``: a DC power flow, which includes the shifts, when the angles are calculated) whenever what sets the angles differs from what the solution it would start from was solved with, whatever the angle, as no rule tells from the angle alone where a start converges, and a cold start is always right. What is compared, exactly, is: whether the power flow calculates the angles (``calculate_voltage_angles``); what connects and supplies the network, as the engine reads it to find the buses that no source supplies: the service state of the buses, lines, transformers, three-winding transformers, impedances, DC lines and sources, the buses each of them joins, the element and state of every switch, and which generator is the slack; and, for each transformer, three-winding transformer and external grid, by its index, the angle it applies (``shift_degree``, ``shift_mv_degree`` and ``shift_lv_degree``, ``va_degree``) and, if its tap adds an angle (an ``Ideal`` tap changer, a step of non-zero ``tap_step_degree``, a tabular or a former ``tap_phase_shifter`` one, for either tap changer), every column of its tap changer. Any change of these starts from scratch, also one that turns the voltages little, such as one step of a phase shifter, or none, such as a table whose rows are reordered. The impedances of the branches and the number of units in parallel are not compared: they move the voltages a little, and are what the strategies change. Not compared either: the rows of the characteristic table of a tabular tap changer (``trafo_characteristic_table``). Taking and comparing all this costs 120 to 150 microseconds a run on the MV/LV feeders, about 60 of them for what connects the network, against 10 to 18 ms for a warm run: about 1 % of a warm run. On 12 feeders of the case study, with 30 % of flexibility and without, each of the 1,692 warm starts of the runs gave the solution of a cold run of the same network, to 6.4e-11 p.u. and 4.2e-8 % of loading: no change of the strategies sends a warm start elsewhere, and none changes what is compared, so that their runs start warm as often as before (on the two tracked feeders, with a transformer upgrade, line upgrades and flexibility, the same 162 warm and 4 cold starts). All the transformers of the case study are at 330 degrees, with ratio tap changers whose step has no angle, and a type change keeps the shift of the unit in place (see `Transformer Upgrades`_): no run of the study changes an angle. Operational Strategies ---------------------- Operational strategies are considered the first line of defense due to their low implementation cost. Transformer Tap Changer Control ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This strategy addresses voltage violations by adjusting the tap position of transformers. The algorithm groups voltage violations by galvanically connected components. For each component, it identifies the supplying transformer and calculates the optimal tap position shift :math:`\Delta \tau` to center the voltage distribution around the nominal target :math:`V_{target}` (typically 1.0 p.u.): .. math:: \Delta \tau = \text{argmin}_{\tau} \left| (V_{avg} + \tau) - V_{target} \right| where :math:`V_{avg}` is the average voltage of the component. The shift is counted in steps from the neutral position, and applied from the position the unit has. An engine refuses a shift that would take the position outside the tap range of the unit (``tap_min`` to ``tap_max``), and changes nothing then; the strategy then takes the largest shorter shift the range allows, one step less at a time, and records the shift it took, with the positions before and after it. Until #64 the pandapower engine refused a shift only from the end of the range, and wrote the others whole, however far beyond it: in a fuzz of 500 random LV feeders, 8 of the 98 runs with tap changes took a unit of range -2 to 2 to position -3, 3 or 5 on the way or to the end, and their units now stop at the end of the range. Active Power Flexibility Management ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When tap changes are insufficient, active power flexibility (load shedding or generation curtailment) is utilized. This strategy employs a sensitivity-based approach. For a selected critical violation (target), sensitivities of the violation value with respect to active power injections are calculated. Voltage Sensitivity Calculation ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The sensitivity of voltage magnitudes with respect to active power injections is derived from the inverse Jacobian matrix of the Newton-Raphson power flow formulation. The linearized power flow equations are given by: .. math:: \begin{bmatrix} \Delta P \\ \Delta Q \end{bmatrix} = \begin{bmatrix} \frac{\partial P}{\partial \theta} & \frac{\partial P}{\partial V} \\ \frac{\partial Q}{\partial \theta} & \frac{\partial Q}{\partial V} \end{bmatrix} \begin{bmatrix} \Delta \theta \\ \Delta V \end{bmatrix} = J \begin{bmatrix} \Delta \theta \\ \Delta V \end{bmatrix} Inverting the Jacobian matrix :math:`J` yields the sensitivity matrix: .. math:: \begin{bmatrix} \Delta \theta \\ \Delta V \end{bmatrix} = J^{-1} \begin{bmatrix} \Delta P \\ \Delta Q \end{bmatrix} The voltage-active power sensitivity :math:`\frac{\partial |V_i|}{\partial P_j}` corresponds to the elements in the lower-left submatrix of :math:`J^{-1}`. .. note:: The sensitivities, of voltage and of loading alike, are those of loads of constant power. The Jacobian they come from, which the engine builds from pandapower's admittance matrix, holds every load as a constant power: the constant-current and constant-impedance share of a load (``const_i_p_percent``, ``const_i_q_percent``, ``const_z_p_percent``, ``const_z_q_percent``) is not in it, so that the sensitivities ignore how such a load follows the voltage. With such a share they are off, by an amount that grows with the share, with the loading of the network and from one metric to another, and they are not corrected. Against central differences of power flows on ``52_MVFeeder1118``, every load at 100 % of the model, ±2 kW of a constant-power generator at 12 load buses, tolerance 1e-11 per unit of the base power (1e-9 MVA, ``sn_mva`` being 100) (``benchmarks/zip_load_sensitivities.py``), the median relative errors are: .. list-table:: :header-rows: 1 * - Loads - Voltage, at the bus itself - Voltage, whole column (2-norm) - Voltage, buses over 20 % of the largest (p10-p90) - Loading, 6 significant pairs (range) * - x1.0, constant current - 2.6 % - 2.4 % - 3.8 % (0.5-6.5 %) - 4.3 % (0.2-4.8 %) * - x1.0, constant impedance - 5.0 % - 4.8 % - 7.5 % (0.9-13 %) - 8.5 % (0.4-9.7 %) * - x2.5, constant current - 7.6 % - 10.6 % - 19 % (3.5-28 %) - 21 % (8.4-23 %) * - x2.5, constant impedance - 14 % - 19 % - 36 % (6.7-55 %) - 39 % (16-44 %) With loads of constant power they are all under 0.01 %. x2.5 is the load factor of the case study, whose feeders have these columns at 0. Thermal Sensitivity Calculation ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ For thermal violations, the sensitivity is that of the loading the engine reports, which is based on current. The current at the end :math:`f` of a branch is a linear function of the complex bus voltages, through the row :math:`Y_f` of the branch admittance matrix of the solved case, which carries the tap ratio and the phase shift of a transformer: .. math:: I_f = Y_f V, \qquad \text{Loading}\% = 100 \, \frac{|I_f|}{I_{rated}} The end taken is the one that sets the loading: the more loaded end of a line, and for a transformer the side whose current, relative to its rated current, is the higher. The sensitivity to the power injected at bus :math:`k` follows from the chain rule: .. math:: \frac{\partial \text{Loading}\%}{\partial P_k} = \frac{100}{I_{rated}} \left( \frac{\partial |I_f|}{\partial \theta} \frac{\partial \theta}{\partial P_k} + \frac{\partial |I_f|}{\partial V} \frac{\partial V}{\partial P_k} \right) The partial derivatives :math:`\frac{\partial \theta}{\partial P_k}` and :math:`\frac{\partial V}{\partial P_k}` are obtained from the Jacobian, with one solve of its transpose for the branch. The value is positive where injecting more power at the bus raises the loading of the branch, whatever the direction of the flow, and is taken at constant reactive injection. Every action reduces the power of an asset: shedding a load raises the injection at its bus, curtailing a generator lowers it. Only the assets whose action reduces the violation are candidates: for a loading violation, the loads where the sensitivity is negative and the generators where it is positive. With :math:`\Delta_k` the change of the violation per MW of the action of asset :math:`k` (the sensitivity above, with the sign of the action), the linear estimate of the relief that the asset can give is: .. math:: R_k = \Delta_k \times \min\left(\text{Margin}_k, \frac{\text{Violation}}{\Delta_k}\right) where :math:`\text{Margin}_k` is the available flexible power capacity of asset :math:`k`: what is left of ``max_flex_pct`` of its power as the run started, :math:`P_k - (1 - \text{max\_flex\_pct}_k / 100) \, P_k^{0}`. The power :math:`P_k^{0}` is read when the run starts and holds for every call of the strategy in the run, whatever the calls before took off, and whatever chain of strategies the run tries and undoes. A ``FlexibilityStrategy`` used on its own, outside a run, counts from the powers at each of its calls, unless it is given them as ``initial_power``. The limits thus hold within a call, or a run, and not across them: a strategy called twice on its own on one network can shed up to ``max_flex_pct`` of what its first call left (a 112 kW load at 30 % ends 45 % under its first power), so that a caller that loops over the strategy must give it the powers to count from as ``initial_power``. A second run on an engine that the first left shed likewise counts from the shed powers, and a copy of the strategy made during a run keeps the ``initial_power`` of that run. Assets whose :math:`R_k` is negligible (under ``min_asset_relief_pct`` of the violation, 0.01 % by default) are left out. Flexibility is used if the remaining candidates can relieve enough of the violation together, :math:`\sum_k R_k` being at least ``min_achievable_relief_pct`` of it (5 % by default): many small assets that are enough together are used. The algorithm then iteratively modifies the active power of the ``n_activation`` candidates of highest :math:`\Delta_k` to resolve the violation. A call of the strategy is given the violations of one type, its group (see `Grid Enhancement Algorithm`_), and acts on them and on what its own steps add to the others. A violation outside the group that was not there as the call started is acted on whole: the call relieves a violation it brought about as far as its assets can, and leaves one that none can relieve at the level at which it set it aside (below), never larger. Of one that was there, the call acts only on what it exceeds its limit by beyond what it did then: that excess is the violation the call ranks, sizes a step for and compares, and a step aims to take it off just inside, at the starting excess less 1e-6 of the limit. The rest is left to the strategies of its type, at its turn in the priority order, where the run chooses between them with its cost model: the call neither resolves it nor takes its relief for progress. The comparison has no tolerance, as the cycle rule below: the values compared are those after the Newton step that ends each power flow, which agree to about 1e-10 p.u. and 1e-7 %, and a step aims 1e-6 of the limit inside, so that a violation brought back where it was is not taken up again by the error of the next power flow. Taking the whole of a violation that a step worsens, however little, would make the call resolve a violation that was there before it for a worsening of 1e-9; leaving it whole to its turn would let the call leave behind a violation larger than it found, which nothing in the run charges to the call. Until #63 the call acted on every violation of the network after its first step: given an overloaded line, it went on, once the line was resolved, to shed loads for the under-voltages of the network, which the run would only have addressed after the over-voltages, and with a choice between flexibility and line upgrades. A violation that no asset can relieve does not stop the call. The candidates of a violation are filtered out when their sensitivity is under 1e-6 per MW, when their margin is under 1e-4 MW, when they are left out after a cycle (below) or after a step undone (next paragraph), when what they can relieve is under ``min_asset_relief_pct`` of the violation, or all together when they cannot relieve ``min_achievable_relief_pct`` of it. A violation left with none is set aside, with what it exceeds its limit by then, its level, and the step is taken on the most severe violation the call acts on that an asset can relieve. The most severe is the one with the largest excess relative to its limit, for a voltage as for a loading, whereas the algorithm rates a voltage excess against the width of its allowed band: an under-voltage of 0.01 pu at a limit of 0.90 pu rates 0.011 in the call and 0.1 in the algorithm. The algorithm gives a call the violations of one type, so the two scales only disagree between voltages that have different limits (MV and LV buses) and once the steps of a call bring up a violation of another type. Ranking by the band was measured (#64) and not adopted: it changes 7 of the 300 runs of the case study, by at most 11 € each, and 4 to 14 % of the runs of three sets of random feeders, as many for the better as for the worse. A call that resolves only part of its group returns its steps as one that resolves it all; ``total_violations_addressed`` counts the violations of the group it resolved, and the run gives the rest of the group to the next strategy of the chain, line or transformer upgrades, on the state the call left, which is rated as any other. Until #63 the call stopped at the first target that no asset could relieve, whatever the violations it could have relieved after it: in the case study, an overloaded line or transformer with too little flexible load beneath it took the whole group to the planning strategies. The level of a violation set aside is what it exceeds its limit by when it is set aside, or, if the call has given up on it before, the lowest of these; it is kept for the rest of the call, also while the violation is taken up again, when the steps for other targets can take it up to its level but not beyond. A step after which a violation given up on exceeds its level, as the power flow after the step measures it, is undone: its assets get their powers back, reactive power included, and it is not part of the action the call returns. A step on one asset leaves that asset out of the candidates of that target for the rest of the call. A step on several assets is taken again one asset at a time, in the order they were ranked, each by what it took in the step and each measured by a power flow: an asset whose step, after those kept before it, takes a violation given up on beyond its level is undone and left out for that target, and the others are kept, so that an asset that did no harm still relieves the target. The harm is measured, not predicted from the sensitivities, which need not show it, and the comparison has no tolerance. The call thus never leaves a violation it gave up on above the lowest level at which it gave up on it, and the planning strategy that follows is sized on a state no worse in that respect. That level can be above the excess at the start of the call, when steps worsened the violation before the call gave up on it: in the 1,626 calls on the random feeders below, 26 violations of the group were left so, 159 violations outside the group were left worse than the call found them, and 70 violations that a call brought about were left because no asset could relieve them, each at the level it was set aside at (counted in the calls that kept at least one step: a violation outside the group is left worse when it was there as the call started and ends it more than 1e-12 above what it exceeded its limit by then). A violation that a call brings about can also be one that only an asset left out of its candidates relieves: by this rule, after the asset's step for it took a violation given up on beyond its level, or by an earlier undoing (below). The conflict is then of the call's own making, and the call can undo the steps that brought the violation about instead of giving up on it (#66). The same holds for a violation that the steps worsened, of the group or not: the steps undone are those since the latest of the states in which the call acted on the least of that violation (none of it, for one it brought about), all at once, and solved again, if it acts on more of it now. It does so only if the network is more severe in total than in that state, by the sum of the excesses of all its violations rated as the algorithm rates states (see `Grid Enhancement Algorithm`_): a loading against its limit, a voltage against the width of its band. What the steps brought about or added must outweigh what they relieved, outside the group as in it: a violation outside the group is weighed, though never worked on beyond what the steps added to it. Counting of such a violation only what the steps added, as a first version did, an undoing could give back what the steps had relieved outside the group: on a stub network, a step that resolved two overloads of the group, one of 2 %, and an under-voltage outside it, 0.02 pu under, and took a third overload from 0.5 % to 2.9 %, was undone (0.529 against 0.525), leaving four violations and 0.725 in all where the step left two and 0.529; it is now kept. A step that resolves an overload of the group at 30 % and brings up one at 2 % is kept, and the 2 % set aside; undoing it would have put the 30 % back. A step that resolves an under-voltage of 0.05 pu, half of a band of 0.1 pu, and brings up an overload of 6 % is kept too: rated against its limit of 0.9 pu, as the call ranks its targets, the 0.05 pu would weigh 0.056 against 0.06, and the 0.05 pu would have been put back for the 6 %. The ranking of the targets keeps that measure (#64). A line of the group 0.01 % over, which a step taken to resolve another overload of 30 % takes to 39 %, with only an asset harming a violation given up on to relieve it, is undone like a line taken from under its limit to 39 %: 89 % in all against 80 %. In the case built by hand in the review of #63, a line given up on at 10 % was taken up again at 8.9 %, and the step that took it to 8.45 % brought about an overload of 21.5 % that only an asset worsening the line relieved: the call left both, 30 % in all where there had been 8.9 %; it now undoes the step and leaves the line at 8.9 %, given up on there. The sum, rather than the worst of the excesses, weighs a step that relieves several violations of the group a little against one it brings about. The comparison is of totals, measured in the state the steps were taken from: it does not guarantee that the call ends with no more violations, nor with none larger, than if it had set the violation aside. Undoing the steps brings that state back, to the precision of the power flow: if a violation given up on exceeded its limit there by more than its level, as a level lowered since can be, they are not undone and the violation is set aside as any other, so that this never breaks the rule above. The call tells both from what it measured in that state, without a power flow. Of the first of the steps undone, an asset on its own is left out of the candidates of its target for the rest of the call; the assets of a step on several are taken again one at a time, in the order they were ranked, and one after which the call acts on more of the violation than in that state, or a violation given up on is beyond its level, is undone and left out, the last one if none is. For a violation that was there in that state, more is more than 1e-6 of its limit, the margin by which a step aims inside one: both excesses are above the limit, and every asset moves every loading a little, so that an asset that resolved an overload of 30 % and added 1.5e-10 % to the violation was left out, and the overload put back; one that was not there is compared with its limit itself, as the violations are (the power flow does not give a state back bit for bit, and an engine can depend on the path). The call goes on from there. It costs one power flow for the undoing, one for each asset of a step on several taken again, one for each of them undone again, and one more if none of them does harm. On the random feeders above it fired in one run of the 384, in each set with flexibility (1,690 calls; 1,688 with five assets a step): the call on the lines relieved an overload of 6 % with one step on two assets, a generator and a load, which added 0.0035 to 0.0059 pu to five over-voltages there from the start, at 0.018 to 0.15 pu, which only assets taking a violation given up on beyond its level relieved. Rated against the band of 0.1 pu, what the step added weighs more than the 6 %, and the step is undone: the overload goes to the line upgrade, and the run costs 136,502.76 € instead of 151,757.68 €, with 26 power flows instead of 51 (unpriced, it ends resolved as before, with other actions, and 26 power flows instead of 51). Rated against the limits, as in a first version of the comparison, it weighed less than the overload, and the step was kept; the severity of what a call leaves does not tell the cost of the rest of the run, which made this run cheaper with the undoing. When only the two assets of a step together take a violation above its level, the one ranked later is the one left out. Without the rule, on a small feeder with flexible generators, a call on the lines set aside two overloads at 67.1 % and 9.5 %, then curtailed and shed for what its steps had added to two voltages, which took the overloads to 106.7 % and 43.9 %, and the line upgrades sized on that state cost 69,994.78 € against 57,338.30 €. Only steps undone cost power flows: 2 for a step on one asset (the step, and the solution after it is undone), 2 + k for a step on k assets, and one more for each of them undone again; on 700 random feeders with flexible loads and generators, 295 steps were undone, 80 of them on several assets, of which 7 kept part, and the call with the most power flows made 55. Each asset undone leaves out one more pair of a target and an asset, of which there are finitely many, and each asset kept is a step kept, so that the call still ends. An undoing of the steps that brought a violation about (above) takes back at least one step kept and leaves out, for the target of the first of them, at least one of its assets, but not always one more pair: a later step for the same target, undone by the level rule, can have left that asset out already. It gives back power that steps kept had taken, so that the margins alone do not bound a call that undoes: no bound tighter than ``max_iterations`` is shown for the undoings, as a step on the same target and asset taken before the one left out, and still kept, can be the first step of a later undoing. Every iteration of the call, an undoing included, counts towards ``max_iterations``, so that the call ends. After a step undone the network has the powers of the state before it, and the call goes on from the violations it measured then: solved again, the network gives them to the precision of the power flow, not bit for bit (up to 5.0e-12 % of loading in that fuzz), and a load or generator whose ``scaling`` is not 1 gets its powers back to a rounding (1.6e-16 relative), as the engine divides them by the scaling, which the revert of operation actions after a planning change shares. Saving the result tables before each step, to put them back exactly, would need the engines to expose their internal state and would cost a copy at each of the 180,000 steps kept in the case study, where no step is undone. Of the filters, the margins and the assets left out only shrink during a call, as every step kept takes power off an asset; but the shares follow the violation, and the sensitivities follow the state of the network, so that a step kept for another violation can bring one set aside within reach. The violations set aside are therefore examined again, most severe first, once no other can be relieved, if a step has been kept since they were last examined (a step undone leaves the network as it was): a violation is examined again at most once per step kept or undoing of the steps that brought a violation about (above), and all of them together at most as many times as the number of violations set aside times the number of those, without a threshold. A violation set aside stays among those the cycle rule compares, so that its relief by the steps for the others is progress of the call. A violation that a call brings about and cannot relieve is left at its level for the strategies of its type, in the same pass: at their turn if its type comes after that of the group in the priority order, and at their turn given again otherwise (see `Grid Enhancement Algorithm`_). Until #66 it waited for the next pass in that case, so that a run with few passes could end with it. In a small feeder run with one pass, the call on the over-voltages overloaded a line that no flexible asset could relieve, after the turn of the line overloads, and the run ended with three violations; before #63 the call on the lines made that overload itself, in the turn of the lines, and the line upgrade that followed it in the same chain removed it. The lines now get their turn again after the over-voltages, and the line upgrade removes the overload: one violation is left, the over-voltage of the source, as before #63. A step can relieve less than the sensitivities estimate, or bring back a violation that another step relieved. The strategy has gone round in a cycle when it comes back to a state no better than one it has been in, every violation of that state still there and none less than it was, and every violation it has resolved since then is one it had met at or before that state: the steps since then have brought none of the violations of that state down, and those they resolved are coming round too. Of the latest such state, the asset acted on first from it is set aside for the rest of the call (a Tabu list), or, if it already is, the next one that is not. Each such cycle sets aside a new asset. A step that relieves a violation, however little, is progress: the comparison has no tolerance, so that a step relieving less than :math:`10^{-4}` of a violation is not taken for a cycle, as it was when the violations were compared to 4 decimals. It needs none for the precision of the power flow either: the violations it compares are those of the solution after one more Newton step (see `Precision of the Power Flow`_), which agree to about 1e-10 p.u. whatever the start of the run. Compared on the solver's own results, a step whose effect on a violation was under the solver's error, up to 5.2e-6 p.u., could be taken for progress or for none depending on where the run started; its effect is now seen as it is. The violations of the states the cycle rule compares are those the call acts on, each with the excess it acts on. A violation that the strategy meets for the first time on the way and resolves gives it one more round: relieving the target can bring up a violation, or worsen one outside the group of violations the strategy was called on, and relieving that one bring the target back larger, where the next round can resolve both. When one of them comes back again, no smaller than the time before, the violation resolved in between has been met before, and it is a cycle. In a small random feeder, curtailing two generators for a line overloaded by their reverse flow lowered by 2.1e-5 p.u. the voltage of a bus 0.0197 p.u. under its limit, which the run had left for later. Before #63 the call shed loads for the whole under-voltage, which overloaded the line again, 3.25 % over its limit against 0.54 % at first, and one more round of curtailment resolved both (setting aside the first generator there, as the rule did without the condition above, made the run cost 197.56 € against 162.19 €). The call now sheds for the 2.1e-5 p.u. it added, which leaves the line within its limit, and stops after 2 rounds of 2 steps, where it took 4; the strategies of under-voltages then resolve the rest, and the run costs 162.19 € as before (162.1895 € against 162.1881 €, flexibility only, at 10,000 €/MW of load and 5,000 €/MW of generation). Two violations that bring each other back, each a little smaller than the time before, are progress by this rule: the strategy goes on alternating between them until one comes back no smaller, which can take until an asset it uses has no margin left. In another small random feeder, shedding a load for a line overload brings up an over-voltage, and curtailing a generator for the over-voltage brings the overload back. Each round multiplies the violations by about the same factor, the product of the four sensitivities involved (what the load relieves of the line and adds to the voltage per MW, what the generator relieves of the voltage and adds to the line): from the second round on, each round relieves about 4.4 % of what is left, slowly less as the network moves. Each round costs about 4.4 % less than the one before, so that the alternation would cost about 23 times its first round if it went on. It went on for 74 steps, a load step and a generator step a round, until the load had no margin left and the over-voltage came back larger; the generator was then set aside and another resolved both, for 421.05 €. It is not a matter of the precision of the power flow: each round shrinks the violations by about 4 %, orders of magnitude above the error left after the Newton step, so that no band tied to the solver tolerance would stop it. Restricting the call to its group (#63) does not change this case: the over-voltage is one that the call's own steps bring up, which it acts on whole. ``min_round_relief_pct`` (#65) is the progress, in percent, that the strategy asks of a round of such a see-saw. It is 5 % by default (see the default, below). At 0 no round is judged, and the strategy is the same to the bit as before #65 (checked against the milestone before #65 on the 945 runs of the conflict fuzz below). *Rounds.* A round ends at a state at which a violation that was met at or before an earlier state, and was not in it, has come back and been resolved again, every violation of that earlier state being there again: these are the windows of the cycle rule that have resolved something since their state, and the latest such earlier state is the first state of the round. The reach of a round is the largest excess of each violation over its states, from its first to the last before the state it ends at: it holds every violation the see-saw passes through, the group's included, at its peak. A round is judged against the round that ended at its first state, the round before it in the same phase of the see-saw. It is slow if none of the violations of the reach of the round before is relieved by more than ``min_round_relief_pct`` of what it reached there, :math:`r_{now} \ge r_{before} (1 - \text{min\_round\_relief\_pct} / 100)` for each of them; a violation the round no longer reaches counts as relieved. A round is judged only against a round that ended exactly at its first state: the first round of a see-saw has nothing to be judged against, nor has a round whose first state is not the end of a round, so that a window that grows from the same first state, one state longer at each step, is never judged (part B). *Setting an asset aside.* A slow round that follows a slow round, the latest judged before it, is taken for a cycle. The asset set aside is taken from the steps of the two rounds, latest first, the steps for a violation outside the group of the call before the others: they are what brings back the violation of the group that the other steps relieve. It is set aside only if another asset could act on the violation that its step was relieving, by the test that picks the candidates of a target (sensitivities at the state now, margins, ``min_asset_relief_pct``, ``min_achievable_relief_pct``, the assets set aside or left out for that target). Otherwise nothing is set aside, the see-saw goes on as without a threshold, and the next slow round tests again. The test runs no power flow: it computes the sensitivities of that violation at the state now. After an asset is set aside, the rounds whose round before started before it are not judged, and the rounds judged before it no longer count: two new slow rounds, with the assets left, are needed for the next. Judging a round again after a step undone gives the same result. When the call undoes steps that brought a violation about (#66), which can be earlier than the latest, the rounds counted so far are forgotten, as the states they were counted from are gone, and two new slow rounds are needed. Without that, a slow round judged on a state that the undoing removed could be paired with the first slow round after it: on a made-up history (a slow round judged at the eighth state, an undoing of the latest two states, two steps on another violation, then a see-saw of 3 % a round), the asset is set aside after two new slow rounds, where it would be after one. On the conflict fuzz below, that undoing fires in 11 calls, 3 of which judge rounds at 5 %, none of them slow after it. The steps of the rounds are kept, as those of a cycle, and the call goes on with the assets left, so that it returns its steps as before, every step kept still takes power off an asset, each set-aside sets aside a new asset, and a violation given up on is still held to its level. *Why these choices.* The threshold bears on rounds, not on steps: a call that relieves its target a little at each step, an asset after another, makes no round and is never cut. On the 30 feeders of part B below, each of the 38 calls of 50 iterations or more has steps that relieve less than 5 % of the violations of the state before; a threshold on the step would cut them. A round is judged on its reach, every violation it passes through, and not on the violations of its first state only, as the rule was first written: in a see-saw between the group's line and an over-voltage the steps bring up, the rounds of the over-voltage start from states that hold the over-voltage only, which comes back about as large each time while the line shrinks by about 25 % a round. Judged on its first state, such a round looked slow; in call 7 of fuzz seed 145 the generator relieving the over-voltage was set aside from 3.9 %, the line was left overloaded, and the run cost 35,418.70 € against 15,959.89 €. The asset set aside is the one that brings the group's violation back, and not the first acted on from the round's first state: that one could be the reliever of the group's violation, depending on which pair of rounds completed first. On the feeder of the see-saw above, the rule as first written set aside the five loads that relieve the line, one after another, at 3.5 to 4.25 %, and left the line overloaded (table below); on the family of part A, it set aside the overload's own load, so that the alternative generator was never used. Two slow rounds are asked, not one, because a see-saw that makes steady progress can have one slow round, when one of its assets runs out and another takes its place: fuzz seed 725 relieves about 11.5 % a round with one round of 1.1 %. The test for another asset keeps the rule from cutting a see-saw that only its own assets can resolve: setting aside the asset would leave the violation to the strategies of its type, or make the run pay for a reinforcement that going on avoids (part A below). On the feeder of the see-saw above, the call on the line overload takes, at 10,000 €/MW of load shed and 5,000 €/MW of generation curtailed (rule as first written, e990292, against the rule above): ===================== ====================================== =================== threshold % as first written rule above ===================== ====================================== =================== 0, 1, 2, 2.5, 3, 3.25 74 steps, 421.05 € 74 steps, 421.05 € 3.5 112 steps, 479.85 €, line left 0.16 % 70 steps, 413.33 € 3.75 74 steps, 426.73 €, line left 0.31 % 46 steps, 351.50 € 4 52 steps, 376.16 €, line left 0.46 % 30 steps, 292.33 € 4.25 36 steps, 324.05 €, line left 0.63 % 18 steps, 234.29 € 4.5, 5, 6, 7.5, 9 10 steps, 188.18 € 10 steps, 187.01 € 9.5, 10, 15 to 100 8 steps, 173.91 € 10 steps, 187.01 € ===================== ====================================== =================== As first written, the five loads relieving the line were set aside at 3.5 to 4.25 %, the load and the generator from 4.5 to 9 %, and the generator only from 9.5 %; by the rule above, the generator only, at every threshold from 3.5 %. On 300 random neighbours of that feeder (line lengths and powers within 30 %), the 160 with a line overload, 82 of which make rounds, cost 65,534 € in all at 0 and 64,723, 57,469, 56,157, 56,155 and 55,112 € at 2.5, 5, 7.5, 10 and 25 %; no call leaves a line of its group that it resolved at 0, where the rule as first written left one at 2.5 and 5 %. Two calls end with one more violation than at 0, outside their group: in the one traced, an over-voltage that was there before the call, which the long see-saw at 0 happened to pull under its limit. *Part A: a family of see-saws with the rate set by design.* A feeder of five buses behind a 0.63 MVA transformer, where a short overloaded line feeds flexible loads and, on a parallel branch, flexible generators held at the upper voltage limit; shedding for the line raises the voltage of the generators' bus, and curtailing them for it loads the line again, so that a round relieves the share of the resistance from the source that lies on the generators' branch, set by its length (scripts in the issue). The networks start with the short line overloaded, by 5 points (2 or 10 in a variant), and the see-saw alternates between that overload and the over-voltage of the generators' bus; at the rate of 1 % a round with the first seed, whose operating point carries the most power to the loads, the line that feeds them is overloaded too (by 8.6 % where the short line is 5 points over), so that these 20 networks start with two overloads. Sixteen rates from 1 to 40 % a round (measured: 0.90 to 40.5 %), each with and without an alternative generator upstream of the line (as in the feeder above), with ample or short margins, without planning or with a line upgrade priced 250 to 20,000 €, ``n_activation`` 1 and 3, starting overloads of 2, 5 and 10 points and two seeds: 384 networks, run as the case study does (cost model, 3 passes, lookahead). Against the run without a threshold: ========================= =========== ========== ========== ========== ========== threshold % 2.5 5 7.5 10 25 ========================= =========== ========== ========== ========== ========== alternative, no planning -32 % -49 % -54 % -59 % -62 % alternative, planning -46 % -73 % -75 % -77 % -78 % no alternative = 0 = 0 = 0 = 0 = 0 ========================= =========== ========== ========== ========== ========== (total cost, 48 and 144 networks with an alternative; every run resolved where it was at 0, plus the three networks at 1 % without planning, which start with two overloads and at 0 leave the short line overloaded after 3 x 500 iterations; one run dearer, by 480 €, at 25 %; power flows down by 29 to 89 %). With no alternative, the runs leave the same violations and cost the same as without a threshold. Where the margins are ample, the test also accepts as another asset the generator that holds the margin on the same bus as the generator of the see-saw: the latter is set aside and its twin carries on the same see-saw. 16 of these 192 networks then differ from 0 at 5 %, by at most 8e-12 of their cost, and, with three assets a step, in their count of steps (608 against 885, for instance), with the same power flows. Without the test for another asset, they were not: without planning, the cut left the overload in 3, 11, 18, 24 and 34 of the 48 networks; with planning, the run paid the upgrade that the lookahead had declined as dearer than the whole see-saw, 79,000 € more at 5 % and 449,000 € more at 25 %. With planning and a cost model, the lookahead already chooses between the whole see-saw and the reinforcement: a cut can only help where the see-saw can be ended more cheaply by another asset. *Part B: real topologies.* 30 feeders of the case study spread over sizes, given photovoltaic generators (at a third of the buses with a load, drawn from the CRC32 of the feeder's name, three times the load of the bus), loads and generators flexible at 30 %, run as the case study at a threshold of 0 on dd00456: 268 calls, of which 33, in 8 feeders, make rounds. Of their 1,181 round ends, by the relief of the latest window on the violations of its first state, 117 are no better (cycles), 96 relieve up to 5 %, 321 relieve 5 to 25 % and 647 relieve more than 25 %. Two calls look slow on that measure, one of 93_MVFeeder1126 on 19 lines and one of 76_MVFeeder1974 on 35 lines, but neither is a see-saw of successive rounds: the measure counts each iteration with a window as a round, and measures its relief against the window's first state. In the call of 93_MVFeeder1126, a round ends at 26 iterations, all from the same first state: for six kept steps the window grows by one state at each, the relief since its first state going from 1.4 to 2.7 % in all, and then the step of each iteration is undone, 20 times the same window. No round ended at that first state, so the rule never judges it. In the call of 76_MVFeeder1974, the 8 round ends are the same window seen again after each undoing of #66, after which the rule forgets its rounds; the call then runs to its 500 iterations with its steps undone, by the undoing and level rules, not by #65. The rule sets nothing aside on these feeders at 5 %, and their runs are the same as at 0. In the other calls with rounds on many lines, a line of the round before that the round no longer reaches, as the call resolves the lines one after another, counts as progress. Before #66, the line call of 84_MVFeeder0598 alternated at about 3 % a round, and its rounds were all judged against the same, much older round: the first state of a round is the latest state whose violations are all back, which stayed the same state for 120 rounds. That a round can span many steps in a call on many violations, and so hide a see-saw that started within it, is a limit of the measure. On the six feeders that made rounds before #66 the runs were also the same at 2.5, 5, 7.5, 10 and 25 % as at 0. *Random feeders.* On the conflict fuzz (seeds 0 to 1,399, a source at 1.03 to 1.07 p.u., 2 to 5 generators, every asset flexible; 945 runs whose first power flow converges and finds violations), 189 calls of 103 runs make rounds. At 5 and 10 %, one run moves, by power flows only (79 against 82, same cost and violations); at 25 %, seed 725, whose see-saw resolved its violations at about 11.5 % a round, is cut, and the run upgrades a line for 22,007.81 € instead of 1,007.89 € of flexibility. There, the test finds another generator for the over-voltage, but its curtailment brings the line back harder, and the call cannot finish: the test does not ask that the alternative leave the group's violation alone. Asking that it worsen the group's violation by less than ``min_asset_relief_pct`` of it removed that cut, but also every gain on the feeder of the see-saw above and on its neighbours, where the generator that resolves both does move the line a little; it was not kept. *The default.* The default is 5 %, chosen from the bench above. It gets the whole gain on the feeder of the see-saw above, where the call takes 10 steps for 187.01 € from 4.5 %. It gets most of the gain on the family: 49 % and 73 % less than at 0 where another generator can end the see-saw, against 59 % and 77 % at 10 %. And it stays a factor of two below the slowest see-saw met that resolved its violations, fuzz seed 725 at about 11.5 % a round. Between 2.5 and 10 %, no run of the benches is dearer or leaves more violations than at 0, but for the two neighbours of the feeder above that leave an over-voltage outside their group which the long see-saw at 0 pulled under its limit. What it can cost: a see-saw that would have resolved its violations at a rate under 5 % a round is cut when the test finds an alternative that cannot finish the job, as seed 725 is at 25 %; and, where no alternative exists, the test runs at each slow round, 4 to 11 % more CPU on such networks of the family. A threshold above about 11 % is advised against: it cuts the see-saw of seed 725, which resolved its violations, and the run then pays a line upgrade of 22,007.81 € instead of 1,007.89 € of flexibility. 0 turns the rule off. At 5 %, the runs that move against 0 on the bench are: the feeder above (421.05 € to 187.01 €); 35 of the 160 neighbours, cheaper by 8,065 € in all (65,534 € to 57,469 €), 2 of which, by 332 €, end with an over-voltage outside their group that the long see-saw at 0 pulled under its limit; the 192 networks of the family with another generator (cost 49 % and 73 % lower), and 16 of the others, by rounding and steps only (part A); one run of the conflict fuzz, by power flows only (79 against 82); none of the 30 feeders of part B. On the case study, whose flexible assets are loads only, the default changes no run: its 300 runs are identical to those of the milestone before #65 in actions, passes, costs, load shed, violations left and power flows (on version 1 of the feeders: 36.22 M€ at 0 % of flexibility; 9.82 M€ and 149.2 MW shed at 30 %; 42,063 power flows). *What the rule does not guarantee.* A threshold above the progress of a see-saw that would have resolved its violations cuts it when the test finds an alternative that cannot finish the job, as seed 725 at 25 %. Where every step of the rounds is for the group's own violations, the asset set aside is that of the latest step, which depends on which round completes the pair. A round is judged only against a round that ended exactly at its first state: a long window whose first state is not the end of a round, as in a call on many violations whose steps are undone, is never judged (part B), and the rounds are forgotten after an undoing of #66. The test for another asset can miss an asset that would end the see-saw but does not pass the relief filters, and the see-saw then goes on as without a threshold. A call cut by the rule leaves the violations outside its group that it found, as without the rule, but no longer those that a long see-saw would have pulled under their limits on the way. A see-saw that makes fast progress, far above the threshold, is not stopped by the rule either: limits are strict, with no tolerance on a violation, so that the call goes on until the excesses are negligible. As recorded for the bench of #65 (not measured again), on seed 1148 of the conflict fuzz a see-saw relieving about 60 % a round took 57 steps over 14 rounds, down to excesses of about 1e-6 p.u., the order of the margin inside the limit that each step aims at (above). The cost is in power flows, not in the result. The strategy stops when the violations it acts on are resolved, when none of those left has a candidate, or when its steps no longer change a power. Every step takes power off an asset and never puts any back, at least the smaller of :math:`10^{-4}` MW (the margin under which an asset is not a candidate) and what aims the target just inside its limit, so that, as long as the call undoes no steps for what they brought about, the margins bound the number of steps; ``max_iterations`` bounds them in every case, an undoing counting as an iteration. Planning Strategies ------------------- If operational measures fail to resolve all violations, grid reinforcement strategies are triggered. Line Upgrades ~~~~~~~~~~~~~ Line overloading is addressed by upgrading the conductors to a type with a higher rated current (:math:`I_{max}`), or by adding conductors of the type in place in parallel (see `Thermal Sizing`_). For voltage violations persisting after operational measures, lines are upgraded to reduce impedance. Without prices, critical lines are identified using voltage-resistance sensitivities (:math:`\frac{\partial V}{\partial R}`), and the conductor is replaced with the next available type having lower resistance per unit length: the line whose next step brings the violated buses the most voltage per km of line is taken at each iteration. With prices, the steps are chosen by the voltage they buy per euro (see `Voltage Steps with Prices`_). An upgrade step for a voltage violation is only taken if it is worth its works. The ``min_voltage_sensitivity`` parameter of ``LineUpgradeStrategy`` is the smallest voltage change, in p.u. of the nominal voltage, that the next step of a line (the next conductor type, or one more parallel conductor) must be predicted to bring to at least one violated bus, in the direction of its limit; a step that brings a bus within its limit is enough whatever its size, and a step that moves the violated buses the wrong way on average is never taken. A step is thus judged on the buses it helps, however many other buses of the network are violated. It defaults to 0.0001 p.u., that is 0.04 V on a 400 V network. When no line has such a step, the strategy stops and leaves the remaining violations to the other strategies: they are not of the kind that line upgrades fix at a sensible cost, as when the voltage of the source itself is out of its limits. As the mean is taken over all the violated buses, a higher threshold leaves out the lines that only act on a few of them. Despite its name, the parameter is not a sensitivity :math:`\frac{\partial V}{\partial R}`, and it does not apply to thermal upgrades. Conductors in Parallel ^^^^^^^^^^^^^^^^^^^^^^ A line can be reinforced by conductors of its type laid in parallel, for its loading or for its voltage, and nothing in the ladder or in the prices stops the stack: a line at the top of its category, under a voltage it cannot fix, was given up to 26 conductors in parallel on an LV network of pv-flex (#80), and the run still ended with its over-voltages. Beyond a few conductors such a stack is not a reinforcement an operator builds: the violation calls for another measure, such as a new MV/LV substation. The ``max_parallel_conductors`` parameter of ``LineUpgradeStrategy`` caps the conductors in parallel a step leaves a line with. It defaults to 3; ``None`` lifts the cap, and the strategy then decides as it did before the cap existed. * For a voltage violation, a line at the cap has no step of one more conductor: without prices, a line whose next step of the ladder is one more conductor (at the top of its category, or an overhead line that the cable cannot carry) has no step at all; with prices, the steps of a line at the cap are its type changes, which never leave it more conductors than it has (see `Voltage Steps with Prices`_). * For a loading violation, an option of `Thermal Sizing`_ that needs more conductors than the cap is left out, a type change as well as conductors of the type in place: a line that a stack of its type would carry takes a larger type with fewer conductors where one carries it. A line left with no option keeps its violation, is logged as a line at the cap, and takes no other step in the action. The cap is on what the strategy lays. A line that has more conductors than the cap before a step keeps them, and may change type with them, but is given no more. No line of the 150 feeders of the MV/LV case study has more than one conductor at the start. The cap can depend on the level of the network: ``max_parallel_conductors={"lv": 1, "mv": None}`` caps the lines of the LV networks and leaves the MV lines without one. Enedis lays no cables in parallel on its LV and MV feeders, but on the direct MV feeders of a customer (Enedis-NMO-RES_011E §3.2.3), so the cap of 3 of the case study is a modelling choice, not an Enedis rule. ``uncapped_lines`` exempts lines from the cap, by name or by a rule of the engine. The rule ``dedicated_lines`` takes the MV lines of a direct feeder: the parts of the network that hang from one source busbar (an external grid, or the MV side of an HV/MV transformer, with the buses that closed bus-bus switches join to it), with no transformer and one bus with a customer, whatever its power. A spur off a shared feeder is not one. The case study keeps the cap of 3 on every line (``line_upgrade_uncap_dedicated_lines``, off). A line at the cap is reported, so that a stack that is not built shows as a violation left, not as a solution. The strategy logs the lines it finds at the cap in an action and lists them in the action as ``lines_at_cap``: an overloaded line with no option left, and, when the action ends with voltage violations, a line at the cap whose one more conductor would have been worth its works by the rule of ``min_voltage_sensitivity`` (with prices, a conductor the run can price, as the priced steps only offer those). The summary of a run counts, in ``lines_at_conductor_cap``, the lines at the cap for the violations the run leaves, including those found at the cap by an action that the run tried and undid, as when it keeps a cheaper state with as many violations: a line found at the cap for its loading if it is still overloaded, and one found at the cap for a voltage violation if a bus that its conductor would have helped enough is still violated. ``PathToSourceLineUpgradeStrategy``, which reproduces the rule of another study, has no cap. Section Changes Extended to a Boundary ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Enedis's study rules extend a section change to a natural boundary (Enedis-NMO-RAC_007E §3.5.1): an LV cable "jusqu'à la dérivation ou l'émergence suivante", an overhead LV line "sur la (les) ligne(s) de même section", an MV line "jusqu'au poste électrique ou à la dérivation la plus proche". In the feeder files nearly every line already runs from one joint to the next, and the emergences of an LV cable (Enedis-NMO-RES_011E §3.3.4) are not in them. ``LineUpgradeStrategy(extend_section_changes=...)`` (#83, off by default) takes one of two readings: * ``"joint"``: the boundary of a section is a substation (a unit, an external grid, a closed bus-bus switch), an end, a branch (a bus with 3 lines or more) or a customer's connection point; * ``"branch"``: the same without the customers' connection points, at LV. At MV a customer's connection is a substation of its own and stays a boundary. Under both, an overhead LV line takes every line of its type connected to it in its LV network, the substations apart. A section is made of the lines of one type, level and category as the run started (``lines_at_start``), joined through buses that are not boundaries. When a step gives a line another type, for its loading or its voltage, the other lines of its section take that type in the same step, with the conductors they have; a line the run has given a type of lower resistance keeps it. Each line extended is an entry of the action of its own, with ``extended_from``, the line whose step it follows, and is charged as a type change from its state at the start of the run. When the strategy compares steps, the works on the lines extended are counted in the price of the type change (see below), and, for a voltage step, the predicted effect of the type change is the sum of the effects of every line it changes, each predicted alone; without prices, the effect is rated per km of all of them. A step undone by its check (see `Steps Checked After the Power Flow`_) is undone with its extension; the check reads the loading of the line of the step. In a thermal iteration, the lines of a section that has changed type take no other step: the power flow that follows tells whether they need more. A conductor in parallel is not extended. With prices, a thermal type change is compared with the reinforcement its section would need without it: its price is the works on every line it changes, less, for each other line of the section that is overloaded in the iteration and has taken no step in it, the cheapest conductors in parallel of its type that would carry it within the cap (or, if none would, its own share of the section change, which it would need anyway). On three overloaded cables of one section, a 4x120 type at 45 €/km against a 4x50 conductor at 50 €/km, the section change is laid (6.75 €) rather than a conductor on each line (7.50 €). A voltage step is ranked on the voltage all its lines bring per euro of all their works. A burial is a type change: an overhead LV line buried into a cable takes with it every line of its type connected to it. Under ``hosting_capacity`` on ``52_MVFeeder1118`` without flexibility, that is 47 lines (2.81 km) against 3 (0.15 km) off. Whether a burial should be extended as a section change is left open until the measurements of step 7 of #83. Measured on the 2 feeders of the tests and 20 feeders of version 2 drawn with the seed 806, loads × 2.5, with the cap of 3 of the case study (#83, step 4). Conductors added are the ``lines_added`` of the summary of each run, summed: * with prices (``standard``), no line is extended in the results, and ``"joint"`` and ``"branch"`` give the same runs. Without flexibility, the runs off have 33 type change entries, 21 of them burying an overhead LV line of ``T_AL_70_lv`` into an LV cable, 8 for the loading of the line and 13 for a voltage violation; 4 more bury an overhead MV line (``O_AM_148_mv``) and 8 change an LV or MV cable. The section of such a line is every line of its type connected to it: 1 to 21 lines for the 8 burials for loading, of which 1 to 4 were overloaded at the start of the run, so that the conductors they would need do not offset the burial of the others. With the option, 5 lines (6.9 km) change type against 25 (7.7 km) off, 287 conductors are added against 253, and the total cost goes from 3,302,164 € to 3,306,078 € (3 runs up, 2 down). At 30 % of flexibility, 0 lines change type against 4 (0.8 km), 87 conductors are added against 77, and the total cost goes from 878,288 € to 886,923 € (2 runs up, 1 down); * without prices (``hosting_capacity``), without flexibility, 590 lines (62.4 km) change type under ``"joint"`` and 622 (63.8 km) under ``"branch"``, against 220 (29.4 km) off, of which 419 (36.6 km) and 469 (38.9 km) are lines extended; at 30 %, 233 (21.8 km) and 249 (22.5 km) against 73 (9.3 km). Every run is resolved, with or without the option. Voltage Steps with Prices ^^^^^^^^^^^^^^^^^^^^^^^^^ Ranked by voltage per km, the steps of the ladder do not see what they cost. A type change replaces every conductor of a line: on a line of :math:`n` conductors it costs :math:`n` times the price of the type, where one more conductor costs one. And the thermal choice (see `Thermal Sizing`_) takes the cheapest option for the loading alone: a ``T_AL_70`` line that it gave a second conductor, the cheapest for its loading, then had both replaced by ``T_AL_150`` for its voltage (70 k€/km more, 120 k€/km in all), where one ``U_AL_288`` in place of the two would have carried it and lifted its voltage for 30 k€/km more (80 k€/km in all). With prices (a run with a cost model), the steps of a line of a configured type, with :math:`n` conductors, are one more conductor of the type in place, and each configured type of the same voltage level and of lower resistance than the type in place (overhead or underground for an overhead line, underground for a cable) for :math:`m` conductors, from the fewest that carry the current of the line within the loading limit up to :math:`n`. A type change to fewer conductors than the line has takes back the others, which the run has laid on it: :math:`m` is never below the conductors the line had at the start of the run. Every type change must carry the line: the rule by which the ladder only buries a line (#51), with the rating of the type times the derating factor of the line, applies here to every type change, also one that keeps the conductors in place, so that a larger type that does not carry a line already overloaded is not offered, where the ladder offered the next type whatever it carried. Only the configured types of the voltage levels of the lines considered are read, as with the ladder: the network need not know the types of another level. Each step is priced as the run charges it, from the state of the line at the start of the run: what the line costs after the step less what it cost before. A strategy used on its own, which does not know the state at the start of the run, prices from the state before its call, as it is charged; in a call given both the overload and the voltage violations of a line, the voltage steps are thus priced from the state before the thermal steps of the call, and can take back the conductors those laid. Since a line is charged for what the run leaves on it, whatever the steps, a step that turns the two ``T_AL_70`` conductors of the example into one ``U_AL_288`` costs 30 k€/km, so that the line ends charged what the ``U_AL_288`` laid at first would have cost: the voltage steps make up for what the thermal choice did not see, without the thermal choice having to predict the voltages, and the lookahead, which chooses between strategies, is not needed for it. The gain of a step is its predicted voltage change at each violated bus towards its limit (``calculate_voltage_line_change_effects_of_steps``), counted up to what the bus exceeds its limit by, and averaged over the violated buses: a voltage brought beyond the limit is worth nothing. A step is only considered if it is worth its works, as without prices (above). The step of the highest gain per euro is taken, of any line. A step charged nothing or less, a type that costs no more than the conductors it replaces, from the start of the run, comes before any step that costs, the highest gain first; ratios of a gain to a zero or negative charge are not formed. Ties go to the cheaper step, then to the order of the steps (the conductor added, then the types in the order of the catalogue, fewer conductors first), then of the lines. Without prices, the steps and their ranking are those of the ladder, unchanged. Counting the gain up to the excess is what settles a bus a hair under its limit. On ``32_MVFeeder0835`` without flexibility, after a thermal take-back (#59), the line upgrades for voltage left an MV bus 0.87 µpu under its 0.95 pu limit, and the ladder, by voltage per km, replaced a 0.83 km MV line for 91 k€ to lift it. The limit stays strict, with no tolerance: a bus 0.87 µpu under it is violated, but a step is only worth the 0.87 µpu it lacks, and a cheap step that brings it within the limit wins over a dear one that brings far more. That run now costs 353 k€, against 490 k€ (and 399 k€ before #59): its voltage steps take another course, and lay 52 k€ of MV works on three lines where they laid 132 k€, the 0.83 km line among them; counting the whole gain of a step, it cost 450 k€. On the 150 feeders of the case study, version 1, before #63, counting the whole gain cost 36.57 M€ without flexibility and 21.33 M€ with 30 %, against 36.22 M€ and 21.05 M€ counting it up to the excess (35 runs dearer and 20 cheaper without flexibility, 10 and 10 with; measured on the code of 6faf4e6, before the flexibility of #63, which only moves the runs with flexibility). A take-back lowers the rating of the line. It is only offered if the conductors left carry the current of the line within the loading limit, as the rating of each type times the derating factor of the line gives it, the rule by which a line is buried (#51). In a mesh, or under generation, the current moves with the step: every type change, a take-back or not, is checked by the power flow that follows it, and undone if its line is over its limit (see `Steps Checked After the Power Flow`_). A line whose take-back is undone takes no other take-back in the action. On an engine that cannot set the conductors of a line and check a step, no conductor is taken back. The steps cannot cycle: each either adds a conductor of the type in place or changes the type to one of lower resistance, so that, but for a step undone, a line never comes back to a state it has had, and the conductors added are bounded by ``max_iterations``; a step undone raises the conductors its type is offered with on that line, which are bounded by the conductors it has. The ranking is greedy: it takes, at each iteration, the step that buys the most voltage per euro, and does not look further. Taking the cheapest increment first, it can lay a conductor and take it back two steps later for a larger type, which costs power flows but nothing in the charge, as the line is charged for its final state. And it is not optimal: on version 1 of the 150 feeders of the MV/LV case study, against the ladder (``benchmarks/results/2026-11-17/study_after_63.json``, milestone after #63), the study cost 36.22 M€ against 38.04 M€ without flexibility (59 runs cheaper, 5 dearer) and 9.82 M€ against 10.38 M€ with 30 % (21 cheaper, 8 dearer, 149.2 MW shed against 140.5 MW); all 300 runs are resolved. Of the 8 runs that #52 had made dearer (``study_after_53_50_51.json`` against ``study_after_52_final.json``), the 7 without flexibility are now cheaper than before #52: ``27_MVFeeder0223`` (35 k€, against 56 k€ before #52 and 59 k€ after it), ``28_MVFeeder1181`` (19 k€, 24 and 26 k€), ``52_MVFeeder0388`` (64 k€, 73 and 93 k€), ``75_MVFeeder3206`` (192 k€, 258 and 259 k€), ``75_MVFeeder3713`` (57 k€, 88 and 96 k€), ``76_MVFeeder0812`` (71 k€, 82 and 82 k€) and ``76_MVFeeder1654`` (36 k€, 49 and 50 k€). The eighth, ``11_MVFeeder4794`` with 30 % of flexibility, is not: it costs 19,927 € against 16,319 € before #52 and 19,070 € after it, and is one of the runs this change makes dearer with flexibility (below); its costs before #52 came with the flexibility before #63, and are not comparable. The dearer runs are where the greedy ranking misses a larger step, or where a cheaper step leaves more to the flexibility: * Without flexibility, ``32_MVFeeder2374`` (+44 k€) and ``32_MVFeeder0100`` (+21 k€) lift an MV under-voltage with 9 and 15 MV segments, 2.56 km for 277 k€ and 3.81 km for 393 k€, one step at a time, each the most voltage per euro, where the ladder replaced one 2.10 km line for 231 k€, and two lines of 3.15 km for 346 k€. ``11_MVFeeder4885`` (+9 k€) takes a 0.18 km ``U_AL_150`` cable to three ``U_AL_288`` (43 k€) in four cheap steps, where the ladder took a 0.48 km cable to ``U_AL_240`` (34 k€). ``52_MVFeeder0054`` (+4 k€) reinforces three short lines (13 k€) where the ladder took a 0.15 km line to ``T_AL_150`` (9 k€), and ``24_MVFeeder0337`` (+1 k€) gives a 0.45 km line a second ``T_AL_70`` and a 0.08 km line a ``U_AL_240`` (28 k€), where the ladder took the first to ``T_AL_150`` (27 k€). * With 30 % of flexibility, the 8 dearer runs all lay less on their lines, or as much, and shed more: ``11_MVFeeder4375`` (+11.0 k€: lines −0.2 k€, flexibility +11.1 k€), ``44_MVFeeder0849`` (+8.0 k€: −4.0, +12.0), ``75_MVFeeder3319`` (+3.1 k€: −3.8, +6.8), ``32_MVFeeder2374`` (+2.2 k€: −0.5, +2.6), ``53_MVFeeder1979`` (+1.6 k€: −4.1, +5.7), ``84_MVFeeder3686`` (+1.0 k€: −5.4, +6.4), ``75_MVFeeder3206`` (+1.0 k€: −5.3, +6.3) and ``11_MVFeeder4794`` (+0.8 k€: −4.7, +5.5). The voltage steps are chosen on the state the flexibility of the first pass leaves; after the planning step, that flexibility is undone and chosen again, and the difference is in that last flexibility. On ``44_MVFeeder0849``, traced step by step before #63 with the same line decisions, the ladder had lifted the voltage with a ``T_AL_150`` on ``44_LVBranch015675``, which also gave that line the rating it lacks without the flexibility; the step per euro, a take-back on another line, leaves ``44_LVBranch015675`` a ``T_AL_70``, 34 % over its limit once the flexibility is undone, and the flexibility chosen again sheds for it and for the under-voltage behind it. The other 7 runs have the same split of costs; their steps were not traced one by one. The rule of `Thermal Sizing`_ and the lookahead are not changed: each takes the cheapest of its own choices, not of the run. Each iteration asks the engine for the effect of every step of every line in one call (``calculate_voltage_line_change_effects_of_steps``). The pandapower engine predicts them with one solve of the factors of the Jacobian, as it predicts the one step of each line of the ladder: the effect of a step is a column of the response, which does not depend on the other steps. An engine that does not implement it falls back on ``calculate_voltage_line_change_effects``, in as many calls as a line has steps. Asked one call for the :math:`k`-th step of every line, as first written, a ranking made one solve for each number of conductors a type could take a line back to: 6 calls for a line of one conductor and 751 for one of 150 laid by the run, 0.9 s a ranking, and 504.7 s against 17.6 s, with the same rankings, on a random feeder with no voltage threshold. The runs take more iterations than with the ladder, as the steps are smaller. On the case study, the runs make 1,571 power flows against 1,222 without flexibility, and 40,492 against 39,098 with 30 % (3.6 % more). Their CPU time is 113 s against 98 s without flexibility and 1,580 s against 1,332 s with 30 %, measured with 2 workers against 3 on a machine shared with other jobs (load average 5 to 7 against 3 to 5), which these figures do not separate from the change. ``PathToSourceLineUpgradeStrategy`` keeps its rule for voltage, which reproduces that of the roseau-postdoc study: the lines of the path take the best type of their category, or a parallel conductor, for every conductor they have, whatever the prices. Its thermal upgrades are those of ``LineUpgradeStrategy``. A type change of a line of the path thus replaces all its conductors, those that earlier actions of the run laid on it included, which the run has paid for, where ``LineUpgradeStrategy`` weighs that with prices since #60; and its voltage rule does not rank steps by the voltage gained per euro, as ``LineUpgradeStrategy`` does with prices (the lines of a step are ranked, with ``ranking="effect"``, by the voltage they bring per km of line). This is left to a follow-up (#70). Voltage-Resistance Sensitivity Calculation ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ To identify the most effective line upgrades for voltage support, the sensitivity of bus voltage magnitudes to changes in line resistance is calculated. This is derived by differentiating the power flow equations with respect to line resistance :math:`R_{ij}`. The line admittance :math:`y_{ij} = g_{ij} + jb_{ij} = \frac{1}{R_{ij} + jX_{ij}}` has derivatives: .. math:: \frac{\partial g_{ij}}{\partial R_{ij}} &= \frac{X_{ij}^2 - R_{ij}^2}{(R_{ij}^2 + X_{ij}^2)^2} \\ \frac{\partial b_{ij}}{\partial R_{ij}} &= \frac{2 R_{ij} X_{ij}}{(R_{ij}^2 + X_{ij}^2)^2} These derivatives propagate to the nodal power injections :math:`P_i` and :math:`Q_i`. For a bus :math:`i` connected to line :math:`ij`: .. math:: \frac{\partial P_i}{\partial R_{ij}} &= V_i^2 \frac{\partial g_{ij}}{\partial R_{ij}} - V_i V_j \left( \frac{\partial g_{ij}}{\partial R_{ij}} \cos \delta_{ij} + \frac{\partial b_{ij}}{\partial R_{ij}} \sin \delta_{ij} \right) \\ \frac{\partial Q_i}{\partial R_{ij}} &= -V_i^2 \frac{\partial b_{ij}}{\partial R_{ij}} - V_i V_j \left( \frac{\partial g_{ij}}{\partial R_{ij}} \sin \delta_{ij} - \frac{\partial b_{ij}}{\partial R_{ij}} \cos \delta_{ij} \right) The sensitivity vector is then computed by solving the linear system involving the Jacobian :math:`J`: .. math:: J \begin{bmatrix} \frac{\partial \theta}{\partial R_{ij}} \\ \frac{\partial V}{\partial R_{ij}} \end{bmatrix} = - \begin{bmatrix} \frac{\partial P}{\partial R_{ij}} \\ \frac{\partial Q}{\partial R_{ij}} \end{bmatrix} The term :math:`\frac{\partial V_k}{\partial R_{ij}}` quantifies the impact of upgrading line :math:`ij` (reducing :math:`R_{ij}`) on the voltage at bus :math:`k`. Transformer Upgrades ~~~~~~~~~~~~~~~~~~~~ Transformer overloading is resolved by replacing the units of the transformer with a type of higher rated apparent power (:math:`S_{max}`), or by adding units of the type in place in parallel (see `Thermal Sizing`_). Only the configured types rated above the unit in place are considered, so that a unit is never replaced by a smaller one. The rating of a unit whose type is not in the standard types, or that has none, is read from the transformer table. A type change gives the units every parameter of the new type but their vector group: they keep their phase shift (``shift_degree``) and the name of their vector group (``vector_group``), whatever the type is catalogued with, as a replacement unit is ordered for the connection of the one it replaces. Taking the shift of the type would turn the network beyond the transformer by the difference, 180 degrees from a Dyn11 unit to a Dyn5 type, which no reinforcement does. Whether a unit may be added in parallel is ``parallel_units`` of ``TransformerUpgradeStrategy`` (#83). Enedis's substation has one LV protection device per transformer ("On ne raccordera qu'un seul dispositif de protection BT par transformateur", Enedis-NMO-RES_011E §4.2.1), and its LV ladder replaces the unit, then creates a substation (Enedis-NMO-RAC_007E §3.5.1): it has no unit in parallel on one LV board. * ``"allowed"``, the default, is the behaviour of before #83: the type in place with more units is one of the options, charged the ``transformer_upgrade`` price of its type for each unit added. * ``"with_works"`` offers the same options, and charges each unit a transformer has beyond the units it had at the start of the run, besides its price, the works of a new substation of its final type (``new_substation["works"]``, ``CostModel.calculate_new_substation_works_cost``): a second unit needs its own LV board and room, a substation of its own on the same site. A replacement keeps its unit price alone. 1 × 250 kVA taken to 2 × 250 kVA is charged one 250 kVA unit and the works of a compact substation (11,491 € in the case study); taken to 2 × 400 kVA, two 400 kVA units and the works of one prefabricated substation (34,878 €). A unit added beside a unit the run created was already charged so since #80. The works enter the price of each option, so that with prices the choice moves towards a type change; without prices the choice is that of ``"allowed"``, and only the charge differs. A new substation that takes back the unit in place (``take_back_transformer_upgrades``) refunds the same works: the algorithm lends the strategies the ``parallel_units`` of the transformer upgrades of the run (``parallel_units_of_the_run``), by which ``NewSubstationStrategy`` refunds unless it is given its own ``transformer_parallel_units``; a run whose strategies disagree on it refuses to start. The works of a unit without a type are priced under the key None, as its unit price is. * ``"none"`` offers no option that adds a unit: a transformer is replaced by a configured type that carries it with the units it has, or gets nothing. One that no configured type carries, a 630 kVA unit at the top of the case study's ladder at 250 % of its limit say, keeps its violation, with a log line; the action lists it under ``units_at_the_top_of_the_ladder``, and the summary of the run counts the transformers left over their limit for that reason (``units_at_the_top_of_the_ladder`` and ``units_at_the_top_of_the_ladder_names``), as it counts the lines at the conductor cap. A type change that the power flow refuses (see `Steps Checked After the Power Flow`_) with no larger type left is undone, and the transformer is counted there too. Flexibility (``FlexibilityStrategy``) still addresses a transformer overload, where the run has flexible assets; the new substation does not, as it is for voltage violations. The case study keeps ``"allowed"`` (``CaseStudyConfig.transformer_upgrade_parallel_units``); ``create_run(parallel_units=...)`` and ``profile_study.py --parallel-units`` set it. ``CaseStudyConfig.transformer_upgrade_extra_types``, ``create_run(extra_transformer_types=...)`` and ``profile_study.py --extra-transformer-types`` add types at the top of the ladder, none by default: Enedis's 1,000 kVA unit, "limitée aux mises en service dans les zones urbaines denses et aux mutations de transformateur" (Enedis-NMO-RAC_007E §5.2.1.3), is ``("FT_Standard_Standard_1000kVA",)``, with the parameters of that type in the feeder files. Its prices in the case study (28,000 € the unit, 34,878 € the works) are extrapolations of the study's own prices, not Enedis prices: Enedis's connection price list prices the replacement of any unit above 160 kVA alike (10,067 € HT, Enedis-NMO-RAC_009E v8 §18.2), and no source read prices a 1,000 kVA unit. The option needs a sourced price before figures rest on it. The investigation of #83 measured two prototypes of these settings on the 150 feeders with ``standard`` (``benchmarks/new_feeder_gap.py --units``, ``research_notes/New feeders/implementation_plan.md``, item 9): with the works charged, every run resolved, 41.985 and 10.901 M€ at 0 and 30 % of flexibility against 33.608 and 9.190 M€, 183 units given a unit in parallel against 525 without flexibility; with no unit in parallel and the 1,000 kVA type at the top of the ladder, 121 and 147 runs resolved of 150, 35.500 and 9.918 M€, 43 units left over their rating on 29 feeders without flexibility. As implemented, on the 20 feeders of version 2 of #80's checks (seed 806) with ``standard``, at 0 and 30 % of flexibility: ``"allowed"`` gives the runs of before #83 entry for entry (and so on the two feeders in git, with the four profiles); ``"with_works"`` gives the prototype's cost in each of the 44 runs (the 20 feeders and the two in git), 3.268 and 0.768 M€ on the 20 against 2.846 and 0.713 M€, with every run resolved and 8 units given more units against 39 without flexibility; ``"none"`` with the ladder of the case study leaves 4 and 1 runs with a unit over its rating, one each, all counted in ``units_at_the_top_of_the_ladder``; with the 1,000 kVA type at the top of the ladder, it gives the prototype's cost in each of the 44 runs, and leaves 1 and 0 runs. The two feeders in git are left unresolved too: under ``"none"``, ``52_MVFeeder1118`` with 3 units over their rating at 0 % and 2 at 30 %, and ``84_MVFeeder4049`` with 1 unit at 0 %; with the 1,000 kVA type, ``52_MVFeeder1118`` at 0 % with 2 units. Thermal Sizing ~~~~~~~~~~~~~~ A branch (a line, a transformer) is made of :math:`n` identical elements in parallel: conductors, or transformer units. The engine reports its loading :math:`L` relative to the rating it holds for the branch, derating included: pandapower divides the current of a line by ``max_i_ka * df * parallel``, and the currents of a transformer, at the rated voltage of each side, by the rated currents of ``sn_mva * df * parallel``. A type change keeps the derating factor ``df`` and the number of elements, and gives each element the rating of the new type. With the current unchanged, :math:`m` elements of rating :math:`r` thus carry the branch within the limit :math:`L_{max}` when .. math:: m \, r \geq \frac{L}{L_{max}} \, n \, r_0 where :math:`r_0` is the rating of an element in place, as the line or transformer table holds it. The sizing reads the loading the engine reports, not the current or the apparent power against the rating of the type: a derating factor, a line rated in its table otherwise than its type, or a transformer that carries its rated power at a low voltage, and so more than its rated current, are sized for what the limit checks. The options for an overloaded branch are each configured type rated above it, by its table and by its type, with as many elements as carry it and at least those in place, as a type change replaces them all; and the type in place with as many more elements as carry it. An overhead line can take an overhead type, or be buried into a cable; an underground line only takes a cable. * With prices, when the run has a cost model, the cheapest option is taken, priced as the run charges it: a line for what is laid on it (the ``line_upgrade`` price of the new type for each conductor it had, if its type changes, and the ``new_line`` price of the type for each conductor added), a transformer for the units laid on it (the ``transformer_upgrade`` price of the new type for each unit it has, if its type changes, and the price of its type for each unit added). An option whose price is missing is left out. A line or a transformer is charged from its state at the start of the run, whatever steps and actions take it to its final state (on an engine that cannot list its lines or transformers, each action is charged from their state before it instead, see the usage guide): an action on an element that an earlier step or action of the run has changed is charged what the element costs after it less what it cost before it, and its options are priced the same way. A type laid and replaced within the run is never charged, nor is an element added in parallel and then replaced, with the others, by one of another type: the charges of the actions add up to the cost of going from the state at the start of the run to the final state, and an action can be charged less than nothing when the works it replaces cost more than its own. A cable that an action for a voltage violation took from 4x50 to 4x120 is thus offered a change to 4x150 at the difference between the 4x150 and the 4x120, not at the full price of the 4x150, which would favour a second 4x120 cable; and, at prices of 30,000 for a 250 kVA unit, 15,000 for a 400 kVA one and 20,000 for a 630 kVA one, a 250 kVA unit that a first action replaced by a 400 kVA one (rather than by two 250 kVA units) is offered a 630 kVA unit at 5,000 (20,000, less the 15,000 of the 400 kVA unit), where a second 400 kVA unit costs 15,000: priced as if the 400 kVA unit had not been charged, the 630 kVA unit cost 20,000, and the run took the second 400 kVA unit, two units laid for 30,000 where one laid for 20,000 carries the load. At the prices of the case study this does not arise: a second 250 kVA unit (10,000) is cheaper than a 400 kVA one (15,000). No run of the MV/LV case study upgrades a transformer by two actions, in the chain it keeps or in those it tries, nor changes its type before another step: its results are those it had when every step was charged in full. * Without prices, the smallest type that carries the branch with the elements it had before the action is taken: a larger type is the usual reinforcement, and nothing tells whether a parallel element costs less. When no type does, elements must be added in parallel anyway, and the option that lays the fewest elements since the action started, then the least rating, is taken, rather than the largest type and then elements of it in parallel. Ties go to the option that lays the fewest elements since the action started, then the least rating, then to the smaller type, the type in place coming last. Each iteration takes one step towards the option chosen, the type change or one more element, and the loading is computed again before the next step. A branch still overloaded is sized again on that loading, but chosen for, and priced from, its state before the action, not the state the steps have reached: a step taken towards an option does not turn the next choice to another. Chosen from the state the steps have reached, a 500 kVA unit at 229 %, planned as three 500 kVA units, would be at 112 % with two, which two 630 kVA units carry with the units then in place: it would end with them, three units laid where two were planned. Because the options are sized again on the new loading, a branch that the steps relieve more than predicted, as a load draws less current once the voltage rises, stops short of the option chosen at first: a 4x50 cable at 202 %, planned as three cables, is left with two at 99 %. Under load, the first choice is sized on a current that the reinforcement then lowers, and fewer elements of a larger type can then carry the branch for less than the elements planned. With prices, a line is therefore offered at each step the type changes sized from the conductors it had before the action, not from those in place, and the type change takes back the conductors the action has added: the engine sets the number of conductors of the line back (``set_line_parallel``). In the MV/LV case study, ``T_AL_70`` lines that need 477 A to 528 A before they are reinforced, a little more than the 474 A of a ``U_AL_288``, are planned as three ``T_AL_70`` conductors (100 k€/km); after the second one they carry 412 A to 460 A, and the two ``T_AL_70`` conductors are replaced by one ``U_AL_288`` (80 k€/km) or ``U_AL_240`` (70 k€/km). The line is charged for what is left on it, from its state at the start of the run, as if the larger type had been laid at first: the conductor taken back is not charged. Such a type change is recorded with the conductors it leaves (``conductors``) and those it takes back (``conductors_removed``). An action never takes back the conductors a line had when it started: those of the network, and those that an earlier action of the run laid, possibly for another violation, which taking them back could bring back. The cost model does not price the removal of a conductor either: a type change is charged for every conductor the line had at the start of the run. A line that came into the run with several conductors thus keeps at least as many. The steps do not cycle: a type change only goes to a type of higher rating, and a conductor added keeps the type, so a line never comes back to a state it has had. A take-back can leave its line overloaded: in a mesh, one conductor of lower impedance draws more current than the conductors it replaces, and in a radial feeder fewer conductors have more reactance. The line could then only take a type rated above the new one, or more conductors of it, which can cost more than the conductors first planned. So when the power flow that follows a take-back shows its line overloaded, the take-back is undone: the engine gives the line back exactly what it was before it (``save_line``, ``restore_line``: its type, its conductors and every parameter of its table), the line takes in its place, in the same iteration, the step it would have taken without take-backs, chosen on the same power flow, and it takes no conductor back for the rest of the action. The other lines having been stepped on that same power flow, the action then goes on exactly as without the take-back, in state, entries and charge, at the cost of one more power flow. Since #57 this is the rule for every type change sized to carry its line or transformer by itself, a take-back or not, and the power flow after the undo starts from the solution the iteration was decided on, put back exactly (see `Steps Checked After the Power Flow`_). Take-backs are only made on an engine that can set the conductors of a line and check a step, which the first take-back of an action tries before it changes the line. The guarantee is for the line taken back: its take-back never leaves it overloaded, and so never makes it end dearer than the conductors it replaced. On small meshes with a 140 A line that a second path relieves (600 cases), the take-backs make 39 runs cheaper and none dearer than without them; without the undo, 9 were dearer, by up to 50 %. The rule is exact, not optimal: it can also give up a gain, when the larger type, given one more conductor, would have ended cheaper, by the voltage violations it relieves for instance; in one of 150 small random feeders it does, which still ends cheaper than without take-backs. A take-back is only undone for its own line, and a take-back kept can still make the run dearer through another line. Fewer conductors of a larger type have a lower resistance but can have a higher reactance: one ``94-AL1/15-ST1A 0.4`` conductor has 2.6 times the reactance of the three ``24-AL1/4-ST1A 0.4`` ones it replaces. In a mesh, current then moves to the parallel path, and can overload a line there. In a three-line mesh with two loads, ``l2`` taken back to one 94 mm² conductor is at 83.6 % and kept; ``l1``, with three 24 mm² conductors, is then at 100.6 %, and is changed to two 94 mm² ones: the run costs 10.20 € against 8.80 € without take-backs. On sweeps of such meshes, 3 runs of 3,168 end dearer and 246 cheaper, and 1 of 2,376 dearer and 203 cheaper; no undo is involved in those dearer runs. A radial feeder does not rule it out either: a take-back that raises the impedance of its line lowers the voltage downstream, which raises the current that constant-power loads draw through the other lines. With a contrived catalogue in which the larger type has a higher resistance and reactance than the conductors it replaces, 4 of 114 cases end dearer and 13 cheaper, 2 of the dearer through an under-voltage that the take-back brings and the voltage upgrades then address. Such a new overload is treated at the next step like any line overloaded along the way, as after any step: in an iteration every overloaded line takes a step on the same power flow, so a new overload cannot be ascribed to one of them, and a step that relieves a line can load another in a mesh whatever the step; a guard on reactance, or a trial power flow for every take-back, was not added for this, the case study being radial with catalogues whose larger types have a lower impedance. A voltage violation that a take-back brings, or leaves, is left to the voltage strategies: the thermal choice does not see voltages, for a take-back as for any of its options. In the MV/LV case study, every line taken back goes from two ``T_AL_70`` conductors to one ``U_AL_240`` or ``U_AL_288``, and none is left overloaded. In one run, ``32_MVFeeder0835``, the line upgrades for voltage that followed, ranked by voltage per km, ended with an MV bus 0.87 µpu below its limit, where they ended 0.5 µpu above it without the take-back, and a 0.83 km MV line was replaced to lift it; ranked by voltage per euro (see `Voltage Steps with Prices`_), they take another course, which replaces no such line. Without prices, a type change keeps at least the elements in place, as before: nothing tells whether the larger type costs less than the elements it would take back. The same holds for an engine that cannot set the number of conductors of a line, the default of ``PowerFlowEngine``, and for transformers: a transformer given a unit in parallel can no longer take a single unit of a larger type. A transformer whose loading one more unit in parallel did not lower gets no more units in the action, with a warning. A unit shares the current between more units, and lowers the loading by about :math:`1/(n+1)` of itself, or by less where the network drives a current through the transformer that grows as its impedance falls, as a flow between two sources it joins (in one such loop, from 59.1 % to 46.4 % with a second unit). A loading that does not fall at all has one of two causes, which the strategy cannot tell apart: a power flow that has not reached the operating solution, as the warm start that converged to a spurious solution after a change of phase shift (see `Precision of the Power Flow`_), read a unit at 1652 % and made the strategy add units up to its 50 iterations; or a flow between two sources stiff enough to drive it whatever the units. Either way more units of the same kind would not lower it. The unit already added is kept in the action, and charged, as any unit the run leaves laid. The prices of the MV/LV case study (``MV_LV_FEEDER`` in ``gridforge/case_study/config.py``) have no ``new_line`` price: a conductor added in parallel is priced at the ``line_upgrade`` price of the type in place, like the replacement of a conductor by that type, which is an assumption, not a measured cost. An element of the type in place then costs less than one of the next type, so a priced run adds an element in parallel wherever one more is enough, where it used to change the type: this assumption drives nearly every thermal decision of the study. The choice is made for the thermal violation alone. It does not see that a voltage violation left by a second conductor of the type in place will be addressed by another action. Ranked by voltage per km, that action replaced both conductors by the next type, at a higher total cost than the larger type laid at first and changed again: in the study, a ``T_AL_70`` line given a second conductor for its loading then had both replaced by ``T_AL_150`` conductors for its voltage, and the lookahead of ``GridEnhancementAlgorithm``, which chooses between strategies, not between the options of one strategy, did not correct this. With prices, the voltage steps are priced from the start of the run and can take back the conductors the thermal choice laid (see `Voltage Steps with Prices`_): the line can then end with the larger type at what it would have cost laid at first, so that the thermal choice need not see voltages. In the 10 runs of the study examined for #60 before #63 (those it then made dearer, and ``32_MVFeeder0835``), 49 voltage steps replace two ``T_AL_70`` conductors by one ``U_AL_240`` or ``U_AL_288``. Steps Checked After the Power Flow ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ A cable a line is buried into, a type a line or a transformer is given for its loading, is sized on the current the element carries before the step. The step moves that current (#57). Under generation, an element of lower impedance lowers the voltage at the generators, which then inject more current for the same power: on a feeder of three 100 m ``94-AL1/15-ST1A 0.4`` lines with PV at its end and a loading limit of 100 %, a line at 268.4 A passes the 270 A of a ``NAYY 4x150 SE`` cable and, buried, carries 270.3 A (100.1 %); the path-to-source rule, burying the three lines at once, takes them from 265.4 A to 271.7 A (100.6 %). Beside a separate element in parallel, an element of lower impedance draws current from it: of two ``94-AL1`` elements between the same buses carrying 219.2 A each, the one buried carries 292.7 A (108.4 %), the other 154.7 A. And a larger transformer lowers the LV voltage under export: a 250 kVA unit at 159.8 % is given a 400 kVA unit, at 100.5 % once laid, and then a 630 kVA one. The derating factor of a line was not read either: the rule by which a line is buried (#51), and by which a priced type change is offered, compared its current with the rating of the type, where the engine rates a line at ``max_i_ka * df``; three 140 A conductors derated to 80 % carrying 313 A were offered one 350 A conductor, which, derated to 280 A, is at 110 %. The derating factor of the line is now part of that rule: the type must carry the current of the line within the limit with its rating times ``df``, which a type change keeps (``df`` of ``get_lines_info``, 1 for an engine that does not give it). The other effects are not predicted: the step is taken, and checked on the power flow the strategy runs after it anyway. The steps checked are, for a voltage violation, every type change, with prices or without (``LineUpgradeStrategy`` and ``PathToSourceLineUpgradeStrategy``): a burying, sized on the current, and the step to a type of the same category as well, the ladder's next overhead conductor or next cable and the best type of the category of the path-to-source rule, which are not sized on the current at all and which a catalogue whose resistances and ratings disagree, or a mesh, can leave over its limit; for a loading violation, a type change of a line or a transformer whose option has no more elements than the step leaves, not one that more elements are planned to follow. A step whose element is over its limit in that power flow, as ``check_violations`` reads it, with no tolerance, is undone: * the engine gives the element back exactly what it was (``save_line`` and ``restore_line``, ``save_transformer`` and ``restore_transformer``) and puts back the solution the step was decided on (``save_solution`` and ``restore_solution``): the result tables, the internal case the sensitivities are computed from and the starting point of the next warm start, bit for bit, with no power flow; * its entry is dropped from the action, or replaced, and the type is offered to that element with at least one more conductor or unit for the rest of the action; a line whose take-back is undone takes no other take-back, as before. The ladder and the path-to-source rule without prices keep the conductors of a line, so a type of its category refused is skipped for that line as if the catalogue had not it (its next type of the category is the next one not refused, its best type of the category the best of the others), and a line refused the best cable is not buried, as for a cable that cannot carry it: a cable of higher impedance would carry it no better; * for a loading violation, the element takes, in the same iteration, the step chosen on the same power flow with that offer, as #59 did for a take-back, and the network is solved again from the solution put back; for a voltage violation, when no step of the iteration is left, the iteration is decided again on the solution put back and does not count against ``max_iterations``, and when steps of the iteration are kept, checked or not (one more conductor is not checked), the network is solved again with them alone from that solution, they are checked again, and the iteration counts. When an iteration steps several galvanic zones (``one_upgrade_per_zone``, or the path-to-source rule, which takes a path in each zone), a zone's type change can thus be undone while another zone's conductor is kept: the kept conductor is solved, not taken a second time on the violations it was decided on (fixed after review, #57). The action then ends as if the type had never been offered with so few elements, in its entries, its charge, the network and its results, bit for bit: the tests compare the burials of the first case, the transformer, a cable given a type for its loading under generation, and an overhead type of lower resistance but lower rating than the one in place (a step of the ladder and of the path-to-source rule within the category), with runs whose catalogue lacks the type refused. The 268.4 A line is given a second ``94-AL1`` conductor, the three lines of the path one each, the element beside another a second conductor, and the 250 kVA unit a 630 kVA one in one step. An iteration whose steps are only partly undone is the exception: its steps kept are solved without those undone, from the same solution, but the iteration is not decided again. The check costs nothing while no step is refused, but a copy of the result tables before each round of steps that has one to check (0.35 ms on the largest feeder of the case study, 1,584 buses, against 13.8 ms for a warm power flow), and one power flow after the last iteration of a voltage action when its last step is checked. A step refused costs the power flow that refuses it: for a voltage violation, the solution is put back without one; for a loading violation, the power flow of the step taken in its place replaces the one the next iteration took, and none is run when the step taken in its place is the type change refused itself, planned with more elements: the power flow that refused it stands for it. What bounds an action. A thermal action is bounded by its iterations, a refusal being taken in the iteration that refused it. A voltage action is bounded by ``max_iterations`` for the iterations whose steps are kept, as before, and refused steps do not count: each refusal raises, for its element and its type, the elements that type is offered with (at least one more than were refused), and the elements of a line are bounded, by those it had at the start of the action and the conductors its kept steps add, at most one per iteration. So an action makes at most, for each element and each type, as many refusals as that element can have elements. This rests on every decision honouring the refusals: a step refused that an earlier refusal had already ruled out is an error (``StepCheck.refuse`` raises a ``RuntimeError``), not a step taken again, so that a slip in a decision ends the run instead of looping. Predicting the current after the step, from the predicted change of voltage at the generators and a share of current by impedance between the elements in parallel, would have saved those power flows, but it is approximate, and the limit has no tolerance: the check would still have been needed, and a margin on the prediction would have changed the steps where nothing is refused. On small LV feeders with generation (1,000 random feeders of 3 to 8 buses, a quarter of the lines derated, a separate element in parallel with another in a third of them, a mesh in a third, run by ``GridEnhancementAlgorithm`` with the line and transformer upgrades), a step that the check covers was left over its limit in 98 runs of the ladder without prices, 99 of the path-to-source rule, 18 of the ladder with prices and 27 of the path-to-source rule with prices, before the check; in none after. Of the type changes for voltage now checked, those within a category had not been rated before: 721 with the ladder without prices, 861 and 993 with the path-to-source rule without and with prices (the path-to-source rule is not priced for voltage). One of them is refused: on a meshed feeder, the path-to-source rule took a 4x120 cable to 4x150, the best of its category, which left it at 121 %; the ladder's steps within a category were never refused there. The violations left are the same, run by run, and so are the power flows within 2 % (5,517 against 5,413 before the check, 5,156 against 5,062, 6,034 against 6,036, 5,007 against 4,975): each step refused costs one, and a step checked and kept costs a copy of the result tables, 2,754, 2,715, 1,262 and 1,675 copies in the four kinds of run. Of the runs that change, 34 end cheaper and 15 dearer with the ladder without prices (priced afterwards at the prices of the run with prices), 32 and 14 with the path-to-source rule, 13 and 2 with prices, 11 and 9 with the path-to-source rule with prices. In the dearer runs examined, the step refused had happened to resolve a voltage violation as well: a line given an overhead type of 350 A for its loading, overloaded by it, was then given a second conductor of it, which also lowered an over-voltage; refused, the type is offered for two conductors, and the cheaper option for the loading, more conductors of the type in place, leaves the voltage to the line upgrades for voltage, which then lay more. The thermal choice does not see voltages (see `Thermal Sizing`_). In one dearer run with prices, the derating rule left out a take-back to one derated ``NAYY 4x120 SE`` cable that the power flow used to undo, after which the line took no other take-back and ended with two such cables; offered instead a take-back to one ``NAYY 4x150 SE``, kept, the line then needed a second one, 4.05 € dearer: the ranking by voltage per euro is greedy (see `Voltage Steps with Prices`_). On the three cases above swept over the load (41 points each, with the four kinds of run), the steps left over their limit (3 burials with the ladder, 30 with the path-to-source rule in 10 runs, 41 beside a separate element, and 4 transformer type changes) are all refused; the final states are the same or cheaper, with as many power flows or fewer (126 against 129, 133 against 143, 164 against 205, 127 against 127). The violations left are not the same on every set of feeders. On the review's random feeders (297 that solve, with derating factors down to 0.7, a third catalogue type of low rating, transformers in parallel and scaled powers), no step is left over its limit (20, 8, 0 and 6 runs before the check in the four kinds of run), and, against the milestone after #66 (dd00456), the violations left change in 6 runs of the ladder, all with fewer, 3 of the path-to-source rule (2 with fewer, 1 with more) and 3 of the path-to-source rule with prices (1 with fewer, 2 with more); with prices, in none. On its feeders of several zones (99 that solve, stepped by zone), the violations left are the same in every run. The runs left with more violations by the path-to-source rule come from its own step rule (#51): when a line of the path can be buried, only the lines that can be are stepped, and if they alone are not worth their works, the zone takes no step. Read with its derating, a line that was buried before #57 no longer can be, and its path can thus be left with no step (``_seed_46_feeder`` in the tests, an expected failure: three over-voltages left, one before #57). Two changes were measured and not made, as they change the path-to-source rule well beyond #57: giving the lines that cannot be buried one more conductor in the step that buries the others (on the review's feeders, 18 runs of the path-to-source rule left with fewer violations and 1 with more, 7 with prices with fewer), and, with it, taking the parallel conductors when the step that buries is not worth its works (violations left 200 to 11 and 171 to 12, 59 and 47 runs with fewer, none with more, but 29 % and 25 % more power flows, and 55 of the 65 runs changed dearer with prices). They are left to a follow-up. On an engine that cannot do all four operations (save and give back the element, save and put back the solution), the default of ``PowerFlowEngine``, the steps are not checked and the strategies take them as before; a line is then not taken back either. The same holds for ``PandaPowerEngine`` when its controllers act (``run_control`` in its settings, with a controller in service): a controller can change the network in the power flow after a step, a tap moved for instance, which undoing the step would not undo, so that the solution put back would not be that of the network. Its ``save_solution`` then refuses, and the steps are taken unchecked, the take-backs of #59 and #60 not made. On the feeder of the first case with a tap controller whose band the buried line crosses, the line is buried, the tap moved, and the line left at 100.1 %, as before #57. New MV/LV Substations ~~~~~~~~~~~~~~~~~~~~~ An LV network can have a violation that its cables cannot fix. On ``93_MVLV26902`` of pv-flex, with the design point of the issue, a line upgrade stacked up to 26 conductors in parallel and the run still ended with over-voltages (#80). The busbar of the network is then too high, or too low, for any cable to bring its voltages within the limits. An operator would build a new MV/LV substation near the generation or the load, and split the network between the old unit and the new one. ``NewSubstationStrategy`` does that for LV over-voltages and under-voltages. The placement it makes was measured by the investigation of the issue (``benchmarks/new_substation_placement.py``, one unit, in ``benchmarks/results/2026-11-23``; ``benchmarks/multiple_substations.py``, several units, in ``benchmarks/results/2026-11-24``). *When it is tried.* It addresses the over-voltages and under-voltages of the LV networks (its levels are ``"lv"``), at planning cost level 5, after the line upgrades. In a run without a cost model it is tried once the line upgrades have stopped, at their conductor cap or at ``min_voltage_sensitivity``, and the conductors they laid stay, unless ``take_back_line_upgrades`` is set, as in ``extended`` and ``hosting_capacity``. With a cost model, the lookahead rates the chain it starts with against the other chains of the turn, like any strategy. It is not registered by the ``standard`` profile of the case study; ``extended`` and ``hosting_capacity`` register it (see :doc:`profiles`). It needs the engine operations of the new substation, which only ``PandaPowerEngine`` implements: on another engine it takes no action. *Split of the network.* The LV networks of the 150 feeders are all radial, so a partition that keeps the cables is a set of opened lines. Each LV bus is fed by the nearest unit along the cables, by length; the lines whose two ends are fed from different units are opened by an open line switch, a normally-open point in the field, and the line stays in place for a later reconfiguration. The parts stay connected because the network is a tree, and the opened lines follow from the choice of the bus: that choice is the only one. The unit goes at the centre of the injection or of the load, not where the network is cut: placing it at the near end of the far part resolved none of the six placements tried on ``93_MVLV26902``. *Ranking by LinDistFlow, in both directions.* The candidate buses are ranked by the number of buses beyond the limit, then by the worst voltage: the highest for an over-voltage, the lowest for an under-voltage. The voltages come from LinDistFlow, a linear load flow of the radial network with the impedance of the new unit and of the lines, and the first ``n_checked`` (3) buses are then checked by a power flow. Against a power flow scan of every candidate bus, the first three are as good in the following shares of the networks, where "as good" means no more buses beyond the limit and a worst voltage within 0.001 pu: .. list-table:: :header-rows: 1 :widths: 30 22 24 24 * - Direction, new unit's tap, design point - Networks: the sample, and a separate sample of 40 buses or more - First 3 as good as a full scan - Scan resolves, the pick does not * - Over 1.10 pu, tap 0 %, pv-flex PV in year 26 (``2026-11-24/substation_placement_over_tap0*.json``) - 100, and 30 more of 40 buses or more - 98 % of the 100; 30 of the 30 large - 0 * - Under 0.90 pu, tap +5 %, case study with loads × 2.5 (``2026-11-23/substation_placement_under*.json``) - 100, and 30 more of 40 buses or more - 99 % of the 100; 29 of the 30 large - 0 The four misses are networks that the scan could not resolve either. LinDistFlow's worst voltage lies a little beyond the power flow's for over-voltages (median +0.002 pu over the 100 networks, +0.003 over the 30 large ones) and a little short of it for under-voltages (median −0.004 pu, losses left out); it orders the candidates almost as the power flow does (median Spearman correlation 0.998 to 0.999). The largest errors come with the largest currents: +0.44 pu on ``84_MVLV070563`` (worst voltage 1.73 pu, 1.7 MW) and +0.16 pu on ``53_MVLV33655`` (1.69 pu, 1.1 MW) in the over-voltage sample, and −0.03 pu on an under-voltage network at 0.81 pu carrying 1.6 MW. The ranking stays useful, and the power flow check guards the choice. The k-medoids placements on the cable length, or on the resistance, were not used: on the 100 over-voltage networks at 0 %, their first three are as good as the scan in 61 % of the networks for both (against 98 % for LinDistFlow), and 4 or 5 networks are left with violations that the scan's best bus resolves. On the under-voltage networks their first three are as good in 63 % of the 100 and in 47 to 50 % of the 30 large ones (against 99 % and 97 %). *Tap of the new unit.* The tap is one of the no-load taps of Enedis, 0, +2.5 or +5 % above 400 V, which are set off load (Enedis-NMO-RAC_007E §5.2.1.3), at the position that the ranking used. The ranking checks both limits, so that a tap chosen for one direction does not cross the other at the same point. Under-voltages use +5 %. An earlier run with the new unit at −5 % (``2026-11-23/substation_placement_y26*.json``, superseded) overstated what it can do: at 0 % (``2026-11-24/substation_placement_over_tap0*.json``), one unit resolves 59 of the 100 over-voltage networks instead of 67, and 20 of the 30 large ones either way. *Several units.* Where one unit does not resolve a network (49 over-voltage and 26 under-voltage networks), units are added one at a time, each ranked and checked as above, and a pass then moves each new unit to its best bus given the others. On these networks two units resolve 24 and 18 of them, and three units 30 and 20. Two units are as good as the best pair found by a power flow on every pair in 34 of 37 networks and in 15 of 15 networks of at most 43 buses, so the units need not be chosen jointly. Over a run, at most ``max_new_substations`` (3) units are added to an LV network, and at most ``units_per_call`` in one call; once the number is reached, the violations left go to the other measures. *Networks beyond the MV limits.* Of the 25 networks left with three units, 22 have their MV side above 1.05 pu (17 of them at 1.067 to 1.144 pu) or below 0.95 pu (5, at 0.817 to 0.921 pu): a new unit at no load is then already beyond the LV limit, or nearly. These are MV problems. They are reported as MV-limited (``lv_networks_mv_limited``) and left to the MV strategies; the other three need more units, or line upgrades on top. *Sizing.* Each unit is sized on Enedis's two situations (Enedis-NMO-RAC_007E §5.2.1.3 and §5.3): the winter consumption peak at the base minimum temperature, with production off, and the summer production peak, with the consumers at 20 % of their maximum. The winter maxima through the unit are 85, 135, 210, 335, 525 and 835 kW for units of 100 to 1000 kVA, in that order. *Connection to the MV network.* The unit is teed into the nearest line of its MV network. The cable runs from the tee to the unit, over the straight distance times ``mv_detour_factor`` (1.0), and is at most ``max_mv_distance_km`` (0.5 km) long. On ``93_MVLV26902`` every LV bus is within 357 m of an MV cable (median 177 m), measured to the line geometry. The nearest MV bus is usually the old substation, so the unit must tee into the MV line. Without geodata the strategy places no unit, unless ``default_mv_distance_km`` is set, which then fixes the cable length as a chosen value and not as a distance found. *Price and origins.* A new substation costs its works (enclosure, MV switchgear, LV board and civil works), its unit at the ``transformer_upgrade`` price of its type, and its MV cable at 145,000 €/km (Enedis's 145 €/m in zone ZFA, trench included, against 90,000 €/km for a conductor of ``U_AL_150_mv`` in the line upgrades). The works are 11,491 € up to 250 kVA, for a compact substation (PRCS/PSS), and 34,878 € above, for a prefabricated one. The compact works are fitted to Enedis's list prices of a compact substation up to 250 kVA (17,787 € HT up to 160 kVA, 21,898 € HT up to 250 kVA, Enedis-NMO-RAC_009E v8 §17), and the prefabricated works to Enedis's 42,545 € HT for the other prefabricated types (the same section), with the unit prices of the case study: 16,491, 19,491 and 21,491 € at 100, 160 and 250 kVA, and 49,878 and 54,878 € at 400 and 630 kVA, where Enedis prices on quote. The works follow the type of the unit, so a unit taken to a larger type is charged the works of that type. Splitting the MV line and opening the LV lines cost nothing. Elements that a run creates are charged from their creation, and not again when a later action upgrades them: each action lists what it created, and the algorithm lends the strategies the states of the run from which the later upgrades are charged. *Take-backs.* With ``take_back_line_upgrades``, before it places a unit in an LV network, the strategy takes back the line upgrades the run has made there: each line gets the type and conductors it had at the start of the run, and the network is then reinforced by copper or by a new unit, not by both. With ``take_back_transformer_upgrades`` (on by default; it acts only with ``take_back_line_upgrades``, which the ``extended`` and ``hosting_capacity`` profiles set), the MV/LV unit in place is taken back too, to the type and number of units it had at the start, and keeps its tap position; a unit the run created is not taken back. The refund of the upgrades taken back is counted apart from the price of the substations. A unit overloaded again once the new unit is placed is upgraded again by the transformer turn that follows. *Residual violations.* An LV network whose worst bus is beyond the limit by less than ``min_excess_pu`` (0.001 pu) gets no new unit in a call where a cheaper strategy of the same chain has acted and a later pass can still take the network up: the threshold delays a unit and never refuses one. In any other call it gets its unit as before. *Limits.* The placement works on one operating point: a tap set for one point can leave under-voltages at another, such as a summer tap that brings winter under-voltages. The MV voltage moves with the new injection or withdrawal, and MV violations are left to the other strategies. The sizing is by Enedis's two situations only; in one resolved under-voltage network a 630 kVA unit of the set was at 130 % of its rating, and the thermal strategies must size the units that follow. New Feeders ~~~~~~~~~~~ Enedis lays no conductors in parallel on its LV and MV feeders. Where a section change is not enough, its study rules build a new feeder, for loading and voltage constraints alike: at LV, a feeder created or duplicated from the busbar of the substation in place, before the unit is replaced or a substation created; at MV, a feeder duplicated or created from the HV/MV substation (Enedis-NMO-RAC_007E §3.5.1). ``NewFeederStrategy`` (``gridforge.strategies.new_feeder``, #83) builds one or the other; one instance is built for one level (``level="lv"`` or ``"mv"``). The investigation and the decisions behind it are in ``research_notes/New feeders/implementation_plan.md``. *State.* As of step 2 of #83, the strategy is usable from the library, without a cost model, and no profile of the case study registers it. It has no price yet: a run with a cost model refuses to start with it (``required_unit_costs`` asks for ``new_feeder[]``, which no cost model holds), and ``calculate_cost`` raises ``NotImplementedError``. The price, its registration in the profiles and the case study, and the summary of a run come with step 3. *A new feeder.* A cable of ``line_type``, one conductor, from the busbar to a bus of the network, the landing bus, and a line of the path from the busbar to the landing bus opened, the cut: the part below the cut is then fed through the new cable, and the buses between the cut and the landing bus hang the other way round. With ``cut="above"`` (the default, D2) the cut is the line just above the landing bus; ``cut="any"`` takes any line of the path. The landing bus just below the busbar with its own line as the cut is not a candidate: it is a section change. The cut is opened by an open switch at its end on the side of the landing bus, and stays in the network, in service, as the lines a new substation opens. The cable runs along the lines of the path in place (``route="path"``, the default, D3), its route theirs, or over the straight distance (``route="straight"``), times ``route_factor`` (1.0), 10 m at least. *Networks.* At LV, the LV network of each violation of the group, if one MV/LV unit in service feeds it, radially, with no closed bus-bus switch. At MV, the MV network of the violation, if one busbar feeds it: the buses of the sources above 1 kV joined by closed bus-bus switches (in the feeder files, the bus of the external grid and the busbar of the HV/MV substation), which are the root of the tree. The MV lines of a direct feeder (``dedicated_lines``, the lines on which Enedis lays cables in parallel) are left out of the MV tree, with the buses they alone reach. The violations counted are those of every kind in the tree, buses beyond a voltage limit of the level and lines over the loading limit, whatever the type of the turn: a feeder that relieves a line by bringing buses beyond their limit is not laid. *Choice.* The candidates are rated without a power flow by the placement core (``gridforge.strategies.feeder_placement``, step 1 of #83): LinDistFlow gives the change of voltages and flows between the tree as it is and the tree with the candidate, the current of each line taken at the voltage of the power flow in place, and the change is applied to that power flow. They are ranked by the violations they leave in the tree, then by their total excess (pu of voltage beyond a limit, loading over the limit in units of 100 %), then by the length of the cable; a candidate whose new cable would be over its rating is left out. The first ``n_checked`` (3) are each built on a copy of the network and checked by a power flow of the whole feeder. Of those whose power flow converges and whose cable is within its rating, the one kept leaves the fewest violations, then the least total excess, then has the shortest cable. It is built if it leaves fewer violations than there were, or as many with a total excess lower by ``min_gain`` (10 %) or more; then, up to ``feeders_per_call`` (1), the next feeder is tried on the network with it. At MV, the injection of each MV/LV unit is what it draws at its HV side in the power flow in place (``get_transformer_parameters``: ``p_hv_mw``, ``q_hv_mvar``). *Left out.* A root that has its ``max_new_feeders`` (2, D7) already: the feeders are counted from their names, ``_new_feeder`` then ``_2``..., so that the count follows the network through the undo of the algorithm. At LV, a board with no outlet left: a new feeder takes a free outlet of the smallest of Enedis's boards (``board_sizes``, 2, 4 and 8 outlets, Enedis-NMO-RES_011E §4.2.1) that holds the lines in place at the busbar, or the next size, which replaces it (``"board": "replaced"`` in the action), and a board of 8 full gets none. The lines at the busbar are counted conducting or opened by a switch: an opened line keeps its outlet, as the first line of a feeder that a cut ``"any"`` opens does. A network whose busbar is itself beyond the limit of each of its voltage violations, the group having no overload there. And, in a call that may leave residuals (as for the new substation), a network whose violations are voltage violations whose worst bus is less than ``min_excess_pu`` (0.001 pu) beyond the limit. *The cable's rating.* Enedis lowers the rating of cables buried side by side, to 0.85 for two LV cables and 0.83 for two MV cables (Enedis-NMO-RAC_007E §3.5.3). ``cable_rating_factor`` (1.0) applies such a factor to the new cable for its choice: by the estimate and by the check, its loading is taken against its rating times the factor. The cable built has the rating of its type, which the later checks of a run use; the cable in place keeps its rating. *The action.* ``{"type": "new_feeder", "level", "feeders", "left_out", "created", ...}``: one entry per feeder, with its cable (``line``, ``line_type``, ``length_km``, ``route``, and its lengths by both routes), its ``root``, ``unit`` (LV), ``landing_bus``, ``opened_line`` and ``opened_at``, ``buses_moved``, the lines at the busbar before (``feeders_before``) and the board (``board``, ``board_outlets``), the rating before, by the estimate and by the check (``before``, ``estimate``, ``checked``, ``cable_loading``), and the rank of the one kept among those checked. ``created`` lists the cables, for a run with prices to charge a later upgrade of one from its creation. *Against the prototype.* ``benchmarks/new_feeder_prototype.py`` calls the strategy since step 2, network by network, and gives the figures of items 6 and 7 of the plan again, on the same inputs (``benchmarks/results/2026-11-28/strategy/``). At MV, on the 7 feeders that the case study at a cap of 1 leaves with MV violations, on pv-flex's three feeders of year 25 and on the 27 feeders of the production design point, every feeder kept, its cable and the violations it leaves are the prototype's: 22 and 24 of the 27 resolved with one and two feeders, 327.2 km of cable along the path. The one difference is the size of the MV tree of ``93_MVFeeder0659`` (23 buses against 27): its direct feeders are left out of it. At LV, the networks resolved are the prototype's in every run: 91 / 119 / 123 of 233 with up to 1 / 2 / 3 feeders (route along the path, either cut), 94 / 119 / 123 (straight route), 604 / 750 / 801 of 1,052 as the case study starts, and, with the board check of 2, 4 and 8 outlets, 80 / 96 / 98. The scan of every candidate on the 137 networks of at most 30 buses finds again no network where the 3 checked leave more violations than the best candidate. Two things move a few first feeders. Candidates that leave the same violations with a total excess within 10⁻⁶ of each other are told apart by the excess rounded to 10⁻⁶, and the power flow of the engine (with its last Newton step, and the cut opened by a switch rather than put out of service) moves the excess by about 10⁻⁶: in 2 of the 156 first feeders along the path (either cut), 2 of the 156 straight and 2 later feeders of the run as the case study starts, another feeder that leaves the same violations is kept, its cable 22 m shorter to 14 m longer. And as the case study starts, 13 networks of ``44_MVFeeder0318``, ``76_MVFeeder2386`` and ``93_MVFeeder0916`` whose busbar is below 0.90 pu, with under-voltages alone, are left out at their first feeder (4) or a later one (9), where the prototype laid feeders that lowered their violations without resolving them: 973 first feeders kept of 1,052 against 975, 185.4 km against 185.8 km. *Limits.* The estimate leaves out the charging current of MV cables, up to 0.006 pu on synthetic cables of 4 to 24 km: the power flow check of the first ``n_checked`` guards the choice. The feeders are chosen one at a time: on ``53_MVFeeder1070`` at the production design point of the plan, the two feeders the strategy lays one after the other leave 4 MV buses above 1.05 pu (272, then 140, then 4), and the 27 feeders of that point are resolved at MV by two feeders in 24 cases; the estimate with the drops at 1 pu, which the prototype first had, laid nearly the same two feeders in the other order and left none, 25 cases. Choosing two feeders jointly is not done. The feeder is laid for one operating point. The model does not hold the free bays of the HV/MV substation, the protection plan of a longer or split feeder, nor the room for an outlet in a given substation: the board sizes are Enedis's three. No-Load Tap ~~~~~~~~~~~ The no-load tap of a unit in place is set off load, and moving it changes the LV voltage of the whole network it feeds at the cost of one site visit. ``NoLoadTapStrategy`` moves it, one position at a time, among the positions that give the rises of ``taps``: Enedis's 0, +2.5 and +5 % by default, which are the positions 0 to 2 of a 20/0.4 kV unit tapped by 2.5 % steps on the LV side (the older units have −2.5, 0 and +2.5 %). A move is taken while it leaves fewer buses beyond the limit and none more beyond the other limit. It is a planning strategy, at cost level 1, and the tap it sets is kept through the works that follow. Unlike ``TapChangeStrategy``, an operational strategy with 10 € per position, it is priced per intervention. *Price.* A no-load tap is priced at 700 € HT per intervention, a site visit, whatever the positions moved (``unit_costs["no_load_tap"]``). Enedis publishes no price for a change of no-load tap, which is on quote (CRE deliberation 2026-142). The price is the direct cost of a visit, rebuilt from quantities: 6.5 agent-hours (1.5 h of preparation, then two agents for 1 h of travel and 1.5 h on site) at 100 € per agent-hour, about 650 €, and 73 € of posted notices to the customers of the unit. The outage is not valued, as the other prices of the study are outlays. The range is 300 to 3,000 € HT, on the labour rate, a mobile generator, the outage at the TURPE 7 incentive and rural units without MV switchgear. A unit whose type or number of units in parallel the run changes pays no intervention on its tap, since the crew of the works sets it. The derivation is in ``research_notes/New MV-LV substations/no_load_tap_price.md``. In the 150-feeder study with the ``standard`` profile, the strategy makes 134 interventions at 0 % of flexibility and 25 at 30 %. Strategy Summary ---------------- .. list-table:: Summary of Grid Enhancement Strategies :widths: 25 25 25 :header-rows: 1 * - Strategy - Applicable Constraints - Stage * - Transformer Tap Change - Voltage (Under/Over) - Operational * - Flexibility Management - Voltage, Thermal (Line/Trafo) - Operational * - Line Upgrade - Thermal (Line), Voltage - Planning * - Transformer Upgrade - Thermal (Transformer) - Planning * - No-Load Tap - Voltage (Under/Over, LV) - Planning * - New MV/LV Substation - Voltage (Under/Over, LV) - Planning * - New LV or MV Feeder (not priced yet) - Thermal (Line), Voltage (Under/Over), at its level - Planning Cost Modeling ------------- A cost model evaluates the economic impact of the applied strategies. The total cost :math:`C_{total}` is the sum of operational costs (e.g., cost of flexibility activation, tap wear) and capital expenditure (CAPEX) for grid reinforcement (line and transformer replacements). Load shedding and generation curtailment are charged per MW activated. The algorithm works on one operating point and knows nothing of how long a constraint lasts, so it cannot compute an energy. The price :math:`\pi` of the activated power must therefore carry that assumption, on the same horizon as the investments it is added to: .. math:: \pi = v \cdot h \cdot T where :math:`v` is the value of the energy not served or not injected, in €/MWh (for curtailment, the compensation owed to the producer), :math:`h` the equivalent number of hours per year at full activation, and :math:`T` the horizon in years, or the equivalent annuity factor with discounting. A study that simulates the whole year can value the energy directly instead, and run the algorithm without a cost model. The cost model guides the search: the strategies of a violation type are chosen by the cost of the run they lead to (see above), so a price can change the actions taken. Without a cost model, or with ``strategy_choice="first"``, the strategies are selected by their cost level only.