Skip to content

Conversation

@nader-00
Copy link
Collaborator

@nader-00 nader-00 commented Dec 11, 2025

Fixes #330

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Summary

This PR allows charging strategies to be applied to a subset of charging parks instead of always to all integrated charging parks. This makes it possible to combine different charging strategies within the same EDisGo instance (e.g. some charging parks using residual, others using dumb).

Changes

  • Extend EDisGo.apply_charging_strategy to accept an optional argument
    charging_park_ids: Iterable[int] | None.
    • If charging_park_ids is None (default), behaviour is unchanged: the strategy is applied to all integrated charging parks.
    • If a list/iterable of IDs is provided, the strategy is applied only to those charging parks.
  • Update flex_opt.charging_strategies.charging_strategy to:
    • Take the same charging_park_ids argument.
    • Determine target_park_ids as the intersection of the provided IDs with the indices of integrated_charging_parks_df.
    • Filter charging_parks and charging_processes_df to target_park_ids.
    • Drop existing active and reactive power time series only for the selected charging parks instead of all integrated charging parks.
    • Add/update active and reactive power time series only for the selected charging parks.
    • Log a warning if non-integrated charging park IDs are passed.
  • Keep the existing strategies "dumb", "reduced" and "residual" working as before, but applied to the filtered subset when charging_park_ids is set, preserving backward compatibility when it is not provided.

Implementation details

  • EDisGo.apply_charging_strategy remains a thin wrapper around charging_strategy, now forwarding the optional charging_park_ids argument.
  • In charging_strategy:
    • integrated_parks is derived from edisgo_obj.electromobility.integrated_charging_parks_df.
    • target_park_ids is computed from charging_park_ids (or all integrated parks if None).
    • edisgo_ids_to_update is taken from integrated_parks.loc[target_park_ids, "edisgo_id"].
  • For the "residual" strategy, charging_processes_df is restricted to target_park_ids instead of all integrated charging parks.
  • Reactive power time series to 0 Mvar are added only for edisgo_ids_to_update, so multiple calls with different subsets do not overwrite each other’s results.

Checklist:

  • New and adjusted code is formatted using the pre-commit hooks
  • New and adjusted code includes type hinting now
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
    (existing test suite still passes; no new tests added)
  • New and existing unit tests pass locally with my changes
  • The Read the Docs documentation is compiling correctly
  • If new packages are needed, I added them to the setup.py, and if needed the rtd_requirements.txt, the eDisGo_env.yml and the eDisGo_env_dev.yml.
  • I have added new features to the corresponding whatsnew file

@nader-00 nader-00 linked an issue Dec 11, 2025 that may be closed by this pull request
@nader-00 nader-00 changed the title Implement flexible charging strategies for subset of charging parks (… Implement flexible charging strategies for subset of charging parks Dec 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Flexibilize charging strategies

2 participants