Orbital library

orbital.moon.evolutionary
Class BreederControl

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by javax.swing.JFrame
                      extended by orbital.moon.evolutionary.BreederControl
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.lang.Runnable, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants

public class BreederControl
extends javax.swing.JFrame
implements java.lang.Runnable

front-end for evolutionary algorithms.

Author:
André Platzer
See Also:
Serialized Form
Stereotype:
UI, Tool

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
 
Nested classes/interfaces inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  Closer closer
           
protected  CustomizerViewController custom
           
protected  orbital.moon.evolutionary.PopulationTableModel data
           
static int defaultChildren
           
static double defaultMaxMutation
           
static double defaultMaxRecombination
           
static int defaultParents
          default values
protected  java.io.File file
          Current population file processed.
protected  GeneticAlgorithm ga
          The current genetic algorithm.
protected  GeneticAlgorithmProblem problem
          The current genetic algorithm problem to solve.
protected  java.util.logging.Logger protocol
          Protocol written for current population.
protected static java.util.ResourceBundle resources
          Program resources.
protected  int startGeneration
           
protected  java.util.Date startTime
           
protected  java.util.Date stopTime
           
static java.lang.String usage
           
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
BreederControl()
          Construct a BreederControl frame.
BreederControl(GeneticAlgorithmProblem problem)
          Construct a BreederControl frame for solving the given problem.
 
Method Summary
 void about()
           
static java.io.File changeExtension(java.io.File file, java.lang.String extension)
          Change the extension of a file name to a new one.
protected  GeneticAlgorithm create()
           
protected  Genome createGenome()
          Create a problem-specific genome prototype.
protected  java.awt.Component createStatusBar()
          Create a status bar to display.
 void destroy()
           
protected  void evolve()
          Evolves and updates view.
protected  void exportGenome(Genome genome, java.io.OutputStream os)
          Save genome to export.
 void fileExit_actionPerformed(java.awt.event.ActionEvent e)
           
protected  GeneticAlgorithm getGeneticAlgorithm()
          Get the current genetic algorithm used for solving.
protected  GeneticAlgorithmProblem getGeneticAlgorithmProblem()
          Get the current genetic algorithm problem to solve.
protected  int getInitialPopulationSize()
          Get the desired initial population size from the user.
protected  java.io.InputStream getInputStream(java.io.File file)
          Get an input stream for a file.
protected  java.io.OutputStream getOutputStream(java.io.File file)
          Get an output stream for a file.
protected  java.util.ResourceBundle getResources()
          Get program resources.
protected  java.lang.String getSelectedAlgorithmType()
          Get the algorithm type selected.
protected  void history()
          Store history file sequence.
protected  Genome importGenome(java.io.InputStream is)
          Load genome to import.
 void init()
           
protected  GeneticAlgorithm load(java.io.InputStream is)
          Load population and genetic algorithm.
static void main(java.lang.String[] arg)
          tool-main
protected  void manipulate(Genome c)
           
protected  void popEnable(boolean e)
          Enable menu options etc.
protected  void properties(GeneticAlgorithm ga)
           
protected  void protocol(java.lang.String text)
          Protocolize a text.
protected  void ready()
          Called when the breeder control is ready again.
 void run()
          Runnable-start entry point.
protected  void save(GeneticAlgorithm ga, java.io.OutputStream os)
          Save population and genetic algorithm.
protected  void setGeneticAlgorithmProblem(GeneticAlgorithmProblem gap)
           
 void start()
           
protected  void statistics(GeneticAlgorithm ga)
           
 void stop()
           
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Frame
addNotify, finalize, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setAlwaysOnTop, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationByPlatform, setLocationRelativeTo, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

defaultParents

public static final int defaultParents
default values

See Also:
Constant Field Values

defaultChildren

public static final int defaultChildren
See Also:
Constant Field Values

defaultMaxRecombination

public static final double defaultMaxRecombination
See Also:
Constant Field Values

defaultMaxMutation

public static final double defaultMaxMutation
See Also:
Constant Field Values

usage

public static final java.lang.String usage

resources

protected static final java.util.ResourceBundle resources
Program resources.


data

protected orbital.moon.evolutionary.PopulationTableModel data

custom

protected final CustomizerViewController custom

closer

protected Closer closer

startTime

protected java.util.Date startTime

stopTime

protected java.util.Date stopTime

startGeneration

protected int startGeneration

file

protected java.io.File file
Current population file processed.

See Also:
ga

protocol

protected java.util.logging.Logger protocol
Protocol written for current population.

See Also:
ga, protocolHeader(GeneticAlgorithm), protocolHandler

problem

protected GeneticAlgorithmProblem problem
The current genetic algorithm problem to solve.


ga

protected GeneticAlgorithm ga
The current genetic algorithm.

Constructor Detail

BreederControl

public BreederControl(GeneticAlgorithmProblem problem)
Construct a BreederControl frame for solving the given problem.


BreederControl

public BreederControl()
Construct a BreederControl frame.

Method Detail

main

public static void main(java.lang.String[] arg)
                 throws java.lang.Exception
tool-main

Throws:
java.lang.Exception

getResources

protected java.util.ResourceBundle getResources()
Get program resources.


getGeneticAlgorithmProblem

protected final GeneticAlgorithmProblem getGeneticAlgorithmProblem()
Get the current genetic algorithm problem to solve.

See Also:
problem

setGeneticAlgorithmProblem

protected final void setGeneticAlgorithmProblem(GeneticAlgorithmProblem gap)

getGeneticAlgorithm

protected final GeneticAlgorithm getGeneticAlgorithm()
Get the current genetic algorithm used for solving.

See Also:
ga

createGenome

protected Genome createGenome()
Create a problem-specific genome prototype. Used for mutation etc.

See Also:
Factory Method

create

protected GeneticAlgorithm create()
                           throws java.lang.InstantiationException
Throws:
java.lang.InstantiationException

load

protected GeneticAlgorithm load(java.io.InputStream is)
                         throws java.io.IOException,
                                java.lang.ClassNotFoundException
Load population and genetic algorithm.

Note: Remember that class names are relative to this package for serialization. If you desire your own package to be default, simply overwrite this method with the body

 super.load(is);
 
to circumvent confusion with different default packages.

Throws:
java.io.IOException
java.lang.ClassNotFoundException

save

protected void save(GeneticAlgorithm ga,
                    java.io.OutputStream os)
             throws java.io.IOException
Save population and genetic algorithm.

Throws:
java.io.IOException

properties

protected void properties(GeneticAlgorithm ga)

importGenome

protected Genome importGenome(java.io.InputStream is)
                       throws java.io.IOException,
                              java.lang.ClassNotFoundException
Load genome to import.

Returns:
the genome to import, or null if it should not be inserted. (either because it's invalid, or because it has already been inserted in a custom way).
Throws:
java.io.IOException
java.lang.ClassNotFoundException

exportGenome

protected void exportGenome(Genome genome,
                            java.io.OutputStream os)
                     throws java.io.IOException
Save genome to export.

Throws:
java.io.IOException

manipulate

protected void manipulate(Genome c)

getInputStream

protected java.io.InputStream getInputStream(java.io.File file)
                                      throws java.io.FileNotFoundException,
                                             java.io.IOException
Get an input stream for a file.

Overwrite to change the stream that data is read from.

Throws:
java.io.FileNotFoundException
java.io.IOException

getOutputStream

protected java.io.OutputStream getOutputStream(java.io.File file)
                                        throws java.io.FileNotFoundException,
                                               java.io.IOException
Get an output stream for a file.

Overwrite to change the stream that data is written to.

Throws:
java.io.FileNotFoundException
java.io.IOException

statistics

protected void statistics(GeneticAlgorithm ga)

protocol

protected void protocol(java.lang.String text)
Protocolize a text.


history

protected void history()
Store history file sequence.


start

public void start()

stop

public void stop()

run

public void run()
Runnable-start entry point.

Specified by:
run in interface java.lang.Runnable

ready

protected void ready()
Called when the breeder control is ready again.


getInitialPopulationSize

protected int getInitialPopulationSize()
                                throws java.lang.NumberFormatException
Get the desired initial population size from the user.

Throws:
java.lang.NumberFormatException

init

public void init()

destroy

public void destroy()

evolve

protected void evolve()
Evolves and updates view.


popEnable

protected void popEnable(boolean e)
Enable menu options etc. depending upon the population's presence.

Parameters:
e - true to enable some menu options etc. because a population is present. false to disable some menu options because no population is present.

getSelectedAlgorithmType

protected java.lang.String getSelectedAlgorithmType()
Get the algorithm type selected.

Returns:
the class name of the algorithm type selected.

createStatusBar

protected java.awt.Component createStatusBar()
Create a status bar to display.

See Also:
Factory Method

fileExit_actionPerformed

public void fileExit_actionPerformed(java.awt.event.ActionEvent e)

about

public void about()

changeExtension

public static java.io.File changeExtension(java.io.File file,
                                           java.lang.String extension)
Change the extension of a file name to a new one.

Parameters:
extension - the new extension (without '.').
Returns:
file with new extension, replacing the last old extension, if any.

Orbital library
1.3.0: 11 Apr 2009

Copyright © 1996-2009 André Platzer
All Rights Reserved.