You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have added the following code in order to show the progress being made when running the model-checker:
def progress_bar(max_time, stop_event):
"""Show progress bar for how much of max_time has elapsed."""
step_time = max_time / 100
with tqdm(
desc="Running model-checker: ",
total=100,
unit="step",
bar_format="{l_bar}{bar}| {n_fmt}/{total_fmt}",
) as pbar:
while not stop_event.is_set():
time.sleep(step_time) # NOTE: gives bad result if multiplied by 4
pbar.update(1)
if pbar.n >= 100:
stop_event.set() # Signal the progress bar to stop
def create_model_setup(module):
"""Creates a model setup based on module attributes."""
return make_model_for(
module.N,
module.premises,
module.conclusions,
module.max_time,
module.contingent_bool,
module.disjoint_bool,
)
def handle_timeout(module, model_setup):
"""Handles timeout scenarios by asking the user for a new time limit."""
print(f"The model timed out at {model_setup.model_runtime} seconds.")
new_max_time = ask_time(model_setup.model_runtime, model_setup.max_time)
if new_max_time is None:
print("Terminating the process.")
os._exit(1)
module.update_max_time(new_max_time)
def optimize_model_setup(module, optimize_model):
"""Runs make_model_for on the values provided by the module and user, optimizing if required."""
max_time = module.max_time
stop_event = Event()
progress_thread = Thread(target=progress_bar, args=(max_time, stop_event))
progress_thread.start()
model_setup = None
try:
model_setup = create_model_setup(module)
run_time = model_setup.model_runtime
if run_time > max_time:
handle_timeout(module, model_setup)
module, model_setup = optimize_model_setup(module, model_setup)
if optimize_model:
module, model_setup = optimize_N(module, model_setup, module, model_setup)
finally:
stop_event.set() # Signal the progress bar to stop
progress_thread.join(timeout=max_time) # Wait for the thread to finish
return module, model_setup
It seems to work well in all circumstances, however, when optimize_bool = True there is a delay after the bar completes. I haven't been able to figure out how to include whatever processing it is doing during that time in the completion of the bar. I also noticed that there are some strange results when the step_time in time.sleep(step_time) is multiplied by 4. I'm not sure what to make of either of these results.
The text was updated successfully, but these errors were encountered:
I have added the following code in order to show the progress being made when running the
model-checker
:It seems to work well in all circumstances, however, when
optimize_bool = True
there is a delay after the bar completes. I haven't been able to figure out how to include whatever processing it is doing during that time in the completion of the bar. I also noticed that there are some strange results when thestep_time
intime.sleep(step_time)
is multiplied by4
. I'm not sure what to make of either of these results.The text was updated successfully, but these errors were encountered: