def loads_tab_layout(episode): return [ html.P("Choose a Load to act on:"), dac.Select( id="select_loads_simulation", options=[{"label": name, "value": name} for name in episode.load_names], mode="default", value=episode.load_names[0], ), html.P("Choose an action type:", className="my-2"), dac.Radio( options=[ {"label": "Set", "value": "Set"}, {"label": "Change", "value": "Change"}, ], value="Set", id="radio_topology_type_loads", buttonStyle="solid", ), html.P("Choose an action:", className="my-2"), dac.Radio( options=[ {"label": "Disconnect", "value": "Disconnect"}, {"label": "Bus 1", "value": "Bus1"}, {"label": "Bus 2", "value": "Bus2"}, ], value="Disconnect", id="radio_bus_loads", buttonStyle="solid", className="mt-1", ), ]
def compare_line(network_graph): return html.Div(id="compare_line", className="lineBlock card", children=[ html.H4("Compare"), html.Div(className="card-body row", children=[ html.Div(className="col-9", children=[ dac.Radio(options=[ {"label": "New State t+1", "value": "new"}, {"label": "Old State t+1", "value": "old"}, {"label": "Delta", "value": "compare"} ], value="new", id="compare_states_radio", buttonStyle="solid"), dcc.Graph(id="network_graph_compare", figure=network_graph), ]), html.Div(className="col-3", children=[ html.H5("Agent's KPIs"), html.Div(className="mb-4", children=[ html.P(id="agent_reward", className="border-bottom h3 mb-0 text-right", children="0"), html.P(className="text-muted", children="Agent's reward") ]), html.Div(className="mb-4", children=[ html.P(id="agent_rho", className="border-bottom h3 mb-0 text-right", children="0"), html.P(className="text-muted", children="Agent's max rho") ]), html.Div(className="mb-4", children=[ html.P(id="agent_overflows", className="border-bottom h3 mb-0 text-right", children="0"), html.P(className="text-muted", children="Agent's overflows") ]), html.Div(className="mb-4", children=[ html.P(id="agent_losses", className="border-bottom h3 mb-0 text-right", children="0"), html.P(className="text-muted", children="Agent's losses") ]), html.H5("New Action's KPIs"), html.Div(className="mb-4", children=[ html.P(id="new_action_reward", className="border-bottom h3 mb-0 text-right", children="0"), html.P(className="text-muted", children="New Action reward") ]), html.Div(className="mb-4", children=[ html.P(id="new_action_rho", className="border-bottom h3 mb-0 text-right", children="0"), html.P(className="text-muted", children="New Action max rho") ]), html.Div(className="mb-4", children=[ html.P(id="new_action_overflows", className="border-bottom h3 mb-0 text-right", children="0"), html.P(className="text-muted", children="New Action overflows") ]), html.Div(className="mb-4", children=[ html.P(id="new_action_losses", className="border-bottom h3 mb-0 text-right", children="0"), html.P(className="text-muted", children="New Action losses") ]), ]), ]), ])
def gens_tab_layout(episode): return [ html.P("Choose a generator to act on:"), dac.Select( id="select_gens_simulation", options=[ {"label": prod_name, "value": prod_name} for prod_name in episode.prod_names ], mode="default", value=episode.prod_names[0], ), html.P("Choose an action type:", className="my-2"), dac.Radio( options=[ {"label": "Redispatch", "value": "Redispatch"}, {"label": "Topology", "value": "Topology"}, ], value="Redispatch", id="radio_action_type_gens", buttonStyle="solid", ), dcc.Input( id="input_redispatch", type="number", placeholder="MW", className="mt-1" ), dac.Radio( options=[ {"label": "Set", "value": "Set"}, {"label": "Change", "value": "Change"}, ], value="Set", id="radio_topology_type_gens", buttonStyle="solid", className="hidden", ), dac.Radio( options=[ {"label": "Disconnect", "value": "Disconnect"}, {"label": "Bus 1", "value": "Bus1"}, {"label": "Bus 2", "value": "Bus2"}, ], value="Disconnect", id="radio_bus_gens", buttonStyle="solid", className="hidden", ), ]
def flux_inspector_line(network_graph=None, slider_params=None): return html.Div( id="flux_inspector_line_id", className="lineBlock card", children=[ html.H4("Flow"), html.Div( className="card-body row", children=[ html.Div( className="col", children=[ html.Div( className="row", children=[ html.Div( className="col", children=[ html.H6( className="text-center", children="Interactive Graph"), dcc.Graph(id="interactive_graph", figure=network_graph), dcc.Slider( id="slider", min=slider_params.min, max=slider_params.max, step=None, marks=slider_params.marks, value=slider_params.value) ]) ]), html.Div( className="row", children=[ html.Div( className="col", children=[ html.H6( className="text-center", children="Voltage and Flow"), dac.Radio(options=[{ 'label': 'Voltage (V)', 'value': 'voltage' }, { 'label': 'Flow', 'value': 'flow' }], value="voltage", id="voltage_flow_choice", buttonStyle="solid"), dac.Radio( options=[{ 'label': 'Active Flow (MW)', "value": "active_flow" }, { 'label': 'Current Flow (A)', 'value': 'current_flow' }, { 'label': 'Flow Usage Rate', 'value': 'flow_usage_rate' }], value='active_flow', id='flow_radio', style={'display': 'none'}), dac.Select(id="line_side_choices", options=[], value=[], mode='multiple', showArrow=True), dcc.Graph( id="voltage_flow_graph", figure=go.Figure( layout=layout_def, data=[ dict(type="scatter") ])) ]), ]) ]) ]) ])
def context_inspector_line(best_episode, study_episode): return html.Div( id="context_inspector_line_id", className="lineBlock card ", children=[ html.H4("Context"), html.Div( className="card-body col row", children=[ html.Div( className="col-xl-5", children=[ html.H5("Best Agent's Environment Time Series"), dac.Radio(options=[ { 'label': 'Load', "value": "Load" }, { 'label': 'Production', "value": "Production" }, { 'label': 'Hazards', "value": "Hazards" }, { 'label': 'Maintenances', "value": "Maintenances" }, ], value="Load", id="environment_choices_buttons", buttonStyle="solid"), dac.Select( id='asset_selector', options=[{ 'label': load_name, 'value': load_name } for load_name in best_episode.load_names], value=best_episode.load_names[0], mode='multiple', showArrow=True), dcc.Graph(id='env_charts_ts', style={'margin-top': '1em'}, figure=go.Figure(layout=layout_def), config=dict(displayModeBar=False)), ]), html.Div( className="col-xl-7", children=[ html.Div( className="row", children=[ html.Div( className='col-6', children=[ html.H5("Usage rate", className='text-center'), dcc.Graph( id='usage_rate_ts', style={'margin-top': '1em'}, figure=go.Figure( layout=layout_def, data=study_episode. usage_rate_trace), config=dict( displayModeBar=False)) ]), html.Div( className='col-6', children=[ html.H5("Overflow", className='text-center'), dcc.Graph( id='overflow_ts', style={'margin-top': '1em'}, figure=go.Figure( layout=layout_def, data=study_episode. total_overflow_trace), config=dict( displayModeBar=False)), ]) ]), ]), ]) ])
def context_inspector_line(best_episode, study_episode): return html.Div( id="context_inspector_line_id", className="lineBlock card ", children=[ html.H4("Context"), html.Div( className="card-body col row", children=[ html.Div( className="col-xl-5", children=[ html.H5("Environment Time Series"), dac.Radio( options=[ { "label": "Production", "value": "Production" }, { "label": "Load", "value": "Load" }, { "label": "Hazards", "value": "Hazards" }, { "label": "Maintenances", "value": "Maintenances" }, ], value="Production", id="environment_choices_buttons", buttonStyle="solid", ), dac.Select( id="asset_selector", options=[{ "label": prod_name, "value": prod_name } for prod_name in best_episode.prod_names], value="solar", # episode.prod_names[3],#[episode.prod_names[0],episode.prod_names[1]],#[prod_name for prod_name in episode.prod_names if prod_name in ['wind','solar']],#episode.prod_names[0] mode="multiple", showArrow=True, ), dcc.Graph( id="env_charts_ts", style={"margin-top": "1em"}, figure=go.Figure(layout=layout_def, data=[dict(type="scatter")]), config=dict(displayModeBar=False), ), ], ), html.Div( className="col-xl-7", children=[ html.H5("Studied agent Metrics"), html.Div( className="row", children=[ html.Div( className="col-6", children=[ html.H5("Usage rate", className="text-center"), dcc.Graph( id="usage_rate_ts", style={"margin-top": "1em"}, figure=go.Figure( layout=layout_def, data=study_episode. usage_rate_trace, ), config=dict( displayModeBar=False), ), ], ), html.Div( className="col-6", children=[ html.H5("Overflow", className="text-center"), dcc.Graph( id="overflow_ts", style={"margin-top": "1em"}, figure=go.Figure( layout=layout_def, data=study_episode. total_overflow_trace, ), config=dict( displayModeBar=False), ), ], ), ], ), ], ), ], ), ], )
def flux_inspector_line(network_graph=None, slider_params=None): return html.Div( id="flux_inspector_line_id", className="lineBlock card", children=[ html.H4("State evolution given agent actions"), html.Div( className="card-body row", children=[ html.Div( className="col", children=[ html.Div( className="row", children=[ html.Div( className="col", children=[ html.H6( className="text-center", children= "Grid State evolution overtime & highlighted subs with action (yellow) - with 2 nodes (green) ", ), card_for_network_graphs( network_graph), dcc.Slider( id="slider", min=slider_params.min, max=slider_params.max, step=None, marks=slider_params.marks, value=slider_params.value, ), html.P( id="tooltip_table_micro", className="more-info-table", children=[ "Click on a row to have more info on the action" ], ), ], ) ], ), html.Div( className="row", children=[ html.Div( className="col", children=[ html.H6( className="text-center", children= "Voltage, Flow and Redispatch time series", ), dac.Radio( options=[ { "label": "Flow", "value": "flow" }, { "label": "Voltage (V)", "value": "voltage", }, { "label": "Redispatch (MW)", "value": "redispatch", }, ], value="flow", id="voltage_flow_choice", buttonStyle="solid", ), dac.Radio( options=[ { "label": "Active Flow (MW)", "value": "active_flow", }, { "label": "Current Flow (A)", "value": "current_flow", }, { "label": "Flow Usage Rate", "value": "flow_usage_rate", }, ], value="active_flow", id="flow_radio", style={"display": "none"}, ), dac.Select( id="line_side_choices", options=[], value=[], mode="multiple", showArrow=True, ), dcc.Graph( id="voltage_flow_graph", figure=go.Figure( layout=layout_def, data=[ dict(type="scatter") ], ), ), ], ), ], ), ], ) ], ), ], )
def lines_tab_layout(episode): return [ html.P("Choose a line to act on:", className="mt-1"), dac.Select( id="select_lines_simulation", options=[{ "label": line_name, "value": line_name } for line_name in episode.line_names], mode="default", value=episode.line_names[0], ), html.P("Choose an action type:", className="mt-1"), dac.Radio( options=[ { "label": "Set", "value": "Set" }, { "label": "Change", "value": "Change" }, ], value="Set", id="radio_topology_type_lines", buttonStyle="solid", ), html.P("Choose a target type:", className="mt-1"), dac.Radio( options=[ { "label": "Status", "value": "Status" }, { "label": "Bus", "value": "Bus" }, ], value="Status", id="radio_target_lines", buttonStyle="solid", ), dac.Radio( options=[ { "label": "Disconnect", "value": "Disconnect" }, { "label": "Bus 1", "value": "Bus1" }, { "label": "Bus 2", "value": "Bus2" }, ], value="Disconnect", id="radio_bus_lines", buttonStyle="solid", className="hidden", ), dac.Radio( options=[ { "label": "Origin", "value": "Origin" }, { "label": "Extremity", "value": "Extremity" }, ], value="Origin", id="radio_ex_or_lines", buttonStyle="solid", className="hidden", ), dac.Radio( options=[ { "label": "Reconnect", "value": "Reconnect" }, { "label": "Disconnect", "value": "Disconnect" }, ], value="Reconnect", id="radio_disc_rec_lines", buttonStyle="solid", className="mt-1", ), ]
def summary_line(episode, ref_agent, scenario): return html.Div( children=[ html.H4("Summary"), html.Div( children=[ html.Div( children=[ html.H5("Environment Time Series"), dac.Radio( options=[ { "label": "Production (MW)", "value": "Production" }, { "label": "Load (MW)", "value": "Load" }, { "label": "Hazards", "value": "Hazards" }, { "label": "Maintenances", "value": "Maintenances" }, ], value="Production", id="scen_overview_ts_switch", buttonStyle="solid", ), dac.Select( id="input_assets_selector", options=[{ "label": prod_name, "value": prod_name } for prod_name in episode.prod_names], value="solar", mode="multiple", showArrow=True, ), dcc.Graph( id="input_env_charts", style={"margin-top": "1em"}, figure=go.Figure(layout=layout_def), config=dict(displayModeBar=False), ), ], className="col-xl-5", ), html.Div( children=[ html.H5("Reference agent Metrics"), # dcc.Dropdown( # id="input_agent_selector", placeholder="select a ref agent", # options=[{'label': agent, 'value': agent} # for agent in agent_scenario[scenario]], # value=ref_agent # ), html.Div( children=[ html.Div( children=[ html.H5("Usage rate", className="text-center"), dcc.Graph( id="usage_rate_graph", style={"margin-top": "1em"}, figure=go.Figure( layout=layout_def), config=dict( displayModeBar=False), ), ], className="col-6", ), html.Div( children=[ html.H5("Overflow", className="text-center"), dcc.Graph( id="overflow_graph", style={"margin-top": "1em"}, figure=go.Figure( layout=layout_def), config=dict( displayModeBar=False), ), ], className="col-6", ), ], className="row", ), ], className="col-xl-7", ), ], className="card-body row", ), ], className="lineBlock card", )
def choose_assist_line(episode, network_graph): return html.Div( id="choose_assist_line", className="lineBlock card", children=[ html.H4("Choose or Assist"), html.Div( className="card-body row", children=[ html.Div( className="col-7", children=[ html.H5("Network at time step t"), dcc.Graph( id="network_graph_choose", figure=network_graph, ), ], ), html.Div( className="col-5", children=[ dbc.Tabs(children=[ dbc.Tab( label="Choose", labelClassName="fas fa-user", children=[ dbc.Tabs(children=[ dbc.Tab( label="Dropdowns", children=[ dbc.Tabs(children=[ dbc.Tab( label="Lines", children=[ html.P( "Choose a line to act on:", className= "mt-1", ), dac.Select( id= "select_lines_simulation", options=[{ "label": line_name, "value": line_name, } for line_name in episode . line_names ], mode= "default", value= episode. line_names[ 0], ), html.P( "Choose an action:", className= "mt-1", ), dac.Radio( options=[ { "label": "Set", "value": "Set", }, { "label": "Change", "value": "Change", }, ], value="Set", id= "select_action_lines", buttonStyle ="solid", ), ], ), dbc.Tab( label="Subs", children=[ html. P("Choose a substation to act on:" ), dac.Select( id= "select_subs_simulation", options=[{ "label": name, "value": name, } for name in episode . name_sub ], mode= "default", value= episode. name_sub[0], ), html. P("Choose an action:" ), dac.Radio( options=[ { "label": "Set", "value": "Set", }, { "label": "Change", "value": "Change", }, ], value="Set", id= "select_action_subs", buttonStyle ="solid", ), ], ), dbc.Tab( label="Gens", children=[ html. P("Choose a generator to act on:" ), dac.Select( id= "select_gens_simulation", options=[{ "label": prod_name, "value": prod_name, } for prod_name in episode . prod_names ], mode= "default", value= episode. prod_names[ 0], ), html. P("Choose an action:" ), dac.Radio( options=[ { "label": "Redispatch", "value": "Redispatch", }, ], value= "Redispatch", id= "select_action_gens", buttonStyle ="solid", ), ], ), ]) ], ), dbc.Tab( label="Dict", children=[ html. P("Enter the action dictionary:" ), dbc.Textarea( id="textarea", className="mb-3", placeholder= '{"set_line_status": []}', ), ], ), ]), ], ), dbc.Tab( label="Assist", labelClassName="fas fa-robot", children=["content"], ), ]), dbc.Button( "Simulate", id="simulate_action", color="danger", className="mt-3 mb-3", ), html.P("Action dictionary:"), html.Div(id="action_dictionary"), ], ), ], ), ], )
def flux_inspector_line(network_graph=None, slider_params=None): return html.Div( id="flux_inspector_line_id", className="lineBlock card", children=[ html.H4("State evolution given agent actions"), html.Div( className="card-body row", children=[ html.Div( className="col", children=[ html.Div( className="row", children=[ html.Div( className="col", children=[ html.H6( className="text-center", children= "Grid State evolution overtime" ), dcc.Graph(id="interactive_graph", figure=network_graph), dcc.Slider( id="slider", min=slider_params.min, max=slider_params.max, step=None, marks=slider_params.marks, value=slider_params.value), html. P(id="tooltip_table_micro", className="more-info-table", children=[ "Click on a row to have more info on the action" ]) ]) ]), html.Div( className="row", children=[ html.Div( className="col", children=[ html. H6(className="text-center", children= "Voltage, Flow and Redispatch time series" ), dac.Radio(options=[{ 'label': 'Flow', 'value': 'flow' }, { 'label': 'Voltage (V)', 'value': 'voltage' }, { 'label': 'Redispatch (MW)', 'value': 'redispatch' }], value="flow", id="voltage_flow_choice", buttonStyle="solid"), dac.Radio( options=[{ 'label': 'Active Flow (MW)', "value": "active_flow" }, { 'label': 'Current Flow (A)', 'value': 'current_flow' }, { 'label': 'Flow Usage Rate', 'value': 'flow_usage_rate' }], value='active_flow', id='flow_radio', style={'display': 'none'}), dac.Select(id="line_side_choices", options=[], value=[], mode='multiple', showArrow=True), dcc.Graph( id="voltage_flow_graph", figure=go.Figure( layout=layout_def, data=[ dict(type="scatter") ])) ]), ]) ]) ]) ])
def summary_line(episode, ref_agent, scenario): return html.Div(children=[ html.H4("Summary"), html.Div(children=[ html.Div(children=[ html.H5("Best Agent's Environment Time Series"), dac.Radio(options=[{ 'label': 'Load (MW)', "value": "Load" }, { 'label': 'Production (MW)', "value": "Production" }, { 'label': 'Hazards', "value": "Hazards" }, { 'label': 'Maintenances', "value": "Maintenances" }], value="Load", id="scen_overview_ts_switch", buttonStyle="solid"), dac.Select(id='input_assets_selector', options=[{ 'label': load_name, 'value': load_name } for load_name in episode.load_names], value=episode.load_names[0], mode='multiple', showArrow=True), dcc.Graph(id='input_env_charts', style={'margin-top': '1em'}, figure=go.Figure(layout=layout_def), config=dict(displayModeBar=False)), ], className="col-xl-5"), html.Div(children=[ dcc.Dropdown(id="input_agent_selector", placeholder="select a ref agent", options=[{ 'label': agent, 'value': agent } for agent in agent_scenario[scenario]], value=ref_agent), html.Div(children=[ html.Div(children=[ html.H5("Usage rate", className='text-center'), dcc.Graph(id='usage_rate_graph', style={'margin-top': '1em'}, figure=go.Figure(layout=layout_def), config=dict(displayModeBar=False)) ], className='col-6'), html.Div(children=[ html.H5("Overflow", className='text-center'), dcc.Graph(id='overflow_graph', style={'margin-top': '1em'}, figure=go.Figure(layout=layout_def), config=dict(displayModeBar=False)) ], className='col-6') ], className="row"), ], className="col-xl-7"), ], className="card-body row"), ], className="lineBlock card")