|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.coinor.opents.TabuSearchBase
org.coinor.opents.SingleThreadedTabuSearch
org.coinor.opents.MultiThreadedTabuSearch
This version of the TabuSearch
can create multiple threads to take advantage
of multiple processors. If more than one thread is requested, then the neighborhood
will be split up evenly after the getAllMoves()
method is called
on your MoveManager
.
TabuSearch
for nearly all well-threaded
applications because it does not block on the startSolving()
method. When done
solving a given set of iterations, the thread will die, freeing up your computer's resources.
If you add iterations with setIterationsToGo()
and call
startSolving()
again,
the thread(s) will restart.
This code is licensed for public use under the Common Public License version 0.5.
The Common Public License, developed by IBM and modeled after their industry-friendly IBM Public License,
differs from other common open source licenses in several important ways:
Copyright © 2001 Robert Harder
Nested Class Summary | |
protected static class |
MultiThreadedTabuSearch.NeighborhoodHelper
|
Field Summary |
Fields inherited from class org.coinor.opents.SingleThreadedTabuSearch |
aspirationCriteria, bestSolution, chooseFirstImprovingMove, currentSolution, err, fireImprovingMoveMade, fireNewBestSolution, fireNewCurrentSolution, fireNoChangeInValueMoveMade, fireUnimprovingMoveMade, iterationsToGo, keepSolving, maximizing, moveManager, objectiveFunction, solving, tabuList |
Constructor Summary | |
MultiThreadedTabuSearch()
Constructs a MultiThreadedTabuSearch with no tabu objects set. |
|
MultiThreadedTabuSearch(Solution initialSolution,
MoveManager moveManager,
ObjectiveFunction objectiveFunction,
TabuList tabuList,
AspirationCriteria aspirationCriteria,
boolean maximizing)
Constructs a MultiThreadedTabuSearch with all tabu objects set. |
Method Summary | |
protected java.lang.Object[] |
getBestMove(Solution soln,
Move[] moves,
ObjectiveFunction objectiveFunction,
TabuList tabuList,
AspirationCriteria aspirationCriteria,
boolean maximizing,
boolean chooseFirstImprovingMove)
Gets the best move--one that should be used for this iteration. |
int |
getThreadPriority()
Returns the thread priority setting for the threads used by the tabu search. |
int |
getThreads()
Returns the number of threads to use when evaluating the tabu search neighborhood. |
void |
setThreadPriority(int threadPriority)
Set the thread priority to use for all threads. |
void |
setThreads(int threads)
Set the number of threads to use when evaluating the tabu search neighborhood. |
void |
startSolving()
Starts the tabu search solving in another thread and immediately returns control to the calling thread. |
void |
stopSolving()
Stops the tabu search and preserves the number of iterations remaining. |
void |
waitToFinish()
Blocks until the tabu search reaches zero iterations to go. |
Methods inherited from class org.coinor.opents.TabuSearchBase |
addTabuSearchListener, fireImprovingMoveMade, fireNewBestSolution, fireNewCurrentSolution, fireNoChangeInValueMoveMade, fireTabuSearchStarted, fireTabuSearchStopped, fireUnimprovingMoveMade, getIterationsCompleted, incrementIterationsCompleted, removeTabuSearchListener |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public MultiThreadedTabuSearch()
public MultiThreadedTabuSearch(Solution initialSolution, MoveManager moveManager, ObjectiveFunction objectiveFunction, TabuList tabuList, AspirationCriteria aspirationCriteria, boolean maximizing)
initialSolution
- The initial currentSolutionmoveManager
- The move managerobjectiveFunction
- The objective functiontabuList
- The tabu listaspirationCriteria
- The aspiration criteria or null if none is to be usedmaximizing
- Whether or not the tabu search should be maximizing the objective functionSolution
,
ObjectiveFunction
,
MoveManager
,
TabuList
,
AspirationCriteria
Method Detail |
public void setThreads(int threads)
threads
- The number of threads to use when evaluating the neighborhoodpublic int getThreads()
public void setThreadPriority(int threadPriority)
java.lang.Thread#MIN_VALUE
or
greater than java.lang.Thread#MAX_VALUE
then the value will actually be set to
java.lang.Thread#MIN_VALUE
or java.lang.Thread#MAX_VALUE
, whichever is closer.
If the tabu search is already running, this will not take effect until the tabu search restarts.
threadPriority
- public int getThreadPriority()
protected java.lang.Object[] getBestMove(Solution soln, Move[] moves, ObjectiveFunction objectiveFunction, TabuList tabuList, AspirationCriteria aspirationCriteria, boolean maximizing, boolean chooseFirstImprovingMove)
getBestMove
in class SingleThreadedTabuSearch
public void startSolving()
startSolving
in interface TabuSearch
startSolving
in class SingleThreadedTabuSearch
public void stopSolving()
stopSolving
in interface TabuSearch
stopSolving
in class SingleThreadedTabuSearch
public void waitToFinish()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |