Skip to content

Commit 031046e

Browse files
author
Saurav Agarwal
committed
Update progress bar
1 parent 29c70e1 commit 031046e

File tree

2 files changed

+30
-19
lines changed

2 files changed

+30
-19
lines changed

python/scripts/data_generation/data_generation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,15 @@ def __init__(self, args):
191191
self.print_tensor_sizes()
192192

193193
columns = [
194-
BarColumn(),
194+
BarColumn(bar_width=None),
195195
TaskProgressColumn(),
196196
TextColumn("[progress.description]{task.description}"),
197197
MofNCompleteColumn(),
198198
TextColumn("#Envs: {task.fields[num_envs]}"),
199199
TimeRemainingColumn(),
200200
TimeElapsedColumn(),
201201
]
202-
with Progress(*columns) as self.progress:
202+
with Progress(*columns, expand=True) as self.progress:
203203
self.task = self.progress.add_task(
204204
"[bold blue]Generating dataset",
205205
total=self.num_dataset,

python/scripts/evaluators/eval.py

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ def __init__(self, in_config):
5959
TaskProgressColumn(),
6060
TextColumn("[progress.description]{task.description}"),
6161
MofNCompleteColumn(),
62-
TextColumn("Controller: {task.fields[info]}"),
62+
TextColumn("{task.fields[info]}"),
63+
TextColumn("Step: {task.fields[step_count]:>4}"),
64+
TextColumn("Obj: {task.fields[obj]:.2e}"),
6365
TimeRemainingColumn(),
6466
TimeElapsedColumn(),
6567
]
@@ -71,7 +73,9 @@ def evaluate(self, save=True):
7173
task = progress.add_task(
7274
"[bold blue]Evaluation",
7375
total=self.num_envs,
74-
info="",
76+
info="Initializing...",
77+
step_count=0,
78+
obj=np.nan,
7579
auto_refresh=False,
7680
)
7781

@@ -95,10 +99,6 @@ def evaluate(self, save=True):
9599
step_count = 0
96100
env = CoverageSystem(self.cc_params, world_idf, robot_init_pos)
97101

98-
# map_dir = self.eval_dir + "/" + self.controllers[controller_id]["Name"] + "/plots/"
99-
# env.RecordPlotData()
100-
# env.PlotMapVoronoi(map_dir, step_count)
101-
102102
if self.controllers_configs[controller_id]["Type"] == "Learning":
103103
Controller = ControllerNN
104104
else:
@@ -114,28 +114,39 @@ def evaluate(self, save=True):
114114

115115
while step_count < self.num_steps:
116116
objective_value, converged = controller.step(env)
117-
cost_data[controller_id, env_count, step_count] = (
117+
normalized_objective_value = (
118118
objective_value / initial_objective_value
119119
)
120+
cost_data[controller_id, env_count, step_count] = (
121+
normalized_objective_value
122+
)
123+
124+
step_count = step_count + 1
120125

121126
if converged:
122127
cost_data[controller_id, env_count, step_count:] = (
123-
objective_value / initial_objective_value
128+
normalized_objective_value
124129
)
130+
step_count = self.num_steps - 1
125131

126-
break
127-
# env.PlotMapVoronoi(map_dir, step_count)
128-
# env.RecordPlotData()
132+
if (step_count) % 10 == 0 or step_count == self.num_steps - 1:
133+
info = f"Controller {controller_id}/{self.num_controllers}: {controller.name} "
129134

130-
if step_count % 10 == 0:
131-
info = (
132-
f"{controller_id}/{self.num_controllers} {controller.name} "
133-
f"Step: {step_count:{len(str(self.num_steps))}} Obj: {cost_data[controller_id, env_count, step_count]:.2e}"
135+
progress.update(
136+
task,
137+
info=info,
138+
step_count=step_count,
139+
obj=normalized_objective_value,
134140
)
135-
progress.update(task, info=info)
136141
progress.refresh()
137142

138-
step_count = step_count + 1
143+
if converged:
144+
break
145+
146+
if controller_id == self.num_controllers - 1:
147+
info = f"Controller {controller_id + 1}/{self.num_controllers}: {controller.name} "
148+
progress.update(task, info=info)
149+
progress.refresh()
139150

140151
if save is True:
141152
self.controller_dir = (

0 commit comments

Comments
 (0)