Spaces:
Sleeping
Sleeping
Commit
·
9bb3b01
1
Parent(s):
6470b3e
better data visualizations
Browse files- python_dash_ia.py +462 -59
python_dash_ia.py
CHANGED
|
@@ -701,7 +701,8 @@ app.layout = html.Div([
|
|
| 701 |
# Bar chart for most reliable path color counts
|
| 702 |
html.Div([
|
| 703 |
dcc.Graph(id="overall-scenario-bar-chart"),
|
| 704 |
-
dcc.Graph(id="most-reliable-bar-chart")
|
|
|
|
| 705 |
]),
|
| 706 |
|
| 707 |
# Footer with copyright
|
|
@@ -722,6 +723,7 @@ app.layout = html.Div([
|
|
| 722 |
Output("interdependence-graph", "figure"),
|
| 723 |
Output("overall-scenario-bar-chart", "figure"),
|
| 724 |
Output("most-reliable-bar-chart", "figure"),
|
|
|
|
| 725 |
Input("procedure-dropdown", "value"),
|
| 726 |
Input("highlight-selector", "value"),
|
| 727 |
Input("responsibility-table", "data")
|
|
@@ -729,7 +731,7 @@ app.layout = html.Div([
|
|
| 729 |
def update_graph_and_bar(procedure, highlight_track, data):
|
| 730 |
df = pd.DataFrame(data)
|
| 731 |
if df.empty:
|
| 732 |
-
return go.Figure(), go.Figure(), go.Figure()
|
| 733 |
if highlight_track == "none":
|
| 734 |
highlight_track = None
|
| 735 |
|
|
@@ -832,50 +834,202 @@ def update_graph_and_bar(procedure, highlight_track, data):
|
|
| 832 |
supporter_orange += 1
|
| 833 |
|
| 834 |
bar_fig_whole_scenario = go.Figure()
|
| 835 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 836 |
bar_fig_whole_scenario.add_trace(go.Bar(
|
| 837 |
-
name="
|
| 838 |
-
x=["
|
| 839 |
-
y=[
|
| 840 |
-
marker_color=
|
|
|
|
|
|
|
|
|
|
|
|
|
| 841 |
))
|
| 842 |
bar_fig_whole_scenario.add_trace(go.Bar(
|
| 843 |
-
name="
|
| 844 |
-
x=["
|
| 845 |
-
y=[
|
| 846 |
-
marker_color=
|
|
|
|
|
|
|
|
|
|
|
|
|
| 847 |
))
|
|
|
|
| 848 |
bar_fig_whole_scenario.add_trace(go.Bar(
|
| 849 |
-
name="
|
| 850 |
-
x=["
|
| 851 |
-
y=[
|
| 852 |
-
marker_color=
|
|
|
|
|
|
|
|
|
|
|
|
|
| 853 |
))
|
| 854 |
-
# Stacked bars for supporter colors
|
| 855 |
bar_fig_whole_scenario.add_trace(go.Bar(
|
| 856 |
-
name="
|
| 857 |
-
x=["Supporter
|
| 858 |
-
y=[
|
| 859 |
-
marker_color=
|
|
|
|
|
|
|
|
|
|
|
|
|
| 860 |
))
|
| 861 |
bar_fig_whole_scenario.add_trace(go.Bar(
|
| 862 |
-
name="
|
| 863 |
-
x=["Supporter
|
| 864 |
-
y=[
|
| 865 |
-
marker_color=
|
|
|
|
|
|
|
|
|
|
|
|
|
| 866 |
))
|
|
|
|
| 867 |
bar_fig_whole_scenario.add_trace(go.Bar(
|
| 868 |
-
name="
|
| 869 |
-
x=["Supporter
|
| 870 |
-
y=[
|
| 871 |
-
marker_color=
|
|
|
|
|
|
|
|
|
|
|
|
|
| 872 |
))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 873 |
bar_fig_whole_scenario.update_layout(
|
| 874 |
title="Performer and Supporter Capacities in Mixed Initiative",
|
| 875 |
xaxis_title="Role and Capacity",
|
| 876 |
yaxis_title="Number of Tasks",
|
| 877 |
-
barmode='
|
| 878 |
-
bargap=0.
|
|
|
|
| 879 |
plot_bgcolor='white',
|
| 880 |
paper_bgcolor='white',
|
| 881 |
showlegend=False
|
|
@@ -1056,56 +1210,305 @@ def update_graph_and_bar(procedure, highlight_track, data):
|
|
| 1056 |
human_supporter_orange += 1
|
| 1057 |
|
| 1058 |
bar_fig = go.Figure()
|
| 1059 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1060 |
bar_fig.add_trace(go.Bar(
|
| 1061 |
-
name="
|
| 1062 |
-
x=["Performer Green"
|
| 1063 |
-
y=[
|
| 1064 |
-
marker_color=
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1065 |
))
|
|
|
|
| 1066 |
bar_fig.add_trace(go.Bar(
|
| 1067 |
-
name="
|
| 1068 |
-
x=["Performer
|
| 1069 |
-
y=[
|
| 1070 |
-
marker_color=
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1071 |
))
|
| 1072 |
bar_fig.add_trace(go.Bar(
|
| 1073 |
-
name="
|
| 1074 |
-
x=["Performer
|
| 1075 |
-
y=[
|
| 1076 |
-
marker_color=
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1077 |
))
|
| 1078 |
-
# Stacked bars for supporter colors
|
| 1079 |
bar_fig.add_trace(go.Bar(
|
| 1080 |
-
name="
|
| 1081 |
-
x=["
|
| 1082 |
-
y=[
|
| 1083 |
-
marker_color=
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1084 |
))
|
|
|
|
| 1085 |
bar_fig.add_trace(go.Bar(
|
| 1086 |
-
name="
|
| 1087 |
-
x=["
|
| 1088 |
-
y=[
|
| 1089 |
-
marker_color=
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1090 |
))
|
| 1091 |
bar_fig.add_trace(go.Bar(
|
| 1092 |
-
name="
|
| 1093 |
-
x=["
|
| 1094 |
-
y=[
|
| 1095 |
-
marker_color=
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1096 |
))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1097 |
bar_fig.update_layout(
|
| 1098 |
title="Most Reliable Path: Performer and Supporter Capacities",
|
| 1099 |
xaxis_title="Role and Capacity",
|
| 1100 |
yaxis_title="Number of Tasks",
|
| 1101 |
-
barmode='
|
| 1102 |
-
bargap=0.
|
|
|
|
| 1103 |
plot_bgcolor='white',
|
| 1104 |
paper_bgcolor='white',
|
| 1105 |
showlegend=False
|
| 1106 |
)
|
| 1107 |
|
| 1108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1109 |
|
| 1110 |
|
| 1111 |
def ensure_all_columns(df, columns):
|
|
|
|
| 701 |
# Bar chart for most reliable path color counts
|
| 702 |
html.Div([
|
| 703 |
dcc.Graph(id="overall-scenario-bar-chart"),
|
| 704 |
+
dcc.Graph(id="most-reliable-bar-chart"),
|
| 705 |
+
dcc.Graph(id="allocation-type-bar-chart")
|
| 706 |
]),
|
| 707 |
|
| 708 |
# Footer with copyright
|
|
|
|
| 723 |
Output("interdependence-graph", "figure"),
|
| 724 |
Output("overall-scenario-bar-chart", "figure"),
|
| 725 |
Output("most-reliable-bar-chart", "figure"),
|
| 726 |
+
Output("allocation-type-bar-chart", "figure"),
|
| 727 |
Input("procedure-dropdown", "value"),
|
| 728 |
Input("highlight-selector", "value"),
|
| 729 |
Input("responsibility-table", "data")
|
|
|
|
| 731 |
def update_graph_and_bar(procedure, highlight_track, data):
|
| 732 |
df = pd.DataFrame(data)
|
| 733 |
if df.empty:
|
| 734 |
+
return go.Figure(), go.Figure(), go.Figure(), go.Figure()
|
| 735 |
if highlight_track == "none":
|
| 736 |
highlight_track = None
|
| 737 |
|
|
|
|
| 834 |
supporter_orange += 1
|
| 835 |
|
| 836 |
bar_fig_whole_scenario = go.Figure()
|
| 837 |
+
|
| 838 |
+
# Individual bars for each agent and color - Performers
|
| 839 |
+
bar_fig_whole_scenario.add_trace(go.Bar(
|
| 840 |
+
name="Human",
|
| 841 |
+
x=["Performer Green"],
|
| 842 |
+
y=[human_performer_green],
|
| 843 |
+
marker_color="seagreen",
|
| 844 |
+
showlegend=False,
|
| 845 |
+
text=["Human"],
|
| 846 |
+
textposition='outside',
|
| 847 |
+
textangle=0
|
| 848 |
+
))
|
| 849 |
+
bar_fig_whole_scenario.add_trace(go.Bar(
|
| 850 |
+
name="UGV",
|
| 851 |
+
x=["Performer Green"],
|
| 852 |
+
y=[ugv_performer_green],
|
| 853 |
+
marker_color="limegreen",
|
| 854 |
+
showlegend=False,
|
| 855 |
+
text=["UGV"],
|
| 856 |
+
textposition='outside',
|
| 857 |
+
textangle=0
|
| 858 |
+
))
|
| 859 |
+
bar_fig_whole_scenario.add_trace(go.Bar(
|
| 860 |
+
name="UAV",
|
| 861 |
+
x=["Performer Green"],
|
| 862 |
+
y=[uav_performer_green],
|
| 863 |
+
marker_color="mediumspringgreen",
|
| 864 |
+
showlegend=False,
|
| 865 |
+
text=["UAV"],
|
| 866 |
+
textposition='outside',
|
| 867 |
+
textangle=0
|
| 868 |
+
))
|
| 869 |
+
|
| 870 |
+
bar_fig_whole_scenario.add_trace(go.Bar(
|
| 871 |
+
name="Human",
|
| 872 |
+
x=["Performer Yellow"],
|
| 873 |
+
y=[human_performer_yellow],
|
| 874 |
+
marker_color="gold",
|
| 875 |
+
showlegend=False,
|
| 876 |
+
text=["Human"],
|
| 877 |
+
textposition='outside',
|
| 878 |
+
textangle=0
|
| 879 |
+
))
|
| 880 |
+
bar_fig_whole_scenario.add_trace(go.Bar(
|
| 881 |
+
name="UGV",
|
| 882 |
+
x=["Performer Yellow"],
|
| 883 |
+
y=[ugv_performer_yellow],
|
| 884 |
+
marker_color="khaki",
|
| 885 |
+
showlegend=False,
|
| 886 |
+
text=["UGV"],
|
| 887 |
+
textposition='outside',
|
| 888 |
+
textangle=0
|
| 889 |
+
))
|
| 890 |
+
bar_fig_whole_scenario.add_trace(go.Bar(
|
| 891 |
+
name="UAV",
|
| 892 |
+
x=["Performer Yellow"],
|
| 893 |
+
y=[uav_performer_yellow],
|
| 894 |
+
marker_color="lemonchiffon",
|
| 895 |
+
showlegend=False,
|
| 896 |
+
text=["UAV"],
|
| 897 |
+
textposition='outside',
|
| 898 |
+
textangle=0
|
| 899 |
+
))
|
| 900 |
+
|
| 901 |
+
bar_fig_whole_scenario.add_trace(go.Bar(
|
| 902 |
+
name="Human",
|
| 903 |
+
x=["Performer Orange"],
|
| 904 |
+
y=[human_performer_orange],
|
| 905 |
+
marker_color="darkorange",
|
| 906 |
+
showlegend=False,
|
| 907 |
+
text=["Human"],
|
| 908 |
+
textposition='outside',
|
| 909 |
+
textangle=0
|
| 910 |
+
))
|
| 911 |
+
bar_fig_whole_scenario.add_trace(go.Bar(
|
| 912 |
+
name="UGV",
|
| 913 |
+
x=["Performer Orange"],
|
| 914 |
+
y=[ugv_performer_orange],
|
| 915 |
+
marker_color="orange",
|
| 916 |
+
showlegend=False,
|
| 917 |
+
text=["UGV"],
|
| 918 |
+
textposition='outside',
|
| 919 |
+
textangle=0
|
| 920 |
+
))
|
| 921 |
+
bar_fig_whole_scenario.add_trace(go.Bar(
|
| 922 |
+
name="UAV",
|
| 923 |
+
x=["Performer Orange"],
|
| 924 |
+
y=[uav_performer_orange],
|
| 925 |
+
marker_color="coral",
|
| 926 |
+
showlegend=False,
|
| 927 |
+
text=["UAV"],
|
| 928 |
+
textposition='outside',
|
| 929 |
+
textangle=0
|
| 930 |
+
))
|
| 931 |
+
|
| 932 |
+
# Individual bars for each agent and color - Supporters
|
| 933 |
+
bar_fig_whole_scenario.add_trace(go.Bar(
|
| 934 |
+
name="Human",
|
| 935 |
+
x=["Supporter Green"],
|
| 936 |
+
y=[human_supporter_green],
|
| 937 |
+
marker_color="seagreen",
|
| 938 |
+
showlegend=False,
|
| 939 |
+
text=["Human"],
|
| 940 |
+
textposition='outside',
|
| 941 |
+
textangle=0
|
| 942 |
+
))
|
| 943 |
bar_fig_whole_scenario.add_trace(go.Bar(
|
| 944 |
+
name="UGV",
|
| 945 |
+
x=["Supporter Green"],
|
| 946 |
+
y=[ugv_supporter_green],
|
| 947 |
+
marker_color="limegreen",
|
| 948 |
+
showlegend=False,
|
| 949 |
+
text=["UGV"],
|
| 950 |
+
textposition='outside',
|
| 951 |
+
textangle=0
|
| 952 |
))
|
| 953 |
bar_fig_whole_scenario.add_trace(go.Bar(
|
| 954 |
+
name="UAV",
|
| 955 |
+
x=["Supporter Green"],
|
| 956 |
+
y=[uav_supporter_green],
|
| 957 |
+
marker_color="mediumspringgreen",
|
| 958 |
+
showlegend=False,
|
| 959 |
+
text=["UAV"],
|
| 960 |
+
textposition='outside',
|
| 961 |
+
textangle=0
|
| 962 |
))
|
| 963 |
+
|
| 964 |
bar_fig_whole_scenario.add_trace(go.Bar(
|
| 965 |
+
name="Human",
|
| 966 |
+
x=["Supporter Yellow"],
|
| 967 |
+
y=[human_supporter_yellow],
|
| 968 |
+
marker_color="gold",
|
| 969 |
+
showlegend=False,
|
| 970 |
+
text=["Human"],
|
| 971 |
+
textposition='outside',
|
| 972 |
+
textangle=0
|
| 973 |
))
|
|
|
|
| 974 |
bar_fig_whole_scenario.add_trace(go.Bar(
|
| 975 |
+
name="UGV",
|
| 976 |
+
x=["Supporter Yellow"],
|
| 977 |
+
y=[ugv_supporter_yellow],
|
| 978 |
+
marker_color="khaki",
|
| 979 |
+
showlegend=False,
|
| 980 |
+
text=["UGV"],
|
| 981 |
+
textposition='outside',
|
| 982 |
+
textangle=0
|
| 983 |
))
|
| 984 |
bar_fig_whole_scenario.add_trace(go.Bar(
|
| 985 |
+
name="UAV",
|
| 986 |
+
x=["Supporter Yellow"],
|
| 987 |
+
y=[uav_supporter_yellow],
|
| 988 |
+
marker_color="lemonchiffon",
|
| 989 |
+
showlegend=False,
|
| 990 |
+
text=["UAV"],
|
| 991 |
+
textposition='outside',
|
| 992 |
+
textangle=0
|
| 993 |
))
|
| 994 |
+
|
| 995 |
bar_fig_whole_scenario.add_trace(go.Bar(
|
| 996 |
+
name="Human",
|
| 997 |
+
x=["Supporter Orange"],
|
| 998 |
+
y=[human_supporter_orange],
|
| 999 |
+
marker_color="darkorange",
|
| 1000 |
+
showlegend=False,
|
| 1001 |
+
text=["Human"],
|
| 1002 |
+
textposition='outside',
|
| 1003 |
+
textangle=0
|
| 1004 |
))
|
| 1005 |
+
bar_fig_whole_scenario.add_trace(go.Bar(
|
| 1006 |
+
name="UGV",
|
| 1007 |
+
x=["Supporter Orange"],
|
| 1008 |
+
y=[ugv_supporter_orange],
|
| 1009 |
+
marker_color="orange",
|
| 1010 |
+
showlegend=False,
|
| 1011 |
+
text=["UGV"],
|
| 1012 |
+
textposition='outside',
|
| 1013 |
+
textangle=0
|
| 1014 |
+
))
|
| 1015 |
+
bar_fig_whole_scenario.add_trace(go.Bar(
|
| 1016 |
+
name="UAV",
|
| 1017 |
+
x=["Supporter Orange"],
|
| 1018 |
+
y=[uav_supporter_orange],
|
| 1019 |
+
marker_color="coral",
|
| 1020 |
+
showlegend=False,
|
| 1021 |
+
text=["UAV"],
|
| 1022 |
+
textposition='outside',
|
| 1023 |
+
textangle=0
|
| 1024 |
+
))
|
| 1025 |
+
|
| 1026 |
bar_fig_whole_scenario.update_layout(
|
| 1027 |
title="Performer and Supporter Capacities in Mixed Initiative",
|
| 1028 |
xaxis_title="Role and Capacity",
|
| 1029 |
yaxis_title="Number of Tasks",
|
| 1030 |
+
barmode='group',
|
| 1031 |
+
bargap=0.15,
|
| 1032 |
+
bargroupgap=0.1,
|
| 1033 |
plot_bgcolor='white',
|
| 1034 |
paper_bgcolor='white',
|
| 1035 |
showlegend=False
|
|
|
|
| 1210 |
human_supporter_orange += 1
|
| 1211 |
|
| 1212 |
bar_fig = go.Figure()
|
| 1213 |
+
|
| 1214 |
+
# Individual bars for each agent and color - Performers
|
| 1215 |
+
bar_fig.add_trace(go.Bar(
|
| 1216 |
+
name="Human",
|
| 1217 |
+
x=["Performer Green"],
|
| 1218 |
+
y=[human_performer_green],
|
| 1219 |
+
marker_color="seagreen",
|
| 1220 |
+
showlegend=False,
|
| 1221 |
+
text=["Human"],
|
| 1222 |
+
textposition='outside',
|
| 1223 |
+
textangle=0
|
| 1224 |
+
))
|
| 1225 |
+
bar_fig.add_trace(go.Bar(
|
| 1226 |
+
name="UGV",
|
| 1227 |
+
x=["Performer Green"],
|
| 1228 |
+
y=[ugv_performer_green],
|
| 1229 |
+
marker_color="limegreen",
|
| 1230 |
+
showlegend=False,
|
| 1231 |
+
text=["UGV"],
|
| 1232 |
+
textposition='outside',
|
| 1233 |
+
textangle=0
|
| 1234 |
+
))
|
| 1235 |
bar_fig.add_trace(go.Bar(
|
| 1236 |
+
name="UAV",
|
| 1237 |
+
x=["Performer Green"],
|
| 1238 |
+
y=[uav_performer_green],
|
| 1239 |
+
marker_color="mediumspringgreen",
|
| 1240 |
+
showlegend=False,
|
| 1241 |
+
text=["UAV"],
|
| 1242 |
+
textposition='outside',
|
| 1243 |
+
textangle=0
|
| 1244 |
))
|
| 1245 |
+
|
| 1246 |
bar_fig.add_trace(go.Bar(
|
| 1247 |
+
name="Human",
|
| 1248 |
+
x=["Performer Yellow"],
|
| 1249 |
+
y=[human_performer_yellow],
|
| 1250 |
+
marker_color="gold",
|
| 1251 |
+
showlegend=False,
|
| 1252 |
+
text=["Human"],
|
| 1253 |
+
textposition='outside',
|
| 1254 |
+
textangle=0
|
| 1255 |
))
|
| 1256 |
bar_fig.add_trace(go.Bar(
|
| 1257 |
+
name="UGV",
|
| 1258 |
+
x=["Performer Yellow"],
|
| 1259 |
+
y=[ugv_performer_yellow],
|
| 1260 |
+
marker_color="khaki",
|
| 1261 |
+
showlegend=False,
|
| 1262 |
+
text=["UGV"],
|
| 1263 |
+
textposition='outside',
|
| 1264 |
+
textangle=0
|
| 1265 |
))
|
|
|
|
| 1266 |
bar_fig.add_trace(go.Bar(
|
| 1267 |
+
name="UAV",
|
| 1268 |
+
x=["Performer Yellow"],
|
| 1269 |
+
y=[uav_performer_yellow],
|
| 1270 |
+
marker_color="lemonchiffon",
|
| 1271 |
+
showlegend=False,
|
| 1272 |
+
text=["UAV"],
|
| 1273 |
+
textposition='outside',
|
| 1274 |
+
textangle=0
|
| 1275 |
))
|
| 1276 |
+
|
| 1277 |
bar_fig.add_trace(go.Bar(
|
| 1278 |
+
name="Human",
|
| 1279 |
+
x=["Performer Orange"],
|
| 1280 |
+
y=[human_performer_orange],
|
| 1281 |
+
marker_color="darkorange",
|
| 1282 |
+
showlegend=False,
|
| 1283 |
+
text=["Human"],
|
| 1284 |
+
textposition='outside',
|
| 1285 |
+
textangle=0
|
| 1286 |
))
|
| 1287 |
bar_fig.add_trace(go.Bar(
|
| 1288 |
+
name="UGV",
|
| 1289 |
+
x=["Performer Orange"],
|
| 1290 |
+
y=[ugv_performer_orange],
|
| 1291 |
+
marker_color="orange",
|
| 1292 |
+
showlegend=False,
|
| 1293 |
+
text=["UGV"],
|
| 1294 |
+
textposition='outside',
|
| 1295 |
+
textangle=0
|
| 1296 |
))
|
| 1297 |
+
bar_fig.add_trace(go.Bar(
|
| 1298 |
+
name="UAV",
|
| 1299 |
+
x=["Performer Orange"],
|
| 1300 |
+
y=[uav_performer_orange],
|
| 1301 |
+
marker_color="coral",
|
| 1302 |
+
showlegend=False,
|
| 1303 |
+
text=["UAV"],
|
| 1304 |
+
textposition='outside',
|
| 1305 |
+
textangle=0
|
| 1306 |
+
))
|
| 1307 |
+
|
| 1308 |
+
# Individual bars for each agent and color - Supporters
|
| 1309 |
+
bar_fig.add_trace(go.Bar(
|
| 1310 |
+
name="Human",
|
| 1311 |
+
x=["Supporter Green"],
|
| 1312 |
+
y=[human_supporter_green],
|
| 1313 |
+
marker_color="seagreen",
|
| 1314 |
+
showlegend=False,
|
| 1315 |
+
text=["Human"],
|
| 1316 |
+
textposition='outside',
|
| 1317 |
+
textangle=0
|
| 1318 |
+
))
|
| 1319 |
+
bar_fig.add_trace(go.Bar(
|
| 1320 |
+
name="UGV",
|
| 1321 |
+
x=["Supporter Green"],
|
| 1322 |
+
y=[ugv_supporter_green],
|
| 1323 |
+
marker_color="limegreen",
|
| 1324 |
+
showlegend=False,
|
| 1325 |
+
text=["UGV"],
|
| 1326 |
+
textposition='outside',
|
| 1327 |
+
textangle=0
|
| 1328 |
+
))
|
| 1329 |
+
bar_fig.add_trace(go.Bar(
|
| 1330 |
+
name="UAV",
|
| 1331 |
+
x=["Supporter Green"],
|
| 1332 |
+
y=[uav_supporter_green],
|
| 1333 |
+
marker_color="mediumspringgreen",
|
| 1334 |
+
showlegend=False,
|
| 1335 |
+
text=["UAV"],
|
| 1336 |
+
textposition='outside',
|
| 1337 |
+
textangle=0
|
| 1338 |
+
))
|
| 1339 |
+
|
| 1340 |
+
bar_fig.add_trace(go.Bar(
|
| 1341 |
+
name="Human",
|
| 1342 |
+
x=["Supporter Yellow"],
|
| 1343 |
+
y=[human_supporter_yellow],
|
| 1344 |
+
marker_color="gold",
|
| 1345 |
+
showlegend=False,
|
| 1346 |
+
text=["Human"],
|
| 1347 |
+
textposition='outside',
|
| 1348 |
+
textangle=0
|
| 1349 |
+
))
|
| 1350 |
+
bar_fig.add_trace(go.Bar(
|
| 1351 |
+
name="UGV",
|
| 1352 |
+
x=["Supporter Yellow"],
|
| 1353 |
+
y=[ugv_supporter_yellow],
|
| 1354 |
+
marker_color="khaki",
|
| 1355 |
+
showlegend=False,
|
| 1356 |
+
text=["UGV"],
|
| 1357 |
+
textposition='outside',
|
| 1358 |
+
textangle=0
|
| 1359 |
+
))
|
| 1360 |
+
bar_fig.add_trace(go.Bar(
|
| 1361 |
+
name="UAV",
|
| 1362 |
+
x=["Supporter Yellow"],
|
| 1363 |
+
y=[uav_supporter_yellow],
|
| 1364 |
+
marker_color="lemonchiffon",
|
| 1365 |
+
showlegend=False,
|
| 1366 |
+
text=["UAV"],
|
| 1367 |
+
textposition='outside',
|
| 1368 |
+
textangle=0
|
| 1369 |
+
))
|
| 1370 |
+
|
| 1371 |
+
bar_fig.add_trace(go.Bar(
|
| 1372 |
+
name="Human",
|
| 1373 |
+
x=["Supporter Orange"],
|
| 1374 |
+
y=[human_supporter_orange],
|
| 1375 |
+
marker_color="darkorange",
|
| 1376 |
+
showlegend=False,
|
| 1377 |
+
text=["Human"],
|
| 1378 |
+
textposition='outside',
|
| 1379 |
+
textangle=0
|
| 1380 |
+
))
|
| 1381 |
+
bar_fig.add_trace(go.Bar(
|
| 1382 |
+
name="UGV",
|
| 1383 |
+
x=["Supporter Orange"],
|
| 1384 |
+
y=[ugv_supporter_orange],
|
| 1385 |
+
marker_color="orange",
|
| 1386 |
+
showlegend=False,
|
| 1387 |
+
text=["UGV"],
|
| 1388 |
+
textposition='outside',
|
| 1389 |
+
textangle=0
|
| 1390 |
+
))
|
| 1391 |
+
bar_fig.add_trace(go.Bar(
|
| 1392 |
+
name="UAV",
|
| 1393 |
+
x=["Supporter Orange"],
|
| 1394 |
+
y=[uav_supporter_orange],
|
| 1395 |
+
marker_color="coral",
|
| 1396 |
+
showlegend=False,
|
| 1397 |
+
text=["UAV"],
|
| 1398 |
+
textposition='outside',
|
| 1399 |
+
textangle=0
|
| 1400 |
+
))
|
| 1401 |
+
|
| 1402 |
bar_fig.update_layout(
|
| 1403 |
title="Most Reliable Path: Performer and Supporter Capacities",
|
| 1404 |
xaxis_title="Role and Capacity",
|
| 1405 |
yaxis_title="Number of Tasks",
|
| 1406 |
+
barmode='group',
|
| 1407 |
+
bargap=0.15,
|
| 1408 |
+
bargroupgap=0.1,
|
| 1409 |
plot_bgcolor='white',
|
| 1410 |
paper_bgcolor='white',
|
| 1411 |
showlegend=False
|
| 1412 |
)
|
| 1413 |
|
| 1414 |
+
# --- Allocation Type Analysis ---
|
| 1415 |
+
single_allocation_independent = 0
|
| 1416 |
+
multiple_allocation_independent = 0
|
| 1417 |
+
interdependent = 0
|
| 1418 |
+
|
| 1419 |
+
for idx, row in df_bar.iterrows():
|
| 1420 |
+
# Get all performer and supporter values
|
| 1421 |
+
human_star = str(row.get("Human*", "") or "").strip().lower()
|
| 1422 |
+
ugv_star = str(row.get("UGV*", "") or "").strip().lower()
|
| 1423 |
+
uav_star = str(row.get("UAV*", "") or "").strip().lower()
|
| 1424 |
+
human = str(row.get("Human", "") or "").strip().lower()
|
| 1425 |
+
ugv = str(row.get("UGV", "") or "").strip().lower()
|
| 1426 |
+
uav = str(row.get("UAV", "") or "").strip().lower()
|
| 1427 |
+
|
| 1428 |
+
VALID_COLORS = {"red", "yellow", "green", "orange"}
|
| 1429 |
+
|
| 1430 |
+
# Count valid performers (not red)
|
| 1431 |
+
performers = []
|
| 1432 |
+
if human_star in VALID_COLORS and human_star != "red":
|
| 1433 |
+
performers.append("Human*")
|
| 1434 |
+
if ugv_star in VALID_COLORS and ugv_star != "red":
|
| 1435 |
+
performers.append("UGV*")
|
| 1436 |
+
if uav_star in VALID_COLORS and uav_star != "red":
|
| 1437 |
+
performers.append("UAV*")
|
| 1438 |
+
|
| 1439 |
+
# Count valid supporters (not red)
|
| 1440 |
+
supporters = []
|
| 1441 |
+
if human in VALID_COLORS and human != "red":
|
| 1442 |
+
supporters.append("Human")
|
| 1443 |
+
if ugv in VALID_COLORS and ugv != "red":
|
| 1444 |
+
supporters.append("UGV")
|
| 1445 |
+
if uav in VALID_COLORS and uav != "red":
|
| 1446 |
+
supporters.append("UAV")
|
| 1447 |
+
|
| 1448 |
+
# Determine task type
|
| 1449 |
+
if len(supporters) > 0:
|
| 1450 |
+
# Has support available = interdependent
|
| 1451 |
+
interdependent += 1
|
| 1452 |
+
elif len(performers) == 1:
|
| 1453 |
+
# Only one performer, no support = single allocation independent
|
| 1454 |
+
single_allocation_independent += 1
|
| 1455 |
+
elif len(performers) > 1:
|
| 1456 |
+
# Multiple performers, no support = multiple allocation independent
|
| 1457 |
+
multiple_allocation_independent += 1
|
| 1458 |
+
|
| 1459 |
+
total_tasks = len(df_bar)
|
| 1460 |
+
|
| 1461 |
+
# Create horizontal stacked bar chart
|
| 1462 |
+
allocation_fig = go.Figure()
|
| 1463 |
+
|
| 1464 |
+
allocation_fig.add_trace(go.Bar(
|
| 1465 |
+
name='Single Allocation Independent',
|
| 1466 |
+
y=['Task Allocation Types'],
|
| 1467 |
+
x=[single_allocation_independent],
|
| 1468 |
+
orientation='h',
|
| 1469 |
+
marker=dict(color='lightcoral'),
|
| 1470 |
+
text=[f'Single Allocation Independent: {single_allocation_independent} ({single_allocation_independent/total_tasks*100:.1f}%)' if total_tasks > 0 and single_allocation_independent > 0 else ''],
|
| 1471 |
+
textposition='inside',
|
| 1472 |
+
textfont=dict(color='black', size=12),
|
| 1473 |
+
hovertemplate='Single Allocation Independent<br>Count: %{x}<br>Percentage: ' + (f'{single_allocation_independent/total_tasks*100:.1f}%' if total_tasks > 0 else '0%') + '<extra></extra>'
|
| 1474 |
+
))
|
| 1475 |
+
|
| 1476 |
+
allocation_fig.add_trace(go.Bar(
|
| 1477 |
+
name='Multiple Allocation Independent',
|
| 1478 |
+
y=['Task Allocation Types'],
|
| 1479 |
+
x=[multiple_allocation_independent],
|
| 1480 |
+
orientation='h',
|
| 1481 |
+
marker=dict(color='lightskyblue'),
|
| 1482 |
+
text=[f'Multiple Allocation Independent: {multiple_allocation_independent} ({multiple_allocation_independent/total_tasks*100:.1f}%)' if total_tasks > 0 and multiple_allocation_independent > 0 else ''],
|
| 1483 |
+
textposition='inside',
|
| 1484 |
+
textfont=dict(color='black', size=12),
|
| 1485 |
+
hovertemplate='Multiple Allocation Independent<br>Count: %{x}<br>Percentage: ' + (f'{multiple_allocation_independent/total_tasks*100:.1f}%' if total_tasks > 0 else '0%') + '<extra></extra>'
|
| 1486 |
+
))
|
| 1487 |
+
|
| 1488 |
+
allocation_fig.add_trace(go.Bar(
|
| 1489 |
+
name='Interdependent (Support Available)',
|
| 1490 |
+
y=['Task Allocation Types'],
|
| 1491 |
+
x=[interdependent],
|
| 1492 |
+
orientation='h',
|
| 1493 |
+
marker=dict(color='lightgreen'),
|
| 1494 |
+
text=[f'Interdependent: {interdependent} ({interdependent/total_tasks*100:.1f}%)' if total_tasks > 0 and interdependent > 0 else ''],
|
| 1495 |
+
textposition='inside',
|
| 1496 |
+
textfont=dict(color='black', size=12),
|
| 1497 |
+
hovertemplate='Interdependent (Support Available)<br>Count: %{x}<br>Percentage: ' + (f'{interdependent/total_tasks*100:.1f}%' if total_tasks > 0 else '0%') + '<extra></extra>'
|
| 1498 |
+
))
|
| 1499 |
+
|
| 1500 |
+
allocation_fig.update_layout(
|
| 1501 |
+
title="Task Type Distribution",
|
| 1502 |
+
xaxis_title="Number of Tasks",
|
| 1503 |
+
barmode='stack',
|
| 1504 |
+
height=200,
|
| 1505 |
+
plot_bgcolor='white',
|
| 1506 |
+
paper_bgcolor='white',
|
| 1507 |
+
showlegend=False,
|
| 1508 |
+
margin=dict(l=50, r=50, t=50, b=50)
|
| 1509 |
+
)
|
| 1510 |
+
|
| 1511 |
+
return workflow_fig, bar_fig_whole_scenario, bar_fig, allocation_fig
|
| 1512 |
|
| 1513 |
|
| 1514 |
def ensure_all_columns(df, columns):
|