Summary
In distribute_private_charging_demand
(edisgo/io/electromobility_import.py), the home branch discards the
return value of weighted_random_choice, so the subsequent
designated_charging_point_capacity_df bookkeeping uses a stale
charging_park_id (the one drawn for the last work car) for every home car.
Found while working on the performance refactor in #675 (which deliberately
preserves this behaviour to keep output identical; this issue tracks the actual
fix).
Where
edisgo/io/electromobility_import.py, distribute_private_charging_demand:
- work branch (correct), ~line 885:
charging_park_id = weighted_random_choice(...) # return captured
...
designated_charging_point_capacity_df.at[charging_park_id, ...] += charging_capacity
- home branch (buggy), ~line 936:
weighted_random_choice(...) # return discarded
...
# charging_park_id is never assigned in the home loop -> stale value
designated_charging_point_capacity_df.at[charging_park_id, ...] += charging_capacity
Destinations are processed in sorted order (0_work before 6_home), so
charging_park_id carries the last work car's park into the entire home loop.
Impact
- The actual charging-point assignment written to
charging_processes_df
is still correct (it is set inside weighted_random_choice).
- The capacity bookkeeping is wrong: all home cars' capacity is added to a
single work charging park instead of their chosen home parks. Since
designated_charging_point_capacity_df feeds back into combine_weights
(capacity-based weighting), the "fuller park becomes less attractive"
feedback is effectively disabled for home charging -> home cars are
distributed without capacity feedback.
- Edge case: a grid with home but no work charging would leave
charging_park_id unassigned and raise NameError.
Suggested fix
Capture the return value in the home branch as well:
charging_park_id = weighted_random_choice(...)
Note this changes the resulting charging-point distribution (the weights, and
thus the stochastic draws, change), so it must be verified separately and is
intentionally not part of #675.
Part of #671.
Summary
In
distribute_private_charging_demand(
edisgo/io/electromobility_import.py), the home branch discards thereturn value of
weighted_random_choice, so the subsequentdesignated_charging_point_capacity_dfbookkeeping uses a stalecharging_park_id(the one drawn for the last work car) for every home car.Found while working on the performance refactor in #675 (which deliberately
preserves this behaviour to keep output identical; this issue tracks the actual
fix).
Where
edisgo/io/electromobility_import.py,distribute_private_charging_demand:Destinations are processed in sorted order (
0_workbefore6_home), socharging_park_idcarries the last work car's park into the entire home loop.Impact
charging_processes_dfis still correct (it is set inside
weighted_random_choice).single work charging park instead of their chosen home parks. Since
designated_charging_point_capacity_dffeeds back intocombine_weights(capacity-based weighting), the "fuller park becomes less attractive"
feedback is effectively disabled for home charging -> home cars are
distributed without capacity feedback.
charging_park_idunassigned and raiseNameError.Suggested fix
Capture the return value in the home branch as well:
Note this changes the resulting charging-point distribution (the weights, and
thus the stochastic draws, change), so it must be verified separately and is
intentionally not part of #675.
Part of #671.