import pandas as pd
import matplotlib.pyplot as plt
def plot_pareto_front(csv_filename: str):
try:
df = pd.read_csv(csv_filename)
if "f1" not in df.columns or "f2" not in df.columns:
print(
f"Error: CSV file '{csv_filename}' must contain 'f1' and 'f2' columns."
)
return
plt.figure(figsize=(10, 8))
plt.scatter(df["f1"], df["f2"], c="blue", label="Pareto Front Solutions")
plt.title("Pareto Front for Binh and Korn Problem", fontsize=16)
plt.xlabel("f1", fontsize=12)
plt.ylabel("f2", fontsize=12)
plt.grid(True, linestyle="--", alpha=0.6)
plt.legend()
plt.show()
except FileNotFoundError:
print(f"Error: The file '{csv_filename}' was not found.")
except Exception as e:
print(f"An error occurred: {e}")
if __name__ == "__main__":
filename = "target/binh_and_korn_pareto.csv"
plot_pareto_front(filename)