I - class of which inputs stems fromO - class of which solution candidates and the eventually returned result stem frompublic interface IAlgorithm<I,O> extends java.lang.Iterable<AlgorithmEvent>, java.util.Iterator<AlgorithmEvent>, java.util.concurrent.Callable<O>, Cancelable
| Modifier and Type | Method and Description |
|---|---|
O |
call()
Overrides the call of Callable to restrict the set of allowed exceptions
|
IAlgorithmConfig |
getConfig() |
java.lang.String |
getId()
globally unique identifier for the algorithm run
|
I |
getInput() |
int |
getNumCPUs() |
TimeOut |
getTimeout() |
AlgorithmEvent |
nextWithException()
Continues the execution of the algorithm until the next event is emitted.
|
void |
registerListener(java.lang.Object listener)
Registers a listener to the algorithm's event bus.
|
void |
setMaxNumThreads(int maxNumberOfThreads)
While setNumCPUs aims at telling the algorithm how many CPUs *should* be used for parallelization,
this method can be used to define a strict constraint on the number of threads that must be spawned
by the algorithm itself at most.
|
void |
setNumCPUs(int numberOfCPUs) |
void |
setTimeout(long timeout,
java.util.concurrent.TimeUnit timeUnit)
Sets the timeout for the algorithm to the given value in the given time unit.
|
void |
setTimeout(TimeOut timeout) |
cancelI getInput()
void registerListener(java.lang.Object listener)
listener - The listener to register.int getNumCPUs()
void setNumCPUs(int numberOfCPUs)
numberOfCPUs - The numer of cpus that is allowed to be used by the algorithm.void setMaxNumThreads(int maxNumberOfThreads)
setNumCPUs
does not put such a restriction, because this is unnecessarily limiting in environment where such
constraints do not exist.
If the value is set to 0, no own threads must be used at all. Note that this may not be possible for
some algorithms that need observers in the background.
If the value is set to -1, any restriction on the number of threads is removed.
Note that different algorithms may have different default behaviors if this number is not set.maxNumberOfThreads - The maximum number of threads that may be spawned by the algorithm itself.void setTimeout(long timeout,
java.util.concurrent.TimeUnit timeUnit)
timeout - The number of e.g. ms, seconds, minutes according to the given time unit.timeUnit - The time unit for which the timeout variable will be interpreted.void setTimeout(TimeOut timeout)
timeout - The timeout for the algorithm.TimeOut getTimeout()
AlgorithmEvent nextWithException() throws java.lang.InterruptedException, AlgorithmExecutionCanceledException, AlgorithmTimeoutedException, AlgorithmException
java.lang.Exceptionjava.lang.InterruptedExceptionAlgorithmExecutionCanceledExceptionAlgorithmTimeoutedExceptionAlgorithmExceptionIAlgorithmConfig getConfig()
O call() throws java.lang.InterruptedException, AlgorithmExecutionCanceledException, AlgorithmTimeoutedException, AlgorithmException
call in interface java.util.concurrent.Callable<O>java.lang.InterruptedExceptionAlgorithmExecutionCanceledExceptionAlgorithmTimeoutedExceptionAlgorithmExceptionjava.lang.String getId()