mean.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import pandas as pd
  2. import numpy as np
  3. # file_path = 'benchmarks/Results/Agents/Time/LI_baseline.csv'
  4. file_path = 'benchmarks/Results/PyPDEVS/Time/minimal/LI_baseline.csv'
  5. # file_path = 'benchmarks/Results/PyPDEVS/Time/parallel/HOmod_baseline.csv'
  6. target_width = 200
  7. target_depth = 200
  8. def format_to_latex(mean, std):
  9. if std == 0:
  10. return f"${mean:.3f} \\pm 0.000$"
  11. std_magnitude = int(np.floor(np.log10(abs(std))))
  12. decimal_places = -std_magnitude
  13. if decimal_places >= 0:
  14. formatted_mean = f"{mean:.{decimal_places}f}"
  15. formatted_std = f"{std:.{decimal_places}f}"
  16. else:
  17. formatted_mean = f"{round(mean, decimal_places):.0f}"
  18. formatted_std = f"{round(std, decimal_places):.0f}"
  19. return f"${formatted_mean} \\pm {formatted_std}$"
  20. try:
  21. df = pd.read_csv(file_path)
  22. filtered_df = df[(df['depth'] == target_depth) & (df['width'] == target_width)]
  23. if filtered_df.empty:
  24. print(f"No rows found matching Depth={target_depth} and Width={target_width}.")
  25. else:
  26. combined_time = filtered_df['creation_time'] + filtered_df['setup_time'] + filtered_df['simulation_time']
  27. mean_val = combined_time.mean()
  28. std_sample = combined_time.std()
  29. latex_code = format_to_latex(mean_val, std_sample)
  30. print(f"--- Results for Width: {target_width} | Height: {target_depth} ---")
  31. print(f"Number of runs found: {len(filtered_df)}")
  32. print(f"Mean Combined Time: {mean_val:.6f} seconds")
  33. print(f"Standard Deviation: {std_sample:.6f} seconds")
  34. print("\n--- Copyable LaTeX Code ---")
  35. print(latex_code)
  36. except FileNotFoundError:
  37. print(f"Error: The file '{file_path}' could not be found. Please check the path and try again.")
  38. except Exception as e:
  39. print(f"An error occurred: {e}")