def __init__(self, name: str = None, children: List["Area"] = None, strategy: BaseStrategy = None, appliance: BaseAppliance = None, config: SimulationConfig = None, budget_keeper=None, balancing_spot_trade_ratio=ConstSettings.BalancingSettings. SPOT_TRADE_RATIO): self.balancing_spot_trade_ratio = balancing_spot_trade_ratio self.active = False self.log = TaggedLogWrapper(log, name) self.current_tick = 0 self.name = name self.slug = slugify(name, to_lower=True) self.area_id = Area._area_id_counter Area._area_id_counter += 1 self.parent = None self.children = children if children is not None else [] for child in self.children: child.parent = self self.strategy = strategy self.appliance = appliance self._config = config self.budget_keeper = budget_keeper if budget_keeper: self.budget_keeper.area = self self._bc = None # type: BlockChainInterface self._markets = AreaMarkets(self.log) self.stats = AreaStats(self._markets) self.dispatcher = AreaDispatcher(self)
def apply(self, area): if self.area_uuid not in [c.uuid for c in area.children]: return False area.children = [c for c in area.children if c.uuid != self.area_uuid] if len(area.children) == 0: # TODO: D3ASIM-2560; Please also catch the case for multiple future markets # TODO: as a re-initiation would delete all results of future markets. area._markets = AreaMarkets(area.log) area.dispatcher = DispatcherFactory(area)() return True
def __init__(self, name: str = None, children: List["Area"] = None, uuid: str = None, strategy: BaseStrategy = None, config: SimulationConfig = None, budget_keeper=None, balancing_spot_trade_ratio=ConstSettings.BalancingSettings.SPOT_TRADE_RATIO, event_list=[], grid_fee_percentage: float = None, grid_fee_constant: float = None, external_connection_available: bool = False, throughput: ThroughputParameters = ThroughputParameters() ): validate_area(grid_fee_constant=grid_fee_constant, grid_fee_percentage=grid_fee_percentage) self.balancing_spot_trade_ratio = balancing_spot_trade_ratio self.active = False self.log = TaggedLogWrapper(log, name) self.current_tick = 0 self.__name = name self.throughput = throughput self.uuid = uuid if uuid is not None else str(uuid4()) self.slug = slugify(name, to_lower=True) self.parent = None self.children = AreaChildrenList(self, children) if children is not None\ else AreaChildrenList(self) for child in self.children: child.parent = self if (len(self.children) > 0) and (strategy is not None): raise AreaException("A leaf area can not have children.") self.strategy = strategy self._config = config self.events = Events(event_list, self) self.budget_keeper = budget_keeper if budget_keeper: self.budget_keeper.area = self self._bc = None self._markets = None self.dispatcher = DispatcherFactory(self)() self._set_grid_fees(grid_fee_constant, grid_fee_percentage) self.display_type = "Area" if self.strategy is None else self.strategy.__class__.__name__ self._markets = AreaMarkets(self.log) self.stats = AreaStats(self._markets, self) log.debug("External connection %s for area %s", external_connection_available, self.name) self.redis_ext_conn = RedisMarketExternalConnection(self) \ if external_connection_available and self.strategy is None else None self.should_update_child_strategies = False self.external_connection_available = external_connection_available
def __init__(self, name: str = None, children: List["Area"] = None, uuid: str = None, strategy: BaseStrategy = None, appliance: BaseAppliance = None, config: SimulationConfig = None, budget_keeper=None, balancing_spot_trade_ratio=ConstSettings.BalancingSettings. SPOT_TRADE_RATIO, event_list=[], grid_fee_percentage: float = None, transfer_fee_const: float = None, external_connection_available=False): validate_area(grid_fee_percentage=grid_fee_percentage) self.balancing_spot_trade_ratio = balancing_spot_trade_ratio self.active = False self.log = TaggedLogWrapper(log, name) self.current_tick = 0 self.name = name self.uuid = uuid if uuid is not None else str(uuid4()) self.slug = slugify(name, to_lower=True) self.parent = None self.children = children if children is not None else [] for child in self.children: child.parent = self if (len(self.children) > 0) and (strategy is not None): raise AreaException("A leaf area can not have children.") self.strategy = strategy self.appliance = appliance self._config = config self.events = Events(event_list, self) self.budget_keeper = budget_keeper if budget_keeper: self.budget_keeper.area = self self._bc = None self._markets = None self.dispatcher = DispatcherFactory(self)() self.grid_fee_percentage = grid_fee_percentage self.transfer_fee_const = transfer_fee_const self.display_type = "Area" if self.strategy is None else self.strategy.__class__.__name__ self._markets = AreaMarkets(self.log) self.stats = AreaStats(self._markets) self.redis_ext_conn = RedisAreaExternalConnection(self) \ if external_connection_available is True else None
def __init__(self, name: str = None, children: List["Area"] = None, uuid: str = None, strategy: BaseStrategy = None, appliance: BaseAppliance = None, config: SimulationConfig = None, budget_keeper=None, balancing_spot_trade_ratio=ConstSettings.BalancingSettings. SPOT_TRADE_RATIO, event_list=[], grid_fee_percentage: float = None, transfer_fee_const: float = None, external_connection_available: bool = False, baseline_peak_energy_import_kWh: float = None, baseline_peak_energy_export_kWh: float = None, import_capacity_kVA: float = None, export_capacity_kVA: float = None): validate_area( grid_fee_constant=transfer_fee_const, grid_fee_percentage=grid_fee_percentage, baseline_peak_energy_import_kWh=baseline_peak_energy_import_kWh, baseline_peak_energy_export_kWh=baseline_peak_energy_export_kWh, import_capacity_kVA=import_capacity_kVA, export_capacity_kVA=export_capacity_kVA) self.balancing_spot_trade_ratio = balancing_spot_trade_ratio self.active = False self.log = TaggedLogWrapper(log, name) self.current_tick = 0 self.name = name self.baseline_peak_energy_import_kWh = baseline_peak_energy_import_kWh self.baseline_peak_energy_export_kWh = baseline_peak_energy_export_kWh self.uuid = uuid if uuid is not None else str(uuid4()) self.slug = slugify(name, to_lower=True) self.parent = None self.children = children if children is not None else [] for child in self.children: child.parent = self if (len(self.children) > 0) and (strategy is not None): raise AreaException("A leaf area can not have children.") self.strategy = strategy self.appliance = appliance self._config = config self.events = Events(event_list, self) self.budget_keeper = budget_keeper if budget_keeper: self.budget_keeper.area = self self._bc = None self._markets = None self.dispatcher = DispatcherFactory(self)() self._set_grid_fees(transfer_fee_const, grid_fee_percentage) self._convert_area_throughput_kva_to_kwh(import_capacity_kVA, export_capacity_kVA) self.display_type = "Area" if self.strategy is None else self.strategy.__class__.__name__ self._markets = AreaMarkets(self.log) self.endpoint_stats = {} self.stats = AreaStats(self._markets) log.debug( f"External connection {external_connection_available} for area {self.name}" ) self.redis_ext_conn = RedisMarketExternalConnection(self) \ if external_connection_available is True else None