def update_agent_log_action_graphs(study_agent, figure_sub, figure_switch_line, scenario): new_episode = make_episode(study_agent, scenario) figure_sub["data"] = actions_model.get_action_per_sub(new_episode) figure_switch_line["data"] = actions_model.get_action_per_line(new_episode) figure_sub["layout"].update( actions_model.update_layout( len(figure_sub["data"][0]["x"]) == 0, "No Actions on subs for this Agent")) figure_switch_line["layout"].update( actions_model.update_layout( len(figure_switch_line["data"][0]["x"]) == 0, "No Actions on lines for this Agent")) return figure_sub, figure_switch_line
def update_action_repartition_pie(study_agent, figure, scenario): new_episode = make_episode(study_agent, scenario) figure['data'] = action_repartition_pie(new_episode) figure['layout'].update( actions_model.update_layout(figure["data"][0].values == (0, 0), "No Actions for this Agent")) return figure
def maintenance_duration_hist(study_agent, figure, scenario): new_episode = make_episode(study_agent, scenario) figure['data'] = [go.Histogram(x=hist_duration_maintenances(new_episode))] figure["layout"].update( actions_model.update_layout( len(figure["data"][0]["x"]) == 0, "No Maintenances for this scenario")) figure["layout"]["xaxis"]["rangemode"] = "tozero" return figure
def update_agent_log_action_graphs(study_agent, ref_agent, figure_sub, figure_switch_line, figure_redisp, scenario): new_episode = make_episode(study_agent, scenario) ref_episode = make_episode(ref_agent, scenario) y_max = None figure_sub["data"] = actions_model.get_action_per_sub(new_episode) if len(figure_sub["data"][0]["x"]) != 0: figure_sub["data"].append( actions_model.get_action_per_sub(ref_episode)[0]) y_max = max( map(max_or_zero, [trace.y for trace in figure_sub["data"]])) + 1 figure_switch_line["data"] = actions_model.get_action_per_line( new_episode) if len(figure_switch_line["data"][0]["x"]) != 0: figure_switch_line["data"].append( actions_model.get_action_per_line(ref_episode)[0]) if y_max is None: y_max = (max( map( max_or_zero, [trace.y for trace in figure_switch_line["data"]], )) + 1) if (max( map(max_or_zero, [trace.y for trace in figure_switch_line["data"]])) > y_max): y_max = (max( map( max_or_zero, [trace.y for trace in figure_switch_line["data"]], )) + 1) figure_redisp["data"] = actions_model.get_action_redispatch( new_episode) if len(figure_redisp["data"][0]["x"]) != 0: figure_redisp["data"].append( actions_model.get_action_redispatch(ref_episode)[0]) if y_max is None: y_max = (max( map(max_or_zero, [trace.y for trace in figure_redisp["data"]])) + 1) if (max( map(max_or_zero, [trace.y for trace in figure_redisp["data"]])) > y_max): y_max = (max( map(max_or_zero, [trace.y for trace in figure_redisp["data"]])) + 1) figure_sub["layout"].update( actions_model.update_layout( len(figure_sub["data"][0]["x"]) == 0, "No Actions on subs for this Agent", )) figure_switch_line["layout"].update( actions_model.update_layout( len(figure_switch_line["data"][0]["x"]) == 0, "No Actions on lines for this Agent", )) figure_redisp["layout"].update( actions_model.update_layout( len(figure_redisp["data"][0]["x"]) == 0, "No redispatching actions for this Agent", )) if y_max: figure_sub["layout"]["yaxis"].update(range=[0, y_max]) figure_switch_line["layout"]["yaxis"].update(range=[0, y_max]) figure_redisp["layout"]["yaxis"].update(range=[0, y_max]) return figure_sub, figure_switch_line, figure_redisp