public abstract class AlgorithmStrategy extends java.lang.Object implements AlgorithmScheduleListener, AlgorithmPoolListener, SolutionJudgeListener
Modifier and Type | Field and Description |
---|---|
protected double |
_efficiency
measure of this strategy's running efficiency in solving the problem
|
Constructor and Description |
---|
AlgorithmStrategy(AlgorithmPool pool)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
algorithmAdded(AlgorithmPool source,
SearchAlgorithm algorithm)
Send a message that an algorithm.
|
void |
algorithmAvailable(AlgorithmPool source,
SearchAlgorithm algorithm)
Send a message that an algorithm is available.
|
void |
algorithmRemoved(AlgorithmPool source,
SearchAlgorithm algorithm)
Send a message that an algorithm was removed from the
pool.
|
void |
algorithmUnavailable(AlgorithmPool source,
SearchAlgorithm algorithm)
Send a message that an algorithm is unvavailable.
|
void |
execute(AlgorithmSchedule schedule,
ScoreBoard scoreboard)
Execute the proposed runs.
|
void |
foundNewOptimalSolution(SolutionJudge source,
java.util.List<Trial> solutions,
Trial solution)
Send a message that a new optimal solution has been found.
|
double |
getEfficiency()
Get this strategy's efficiency for improving satisfaction.
|
abstract java.lang.String |
getLabel()
Return the label for the algorithm strategy.
|
protected static int |
getNearestIntegerInRange(int target,
int lower,
int upper)
Get the nearest integer to the specified target that is within the specified range.
|
protected static int |
getRunCount(int targetCount,
SearchAlgorithm algorithm)
Get the number of runs that is nearest the target count but withing the algorithm's accepted range.
|
protected abstract AlgorithmRunStack |
proposeRuns()
Propose some algorithms that should be run.
|
void |
strategyExecuted(AlgorithmSchedule schedule,
AlgorithmStrategy strategy,
ScoreBoard scoreBoard)
Handle an event where a new algorithm run stack has completed.
|
void |
strategyWillExecute(AlgorithmSchedule schedule,
AlgorithmStrategy strategy,
ScoreBoard scoreBoard)
Handle an event where a new algorithm run stack will start.
|
java.lang.String |
toString()
Get a string representation of this strategy.
|
void |
trialScored(AlgorithmSchedule algorithmSchedule,
Trial trial)
Send a message that a trial has been scored.
|
void |
trialVetoed(AlgorithmSchedule algorithmSchedule,
Trial trial)
Send a message that a trial has been vetoed.
|
protected double _efficiency
public AlgorithmStrategy(AlgorithmPool pool)
pool
- the pool of algorithms from which to chooseprotected abstract AlgorithmRunStack proposeRuns()
public abstract java.lang.String getLabel()
public final double getEfficiency()
public java.lang.String toString()
toString
in class java.lang.Object
protected static int getNearestIntegerInRange(int target, int lower, int upper)
target
- the target that we are trying to meetlower
- the minimum value of the allowed rangeupper
- the maximum value of the allowed rangeprotected static int getRunCount(int targetCount, SearchAlgorithm algorithm)
targetCount
- the target that we are trying to meetalgorithm
- the algorithm that specifies the valid rangepublic final void execute(AlgorithmSchedule schedule, ScoreBoard scoreboard)
schedule
- the schedule requesting the strategy executionscoreboard
- the scoreboard of solver statuspublic void trialScored(AlgorithmSchedule algorithmSchedule, Trial trial)
trialScored
in interface AlgorithmScheduleListener
algorithmSchedule
- The algorithm schedule that
holds the trial scored.trial
- The trial that was scored.public void trialVetoed(AlgorithmSchedule algorithmSchedule, Trial trial)
trialVetoed
in interface AlgorithmScheduleListener
algorithmSchedule
- The algorithm schedule
that holds the trial vetoed.trial
- The trial that was vetoed.public void strategyWillExecute(AlgorithmSchedule schedule, AlgorithmStrategy strategy, ScoreBoard scoreBoard)
strategyWillExecute
in interface AlgorithmScheduleListener
schedule
- the schedule posting the eventstrategy
- the strategy which will executescoreBoard
- the scoreboardpublic void strategyExecuted(AlgorithmSchedule schedule, AlgorithmStrategy strategy, ScoreBoard scoreBoard)
strategyExecuted
in interface AlgorithmScheduleListener
schedule
- the schedule posting the eventstrategy
- the strategy that has executedscoreBoard
- the scoreboardpublic void algorithmAdded(AlgorithmPool source, SearchAlgorithm algorithm)
algorithmAdded
in interface AlgorithmPoolListener
source
- The source of the added algorithm.algorithm
- The algorithm which was added.public void algorithmRemoved(AlgorithmPool source, SearchAlgorithm algorithm)
algorithmRemoved
in interface AlgorithmPoolListener
source
- The source of the removed algorithm.algorithm
- The algorithm which was removed.public void algorithmAvailable(AlgorithmPool source, SearchAlgorithm algorithm)
algorithmAvailable
in interface AlgorithmPoolListener
source
- The source of the available algorithm.algorithm
- The algorithm which has become available.public void algorithmUnavailable(AlgorithmPool source, SearchAlgorithm algorithm)
algorithmUnavailable
in interface AlgorithmPoolListener
source
- The source of the unavailable algorithm.algorithm
- The algorithm which has become unavailable.public void foundNewOptimalSolution(SolutionJudge source, java.util.List<Trial> solutions, Trial solution)
foundNewOptimalSolution
in interface SolutionJudgeListener
source
- The source of the new optimal solution.solutions
- The list of solutions.solution
- The new optimal solution.