swarm 0.1.3

Fast blackbox optimisation tool.
Documentation
import pandas as pd
import matplotlib.pyplot as plt


def plot_pareto_front(csv_filename: str):
    """
    Reads optimisation results from a CSV file and plots the Pareto front.

    Args:
        csv_filename (str): The path to the CSV file containing the results.
    """
    try:
        # Read the data from the CSV file into a pandas DataFrame
        df = pd.read_csv(csv_filename)

        # Ensure the required columns exist
        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

        # Create the scatter plot
        plt.figure(figsize=(10, 8))
        plt.scatter(df["f1"], df["f2"], c="blue", label="Pareto Front Solutions")

        # Add titles and labels for clarity
        plt.title("Pareto Front for Binh and Korn Problem", fontsize=16)
        plt.xlabel("f1", fontsize=12)
        plt.ylabel("f2", fontsize=12)

        # Improve the visual appearance
        plt.grid(True, linestyle="--", alpha=0.6)
        plt.legend()

        # Show the plot
        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__":
    # The name of the file generated by your Rust test
    filename = "target/binh_and_korn_pareto.csv"
    plot_pareto_front(filename)