@@ -52,6 +52,7 @@ def __init__(self, in_config):
5252 self .num_features = self .cc_params .pNumGaussianFeatures
5353 self .num_envs = self .config ["NumEnvironments" ]
5454 self .num_steps = self .config ["NumSteps" ]
55+ self .every_num_steps = self .config ["EveryNumSteps" ]
5556
5657 self .columns = [
5758 BarColumn (bar_width = None ),
@@ -66,7 +67,8 @@ def __init__(self, in_config):
6667 ]
6768
6869 def evaluate (self , save = True ):
69- cost_data = np .zeros ((self .num_controllers , self .num_envs , self .num_steps ))
70+ total_samples = self .num_steps // self .every_num_steps
71+ cost_data = np .zeros ((self .num_controllers , self .num_envs , total_samples ))
7072
7173 with Progress (* self .columns , expand = True ) as progress :
7274 task = progress .add_task (
@@ -94,7 +96,7 @@ def evaluate(self, save=True):
9496 robot_init_pos = env_main .GetRobotPositions (force_no_noise = True )
9597
9698 for controller_id in range (self .num_controllers ):
97- step_count = 0
99+ sample_count = 0
98100 env = CoverageSystem (self .cc_params , world_idf , robot_init_pos )
99101
100102 if self .controllers_configs [controller_id ]["Type" ] == "Learning" :
@@ -105,30 +107,30 @@ def evaluate(self, save=True):
105107 self .controllers_configs [controller_id ], self .cc_params , env
106108 )
107109 initial_objective_value = env .GetObjectiveValue ()
108- cost_data [controller_id , env_count , step_count ] = (
110+ cost_data [controller_id , env_count , sample_count ] = (
109111 env .GetObjectiveValue () / initial_objective_value
110112 )
111- step_count = step_count + 1
113+ sample_count = sample_count + 1
112114
113- while step_count < self .num_steps :
115+ for step_count in range ( 1 , self .num_steps ) :
114116 converged = controller .step (env )
115- objective_value = env .GetObjectiveValue ()
116- normalized_objective_value = (
117- objective_value / initial_objective_value
118- )
119- cost_data [controller_id , env_count , step_count ] = (
120- normalized_objective_value
121- )
122-
123- step_count = step_count + 1
124-
125- if converged :
126- cost_data [controller_id , env_count , step_count :] = (
117+ if step_count % self .every_num_steps == 0 :
118+ objective_value = env .GetObjectiveValue ()
119+ normalized_objective_value = (
120+ objective_value / initial_objective_value
121+ )
122+ cost_data [controller_id , env_count , sample_count ] = (
127123 normalized_objective_value
128124 )
129- step_count = self .num_steps
125+ sample_count = sample_count + 1
126+
127+ if converged :
128+ cost_data [controller_id , env_count , sample_count :] = (
129+ normalized_objective_value
130+ )
131+ step_count = self .num_steps
132+ sample_count = total_samples
130133
131- if (step_count ) % 10 == 0 or step_count == self .num_steps :
132134 info = f"Controller { controller_id } /{ self .num_controllers } : { controller .name } "
133135
134136 progress .update (
0 commit comments