Exemple #1
0
def layout(user_selected_timestamp, study_agent, ref_agent, scenario):
    best_episode = make_episode(best_agents[scenario]["agent"], scenario)
    new_episode = make_episode(study_agent, scenario)
    center_indx = center_index(user_selected_timestamp, new_episode)
    network_graph = make_network_agent_study(new_episode, timestep=center_indx)

    open_help = should_help_open(
        Path(grid2viz_home_directory) / DONT_SHOW_FILENAME("micro"))
    header = "Analyze further your agent"
    body = (
        "Select a time step in the navbar dropdown and analyze what happened "
        "at that time to understand the agent behavior.")
    return html.Div(
        id="micro_page",
        children=[
            indicator_line(),
            flux_inspector_line(
                network_graph,
                slider_params(user_selected_timestamp, new_episode),
            ),
            context_inspector_line(best_episode, new_episode),
            all_info_line,
            modal(id_suffix="micro",
                  is_open=open_help,
                  header=header,
                  body=body),
        ],
    )
Exemple #2
0
def layout(timestamps, scenario, study_agent, ref_agent,
           from_scenario_selection):
    if study_agent is None:
        study_agent = best_agents[scenario]["agent"]
    open_help = should_help_open(
        Path(grid2viz_home_directory) / DONT_SHOW_FILENAME("macro"))
    header = "Take a look at your agent"
    body = (
        "Select an agent to study in the dropdown menu and analyse it with "
        "respect to the reference agent. Click on the reward graph to select "
        "some time steps to study further your agent. When you have selected time steps, "
        "go on to the Study agent view.")

    return html.Div(
        id="overview_page",
        children=[
            dcc.Store(id="relayoutStoreMacro"),
            indicator_line(scenario, study_agent, ref_agent),
            overview_line(timestamps, from_scenario_selection),
            inspector_line(study_agent, scenario),
            modal(id_suffix="macro",
                  is_open=open_help,
                  header=header,
                  body=body),
        ],
    )
Exemple #3
0
 def toggle_modal(close_n_clicks, open_n_clicks, is_open, dont_show_again):
     dsa_filepath = Path(grid2viz_home_directory) / DONT_SHOW_FILENAME("overview")
     return toggle_modal_helper(
         close_n_clicks,
         open_n_clicks,
         is_open,
         dont_show_again,
         dsa_filepath,
         "page_help",
     )
Exemple #4
0
def layout(scenario, ref_agent):
    try:
        episode = make_episode(best_agents[scenario]["agent"], scenario)
    except Exception as ex:
        print(ex)
        return
    if ref_agent is None:
        ref_agent = agent_scenario[scenario][0]

    network_graph = make_network_scenario_overview(episode)

    # /!\ As of 2020/10/29 the mpl_to_plotly functions is broken and not maintained
    # It calls a deprecated function of matplotlib.
    # Work around below : insert the image.
    # https://stackoverflow.com/questions/63120058/plotly-mpl-to-plotly-error-spine-object-has-no-attribute-is-frame-like
    buf = io.BytesIO()
    plt.figure(network_graph.number)
    plt.savefig(buf, format="png")
    buf.seek(0)
    encoded_image = base64.b64encode(buf.read())
    buf.close()

    open_help = should_help_open(
        Path(grid2viz_home_directory) / DONT_SHOW_FILENAME("overview"))
    header = "Take a deeper look at the Scenario"
    body = (
        "Look at the grid, inspect indicators as well as chronics"
        "Select a reference agent in the dropdown menu to get a sense of flows and overflows over the scenario"
        "When done, move to Agent Overview section. The reference agent will be used there as baseline to compare with"
    )
    return html.Div(
        id="overview_page",
        children=[
            dcc.Store(id="relayoutStoreOverview"),
            indicators_line(encoded_image.decode()),
            summary_line(episode, ref_agent, scenario),
            ref_agent_line,
            modal(id_suffix="overview",
                  is_open=open_help,
                  header=header,
                  body=body),
        ],
    )
Exemple #5
0
def layout():
    open_help = should_help_open(
        Path(grid2viz_home_directory) / DONT_SHOW_FILENAME("episodes"))
    header = "Take a look at the Scenarios"
    body = (
        " Choose a specific scenario to analyze by clicking its Open button.  "
        "Get more detailed information when choosing your scenario by clicking on the comparison & filtering button"
    )
    return html.Div(
        id="scenario_page",
        children=[
            dcc.Store(id="relayoutStoreScenario"),
            comparison_button(),
            generate_heatmap_components(survival_df),
            dbc.Row(id="cards_container", className="m-1"),
            modal(id_suffix="episodes",
                  is_open=open_help,
                  header=header,
                  body=body),
        ],
    )