|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sourceforge.cilib.algorithm.Algorithm
public abstract class Algorithm
All algorithms in CIlib should be subclasses of Algorithm
. This class handles
stopping criteria, events, threading and measurements. Subclasses of Algorithm
must provide an implementation for protected abstract void performIteration()
. If
a subclass overrides initialise()
then it must call super.initialise()
.
Failure to do so will cause an InitialisationException to be thrown when run()
is called.
Field Summary | |
---|---|
protected OptimisationProblem |
optimisationProblem
|
Constructor Summary | |
---|---|
protected |
Algorithm()
Default constructor for Algorithm classes. |
protected |
Algorithm(Algorithm copy)
Copy constructor. |
Method Summary | |
---|---|
void |
addAlgorithmListener(AlgorithmListener listener)
Adds an algorithm event listener. |
void |
addStoppingCondition(StoppingCondition stoppingCondition)
Adds a stopping condition. |
protected abstract void |
algorithmIteration()
The actual operations that the current Algorithm performs within a single iteration. |
static Algorithm |
get()
Accessor for the top-level currently executing algorithm running in the current thread. |
static List<Algorithm> |
getAlgorithmList()
Static accessor to allow the current level of algorithm composition to be returned. |
abstract OptimisationSolution |
getBestSolution()
Get the best current solution. |
abstract Algorithm |
getClone()
Create a cloned copy of the current object and return it. |
int |
getIterations()
Returns the number of iterations that have been performed by the algorihtm. |
OptimisationProblem |
getOptimisationProblem()
Get the specified OptimisationProblem. |
double |
getPercentageComplete()
Returns the percentage the algorithm is from completed (as a fraction). |
abstract List<OptimisationSolution> |
getSolutions()
Get the collection of best solutions. |
List<StoppingCondition> |
getStoppingConditions()
Get the current list of StoppingCondition instances that are associated with the current Algorithm. |
void |
initialise()
Initialises the algorithm. |
boolean |
isFinished()
Returns true if the algorithm has finished executing. |
void |
performInitialisation()
Perform the needed initialisation required before the execution of the algorithm starts. |
void |
performIteration()
Perform the actions of the current Algorithm for a single iteration. |
void |
performUninitialisation()
Perform the needed unintialisation steps after the algorithm completes it's execution. |
void |
removeAlgorithmListener(AlgorithmListener listener)
Removes an algorithm event listener. |
void |
removeStoppingCondition(StoppingCondition stoppingCondition)
Removes a stopping condition. |
void |
reset()
Reset the Algorithm internals if needed. |
void |
run()
Executes the algorithm. |
void |
setOptimisationProblem(OptimisationProblem problem)
Set the optimisation problem to be solved. |
void |
terminate()
Terminates the algorithm. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected OptimisationProblem optimisationProblem
Constructor Detail |
---|
protected Algorithm()
protected Algorithm(Algorithm copy)
copy
- The instance to copy.Method Detail |
---|
public abstract Algorithm getClone()
getClone
in interface Cloneable
Object.clone()
public void reset()
public final void initialise()
run()
is called.
public final void performIteration()
protected abstract void algorithmIteration()
public void performInitialisation()
public void performUninitialisation()
public void run()
run
in interface Runnable
InitialisationException
- algorithm was not properly initialised.public final void addStoppingCondition(StoppingCondition stoppingCondition)
stoppingCondition
- A StoppingCondition
to be added.public final void removeStoppingCondition(StoppingCondition stoppingCondition)
stoppingCondition
- The StoppingCondition
to be removed.public final void addAlgorithmListener(AlgorithmListener listener)
listener
- An AlgorithmListener
to be added.public final void removeAlgorithmListener(AlgorithmListener listener)
listener
- The AlgorithmListener
to be removed.public final int getIterations()
public final double getPercentageComplete()
public final boolean isFinished()
public final void terminate()
public static Algorithm get()
public static List<Algorithm> getAlgorithmList()
AlgorithmStack.asList()
public List<StoppingCondition> getStoppingConditions()
public void setOptimisationProblem(OptimisationProblem problem)
null
.
That is, it is necessary to set the optimisation problem before calling initialise()
.
problem
- An implementation of the
OptimisationProblemAdapter
interface.public OptimisationProblem getOptimisationProblem()
public abstract OptimisationSolution getBestSolution()
OptimisationSolution
representing the best solution.public abstract List<OptimisationSolution> getSolutions()
Collection<OptimisationSolution>
containing the solutions.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |