@@ -47,7 +47,7 @@ def plot(axis, history, history_g=None):
4747 axis1 .legend (ncol = 1 , bbox_to_anchor = (0. , 1.02 , 1. , 0.102 ), loc = 3 )
4848 figure .savefig (path , bbox_inches = "tight" , pad_inches = 0.05 )
4949
50- def plot_results (args , history_x , history_u , history_g = None ):
50+ def plot_results (history_x , history_u , history_g = None , args = None ):
5151 """
5252
5353 Args:
@@ -56,14 +56,21 @@ def plot_results(args, history_x, history_u, history_g=None):
5656 Returns:
5757 None
5858 """
59+ env = "Env"
60+ controller_type = "controller"
61+
62+ if args is not None :
63+ env = args .env
64+ controller_type = args .controller_type
65+
5966 plot_result (history_x , history_g = history_g , ylabel = "x" ,
60- name = args . env + "-state_history" ,
61- save_dir = "./result/" + args . controller_type )
67+ name = env + "-state_history" ,
68+ save_dir = "./result/" + controller_type )
6269 plot_result (history_u , history_g = np .zeros_like (history_u ), ylabel = "u" ,
63- name = args . env + "-input_history" ,
64- save_dir = "./result/" + args . controller_type )
70+ name = env + "-input_history" ,
71+ save_dir = "./result/" + controller_type )
6572
66- def save_plot_data (args , history_x , history_u , history_g = None ):
73+ def save_plot_data (history_x , history_u , history_g = None , args = None ):
6774 """ save plot data
6875
6976 Args:
@@ -72,16 +79,23 @@ def save_plot_data(args, history_x, history_u, history_g=None):
7279 Returns:
7380 None
7481 """
75- path = os .path .join ("./result/" + args .controller_type ,
76- args .env + "-history_x.pkl" )
82+ env = "Env"
83+ controller_type = "controller"
84+
85+ if args is not None :
86+ env = args .env
87+ controller_type = args .controller_type
88+
89+ path = os .path .join ("./result/" + controller_type ,
90+ env + "-history_x.pkl" )
7791 save_pickle (path , history_x )
7892
79- path = os .path .join ("./result/" + args . controller_type ,
80- args . env + "-history_u.pkl" )
93+ path = os .path .join ("./result/" + controller_type ,
94+ env + "-history_u.pkl" )
8195 save_pickle (path , history_u )
8296
83- path = os .path .join ("./result/" + args . controller_type ,
84- args . env + "-history_g.pkl" )
97+ path = os .path .join ("./result/" + controller_type ,
98+ env + "-history_g.pkl" )
8599 save_pickle (path , history_g )
86100
87101def load_plot_data (env , controller_type , result_dir = "./result" ):
0 commit comments