def apply(self, area): if area.uuid != self.area_uuid: return False area_type = self.area_params.pop("type", None) self.sanitize_live_event_parameters() if area_type is not None and area_type != "Area": if area.strategy is None: return False reactivate = False if area_type == "MarketMaker": area.strategy = MarketMakerStrategy(**self.area_params) reactivate = True elif area_type == "InfiniteBus": # TODO: After hack to move this parameter casting at the web side self.area_params['energy_sell_rate'] = self.area_params.pop( 'energy_rate', None) area.strategy = InfiniteBusStrategy(**self.area_params) reactivate = True if reactivate: area.activate() area.strategy.event_activate() area.strategy.event_market_cycle() area.area_reconfigure_event(**self.area_params) return True
def test_update_area_event_can_switch_strategy_from_market_maker_to_infinite_bus( self): self.strategy_mmr = MarketMakerStrategy(energy_rate=30) self.area_mmr = Area("mmr", None, None, self.strategy_mmr, self.config, None, grid_fee_percentage=0) self.area_mmr.parent = self.area_grid self.area_grid.children.append(self.area_mmr) event_dict = { "eventType": "update_area", "area_uuid": self.area_mmr.uuid, "area_representation": { 'type': 'InfiniteBus' } } self.area_grid.activate() self.live_events.add_event(event_dict) self.live_events.handle_all_events(self.area_grid) assert type(self.area_mmr.strategy) == InfiniteBusStrategy
def test_market_maker_strategy_constructor_modifies_global_market_maker_rate(): import d3a_interface.constants_limits from d3a.models.strategy.market_maker_strategy import MarketMakerStrategy MarketMakerStrategy(energy_rate=22) assert all( v == 22 for v in d3a_interface.constants_limits.GlobalConfig.market_maker_rate.values())
def get_setup(config): ConstSettings.IAASettings.MIN_BID_AGE = 0 ConstSettings.IAASettings.MIN_OFFER_AGE = 0 area = Area('Grid', [ Area('House 1', [ Area('H1 General Load', strategy=LoadHoursStrategy(avg_power_W=200, hrs_per_day=6, hrs_of_day=list(range(12, 18)), final_buying_rate=35)), Area('H1 Storage1', strategy=StorageStrategy(initial_soc=100, battery_capacity_kWh=20)), Area('H1 Storage2', strategy=StorageStrategy(initial_soc=100, battery_capacity_kWh=20)), ], grid_fee_constant=2), Area('House 2', [ Area('load', strategy=LoadHoursExternalStrategy(avg_power_W=200, hrs_per_day=24, hrs_of_day=list( range(0, 24)), final_buying_rate=35)), Area('pv', strategy=PVExternalStrategy(panel_count=4)), ], external_connection_available=True, grid_fee_constant=1), Area('Market Maker', strategy=MarketMakerStrategy(energy_rate=30)), ], grid_fee_constant=10, config=config) return area
def get_setup(config): ConstSettings.IAASettings.MARKET_TYPE = 2 ConstSettings.GeneralSettings.EXPORT_ENERGY_TRADE_PROFILE_HR = True ConstSettings.GeneralSettings.EXPORT_OFFER_BID_TRADE_HR = True area = Area('Grid', [ Area('House 1', [ Area('H1 General Load', strategy=LoadHoursStrategy(avg_power_W=100, hrs_per_day=6, hrs_of_day=list(range(12, 18)), final_buying_rate=30, fit_to_limit=True, update_interval=1)), Area('H1 Storage1', strategy=StorageStrategy(initial_soc=50, min_allowed_soc=10, battery_capacity_kWh=1.2, max_abs_battery_power_kW=5, initial_selling_rate=30, final_buying_rate=25, final_selling_rate=25.1, initial_buying_rate=0, fit_to_limit=True, update_interval=1)), ]), Area('House 2', [ Area('H2 General Load', strategy=LoadHoursStrategy(avg_power_W=100, hrs_per_day=4, hrs_of_day=list(range(12, 16)), final_buying_rate=30, fit_to_limit=True, update_interval=1)), Area('H2 PV', strategy=PVStrategy(4, initial_selling_rate=30, final_selling_rate=0, fit_to_limit=True, update_interval=1)), ]), Area('Cell Tower', strategy=LoadHoursStrategy(avg_power_W=100, hrs_per_day=24, hrs_of_day=list(range(0, 24)), final_buying_rate=30, fit_to_limit=True, update_interval=1)), Area('Market Maker', strategy=MarketMakerStrategy(energy_rate=30, grid_connected=True)), ], config=config) return area
def get_setup(config): ConstSettings.IAASettings.MARKET_TYPE = 2 ConstSettings.IAASettings.BID_OFFER_MATCH_TYPE = ( BidOfferMatchAlgoEnum.EXTERNAL.value) area = Area("Grid", [ Area( "House 1", [ Area("H1 General Load1", strategy=LoadHoursExternalStrategy(avg_power_W=200, hrs_per_day=6, hrs_of_day=list( range(12, 18)), final_buying_rate=35)), Area("H1 General Load2", strategy=LoadHoursExternalStrategy(avg_power_W=150, hrs_per_day=24, hrs_of_day=list( range(0, 24)), final_buying_rate=40)), Area("H1 Storage1", strategy=StorageExternalStrategy( initial_soc=100, battery_capacity_kWh=20)), Area("H1 Storage2", strategy=StorageExternalStrategy( initial_soc=100, battery_capacity_kWh=20)), Area("H1 PV1", strategy=PVExternalStrategy(panel_count=4)), Area("H1 PV2", strategy=PVExternalStrategy(panel_count=4)), ], ), Area( "House 2", [ Area("H2 General Load1", strategy=LoadHoursExternalStrategy(avg_power_W=200, hrs_per_day=24, hrs_of_day=list( range(0, 24)), final_buying_rate=35)), Area("H2 Storage1", strategy=StorageExternalStrategy( initial_soc=100, battery_capacity_kWh=20)), Area("H2 PV", strategy=PVExternalStrategy(panel_count=4)), ], ), Area("Cell Tower", strategy=LoadHoursExternalStrategy(avg_power_W=100, hrs_per_day=24, hrs_of_day=list(range(0, 24)), final_buying_rate=35)), Area("Market Maker", strategy=MarketMakerStrategy(energy_rate=30)), ], config=config) return area
def get_setup(config): area = Area('Grid', [ Area('H1 General Load', strategy=LoadHoursStrategy(avg_power_W=100, hrs_per_day=9, hrs_of_day=list(range(8, 18)))), Area('Market Maker', strategy=MarketMakerStrategy(energy_rate=30, grid_connected=True)), ], config=config) return area
def get_setup(config): area = Area('Grid', [ Area('Load', strategy=LoadHoursStrategy(avg_power_W=200, hrs_per_day=24, hrs_of_day=list(range(0, 24)), final_buying_rate=40), appliance=SwitchableAppliance()), Area('Market Maker', strategy=MarketMakerStrategy(energy_rate=18.7), appliance=SimpleAppliance()), ], config=config) return area
def get_setup(config): area = Area( 'Grid', [ Area('Load', strategy=LoadHoursStrategy(avg_power_W=200, hrs_per_day=24, hrs_of_day=list( range(0, 24)), final_buying_rate=40) ), Area('Market Maker', strategy=MarketMakerStrategy(energy_rate=18.7, grid_connected=False) ), ], config=config ) return area
def get_setup(config): area = Area( 'Grid', [ Area('Load', strategy=LoadHoursStrategy(avg_power_W=100, hrs_per_day=24, hrs_of_day=list(range(0, 24)), initial_buying_rate=0, use_market_maker_rate=True)), Area('Market Maker', strategy=MarketMakerStrategy(energy_rate=30) ), ], config=config, grid_fee_constant=5, ) return area
def get_setup(config): ConstSettings.IAASettings.MARKET_TYPE = 2 area = Area('Grid', [ Area('Market Maker', strategy=MarketMakerStrategy(energy_rate=30, grid_connected=True)), Area('House 1', [ Area('H1 PV', strategy=PVPredefinedStrategy(cloud_coverage=0, use_market_maker_rate=True)), Area('H1 General Load', strategy=LoadHoursStrategy(avg_power_W=100, hrs_per_day=9, hrs_of_day=list(range(15, 24)), final_buying_rate=0, use_market_maker_rate=True)), ]), ], config=config) return area
def get_setup(config): ConstSettings.IAASettings.MARKET_TYPE = 2 area = Area('Grid', [ Area( 'Community', [ Area('H1', [ Area('Load', strategy=LoadHoursStrategy(avg_power_W=1000, hrs_per_day=1, hrs_of_day=list( range(10, 11)), initial_buying_rate=60, final_buying_rate=60, update_interval=1), appliance=SwitchableAppliance()), ], grid_fee_constant=2) ], grid_fee_constant=3, ), Area( 'DSO', [ Area('Power Plant', strategy=FinitePowerPlant(energy_rate=30, max_available_power_kW=1000), appliance=SwitchableAppliance()), ], grid_fee_constant=10, ), Area('Market Maker', strategy=MarketMakerStrategy(grid_connected=True, energy_rate=50), appliance=SwitchableAppliance()), ], grid_fee_constant=10, config=config) return area
def get_setup(config): config.grid_fee_type = 1 ConstSettings.GeneralSettings.DEFAULT_UPDATE_INTERVAL = 5 area = Area('Grid', [ Area('Neighborhood 1', [ Area('House 1', [ Area( name='H1 General Load', strategy=LoadHoursStrategy(avg_power_W=200, hrs_per_day=24, hrs_of_day=list(range(0, 24)), use_market_maker_rate=True), ) ], grid_fee_constant=4) ], grid_fee_constant=3), Area('Neighborhood 2', [ Area('House 2', [ Area( name='H2 PV', strategy=PVStrategy(panel_count=10, max_panel_power_W=50, use_market_maker_rate=True), ) ], grid_fee_constant=2), ], grid_fee_constant=1), Area('Market Maker', strategy=MarketMakerStrategy(energy_rate=30), grid_fee_constant=0) ], config=config, grid_fee_constant=0) return area
def get_setup(config): ConstSettings.GeneralSettings.DEFAULT_UPDATE_INTERVAL = 1 ConstSettings.IAASettings.MARKET_TYPE = 2 ConstSettings.GeneralSettings.KEEP_PAST_MARKETS = False ConstSettings.IAASettings.MIN_OFFER_AGE = 1 area = Area( 'Grid', [ Area( 'Community', [ Area( 'House 1', [ Area('H1 General Load', strategy=DefinedLoadStrategy( daily_load_profile=os.path.join( current_dir, "../../resources/KPI_L1.csv"), initial_buying_rate=20, final_buying_rate=30, fit_to_limit=True), appliance=SwitchableAppliance()), Area('H1 PV', strategy=PVUserProfileStrategy( power_profile=os.path.join( current_dir, "../../resources/KPI_PV1.csv"), initial_selling_rate=20, final_selling_rate=15, fit_to_limit=True), appliance=PVAppliance()), Area('H1 General Load evening', strategy=LoadHoursStrategy( hrs_per_day=1, hrs_of_day=list([22, 23]), avg_power_W=2000, initial_buying_rate=20, final_buying_rate=30), appliance=SwitchableAppliance()), ], grid_fee_percentage=0, transfer_fee_const=0, ), Area('central storage', strategy=StorageStrategy(initial_soc=10, min_allowed_soc=10, battery_capacity_kWh=6, max_abs_battery_power_kW=5, initial_buying_rate=12, final_buying_rate=20, initial_selling_rate=29, final_selling_rate=20.01), appliance=SwitchableAppliance()), Area( 'House 2', [ Area('H2 General Load', strategy=DefinedLoadStrategy( daily_load_profile=os.path.join( current_dir, "../../resources/KPI_L1.csv"), initial_buying_rate=20, final_buying_rate=30, fit_to_limit=True), appliance=SwitchableAppliance()), Area('H2 PV', strategy=PVUserProfileStrategy( power_profile=os.path.join( current_dir, "../../resources/KPI_PV2.csv"), initial_selling_rate=20, final_selling_rate=15, fit_to_limit=True), appliance=PVAppliance()), ], grid_fee_percentage=0, transfer_fee_const=0, ), Area( 'House 3', [ Area('H3 General Load', strategy=DefinedLoadStrategy( daily_load_profile=os.path.join( current_dir, "../../resources/KPI_L1.csv"), initial_buying_rate=20, final_buying_rate=30, fit_to_limit=True), appliance=SwitchableAppliance()), Area('H3 PV', strategy=PVUserProfileStrategy( power_profile=os.path.join( current_dir, "../../resources/KPI_PV3.csv"), initial_selling_rate=20, final_selling_rate=15, fit_to_limit=True), appliance=PVAppliance()), ], grid_fee_percentage=0, transfer_fee_const=0, ), ], grid_fee_percentage=0, transfer_fee_const=0, ), Area('Feed In Tariff', strategy=InfiniteBusStrategy(energy_buy_rate=15.2, energy_sell_rate=200), appliance=SimpleAppliance()), Area('Market Maker', strategy=MarketMakerStrategy(energy_rate=30, grid_connected=True)) ], config=config, grid_fee_percentage=0, transfer_fee_const=0, ) return area
def get_setup(config): ConstSettings.GeneralSettings.DEFAULT_UPDATE_INTERVAL = 3 ConstSettings.IAASettings.MARKET_TYPE = 2 ConstSettings.GeneralSettings.DEFAULT_MARKET_MAKER_RATE = 30 Houses_initial_buying_rate = 10 PV_initial = 20 PV_final = 4 area = Area('grid', [ Area('Community', [ Area('house-1-s', [ Area('h1-load-s', strategy=LoadProfileExternalStrategy( daily_load_profile=load1, initial_buying_rate=Houses_initial_buying_rate, use_market_maker_rate=True), appliance=SwitchableAppliance()), Area('h1-pv-s', strategy=PVUserProfileExternalStrategy( power_profile=pv1, initial_selling_rate=PV_initial, final_selling_rate=PV_final), appliance=PVAppliance()), Area('h1-storage-s', strategy=StorageExternalStrategy( initial_soc=50, min_allowed_soc=10, battery_capacity_kWh=5, max_abs_battery_power_kW=4), appliance=SwitchableAppliance()), ], grid_fee_percentage=0, transfer_fee_const=0, external_connection_available=True), Area( 'house-2', [ Area('h2-load', strategy=DefinedLoadStrategy( daily_load_profile=load2, initial_buying_rate=Houses_initial_buying_rate * round((random() - 0.5) * VARIANCE_RATES + 1, 2), use_market_maker_rate=True), appliance=SwitchableAppliance()), Area('h2-pv', strategy=PVUserProfileStrategy( power_profile=pv2, initial_selling_rate=PV_initial * round( (random() - 0.5) * VARIANCE_RATES + 1, 2), final_selling_rate=PV_final), appliance=PVAppliance()), Area('h2-storage', strategy=StorageStrategy(initial_soc=50, min_allowed_soc=10, battery_capacity_kWh=5, max_abs_battery_power_kW=4, initial_buying_rate=12, final_buying_rate=15, initial_selling_rate=29, final_selling_rate=15.01), appliance=SwitchableAppliance()), ], grid_fee_percentage=0, transfer_fee_const=0, ), Area( 'house-3', [ Area('h3-load', strategy=DefinedLoadStrategy( daily_load_profile=load3, initial_buying_rate=Houses_initial_buying_rate * round((random() - 0.5) * VARIANCE_RATES + 1, 2), use_market_maker_rate=True), appliance=SwitchableAppliance()), Area('h3-pv', strategy=PVUserProfileStrategy( power_profile=pv3, initial_selling_rate=PV_initial * round( (random() - 0.5) * VARIANCE_RATES + 1, 2), final_selling_rate=PV_final), appliance=PVAppliance()), ], grid_fee_percentage=0, transfer_fee_const=0, ), Area( 'house-4', [ Area('h4-load', strategy=DefinedLoadStrategy( daily_load_profile=load4, initial_buying_rate=Houses_initial_buying_rate * round((random() - 0.5) * VARIANCE_RATES + 1, 2), use_market_maker_rate=True), appliance=SwitchableAppliance()), Area('h4-pv', strategy=PVUserProfileStrategy( power_profile=pv4, initial_selling_rate=PV_initial * round( (random() - 0.5) * VARIANCE_RATES + 1, 2), final_selling_rate=PV_final), appliance=PVAppliance()), ], grid_fee_percentage=0, transfer_fee_const=0, ), Area( 'house-5', [ Area('h5-load', strategy=DefinedLoadStrategy( daily_load_profile=load5, initial_buying_rate=Houses_initial_buying_rate * round((random() - 0.5) * VARIANCE_RATES + 1, 2), use_market_maker_rate=True), appliance=SwitchableAppliance()), ], grid_fee_percentage=0, transfer_fee_const=0, ), Area( 'house-6', [ Area('h6-load', strategy=DefinedLoadStrategy( daily_load_profile=load6, initial_buying_rate=Houses_initial_buying_rate * round((random() - 0.5) * VARIANCE_RATES + 1, 2), use_market_maker_rate=True), appliance=SwitchableAppliance()), Area('h6-pv', strategy=PVUserProfileStrategy( power_profile=pv6, initial_selling_rate=PV_initial * round( (random() - 0.5) * VARIANCE_RATES + 1, 2), final_selling_rate=PV_final), appliance=PVAppliance()), ], grid_fee_percentage=0, transfer_fee_const=0, ), Area( 'house-7', [ Area('h7-load', strategy=DefinedLoadStrategy( daily_load_profile=load7, initial_buying_rate=Houses_initial_buying_rate * round((random() - 0.5) * VARIANCE_RATES + 1, 2), use_market_maker_rate=True), appliance=SwitchableAppliance()), Area('h7-pv', strategy=PVUserProfileStrategy( power_profile=pv7, initial_selling_rate=PV_initial * round( (random() - 0.5) * VARIANCE_RATES + 1, 2), final_selling_rate=PV_final), appliance=PVAppliance()), ], grid_fee_percentage=0, transfer_fee_const=0, ), Area( 'house-8', [ Area('h8-load', strategy=DefinedLoadStrategy( daily_load_profile=load8, initial_buying_rate=Houses_initial_buying_rate * round((random() - 0.5) * VARIANCE_RATES + 1, 2), use_market_maker_rate=True), appliance=SwitchableAppliance()), Area('h8-pv', strategy=PVUserProfileStrategy( power_profile=pv8, initial_selling_rate=PV_initial * round( (random() - 0.5) * VARIANCE_RATES + 1, 2), final_selling_rate=PV_final), appliance=PVAppliance()), ], grid_fee_percentage=0, transfer_fee_const=0, ), Area( 'house-9', [ Area('h9-load', strategy=DefinedLoadStrategy( daily_load_profile=load9, initial_buying_rate=Houses_initial_buying_rate * round((random() - 0.5) * VARIANCE_RATES + 1, 2), use_market_maker_rate=True), appliance=SwitchableAppliance()), Area('h9-pv', strategy=PVUserProfileStrategy( power_profile=pv9, initial_selling_rate=PV_initial * round( (random() - 0.5) * VARIANCE_RATES + 1, 2), final_selling_rate=PV_final), appliance=PVAppliance()), ], grid_fee_percentage=0, transfer_fee_const=0, ), Area( 'house-10', [ Area('h10-load', strategy=DefinedLoadStrategy( daily_load_profile=load10, initial_buying_rate=Houses_initial_buying_rate * round((random() - 0.5) * VARIANCE_RATES + 1, 2), use_market_maker_rate=True), appliance=SwitchableAppliance()), Area('h10-pv', strategy=PVUserProfileStrategy( power_profile=pv10, initial_selling_rate=PV_initial * round( (random() - 0.5) * VARIANCE_RATES + 1, 2), final_selling_rate=PV_final), appliance=PVAppliance()), ], grid_fee_percentage=0, transfer_fee_const=0, ), Area( 'house-11', [ Area('h11-load', strategy=DefinedLoadStrategy( daily_load_profile=load11, initial_buying_rate=Houses_initial_buying_rate * round((random() - 0.5) * VARIANCE_RATES + 1, 2), use_market_maker_rate=True), appliance=SwitchableAppliance()), Area('h11-pv', strategy=PVUserProfileStrategy( power_profile=pv11, initial_selling_rate=PV_initial * round( (random() - 0.5) * VARIANCE_RATES + 1, 2), final_selling_rate=PV_final), appliance=PVAppliance()), ], grid_fee_percentage=0, transfer_fee_const=0, ), ], grid_fee_percentage=0, transfer_fee_const=0, external_connection_available=True), Area('Feed-in tariff', strategy=LoadHoursStrategy(avg_power_W=100000000, hrs_per_day=24, hrs_of_day=list(range(0, 24)), initial_buying_rate=11, final_buying_rate=11), appliance=SwitchableAppliance()), Area('Market Maker', strategy=MarketMakerStrategy( energy_rate=ConstSettings.GeneralSettings. DEFAULT_MARKET_MAKER_RATE, grid_connected=True), appliance=SimpleAppliance()), ], config=config, grid_fee_percentage=0, transfer_fee_const=0, external_connection_available=False) return area