|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.usa.rharder.tabusearch22.TSEngine
The TSEngine
is the main source of control
for the programmer. The extended and instantiated
tabu objects are passed to the engine, and the engine
fires off relevant events to interested listeners. These
events make it easy to extend the tabu search to include
popular techniques such as intensification, diversification,
and strategic oscillation.
Field Summary | |
protected static boolean |
DEBUGGING
When set to true , information will be printed
to System.out and System.err at various
points in the code. |
Constructor Summary | |
TSEngine(TSSolution initialSolution,
TSTabuList tabuList,
TSFunction objectiveFunction,
TSFunction penaltyFunction,
TSMoveManager moveManager)
This most basic constructor assumes a maximization problem and uses just one thread for searching. |
|
TSEngine(TSSolution initialSolution,
TSTabuList tabuList,
TSFunction objectiveFunction,
TSFunction penaltyFunction,
TSMoveManager moveManager,
boolean maximizing)
This constructor lets you specify if you are maximizing or minimizing. |
|
TSEngine(TSSolution initialSolution,
TSTabuList tabuList,
TSFunction objectiveFunction,
TSFunction penaltyFunction,
TSMoveManager moveManager,
boolean maximizing,
int numberOfThreads)
This constructor lets you specify if you are maximizing or minimizing. |
Method Summary | |
void |
addEngineFinishedListener(TSEngineFinishedListener listener)
Registers listener to receive tabu events when
the engine finishes. |
void |
addEngineStartedListener(TSEngineStartedListener listener)
Registers listener to receive tabu events when
the engine starts. |
void |
addNewBestSolutionListener(TSNewBestSolutionListener listener)
Registers listener to receive tabu events when
a new best solution is found. |
void |
addNewCurrentSolutionListener(TSNewCurrentSolutionListener listener)
Registers listener to receive tabu events when a
new current solution is found. |
void |
addUnimprovingMoveListener(TSUnimprovingMoveListener listener)
Registers listener to receive tabu events when an
unimproving move is made. |
protected void |
fireEngineFinished()
This quick method is called when the engine finishes. |
protected void |
fireEngineStarted()
This quick method is called when the engine starts. |
protected void |
fireNewBestSolution()
This quick method is called when a new best solution is found. |
protected void |
fireNewCurrentSolution()
This quick method is called when a new current solution is found. |
protected void |
fireUnimprovingMoveMade()
This quick method is called when an unimproving move is made. |
TSSolution |
getBestSolution()
Returns the best solution found so far. |
int |
getCurrentIteration()
Returns the current iteration of the engine. |
TSSolution |
getCurrentSolution()
Returns the current solution. |
int |
getIterationOfBestSolution()
Returns the iteration number when the best solution was found. |
int |
getIterationsToGo()
Returns the iterations left in the engine. |
long |
getLastSolveMillis()
Returns the number of milliseconds it took to solve the last set of iterations. |
TSMoveManager |
getMoveManager()
Returns the move manager being used by the engine. |
TSMove[] |
getMovesUsedOnLastIteration()
Returns the moves that were used on the last iteration. |
TSFunction |
getObjectiveFunction()
Returns the objective function being used by the engine. |
TSFunction |
getPenaltyFunction()
Returns the penalty function being used by the engine. |
TSTabuList |
getTabuList()
Returns the tabu list that is being used by the engine. |
void |
removeEngineFinishedListener(TSEngineFinishedListener listener)
Removes listener from list of objects to notify
when the engine finished its appointed iterations. |
void |
removeEngineStartedListener(TSEngineStartedListener listener)
Removes listener from list of objects to notify
when the engine starts its appointed iterations. |
void |
removeNewBestSolutionListener(TSNewBestSolutionListener listener)
Removes listener from list of objects to notify
when a new best solution is found. |
void |
removeNewCurrentSolutionListener(TSNewCurrentSolutionListener listener)
Removes listener from list of objects to notify when
a new current solution is found. |
void |
removeUnimprovingMoveListener(TSUnimprovingMoveListener listener)
Removes listener from list of objects to notify
when an unimproving move is made. |
void |
setBestSolutionToCopyOf(TSSolution solution)
Sets the best solution to a copy of the passed solution. |
void |
setCurrentSolutionToCopyOf(TSSolution solution)
Sets the current solution to a copy of the passed solution. |
void |
startSolving(int additionalIterations)
Starts the engine solving for the given number of iterations. |
void |
stopSolving()
Stop the engine after the current iteration. |
void |
trySettingBestSolutionToCopyOf(TSSolution solution)
Sets the best solution to a copy of the passed solution but only if the new solution is better than the existing best solution. |
void |
waitToFinish()
Returns control when the engine has stopped. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
protected static final boolean DEBUGGING
true
, information will be printed
to System.out
and System.err
at various
points in the code.Constructor Detail |
public TSEngine(TSSolution initialSolution, TSTabuList tabuList, TSFunction objectiveFunction, TSFunction penaltyFunction, TSMoveManager moveManager)
initialSolution
- The initial solutiontabuList
- The tabu listobjectiveFunction
- The objective function. Note that the objective function
and the penalty function are really very much the same.
They are divided up for easier programming and for
possible future enhancements.penaltyFunction
- The penalty function.moveManager
- The Move Manager.TSSolution
,
TSTabuList
,
TSFunction
,
TSMoveManager
public TSEngine(TSSolution initialSolution, TSTabuList tabuList, TSFunction objectiveFunction, TSFunction penaltyFunction, TSMoveManager moveManager, boolean maximizing)
initialSolution
- The initial solutiontabuList
- The tabu listobjectiveFunction
- The objective function. Note that the objective function
and the penalty function are really very much the same.
They are divided up for easier programming and for
possible future enhancements.penaltyFunction
- The penalty function.moveManager
- The Move Manager.maximizing
- true
if maximizing, false if minimizingTSSolution
,
TSTabuList
,
TSFunction
,
TSMoveManager
public TSEngine(TSSolution initialSolution, TSTabuList tabuList, TSFunction objectiveFunction, TSFunction penaltyFunction, TSMoveManager moveManager, boolean maximizing, int numberOfThreads)
initialSolution
- The initial solutiontabuList
- The tabu listobjectiveFunction
- The objective function. Note that the objective function
and the penalty function are really very much the same.
They are divided up for easier programming and for
possible future enhancements.penaltyFunction
- The penalty function.moveManager
- The Move Manager.maximizing
- true
if maximizing, false if minimizingnumberOfThreads
- number of threads to use when searchingTSSolution
,
TSTabuList
,
TSFunction
,
TSMoveManager
Method Detail |
public final void startSolving(int additionalIterations)
TSEngineStartedListener
s.additionalIterations
- Additional iterations to solve.TSEngineStartedListener
public final void stopSolving()
TSEngineFinishedListener
s.TSEngineFinishedListener
public final void waitToFinish()
TSEngineFinishedListener
.TSEngineFinishedListener
public final void setCurrentSolutionToCopyOf(TSSolution solution)
solution
- The new solutionTSSolution
public final void setBestSolutionToCopyOf(TSSolution solution)
solution
- The new best solutionTSSolution
public final void trySettingBestSolutionToCopyOf(TSSolution solution)
solution
- The new best solutionTSSolution
public final long getLastSolveMillis()
startSolving
method, the time returned will reflect
the time needed to solve the total number of iterations.public final TSSolution getBestSolution()
TSSolution
public final int getIterationOfBestSolution()
TSSolution
public final int getCurrentIteration()
public final int getIterationsToGo()
public final TSSolution getCurrentSolution()
TSSolution
public final TSTabuList getTabuList()
TSTabuList
public final TSFunction getObjectiveFunction()
TSFunction
public final TSFunction getPenaltyFunction()
TSFunction
public final TSMoveManager getMoveManager()
TSMoveManager
public final TSMove[] getMovesUsedOnLastIteration()
TSMove
public final void addNewBestSolutionListener(TSNewBestSolutionListener listener)
listener
to receive tabu events when
a new best solution is found.listener
- The TSNewBestSolutionListener
to register.TSNewBestSolutionListener
public final void addNewCurrentSolutionListener(TSNewCurrentSolutionListener listener)
listener
to receive tabu events when a
new current solution is found.listener
- TSNewCurrentSolutionListener
to register.TSNewCurrentSolutionListener
public final void addUnimprovingMoveListener(TSUnimprovingMoveListener listener)
listener
to receive tabu events when an
unimproving move is made.listener
- TSUnimprovingMoveListener
to register.TSUnimprovingMoveListener
public final void addEngineFinishedListener(TSEngineFinishedListener listener)
listener
to receive tabu events when
the engine finishes.listener
- that listens for the engine to finishTSEngineFinishedListener
public final void addEngineStartedListener(TSEngineStartedListener listener)
listener
to receive tabu events when
the engine starts.listener
- that listens for the engine to startTSEngineStartedListener
public final void removeNewBestSolutionListener(TSNewBestSolutionListener listener)
listener
from list of objects to notify
when a new best solution is found.listener
- TSNewBestSolutionListener
to remove from notification list.TSNewBestSolutionListener
public final void removeNewCurrentSolutionListener(TSNewCurrentSolutionListener listener)
listener
from list of objects to notify when
a new current solution is found.listener
- TSNewCurrentSolutionListener
to remove from notification list.TSNewCurrentSolutionListener
public final void removeUnimprovingMoveListener(TSUnimprovingMoveListener listener)
listener
from list of objects to notify
when an unimproving move is made.listener
- TSUnimprovingMoveListener
to remove from notification list.TSUnimprovingMoveListener
public final void removeEngineFinishedListener(TSEngineFinishedListener listener)
listener
from list of objects to notify
when the engine finished its appointed iterations.listener
- TSEngineFinishedListener
to
remove from notification list.TSEngineFinishedListener
public final void removeEngineStartedListener(TSEngineStartedListener listener)
listener
from list of objects to notify
when the engine starts its appointed iterations.listener
- TSEngineStartedListener
to
remove from notification list.TSEngineStartedListener
protected final void fireNewBestSolution()
TSTabuEvent
sent to the listeners is a
"lightweight" event, specifying only the source object,
this
.TSTabuEvent
protected final void fireNewCurrentSolution()
TSTabuEvent
sent to the listeners is a
"lightweight" event, specifying only the source object,
this
.TSTabuEvent
protected final void fireUnimprovingMoveMade()
TSTabuEvent
sent to the listeners is a
"lightweight" event, specifying only the source object,
this
.TSTabuEvent
protected final void fireEngineFinished()
TSTabuEvent
sent to the listeners is a
"lightweight" event, specifying only the source object,
this
.TSTabuEvent
protected final void fireEngineStarted()
TSTabuEvent
sent to the listeners is a
"lightweight" event, specifying only the source object,
this
.TSTabuEvent
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |