From 40cb44b9a434ce643d5343a3039f8c6513a93477 Mon Sep 17 00:00:00 2001 From: Nick Harder Date: Mon, 25 Sep 2023 16:08:21 +0200 Subject: [PATCH] -no more outputs written when learning -adjusted learning dashboard --- assume/common/outputs.py | 26 +- assume/common/units_operator.py | 105 +-- assume/markets/base_market.py | 8 + assume/world.py | 3 +- .../ASSUME_Learning.json | 856 +++++++++++++----- examples/inputs/example_01_rl/config.yaml | 4 +- 6 files changed, 688 insertions(+), 314 deletions(-) diff --git a/assume/common/outputs.py b/assume/common/outputs.py index 392644f8..4cb668fd 100644 --- a/assume/common/outputs.py +++ b/assume/common/outputs.py @@ -341,19 +341,20 @@ async def on_stop(self): await self.store_dfs() if self.db is None: return - queries = [ - f"select 'avg_price' as variable, market_id as ident, avg(price) as value from market_meta where simulation = '{self.simulation_id}' group by market_id", - f"select 'total_cost' as variable, market_id as ident, sum(price*demand_volume_energy) as value from market_meta where simulation = '{self.simulation_id}' group by market_id", - f"select 'total_volume' as variable, market_id as ident, sum(demand_volume_energy) as value from market_meta where simulation = '{self.simulation_id}' group by market_id", - f"select 'capacity_factor' as variable, market_id as ident, avg(power/max_power) as value from market_dispatch ud join power_plant_meta um on ud.unit_id = um.\"index\" and ud.simulation=um.simulation where um.simulation = '{self.simulation_id}' group by variable, market_id", - ] - dfs = [] - learning_queries = self.learning_queries() - if learning_queries: - queries.extend(learning_queries) + queries = [] + if self.learning_mode: + queries.extend(self.learning_queries()) + else: + queries = [ + f"select 'avg_price' as variable, market_id as ident, avg(price) as value from market_meta where simulation = '{self.simulation_id}' group by market_id", + f"select 'total_cost' as variable, market_id as ident, sum(price*demand_volume_energy) as value from market_meta where simulation = '{self.simulation_id}' group by market_id", + f"select 'total_volume' as variable, market_id as ident, sum(demand_volume_energy) as value from market_meta where simulation = '{self.simulation_id}' group by market_id", + f"select 'capacity_factor' as variable, market_id as ident, avg(power/max_power) as value from market_dispatch ud join power_plant_meta um on ud.unit_id = um.\"index\" and ud.simulation=um.simulation where um.simulation = '{self.simulation_id}' group by variable, market_id", + ] try: + dfs = [] for query in queries: df = pd.read_sql(query, self.db) dfs.append(df) @@ -372,13 +373,10 @@ async def on_stop(self): with self.db.begin() as db: df.to_sql("kpis", self.db, if_exists="append", index=None) except ProgrammingError as e: - self.db.rollback() + # self.db.rollback() not working, no rollback function logger.error(f"No scenario run Yet {e}") def learning_queries(self): - if not self.learning_mode: - return [] - queries = [ f"SELECT 'sum_reward' as variable, simulation as ident, sum(reward) as value FROM rl_params WHERE episode='{self.episode}' AND simulation='{self.simulation_id}' GROUP BY simulation", f"SELECT 'sum_regret' as variable, simulation as ident, sum(regret) as value FROM rl_params WHERE episode='{self.episode}' AND simulation='{self.simulation_id}' GROUP BY simulation", diff --git a/assume/common/units_operator.py b/assume/common/units_operator.py index 98ac0fd0..fcd691e7 100644 --- a/assume/common/units_operator.py +++ b/assume/common/units_operator.py @@ -86,24 +86,25 @@ async def add_unit( """ self.units[unit.id] = unit - db_aid = self.context.data_dict.get("output_agent_id") - db_addr = self.context.data_dict.get("output_agent_addr") - if db_aid and db_addr: - # send unit data to db agent to store it - message = { - "context": "write_results", - "type": "store_units", - "data": self.units[unit.id].as_dict(), - } - await self.context.send_acl_message( - receiver_id=db_aid, - receiver_addr=db_addr, - content=message, - acl_metadata={ - "sender_addr": self.context.addr, - "sender_id": self.context.aid, - }, - ) + if not self.context.data_dict.get("learning_mode"): + db_aid = self.context.data_dict.get("output_agent_id") + db_addr = self.context.data_dict.get("output_agent_addr") + if db_aid and db_addr: + # send unit data to db agent to store it + message = { + "context": "write_results", + "type": "store_units", + "data": self.units[unit.id].as_dict(), + } + await self.context.send_acl_message( + receiver_id=db_aid, + receiver_addr=db_addr, + content=message, + acl_metadata={ + "sender_addr": self.context.addr, + "sender_id": self.context.aid, + }, + ) def participate(self, market: MarketConfig): """ @@ -231,33 +232,34 @@ def write_actual_dispatch(self): data["unit"] = unit_id unit_dispatch_dfs.append(data) - db_aid = self.context.data_dict.get("output_agent_id") - db_addr = self.context.data_dict.get("output_agent_addr") - if db_aid and db_addr: - self.context.schedule_instant_acl_message( - receiver_id=db_aid, - receiver_addr=db_addr, - content={ - "context": "write_results", - "type": "market_dispatch", - "data": market_dispatch, - }, - ) - if unit_dispatch_dfs: - unit_dispatch = pd.concat(unit_dispatch_dfs) + self.valid_orders = list( + filter(lambda x: x["end_time"] >= now, self.valid_orders) + ) + + if not self.context.data_dict.get("learning_mode"): + db_aid = self.context.data_dict.get("output_agent_id") + db_addr = self.context.data_dict.get("output_agent_addr") + if db_aid and db_addr: self.context.schedule_instant_acl_message( receiver_id=db_aid, receiver_addr=db_addr, content={ "context": "write_results", - "type": "unit_dispatch", - "data": unit_dispatch, + "type": "market_dispatch", + "data": market_dispatch, }, ) - - self.valid_orders = list( - filter(lambda x: x["end_time"] >= now, self.valid_orders) - ) + if unit_dispatch_dfs: + unit_dispatch = pd.concat(unit_dispatch_dfs) + self.context.schedule_instant_acl_message( + receiver_id=db_aid, + receiver_addr=db_addr, + content={ + "context": "write_results", + "type": "unit_dispatch", + "data": unit_dispatch, + }, + ) async def submit_bids(self, opening: OpeningMessage): """ @@ -394,18 +396,20 @@ def write_learning_to_output(self, start: datetime, marketconfig: MarketConfig): output_dict[f"actions_{i}"] = action_tuple[i] output_agent_list.append(output_dict) - db_aid = self.context.data_dict.get("output_agent_id") - db_addr = self.context.data_dict.get("output_agent_addr") - if db_aid and db_addr: - self.context.schedule_instant_acl_message( - receiver_id=db_aid, - receiver_addr=db_addr, - content={ - "context": "write_results", - "type": "rl_learning_params", - "data": output_agent_list, - }, - ) + + if self.context.data_dict.get("learning_mode"): + db_aid = self.context.data_dict.get("output_agent_id") + db_addr = self.context.data_dict.get("output_agent_addr") + if db_aid and db_addr: + self.context.schedule_instant_acl_message( + receiver_id=db_aid, + receiver_addr=db_addr, + content={ + "context": "write_results", + "type": "rl_learning_params", + "data": output_agent_list, + }, + ) def write_to_learning( self, @@ -426,7 +430,6 @@ def write_to_learning( except ImportError: logger.error("tried writing learning_params, but torch is not installed") - all_actions = np.zeros((learning_unit_count, act_dim)) return all_observations = th.zeros((learning_unit_count, obs_dim), device=device) diff --git a/assume/markets/base_market.py b/assume/markets/base_market.py index bd60c072..e8e8ab8f 100644 --- a/assume/markets/base_market.py +++ b/assume/markets/base_market.py @@ -406,12 +406,16 @@ async def store_order_book(self, orderbook: Orderbook): :param orderbook: The order book to be stored :type orderbook: Orderbook """ + if self.context.data_dict.get("learning_mode"): + return + message = { "context": "write_results", "type": "store_order_book", "sender": self.marketconfig.name, "data": orderbook, } + db_aid = self.context.data_dict.get("output_agent_id") db_addr = self.context.data_dict.get("output_agent_addr") if db_aid and db_addr: @@ -429,6 +433,10 @@ async def store_market_results(self, market_meta): :param market_meta: The metadata of the market :type market_meta: any """ + + if self.context.data_dict.get("learning_mode"): + return + message = { "context": "write_results", "type": "store_market_results", diff --git a/assume/world.py b/assume/world.py index 116d5822..8f92b66d 100644 --- a/assume/world.py +++ b/assume/world.py @@ -13,7 +13,6 @@ from mango.util.termination_detection import tasks_complete_or_sleeping from sqlalchemy import create_engine from sqlalchemy.exc import OperationalError -from sqlalchemy.orm import scoped_session, sessionmaker from tqdm import tqdm from assume.common import ( @@ -214,6 +213,7 @@ def add_unit_operator( unit_operator_agent._role_context.data_dict = { "output_agent_addr": self.output_agent_addr[0], "output_agent_id": self.output_agent_addr[1], + "learning_mode": self.learning_mode, } async def async_add_unit( @@ -306,6 +306,7 @@ def add_market_operator( market_operator_agent._role_context.data_dict = { "output_agent_addr": self.output_agent_addr[0], "output_agent_id": self.output_agent_addr[1], + "learning_mode": self.learning_mode, } self.market_operators[id] = market_operator_agent diff --git a/docker_configs/dashboard-definitions/ASSUME_Learning.json b/docker_configs/dashboard-definitions/ASSUME_Learning.json index a2caeede..4b38069c 100644 --- a/docker_configs/dashboard-definitions/ASSUME_Learning.json +++ b/docker_configs/dashboard-definitions/ASSUME_Learning.json @@ -896,40 +896,234 @@ "type": "postgres", "uid": "P7B13B9DF907EC40C" }, - "description": "", "fieldConfig": { "defaults": { "color": { - "mode": "palette-classic" + "mode": "thresholds" }, "custom": { "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, + "fillOpacity": 80, "gradientMode": "none", "hideFrom": { "legend": false, "tooltip": false, "viz": false }, - "lineInterpolation": "linear", "lineWidth": 1, - "pointSize": 5, "scaleDistribution": { "type": "linear" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "reward (mean)" }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "green", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 65 + }, + "id": 31, + "options": { + "barRadius": 0, + "barWidth": 0.97, + "groupWidth": 0.7, + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "orientation": "auto", + "showValue": "always", + "stacking": "none", + "tooltip": { + "mode": "single", + "sort": "none" + }, + "xField": "episode", + "xTickLabelRotation": 0, + "xTickLabelSpacing": 100 + }, + "pluginVersion": "9.2.15", + "targets": [ + { + "datasource": { + "type": "postgres", + "uid": "P7B13B9DF907EC40C" + }, + "format": "table", + "group": [], + "metricColumn": "simulation", + "rawQuery": true, + "rawSql": "SELECT\n datetime,\n simulation,\n unit,\n episode,\n reward\nFROM rl_params\nwhere simulation like ${simulation} || '_%' AND\n unit = '$rl_unit'", + "refId": "A", + "select": [ + [ + { + "params": [ + "reward" + ], + "type": "column" + }, + { + "params": [ + "avg", + "24" + ], + "type": "moving_window" + }, + { + "params": [ + "avg_reward" + ], + "type": "alias" + } + ], + [ + { + "params": [ + "reward" + ], + "type": "column" + }, + { + "params": [ + "avg", + "24" + ], + "type": "moving_window" + }, + { + "params": [ + "avg_reward" + ], + "type": "alias" + } + ] + ], + "table": "rl_params", + "timeColumn": "index", + "timeColumnType": "timestamp", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Avg. reward of unit $rl_unit", + "transformations": [ + { + "id": "calculateField", + "options": { + "binary": { + "left": "index", + "reducer": "sum", + "right": "episode" }, - "thresholdsStyle": { - "mode": "off" + "mode": "binary", + "reduce": { + "reducer": "sum" + } + } + }, + { + "id": "groupBy", + "options": { + "fields": { + "episode": { + "aggregations": [], + "operation": "groupby" + }, + "index episode": { + "aggregations": [], + "operation": "aggregate" + }, + "reward": { + "aggregations": [ + "mean" + ], + "operation": "aggregate" + } + } + } + }, + { + "id": "sortBy", + "options": { + "fields": {}, + "sort": [ + { + "field": "episode" + } + ] + } + } + ], + "type": "barchart" + }, + { + "datasource": { + "type": "postgres", + "uid": "P7B13B9DF907EC40C" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "fillOpacity": 80, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineWidth": 1, + "scaleDistribution": { + "type": "linear" } }, "mappings": [], @@ -947,70 +1141,303 @@ ] } }, - "overrides": [] + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "profit (sum)" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "red", + "mode": "fixed" + } + } + ] + } + ] }, "gridPos": { - "h": 12, + "h": 16, "w": 12, - "x": 0, + "x": 12, "y": 65 }, - "id": 2, + "id": 33, "options": { + "barRadius": 0, + "barWidth": 0.97, + "groupWidth": 0.7, "legend": { "calcs": [], "displayMode": "list", "placement": "bottom", "showLegend": true }, + "orientation": "auto", + "showValue": "always", + "stacking": "none", "tooltip": { "mode": "single", "sort": "none" + }, + "xField": "episode", + "xTickLabelRotation": 0, + "xTickLabelSpacing": 100 + }, + "pluginVersion": "9.2.15", + "targets": [ + { + "datasource": { + "type": "postgres", + "uid": "P7B13B9DF907EC40C" + }, + "format": "table", + "group": [], + "metricColumn": "simulation", + "rawQuery": true, + "rawSql": "SELECT\n datetime,\n simulation,\n unit,\n episode,\n profit\nFROM rl_params\nwhere simulation like ${simulation} || '_%' AND\n unit = '$rl_unit'", + "refId": "A", + "select": [ + [ + { + "params": [ + "reward" + ], + "type": "column" + }, + { + "params": [ + "avg", + "24" + ], + "type": "moving_window" + }, + { + "params": [ + "avg_reward" + ], + "type": "alias" + } + ], + [ + { + "params": [ + "reward" + ], + "type": "column" + }, + { + "params": [ + "avg", + "24" + ], + "type": "moving_window" + }, + { + "params": [ + "avg_reward" + ], + "type": "alias" + } + ] + ], + "table": "rl_params", + "timeColumn": "index", + "timeColumnType": "timestamp", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] } + ], + "title": "Total profit of unit $rl_unit", + "transformations": [ + { + "id": "calculateField", + "options": { + "binary": { + "left": "index", + "reducer": "sum", + "right": "episode" + }, + "mode": "binary", + "reduce": { + "reducer": "sum" + } + } + }, + { + "id": "groupBy", + "options": { + "fields": { + "episode": { + "aggregations": [], + "operation": "groupby" + }, + "index episode": { + "aggregations": [], + "operation": "aggregate" + }, + "profit": { + "aggregations": [ + "sum" + ], + "operation": "aggregate" + }, + "regret": { + "aggregations": [ + "mean" + ], + "operation": "aggregate" + }, + "reward": { + "aggregations": [ + "mean" + ], + "operation": "aggregate" + } + } + } + }, + { + "id": "sortBy", + "options": { + "fields": {}, + "sort": [ + { + "field": "episode" + } + ] + } + } + ], + "type": "barchart" + }, + { + "datasource": { + "type": "postgres", + "uid": "P7B13B9DF907EC40C" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "fillOpacity": 80, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineWidth": 1, + "scaleDistribution": { + "type": "linear" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "regret (mean)" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "purple", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 73 + }, + "id": 32, + "options": { + "barRadius": 0, + "barWidth": 0.97, + "groupWidth": 0.7, + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "orientation": "auto", + "showValue": "always", + "stacking": "none", + "tooltip": { + "mode": "single", + "sort": "none" + }, + "xField": "episode", + "xTickLabelRotation": 0, + "xTickLabelSpacing": 100 }, + "pluginVersion": "9.2.15", "targets": [ { "datasource": { "type": "postgres", "uid": "P7B13B9DF907EC40C" }, - "format": "time_series", - "group": [ - { - "params": [ - "$__interval", - "none" - ], - "type": "time" - }, - { - "params": [ - "simulation" - ], - "type": "column" - } - ], - "metricColumn": "none", + "format": "table", + "group": [], + "metricColumn": "simulation", "rawQuery": true, - "rawSql": "SELECT\n $__timeGroupAlias(datetime,$__interval),\n avg(profit) AS \"profit\",\n simulation AS \"simulation\"\nFROM rl_params\nWHERE\n $__timeFilter(datetime) AND\n simulation IN ($simulation) AND\n unit = '$rl_unit'\nGROUP BY 1, simulation\nORDER BY 1", + "rawSql": "SELECT\n datetime,\n simulation,\n unit,\n episode,\n regret\nFROM rl_params\nwhere simulation like ${simulation} || '_%' AND\n unit = '$rl_unit'", "refId": "A", "select": [ [ { "params": [ - "profit" + "reward" ], "type": "column" }, { "params": [ - "avg" + "avg", + "24" ], - "type": "aggregate" + "type": "moving_window" }, { "params": [ - "profit" + "avg_reward" ], "type": "alias" } @@ -1018,13 +1445,20 @@ [ { "params": [ - "simulation" + "reward" ], "type": "column" }, { "params": [ - "simulation" + "avg", + "24" + ], + "type": "moving_window" + }, + { + "params": [ + "avg_reward" ], "type": "alias" } @@ -1038,32 +1472,66 @@ "name": "$__timeFilter", "params": [], "type": "macro" - }, - { - "datatype": "text", - "name": "", - "params": [ - "simulation", - "IN", - "($simulation)" - ], - "type": "expression" - }, - { - "datatype": "text", - "name": "", - "params": [ - "unit", - "=", - "'$rl_unit'" - ], - "type": "expression" } ] } ], - "title": "Unitwise Profit for $rl_unit in $simulation", - "type": "timeseries" + "title": "Arg. regret of unit $rl_unit", + "transformations": [ + { + "id": "calculateField", + "options": { + "binary": { + "left": "index", + "reducer": "sum", + "right": "episode" + }, + "mode": "binary", + "reduce": { + "reducer": "sum" + } + } + }, + { + "id": "groupBy", + "options": { + "fields": { + "episode": { + "aggregations": [], + "operation": "groupby" + }, + "index episode": { + "aggregations": [], + "operation": "aggregate" + }, + "regret": { + "aggregations": [ + "mean" + ], + "operation": "aggregate" + }, + "reward": { + "aggregations": [ + "mean" + ], + "operation": "aggregate" + } + } + } + }, + { + "id": "sortBy", + "options": { + "fields": {}, + "sort": [ + { + "field": "episode" + } + ] + } + } + ], + "type": "barchart" }, { "datasource": { @@ -1120,52 +1588,15 @@ ] } }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "reward" - }, - "properties": [ - { - "id": "unit", - "value": "none" - }, - { - "id": "custom.axisPlacement", - "value": "left" - }, - { - "id": "max", - "value": 5 - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "regret" - }, - "properties": [ - { - "id": "unit", - "value": "none" - }, - { - "id": "custom.axisPlacement", - "value": "right" - } - ] - } - ] + "overrides": [] }, "gridPos": { - "h": 12, + "h": 8, "w": 12, - "x": 12, - "y": 65 + "x": 0, + "y": 81 }, - "id": 4, + "id": 29, "options": { "legend": { "calcs": [], @@ -1178,121 +1609,42 @@ "sort": "none" } }, + "pluginVersion": "9.2.15", "targets": [ { "datasource": { "type": "postgres", "uid": "P7B13B9DF907EC40C" }, - "format": "time_series", - "group": [ - { - "params": [ - "$__interval", - "none" - ], - "type": "time" - }, - { - "params": [ - "simulation" - ], - "type": "column" - } - ], + "format": "table", + "group": [], "metricColumn": "none", "rawQuery": true, - "rawSql": "SELECT\n $__timeGroupAlias(datetime,$__interval),\n avg(regret) AS \"regret\",\n avg(reward) AS \"reward\",\n simulation AS \"simulation\"\nFROM rl_params\nWHERE\n $__timeFilter(datetime) AND\n simulation IN ($simulation) AND\n unit = '$rl_unit'\nGROUP BY 1, simulation\nORDER BY 1", + "rawSql": "SELECT\n $__timeGroupAlias(start_time,$__interval),\n avg(accepted_volume) AS \" \",\n bid_id AS \"bid_id\"\nFROM market_orders\nWHERE\n $__timeFilter(start_time) AND\n simulation = '$simulation'\nGROUP BY 1, bid_id\nORDER BY 1", "refId": "A", "select": [ [ { "params": [ - "regret" - ], - "type": "column" - }, - { - "params": [ - "avg" - ], - "type": "aggregate" - }, - { - "params": [ - "regret" - ], - "type": "alias" - } - ], - [ - { - "params": [ - "reward" - ], - "type": "column" - }, - { - "params": [ - "avg" - ], - "type": "aggregate" - }, - { - "params": [ - "reward" - ], - "type": "alias" - } - ], - [ - { - "params": [ - "simulation" + "power" ], "type": "column" - }, - { - "params": [ - "simulation" - ], - "type": "alias" } ] ], - "table": "rl_params", - "timeColumn": "index", + "table": "market_dispatch", + "timeColumn": "datetime", "timeColumnType": "timestamp", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" - }, - { - "datatype": "text", - "name": "", - "params": [ - "simulation", - "IN", - "($simulation)" - ], - "type": "expression" - }, - { - "datatype": "text", - "name": "", - "params": [ - "unit", - "=", - "'$rl_unit'" - ], - "type": "expression" } ] } ], - "title": "Unitwise Regret&Reward for $rl_unit in $simulation", + "title": "Bid price", "type": "timeseries" }, { @@ -1303,12 +1655,37 @@ "fieldConfig": { "defaults": { "color": { - "mode": "thresholds" + "mode": "palette-classic" }, "custom": { - "align": "auto", - "displayMode": "auto", - "inspect": false + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } }, "mappings": [], "thresholds": { @@ -1328,21 +1705,23 @@ "overrides": [] }, "gridPos": { - "h": 16, + "h": 8, "w": 12, - "x": 0, - "y": 77 + "x": 12, + "y": 81 }, - "id": 29, + "id": 34, "options": { - "footer": { - "fields": "", - "reducer": [ - "sum" - ], - "show": false + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true }, - "showHeader": true + "tooltip": { + "mode": "single", + "sort": "none" + } }, "pluginVersion": "9.2.15", "targets": [ @@ -1355,7 +1734,7 @@ "group": [], "metricColumn": "none", "rawQuery": true, - "rawSql": "SELECT\r\n*\r\nFROM \r\nmarket_orders\r\nwhere\r\n$__timeFilter(start_time) and\r\nsimulation in ($simulation) \r\n\r\n\r\n\r\n\r\n", + "rawSql": "SELECT\n $__timeGroupAlias(start_time,$__interval),\n avg(accepted_volume) AS \" \",\n bid_id AS \"bid_id\"\nFROM market_orders\nWHERE\n $__timeFilter(start_time) AND\n simulation = '$simulation'\nGROUP BY 1, bid_id\nORDER BY 1", "refId": "A", "select": [ [ @@ -1379,8 +1758,8 @@ ] } ], - "title": "Bid Overview", - "type": "table" + "title": "Bid volume", + "type": "timeseries" }, { "datasource": { @@ -1442,8 +1821,8 @@ "gridPos": { "h": 8, "w": 12, - "x": 12, - "y": 77 + "x": 0, + "y": 89 }, "id": 26, "options": { @@ -1541,7 +1920,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null }, { "color": "red", @@ -1556,7 +1936,7 @@ "h": 8, "w": 12, "x": 12, - "y": 85 + "y": 89 }, "id": 30, "options": { @@ -1635,7 +2015,7 @@ "name": "rl_unit", "options": [], "query": "SELECT distinct unit\nFROM rl_params\nwhere simulation like ${simulation} || '_%'", - "refresh": 1, + "refresh": 2, "regex": "", "skipUrlSync": false, "sort": 0, @@ -1655,44 +2035,19 @@ "type": "postgres", "uid": "P7B13B9DF907EC40C" }, - "definition": "SELECT DISTINCT\n SUBSTRING(m.simulation, 0, LENGTH(m.simulation) +1 - strpos(REVERSE(m.simulation),'_')) AS market_simulation\n FROM \n market_meta m\n LEFT OUTER JOIN\n rl_params o\n ON\n m.simulation = o.simulation\n WHERE\n o.learning_mode is true", + "definition": "SELECT DISTINCT\n SUBSTRING(m.simulation, 0, LENGTH(m.simulation) +1 - strpos(REVERSE(m.simulation),'_')) AS market_simulation\n FROM \n rl_params m", "description": "Can choose which simulation we want to show ", "hide": 0, "includeAll": false, "multi": true, "name": "simulation", "options": [], - "query": "SELECT DISTINCT\n SUBSTRING(m.simulation, 0, LENGTH(m.simulation) +1 - strpos(REVERSE(m.simulation),'_')) AS market_simulation\n FROM \n market_meta m\n LEFT OUTER JOIN\n rl_params o\n ON\n m.simulation = o.simulation\n WHERE\n o.learning_mode is true", - "refresh": 1, + "query": "SELECT DISTINCT\n SUBSTRING(m.simulation, 0, LENGTH(m.simulation) +1 - strpos(REVERSE(m.simulation),'_')) AS market_simulation\n FROM \n rl_params m", + "refresh": 2, "regex": "", "skipUrlSync": false, "sort": 1, "type": "query" - }, - { - "current": { - "selected": false, - "text": "1", - "value": "1" - }, - "datasource": { - "type": "postgres", - "uid": "P7B13B9DF907EC40C" - }, - "definition": "SELECT \n distinct episode\nFROM rl_params\nwhere simulation like ${simulation} || '_%';", - "description": "Gives us the number of runs of the simulation period learned ", - "hide": 0, - "includeAll": false, - "label": "learning episode", - "multi": false, - "name": "episode", - "options": [], - "query": "SELECT \n distinct episode\nFROM rl_params\nwhere simulation like ${simulation} || '_%';", - "refresh": 1, - "regex": "", - "skipUrlSync": false, - "sort": 3, - "type": "query" } ] }, @@ -1700,10 +2055,19 @@ "from": "2018-12-31T23:00:00.000Z", "to": "2019-01-05T22:59:59.000Z" }, - "timepicker": {}, + "timepicker": { + "refresh_intervals": [ + "1m", + "5m", + "15m", + "30m", + "1h", + "2h" + ] + }, "timezone": "", "title": "Assume_Learning", "uid": "JKQzx0q4k", - "version": 13, + "version": 4, "weekStart": "" } diff --git a/examples/inputs/example_01_rl/config.yaml b/examples/inputs/example_01_rl/config.yaml index 636d1bdb..7142c9fd 100644 --- a/examples/inputs/example_01_rl/config.yaml +++ b/examples/inputs/example_01_rl/config.yaml @@ -1,8 +1,8 @@ base: start_date: 2019-01-01 00:00 - end_date: 2019-01-05 00:00 + end_date: 2019-02-01 00:00 time_step: 1h - save_frequency_hours: 24 + save_frequency_hours: Null learning_config: observation_dimension: 50