Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
585 changes: 376 additions & 209 deletions assume/common/outputs.py

Large diffs are not rendered by default.

21 changes: 19 additions & 2 deletions assume/common/units_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
)
from assume.common.utils import (
aggregate_step_amount,
convert_tensors,
timestamp2datetime,
)
from assume.strategies import BaseStrategy
from assume.strategies import BaseStrategy, LearningStrategy
from assume.units import BaseUnit

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -74,6 +75,8 @@ def __init__(
self.valid_orders = defaultdict(list)
self.units: dict[str, BaseUnit] = {}

self.rl_operator = False

def setup(self):
super().setup()
self.context.subscribe_message(
Expand Down Expand Up @@ -144,6 +147,14 @@ def add_unit(
"""
self.units[unit.id] = unit

# only do the market‐loop if we haven't already flipped rl_operator
if not self.rl_operator:
for market in self.available_markets:
strategy = unit.bidding_strategies.get(market.market_id)
if isinstance(strategy, LearningStrategy):
self.rl_operator = True
break

def participate(self, market: MarketConfig) -> bool:
"""
Method which decides if we want to participate on a given Market.
Expand Down Expand Up @@ -545,4 +556,10 @@ async def formulate_bids(
order["unit_id"] = unit_id
orderbook.append(order)

return orderbook
if not self.rl_operator:
# if we are not a learning agent, we can just return the orderbook
return orderbook
# if we are a learning agent, we need to convert the orderbook to tensors
else:
# convert all CUDA tensors to CPU in one pass
orderbook = convert_tensors(orderbook)
2 changes: 2 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ services:
volumes:
# needed for normal image
- ./assume-db:/var/lib/postgresql/data
# new init-script folder (runs only on first container init)
- ./docker_configs/db-init:/docker-entrypoint-initdb.d:ro
ports:
- 5432:5432
deploy:
Expand Down
18 changes: 9 additions & 9 deletions docker_configs/dashboard-definitions/ASSUME Comparison.json
Original file line number Diff line number Diff line change
Expand Up @@ -1463,7 +1463,7 @@
"group": [],
"metricColumn": "none",
"rawQuery": true,
"rawSql": "SELECT * FROM power_plant_meta\nWHERE index in ($Gen_Units) and simulation = '$simulation'\n",
"rawSql": "SELECT * FROM power_plant_meta\nWHERE unit_id in ($Gen_Units) and simulation = '$simulation'\n",
"refId": "A",
"select": [
[
Expand Down Expand Up @@ -1949,7 +1949,7 @@
"group": [],
"metricColumn": "none",
"rawQuery": true,
"rawSql": "SELECT * FROM demand_meta\nWHERE index in ($Demand_Units) and simulation = '$simulation'\n",
"rawSql": "SELECT * FROM demand_meta\nWHERE unit_id in ($Demand_Units) and simulation = '$simulation'\n",
"refId": "A",
"select": [
[
Expand Down Expand Up @@ -2212,7 +2212,7 @@
"group": [],
"metricColumn": "none",
"rawQuery": true,
"rawSql": "SELECT * FROM storage_meta\nWHERE index in ($Storage_Units) and simulation = '$simulation'\n",
"rawSql": "SELECT * FROM storage_meta\nWHERE unit_id in ($Storage_Units) and simulation = '$simulation'\n",
"refId": "A",
"select": [
[
Expand Down Expand Up @@ -2324,13 +2324,13 @@
"type": "postgres",
"uid": "P7B13B9DF907EC40C"
},
"definition": "SELECT index\nFROM power_plant_meta\nwhere simulation = '$simulation';",
"definition": "SELECT unit_id\nFROM power_plant_meta\nwhere simulation = '$simulation';",
"description": "Can choose which units we want to display ",
"includeAll": false,
"multi": true,
"name": "Gen_Units",
"options": [],
"query": "SELECT index\nFROM power_plant_meta\nwhere simulation = '$simulation';",
"query": "SELECT unit_id\nFROM power_plant_meta\nwhere simulation = '$simulation';",
"refresh": 2,
"regex": "",
"sort": 1,
Expand All @@ -2349,13 +2349,13 @@
"type": "postgres",
"uid": "P7B13B9DF907EC40C"
},
"definition": "SELECT index\nFROM demand_meta\nwhere simulation = '$simulation';",
"definition": "SELECT unit_id\nFROM demand_meta\nwhere simulation = '$simulation';",
"description": "Can choose which units we want to display ",
"includeAll": false,
"multi": true,
"name": "Demand_Units",
"options": [],
"query": "SELECT index\nFROM demand_meta\nwhere simulation = '$simulation';",
"query": "SELECT unit_id\nFROM demand_meta\nwhere simulation = '$simulation';",
"refresh": 2,
"regex": "",
"sort": 1,
Expand All @@ -2370,13 +2370,13 @@
"type": "postgres",
"uid": "P7B13B9DF907EC40C"
},
"definition": "SELECT index\nFROM storage_meta\nwhere simulation = '$simulation';",
"definition": "SELECT unit_id\nFROM storage_meta\nwhere simulation = '$simulation';",
"description": "Can choose which storage units we want to display ",
"includeAll": false,
"multi": true,
"name": "Storage_Units",
"options": [],
"query": "SELECT index\nFROM storage_meta\nwhere simulation = '$simulation';",
"query": "SELECT unit_id\nFROM storage_meta\nwhere simulation = '$simulation';",
"refresh": 2,
"regex": "",
"sort": 1,
Expand Down
Loading