@CodeReview(reviewer="Kevin R. Dixon",date="2008-02-08",changesNeeded=false,comments="Class looks fine.") @CodeReview(reviewer="Justin Basilico",date="2006-10-02",changesNeeded=false,comments="Interface is fine.") public abstract class AbstractIterativeAlgorithm extends AbstractCloneableSerializable implements IterativeAlgorithm
AbstractIterativeAlgorithm
class implements a simple part of
the IterativeAlgorithm
interface that manages the listeners for the
algorithm. It contains methods for firing off the various learning events.IterativeAlgorithm
,
Serialized FormModifier and Type | Field and Description |
---|---|
static int |
DEFAULT_ITERATION
The default iteration number is zero.
|
protected int |
iteration
Number of iterations the algorithm has executed.
|
Constructor and Description |
---|
AbstractIterativeAlgorithm()
Creates a new instance of
AbstractIterativeAlgorithm . |
AbstractIterativeAlgorithm(int iteration)
Creates a new instance of
AbstractIterativeAlgorithm . |
Modifier and Type | Method and Description |
---|---|
void |
addIterativeAlgorithmListener(IterativeAlgorithmListener listener)
Adds a listener for the iterations of the algorithm.
|
AbstractIterativeAlgorithm |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
protected void |
fireAlgorithmEnded()
Fires off a algorithm ended event for the algorithm, which notifies all
the listeners that the algorithm has ended.
|
protected void |
fireAlgorithmStarted()
Fires off a algorithm started event for this algorithm, which notifies
all of the listeners that the algorithm has started.
|
protected void |
fireStepEnded()
Fires off a algorithm ended event for the algorithm, which notifies all
the listeners that a step has ended.
|
protected void |
fireStepStarted()
Fires off a algorithm started event for the algorithm, which notifies
all the listeners that a step has started.
|
int |
getIteration()
Gets the current number of iterations executed by this algorithm since
its it was started.
|
protected java.util.LinkedList<IterativeAlgorithmListener> |
getListeners()
Retrieves the list of listeners for this algorithm.
|
void |
removeIterativeAlgorithmListener(IterativeAlgorithmListener listener)
Removes a listener for the iterations of the algorithm.
|
protected void |
setIteration(int iteration)
Sets the current iteration number.
|
protected void |
setListeners(java.util.LinkedList<IterativeAlgorithmListener> listeners)
Sets the list of listeners for this algorithm.
|
public static final int DEFAULT_ITERATION
protected int iteration
public AbstractIterativeAlgorithm()
AbstractIterativeAlgorithm
.public AbstractIterativeAlgorithm(int iteration)
AbstractIterativeAlgorithm
.iteration
- The initial iteration number.public AbstractIterativeAlgorithm clone()
AbstractCloneableSerializable
Object
class and
removes the exception that it throws. Its default behavior is to
automatically create a clone of the exact type of object that the
clone is called on and to copy all primitives but to keep all references,
which means it is a shallow copy.
Extensions of this class may want to override this method (but call
super.clone()
to implement a "smart copy". That is, to target
the most common use case for creating a copy of the object. Because of
the default behavior being a shallow copy, extending classes only need
to handle fields that need to have a deeper copy (or those that need to
be reset). Some of the methods in ObjectUtil
may be helpful in
implementing a custom clone method.
Note: The contract of this method is that you must use
super.clone()
as the basis for your implementation.clone
in interface CloneableSerializable
clone
in class AbstractCloneableSerializable
protected void fireAlgorithmStarted()
protected void fireAlgorithmEnded()
protected void fireStepStarted()
protected void fireStepEnded()
public void addIterativeAlgorithmListener(IterativeAlgorithmListener listener)
IterativeAlgorithm
addIterativeAlgorithmListener
in interface IterativeAlgorithm
listener
- The listener to add.public void removeIterativeAlgorithmListener(IterativeAlgorithmListener listener)
IterativeAlgorithm
removeIterativeAlgorithmListener
in interface IterativeAlgorithm
listener
- The listener to remove.protected java.util.LinkedList<IterativeAlgorithmListener> getListeners()
protected void setListeners(java.util.LinkedList<IterativeAlgorithmListener> listeners)
listeners
- The new list of listeners.public int getIteration()
IterativeAlgorithm
getIteration
in interface IterativeAlgorithm
protected void setIteration(int iteration)
iteration
- Number of iterations executed in the algorithm.