Class EvolutionMonitor<T>
- java.lang.Object
-
- org.uncommons.watchmaker.swing.evolutionmonitor.EvolutionMonitor<T>
-
- Type Parameters:
T
- The type of the evolved entities monitored by this component.
- All Implemented Interfaces:
EvolutionObserver<T>
,IslandEvolutionObserver<T>
public class EvolutionMonitor<T> extends Object implements IslandEvolutionObserver<T>
The Evolution Monitor is a component that can be attached to anEvolutionEngine
to provide real-time information (in a Swing GUI) about the current state of the evolution.
-
-
Constructor Summary
Constructors Constructor Description EvolutionMonitor()
Creates an EvolutionMonitor with a single panel that graphs the fitness scores of the population from generation to generation.EvolutionMonitor(boolean islands)
Creates an EvolutionMonitor with a single panel that graphs the fitness scores of the population from generation to generation.EvolutionMonitor(Renderer<? super T,JComponent> renderer, boolean islands)
Creates an EvolutionMonitor with a second panel that displays a graphical representation of the fittest candidate in the population.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JComponent
getGUIComponent()
void
islandPopulationUpdate(int islandIndex, PopulationData<? extends T> populationData)
Method called to notify the listener of the state of the population of an individual island.void
populationUpdate(PopulationData<? extends T> populationData)
Invoked when the state of the population has changed (typically at the end of a generation).void
showInDialog(JFrame owner, String title, boolean modal)
Displays the evolution monitor component in a newJDialog
.void
showInFrame(String title, boolean exitOnClose)
Displays the evolution monitor component in a newJFrame
.
-
-
-
Constructor Detail
-
EvolutionMonitor
public EvolutionMonitor()
Creates an EvolutionMonitor with a single panel that graphs the fitness scores of the population from generation to generation.
If you are using
IslandEvolution
, use theEvolutionMonitor(boolean)
constructor instead, to enable island support.
-
EvolutionMonitor
public EvolutionMonitor(boolean islands)
Creates an EvolutionMonitor with a single panel that graphs the fitness scores of the population from generation to generation.- Parameters:
islands
- Whether the monitor should be configured for displaying data fromIslandEvolution
. Set this parameter to false when using a standardEvolutionEngine
or if you don't want to display island-specific data for island evolution.
-
EvolutionMonitor
public EvolutionMonitor(Renderer<? super T,JComponent> renderer, boolean islands)
Creates an EvolutionMonitor with a second panel that displays a graphical representation of the fittest candidate in the population.- Parameters:
renderer
- Renders a candidate solution as a JComponent.islands
- Whether the monitor should be configured for displaying data fromIslandEvolution
. Set this parameter to false when using a standardEvolutionEngine
-
-
Method Detail
-
populationUpdate
public void populationUpdate(PopulationData<? extends T> populationData)
Invoked when the state of the population has changed (typically at the end of a generation).- Specified by:
populationUpdate
in interfaceEvolutionObserver<T>
- Parameters:
populationData
- Statistics about the state of the current generation.
-
islandPopulationUpdate
public void islandPopulationUpdate(int islandIndex, PopulationData<? extends T> populationData)
Method called to notify the listener of the state of the population of an individual island. This will be called once for each generation on each island.- Specified by:
islandPopulationUpdate
in interfaceIslandEvolutionObserver<T>
- Parameters:
islandIndex
- Identifies which individual island the data comes from. Indices start at zero and are sequential.populationData
- The latest data from the evolution on the specified island.
-
getGUIComponent
public JComponent getGUIComponent()
-
showInFrame
public void showInFrame(String title, boolean exitOnClose)
Displays the evolution monitor component in a newJFrame
. There is no need to make sure this method is invoked from the Event Dispatch Thread, the method itself ensures that the window is created and displayed from the EDT.- Parameters:
title
- The title for the new frame.exitOnClose
- Whether the JVM should exit when the frame is closed. Useful if this is the only application window.
-
showInDialog
public void showInDialog(JFrame owner, String title, boolean modal)
Displays the evolution monitor component in a newJDialog
. There is no need to make sure this method is invoked from the Event Dispatch Thread, the method itself ensures that the window is created and displayed from the EDT.- Parameters:
owner
- The owning frame for the new dialog.title
- The title for the new dialog.modal
- Whether the
-
-