|
MOEA Framework 2.5 API Specification |
|||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||
java.lang.Objectorg.moeaframework.algorithm.AbstractAlgorithm
public abstract class AbstractAlgorithm
Abstract class providing default implementations for several
Algorithm methods. All method extending this class must use the
evaluate(org.moeaframework.core.Solution) method to evaluate a solution. This is mandatory to ensure
the getNumberOfEvaluations() method returns the correct result.
Subclasses should avoid overriding the step() method and instead
override the initialize() and iterate() methods
individually.
| Field Summary | |
|---|---|
protected boolean |
initialized
true if the initialize() method has been invoked;
false otherwise. |
protected int |
numberOfEvaluations
The number of times the evaluate(org.moeaframework.core.Solution) method was invoked. |
protected Problem |
problem
The problem being solved. |
protected boolean |
terminated
true if the terminate() method has been invoked;
false otherwise. |
| Constructor Summary | |
|---|---|
AbstractAlgorithm(Problem problem)
Constructs an abstract algorithm for solving the specified problem. |
|
| Method Summary | |
|---|---|
void |
evaluate(Solution solution)
Evaluates the specified solution for the problem being solved by this algorithm. |
void |
evaluateAll(Iterable<Solution> solutions)
Evaluates the specified solutions. |
void |
evaluateAll(Solution[] solutions)
Evaluates the specified solutions. |
protected void |
finalize()
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. |
int |
getNumberOfEvaluations()
Returns the number of times the evaluate method was invoked. |
Problem |
getProblem()
Returns the problem being solved by this algorithm. |
Serializable |
getState()
Returns a Serializable object representing the internal state of
this algorithm. |
protected void |
initialize()
Performs any initialization that is required by this algorithm. |
boolean |
isInitialized()
Returns true if the initialize() method has been
invoked; false otherwise. |
boolean |
isTerminated()
Returns true if this algorithm is terminated; false
otherwise. |
protected abstract void |
iterate()
Performs one iteration of the algorithm. |
void |
setState(Object state)
Sets the internal state of of this algorithm. |
void |
step()
This method first checks if the algorithm is initialized. |
void |
terminate()
Implementations should always invoke super.terminate() to ensure
the hierarchy is terminated correctly. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.moeaframework.core.Algorithm |
|---|
getResult |
| Field Detail |
|---|
protected final Problem problem
protected int numberOfEvaluations
evaluate(org.moeaframework.core.Solution) method was invoked.
protected boolean initialized
true if the initialize() method has been invoked;
false otherwise.
protected boolean terminated
true if the terminate() method has been invoked;
false otherwise.
| Constructor Detail |
|---|
public AbstractAlgorithm(Problem problem)
problem - the problem being solved| Method Detail |
|---|
public void evaluateAll(Iterable<Solution> solutions)
evaluate(Solution) on each of the solutions. Subclasses should
prefer calling this method over evaluate whenever possible,
as this ensures the solutions can be evaluated in parallel.
solutions - the solutions to evaluatepublic void evaluateAll(Solution[] solutions)
evaluateAll(Arrays.asList(solutions)).
solutions - the solutions to evaluatepublic void evaluate(Solution solution)
Algorithm
evaluate in interface Algorithmsolution - the solution to be evaluatedProblem.evaluate(Solution)public int getNumberOfEvaluations()
Algorithmevaluate method was invoked. This
is the primary measure of runtime for optimization algorithms.
getNumberOfEvaluations in interface Algorithmevaluate method was invokedpublic Problem getProblem()
Algorithm
getProblem in interface Algorithmprotected void initialize()
step(), but may also be called manually prior to any invocations
of step. Implementations should always invoke
super.initialize() to ensure the hierarchy is initialized
correctly.
AlgorithmInitializationException - if the algorithm has already
been initializedpublic boolean isInitialized()
true if the initialize() method has been
invoked; false otherwise.
true if the initialize() method has been
invoked; false otherwisepublic void step()
initialize() method is invoked. If initialized, all calls to
step invoke iterate(). Implementations should override
the initialize and iterate methods in preference to
modifying this method.
step in interface AlgorithmAlgorithmTerminationException - if the algorithm has already
terminatedprotected abstract void iterate()
public boolean isTerminated()
Algorithmtrue if this algorithm is terminated; false
otherwise.
isTerminated in interface Algorithmtrue if this algorithm is terminated; false
otherwiseAlgorithm.terminate()public void terminate()
super.terminate() to ensure
the hierarchy is terminated correctly. This method is automatically
invoked during finalization, and need only be called directly if
non-Java resources are in use.
terminate in interface AlgorithmAlgorithmTerminationException - if the algorithm has already
terminated
protected void finalize()
throws Throwable
java.lang.Objectfinalize method to dispose of
system resources or to perform other cleanup.
The general contract of finalize is that it is invoked if and when the JavaTM virtual machine has determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, except as a result of an action taken by the finalization of some other object or class which is ready to be finalized. The finalize method may take any action, including making this object available again to other threads; the usual purpose of finalize, however, is to perform cleanup actions before the object is irrevocably discarded. For example, the finalize method for an object that represents an input/output connection might perform explicit I/O transactions to break the connection before the object is permanently discarded.
The finalize method of class Object performs no special action; it simply returns normally. Subclasses of Object may override this definition.
The Java programming language does not guarantee which thread will invoke the finalize method for any given object. It is guaranteed, however, that the thread that invokes finalize will not be holding any user-visible synchronization locks when finalize is invoked. If an uncaught exception is thrown by the finalize method, the exception is ignored and finalization of that object terminates.
After the finalize method has been invoked for an object, no further action is taken until the Java virtual machine has again determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, including possible actions by other objects or classes which are ready to be finalized, at which point the object may be discarded.
The finalize method is never invoked more than once by a Java virtual machine for any given object.
Any exception thrown by the finalize method causes
the finalization of this object to be halted, but is otherwise
ignored.
finalize in class ObjectThrowable - the Exception raised by this method
public Serializable getState()
throws NotSerializableException
AlgorithmSerializable object representing the internal state of
this algorithm.
getState in interface AlgorithmSerializable object representing the internal state of
this algorithm
NotSerializableException - if this algorithm does not support
serialization
public void setState(Object state)
throws NotSerializableException
Algorithm
setState in interface Algorithmstate - the internal state of this algorithm
NotSerializableException - if this algorithm does not support
serialization
|
MOEA Framework 2.5 API Specification |
|||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||