Skip to content

Commit

Permalink
Merge branch 'master_fix' into 'master'
Browse files Browse the repository at this point in the history
Bugfix: Meters record all energy types for each component instead of only one (#90)

See merge request tum-ens/HAMLET!116
  • Loading branch information
TUM-Doepfert committed Jun 21, 2024
2 parents 321aaa1 + a66e7f9 commit d1000dd
Show file tree
Hide file tree
Showing 21 changed files with 734 additions and 408 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.rar filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
6 changes: 5 additions & 1 deletion 02_config/example_single_market/config_agents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1040,9 +1040,13 @@ sfh:
market: # market parameters
strategy: linear # market agent trading strategy
# options:
# - linear: see docs
# - zi: zero intelligence, random bid and offer prices
# in market price range
# - linear: trading strategy based on linear price change the
# closer it gets to the market settlement
# - retailer: agent offers energy at the retailer prices, i.e. buys
# at the retailer sell price and sells at the retailer
# buy price (default strategy when there is no clearing)
# note: does not apply when simulation ex-post markets

horizon: [86_400, 72_000, 57_600, 43_200] # market agent trading horizon
Expand Down
19 changes: 9 additions & 10 deletions 02_config/example_single_market/config_markets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,23 @@ lem_continuous: # name of the market (must be unique in it
clearing:
type: ex-ante # type of market clearing
# options:
# - ex-ante: market clearing is done before the delivery period
# - TODO ex-post: market clearing is done after the delivery period
# - None: no market clearing is done (all energy is purchased from retailer)
# - ex-ante: market clearing is done before the settlement
# - ex-post: market clearing is done after the settlement (to be implemented)

method: pda # method of market clearing
# options:
# - pda: periodic double auction
# - community: community clearing
# note: for further information about the method options see the documentation
# - None: energy can only be sold to and bought from the retailer
# (practically no local market exists)
# - pda (ex-ante): periodic double auction
# - community (ex-post): community clearing (to be implemented)

pricing: uniform # pricing method of the market clearing
# options:
# - uniform (ex-ante): all participants pay the same price
# - discriminatory (ex-ante): each participant pays a different price
# - standard (ex-post): see details in the ex-post folder
# note: for further information about the pricing options see the documentation
# - discriminatory (ex-ante): each participant pays a different price (to be implemented)
# - standard (ex-post): see details in the ex-post folder (to be implemented)

coupling: above_l # method of coupling market regions (are uncleared positions posted elsewhere?)
coupling: None # method of coupling market regions (are uncleared positions posted elsewhere?)
# options:
# - None: unsettled bids are not offered at other markets, i.e. bids get feed-in tariff and offers pay retail wholesale price
# - above_c: unsettled bids are continuously offered at higher market levels (if possible)
Expand Down
244 changes: 142 additions & 102 deletions 02_config/templates/config_agents.yaml

Large diffs are not rendered by default.

19 changes: 9 additions & 10 deletions 02_config/templates/config_markets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,23 @@ lem_continuous: # name of the market (must be unique in it
clearing:
type: ex-ante # type of market clearing
# options:
# - ex-ante: market clearing is done before the delivery period
# - TODO ex-post: market clearing is done after the delivery period
# - None: no market clearing is done (all energy is purchased from retailer)
# - ex-ante: market clearing is done before the settlement
# - ex-post: market clearing is done after the settlement (to be implemented)

method: pda # method of market clearing
# options:
# - pda: periodic double auction
# - community: community clearing
# note: for further information about the method options see the documentation
# - None: energy can only be sold to and bought from the retailer
# (practically no local market exists)
# - pda (ex-ante): periodic double auction
# - community (ex-post): community clearing (to be implemented)

pricing: uniform # pricing method of the market clearing
# options:
# - uniform (ex-ante): all participants pay the same price
# - discriminatory (ex-ante): each participant pays a different price
# - standard (ex-post): see details in the ex-post folder
# note: for further information about the pricing options see the documentation
# - discriminatory (ex-ante): each participant pays a different price (to be implemented)
# - standard (ex-post): see details in the ex-post folder (to be implemented)

coupling: above_l # method of coupling market regions (are uncleared positions posted elsewhere?)
coupling: None # method of coupling market regions (are uncleared positions posted elsewhere?)
# options:
# - None: unsettled bids are not offered at other markets, i.e. bids get feed-in tariff and offers pay retail wholesale price
# - above_c: unsettled bids are continuously offered at higher market levels (if possible)
Expand Down
38 changes: 19 additions & 19 deletions env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ dependencies:
- python=3.11
- pip
- pip:
- gurobipy
- linopy
- matplotlib
- numpy
- openpyxl
- pandapower
- gurobipy==11.0
- hplib==1.9
- linopy==0.3
- matplotlib==3.9
- numpy>=1.26
- openpyxl==3.1
- pandapower>=2.14
- pandas>=2.0
- polars==0.18
- psycopg2
- pvlib
- pyarrow
- ruamel.yaml
- scikit-learn
- scipy
- sktime
- tensorflow
- tqdm
- windpowerlib
- xlsxwriter
- hplib
- polars==0.20
- psycopg2==2.9
- pvlib==0.10
- pyarrow>=16.0
- ruamel.yaml==0.18
- scikit-learn==1.5
- scipy==1.13
- sktime==0.30
- tensorflow==2.16
- tqdm==4.66
- windpowerlib==0.2
- xlsxwriter==3.2
8 changes: 7 additions & 1 deletion hamlet/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
MCT_EX_POST = 'ex-post'

# MARKET CLEARING METHODS
MCM_NONE = 'None'
MCM_PDA = 'pda'
MCM_COMMUNITY = 'community'

Expand Down Expand Up @@ -191,7 +192,7 @@
TC_DHI = 'dhi'
TC_DNI = 'dni'

# SCHEMAS
# TABLE SCHEMAS
# Note: The schemas are used to define the data types of the columns in the tables and are taken from tables.xlsx
TS_MARKET_TRANSACTIONS = {TC_TIMESTAMP: pl.Datetime(time_unit='ns', time_zone='UTC'),
TC_TIMESTEP: pl.Datetime(time_unit='ns', time_zone='UTC'),
Expand Down Expand Up @@ -287,6 +288,11 @@
C_RTC = 'rtc'
C_MPC = 'mpc'

# MARKET TRADING STRATEGIES
MTS_ZI = 'zi'
MTS_LINEAR = 'linear'
MTS_RETAILER = 'retailer'

# COMPONENT MAPPING
# Note: Key states which type of plant is addressed and the value states which type of operation it has for the given
# energy type
Expand Down
21 changes: 11 additions & 10 deletions hamlet/creator/agents/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ def _create_plants_for_agent(self, account: dict, agent_type: str) -> Tuple:
# Length of the forecasting period in seconds
fcast_period = account[c.K_EMS]['fcasts']['horizon']
# Start of the simulation in UTC
start = self.setup['time']['start'].replace(tzinfo=datetime.timezone.utc)
start = datetime.datetime.fromisoformat(str(self.setup['time']['start'])).astimezone(datetime.timezone.utc)
# Start of the forecasting period in UTC
start_fcast_train = start - train_period
# End of the simulation in UTC (one day added to ensure no foreward forecasting issues)
Expand Down Expand Up @@ -472,11 +472,12 @@ def _create_plants_for_agent(self, account: dict, agent_type: str) -> Tuple:
except ValueError:
continue

# Add general information to the plant dictionary
plant_dict["type"] = plant

# Process each device individually (agent can have more than one of each type)
# Process each device individually
for num_plant in range(num_plants):

# Add plant type
plant_dict["type"] = plant

# Generate and store plant ID
plant_id = self._gen_new_ids()
plant_dict["id"] = plant_id
Expand All @@ -492,7 +493,7 @@ def _create_plants_for_agent(self, account: dict, agent_type: str) -> Tuple:
setpoints[plant_id] = self.__init_vals(df=setpoints)

# Add and process additional plant information
plant_dict.update(info)
plant_dict.update(copy.deepcopy(info))
plant_dict = self.__clean_indexed_info(data=plant_dict, key='sizing', index=num_plant)

# Add time series if applicable
Expand All @@ -509,7 +510,8 @@ def _create_plants_for_agent(self, account: dict, agent_type: str) -> Tuple:
# Add state of charge (SOC) if applicable
try:
socs[plant_id] = self.__init_vals(df=socs,
vals=round(info["sizing"]["soc"] * info["sizing"]["capacity"]))
vals=round(plant_dict["sizing"]["soc"]
* plant_dict["sizing"]["capacity"]))
except KeyError:
pass

Expand All @@ -519,9 +521,8 @@ def _create_plants_for_agent(self, account: dict, agent_type: str) -> Tuple:

# Add plant information to the main dictionary
plants_dict[plant_id] = plant_dict

# Reset for the next entry
plant_dict = {}
# Reset for the next entry
plant_dict = {}

# Add forecast columns
forecasts = pd.DataFrame(columns=timeseries.columns, index=forecasts.index)
Expand Down
Loading

0 comments on commit d1000dd

Please sign in to comment.