Package org.uncommons.watchmaker.swing
Class SelectionStrategyControl<T>
- java.lang.Object
-
- org.uncommons.watchmaker.swing.SelectionStrategyControl<T>
-
- Type Parameters:
T- A generic type that matches the type associated with the selection strategies.
- All Implemented Interfaces:
EvolutionControl
public class SelectionStrategyControl<T> extends Object implements EvolutionControl
An evolution control for selecting between differentSelectionStrategyimplementations. This control provides a proxy selection strategy that delegates to the currently selected strategy. Using this proxy strategy with anEvolutionEnginemeans that any change to the combo-box selection is immediately reflected in the selection used by the running evolution engine.
-
-
Constructor Summary
Constructors Constructor Description SelectionStrategyControl(List<SelectionStrategy<? super T>> options)Creates a control for choosing between a specified set of selection strategies.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> List<SelectionStrategy<? super T>>createDefaultOptions(Probability tournamentProbability, double truncationRatio)Creates a list containing one instance of each of the standard selection strategies.JComboBoxgetControl()SelectionStrategy<T>getSelectionStrategy()voidreset()Resets the control to its initial configuration.voidsetDescription(String description)Provides a textual description of the purpose of the control.
-
-
-
Constructor Detail
-
SelectionStrategyControl
public SelectionStrategyControl(List<SelectionStrategy<? super T>> options)
Creates a control for choosing between a specified set of selection strategies.- Parameters:
options- The selection strategies to choose from.
-
-
Method Detail
-
createDefaultOptions
public static <T> List<SelectionStrategy<? super T>> createDefaultOptions(Probability tournamentProbability, double truncationRatio)
Creates a list containing one instance of each of the standard selection strategies. These strategies areRankSelection,RouletteWheelSelection,StochasticUniversalSampling,TournamentSelectionandTruncationSelection.- Parameters:
tournamentProbability- The probability parameter forTournamentSelection.truncationRatio- The ratio parameter forTruncationSelection.- Returns:
- A list of selection strategies.
-
getControl
public JComboBox getControl()
- Specified by:
getControlin interfaceEvolutionControl- Returns:
- The GUI component used by this control.
-
reset
public void reset()
Resets the control to its initial configuration.- Specified by:
resetin interfaceEvolutionControl
-
setDescription
public void setDescription(String description)
Provides a textual description of the purpose of the control. This may be displayed somewhere on the GUI component (typically as tooltip text).- Specified by:
setDescriptionin interfaceEvolutionControl- Parameters:
description- The description of the control.
-
getSelectionStrategy
public SelectionStrategy<T> getSelectionStrategy()
- Returns:
- A proxied
SelectionStrategythat delegates to whichever concrete selection strategy is currently selected.
-
-