commonpower.extensions.cost_allocation.UncertaintyAwareShapleySimulator

class UncertaintyAwareShapleySimulator(sys: System, community_controller: BaseController, horizon: timedelta = datetime.timedelta(days=1), dt: timedelta = datetime.timedelta(seconds=3600), n_sample_coalitions: int = 100, seed=None)[source]

Bases: BaseShapleySimulator

This simulator simulates the imperfect knowledge system and computes Shapley values based on the perfect knowledge system.

Simulator that simulates the imperfect knowledge system to obtain the realized cost but computes Shapley values based on the perfect knowledge system. This can be used for allocation methods that make this distinction.

The given system is a template representing the entire energy community (grand coalition). For the simulation of coalitions, the template system is cloned and rearranged accordingly.

Parameters:
  • sys (System) – (Template) system to simulate.

  • community_controller (BaseController) – (Template) controller for the community.

  • horizon (timedelta, optional) – Forecast horizon. Defaults to timedelta(days=1).

  • dt (timedelta, optional) – Sample time aka frequency. Defaults to timedelta(minutes=60).

  • n_sample_coalitions (int, optional) – Number of coalitions to sample. Defaults to 100.

  • seed (int, optional) – Seed for the coalition sampling. Defaults to None.

Methods

simulate

Simulate the system and compute a simulation result, including the realized cost, Shapley values (perfect knowledge), and stand-alone costs (perfect knowledge).

_make_sys_perfect_knowledge(sys: System) System[source]

Make a perfect knowledge system by replacing all existing forecasters with perfect knowledge forecasters.

Parameters:

sys (System) – _description_

Returns:

System – _description_

simulate(sim_steps: int, fixed_start: datetime) ShapleySimulationResult[source]

Simulate the system and compute a simulation result, including the realized cost, Shapley values (perfect knowledge), and stand-alone costs (perfect knowledge).

Parameters:
  • sim_steps (int) – Number of simulation steps.

  • fixed_start (datetime) – Start time of the simulation.

Returns:

ShapleySimulationResult – Simulation result.