Class FrontPlotObserver<S extends Solution<?>>
java.lang.Object
org.uma.jmetal.util.observer.impl.FrontPlotObserver<S>
- Type Parameters:
S- Type of the solutions being observed, must extendSolution<?>
public class FrontPlotObserver<S extends Solution<?>>
extends Object
implements Observer<Map<String,Object>>
An observer that displays the current Pareto front during the execution of a multi-objective
optimization algorithm. It visualizes the solutions in a 2D scatter plot, showing how the front
evolves over time.
This observer is typically used to monitor the progress of multi-objective optimization algorithms by plotting the objective values of the current population. It can also display reference fronts for comparison and filter out dominated solutions if needed.
Example usage:
FrontPlotObserver<Solution<?>> observer = new FrontPlotObserver<>(
"Front Plot", "Objective 1", "Objective 2", "Population", 100);
algorithm.getObservable().register(observer);
- Author:
- Antonio J. Nebro
-
Constructor Summary
ConstructorsConstructorDescriptionFrontPlotObserver(String title, String xAxisTitle, String yAxisTitle, String legend, int plotUpdateFrequency) Creates a new FrontPlotObserver instance. -
Method Summary
Modifier and TypeMethodDescriptionorg.knowm.xchart.XYChartchart()Returns the underlying XYChart instance for advanced customization.voidfilterDominatedSolutions(boolean filterDominatedSolutions) Enables or disables filtering of dominated solutions.voidAdds a reference front to the plot for comparison with the current population.voidAdds a single point to the plot, which can be used to mark specific solutions or reference points.voidUpdates the plot with the current population from the optimization algorithm.
-
Constructor Details
-
FrontPlotObserver
public FrontPlotObserver(String title, String xAxisTitle, String yAxisTitle, String legend, int plotUpdateFrequency) Creates a new FrontPlotObserver instance.- Parameters:
title- The title of the plotxAxisTitle- Title for the X-axis (typically first objective name)yAxisTitle- Title for the Y-axis (typically second objective name)legend- Legend text for the population pointsplotUpdateFrequency- How often to update the plot (in number of evaluations)- Throws:
IllegalArgumentException- if plotUpdateFrequency is less than 1
-
-
Method Details
-
setFront
Adds a reference front to the plot for comparison with the current population. The reference front is typically a known Pareto-optimal front or another reference set of solutions.- Parameters:
front- 2D array where each row represents a solution in the reference frontfrontName- The name to display in the legend for this front- Throws:
IllegalArgumentException- if front is null or empty
-
setPoint
Adds a single point to the plot, which can be used to mark specific solutions or reference points.- Parameters:
x- X-coordinate of the point (first objective value)y- Y-coordinate of the point (second objective value)pointName- The name to display for this point in the legend
-
filterDominatedSolutions
public void filterDominatedSolutions(boolean filterDominatedSolutions) Enables or disables filtering of dominated solutions. When enabled, only non-dominated solutions from the current population will be displayed.- Parameters:
filterDominatedSolutions- If true, only non-dominated solutions will be plotted
-
update
Updates the plot with the current population from the optimization algorithm. This method is called automatically by the observed algorithm.- Specified by:
updatein interfaceObserver<S extends Solution<?>>- Parameters:
observable- The observable object (typically the optimization algorithm)data- Map containing the current state with the following expected keys: - "EVALUATIONS": Current number of evaluations (Integer) - "POPULATION": Current population of solutions (List)- Throws:
ClassCastException- if the data map contains values of unexpected types
-
chart
public org.knowm.xchart.XYChart chart()Returns the underlying XYChart instance for advanced customization. Use this method to modify chart properties not exposed by the FrontScatterPlot API.- Returns:
- The XYChart instance used for plotting
-