Plotting Convergence for Multi-Objective Optimization
Yeshwanth Nagaraj
Democratizing Math and Core AI // Levelling playfield for the future
Objective Space Plot Illustration :
To illustrate how a population in a multi-objective optimization problem evolves over generations towards the Pareto front, let's create a hypothetical scenario. We'll have the same two objectives as before, and I'll generate sample data for four generations. Each generation will represent the population at that point in the optimization process.
We'll observe how the solutions in each generation move closer to the Pareto optimal front, which is the set of solutions that are not dominated by any other solution in terms of both objectives.
import numpy as np
# Generating sample data for 4 generations
np.random.seed(0)
generations = 4
solutions_per_generation = 10
# Random data generation for illustration
data = {}
for gen in range(1, generations + 1):
data[f"Generation {gen}"] = {
"Objective 1": np.random.rand(solutions_per_generation) * (generations - gen + 1),
"Objective 2": np.random.rand(solutions_per_generation) * (generations - gen + 1)
}
# Plotting
plt.figure(figsize=(10, 8))
for gen, values in data.items():
plt.scatter(values["Objective 1"], values["Objective 2"], label=gen)
plt.xlabel('Objective 1')
plt.ylabel('Objective 2')
plt.title('Evolution of Solutions Over Generations')
plt.legend()
plt.grid(True)
plt.show()
Convergence Metric Graph :
Let's say you have a multi-objective algorithm running for 100 generations. You calculate the Hypervolume at each generation. A typical plot might show a rapid increase in the initial generations, indicating quick convergence, followed by a slower ascent or plateau as the algorithm refines the solutions.
This plot can also be used to compare different algorithms: if one algorithm’s Hypervolume increases more quickly or reaches a higher value, it can be considered as having better performance in terms of convergence and diversity.
Caveats
This type of plot is very useful for visualizing and comparing the performance of multi-objective optimization algorithms, especially when the primary goal is to understand how quickly and effectively the algorithms converge to a good approximation of the Pareto front.
领英推荐
import matplotlib.pyplot as plt
import numpy as np
# Generate sample data for demonstration purposes
# Hypothetical hypervolume values for 100 generations
np.random.seed(0)
hypervolume_values = np.cumsum(np.random.rand(100) * 0.05) # Cumulative sum to simulate increasing trend
# Number of generations
generations = np.arange(1, 101)
# Plotting the convergence metric (Hypervolume) over generations
plt.figure(figsize=(10, 6))
plt.plot(generations, hypervolume_values, marker='o', color='b', linestyle='-', linewidth=1, markersize=4)
plt.title('Convergence Metric Plot: Hypervolume over Generations')
plt.xlabel('Generation')
plt.ylabel('Hypervolume')
plt.grid(True)
plt.show()
Here is the Convergence Metric Plot illustrating the Hypervolume over generations for a multi-objective optimization algorithm. In this hypothetical example:
You can observe how the Hypervolume increases over generations. Initially, there is a more rapid increase, indicating quick convergence towards better solutions. As the generations progress, the increase in Hypervolume slows down, suggesting that the algorithm is refining the solutions and approaching a state of convergence.
This type of plot is valuable for assessing the performance of a multi-objective optimization algorithm, particularly in terms of its ability to converge towards and cover the Pareto front effectively.
Parallel Coordinates Plot :
The Parallel Coordinates Plot above visualizes the performance of multiple solutions across different objectives in a multi-objective optimization scenario. This plot is particularly useful when dealing with more than two objectives, as it provides a clear view of how each solution fares across all objectives simultaneously.
In this hypothetical example:
This visualization helps in understanding the trade-offs between different objectives for each solution. For instance, a solution that performs very well on one objective but poorly on another will have a line that spans a wide range across the vertical axes.
The use of different colors for each solution enhances the clarity of the plot, making it easier to distinguish between the performance of each solution. This kind of plot is instrumental in multi-objective optimization for comparing solutions and understanding the trade-offs involved.
import pandas as pd
import matplotlib.pyplot as plt
from pandas.plotting import parallel_coordinates
# Generate sample data for demonstration purposes
# Hypothetical objective values for a set of solutions
np.random.seed(0)
num_solutions = 30
num_objectives = 4
# Creating a DataFrame with sample data
data = np.random.rand(num_solutions, num_objectives)
df = pd.DataFrame(data, columns=[f'Objective {i+1}' for i in range(num_objectives)])
df['Solution'] = [f'Solution {i+1}' for i in range(num_solutions)]
# Plotting the Parallel Coordinates Plot
plt.figure(figsize=(10, 6))
parallel_coordinates(df, 'Solution', colormap=plt.get_cmap("Set2"))
plt.title('Parallel Coordinates Plot for Multi-Objective Optimization')
plt.xlabel('Objectives')
plt.ylabel('Values')
plt.grid(True)
plt.show()