Package xal.extension.solver
Class AlgorithmPool
java.lang.Object
xal.extension.solver.AlgorithmPool
- All Implemented Interfaces:
SearchAlgorithmListener,AlgorithmScheduleListener,SolutionJudgeListener
public class AlgorithmPool
extends Object
implements SearchAlgorithmListener, SolutionJudgeListener, AlgorithmScheduleListener
AlgorithmPool keeps track of the available algorithms.
- Author:
- ky6, t6p
-
Constructor Summary
ConstructorsConstructorDescriptionEmpty constructor which populates the pool of all algorithmsAlgorithmPool(Collection<SearchAlgorithm> algorithms) Creates a new AlgorithmPool instance Constructor that takes a list of algorithmsAlgorithmPool(SearchAlgorithm algorithm) Creates a new AlgorithmPool instance Constructor that takes a list of algorithms -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAlgorithm(SearchAlgorithm algorithm) Add an algorithm to the pool.voidAdd an algorithm pool listener.voidaddAlgorithms(Collection<SearchAlgorithm> algorithms) Add existing algorithms to the algorithm list.voidalgorithmAvailable(SearchAlgorithm source) Send a message that an algorithm is available.voidalgorithmRunExecuted(AlgorithmSchedule schedule, SearchAlgorithm algorithm, ScoreBoard scoreBoard) Handle an event where a new algorithm run stack has completed.voidalgorithmRunWillExecute(AlgorithmSchedule schedule, SearchAlgorithm algorithm, ScoreBoard scoreBoard) Handle an event where a new algorithm run stack will start.voidalgorithmUnavailable(SearchAlgorithm source) Send a message that an algorithm is not available.voidfoundNewOptimalSolution(SolutionJudge source, List<Trial> solutions, Trial solution) Event indicating that a new optimal solution has been found.static Collection<SearchAlgorithm>Get all the algorithms.Get a copy of the algorithms.Get the available algorithms.voidremoveAlgorithm(SearchAlgorithm algorithm) Remove an algorithm from the pool.voidRemove a algorithm pool listener.voidremoveAlgorithms(Collection<SearchAlgorithm> algorithms) Remove the specified algorithms.voidRemove all algorithms.voidreset()Reset the algorithm pool by resetting all the algorithms.voidsetAlgorithm(SearchAlgorithm algorithm) Set the algorithm as the sole algorithm in the pool.voidsetProblem(Problem problem) Assign the problem to each algorithm in the pool.voidtrialScored(AlgorithmSchedule algorithmSchedule, Trial trial) Send a message that a trial has been scored.voidtrialVetoed(AlgorithmSchedule algorithmSchedule, Trial trial) Send a message that a trial has been vetoed.
-
Constructor Details
-
AlgorithmPool
Creates a new AlgorithmPool instance Constructor that takes a list of algorithms- Parameters:
algorithms- the collection of algorithms to populate the pool
-
AlgorithmPool
public AlgorithmPool()Empty constructor which populates the pool of all algorithms -
AlgorithmPool
Creates a new AlgorithmPool instance Constructor that takes a list of algorithms- Parameters:
algorithm- Description of the Parameter
-
-
Method Details
-
generateDefaultAlgorithms
Get all the algorithms.- Returns:
- The default set of algorithms
-
reset
public void reset()Reset the algorithm pool by resetting all the algorithms. -
setProblem
Assign the problem to each algorithm in the pool.- Parameters:
problem- the problem to solve
-
addAlgorithmPoolListener
Add an algorithm pool listener.- Parameters:
listener- The listener to add.
-
removeAlgorithmPoolListener
Remove a algorithm pool listener.- Parameters:
listener- The listener to remove.
-
setAlgorithm
Set the algorithm as the sole algorithm in the pool.- Parameters:
algorithm- the algorithm to set as the only item in the pool
-
addAlgorithms
Add existing algorithms to the algorithm list.- Parameters:
algorithms- The feature to be added to the Algorithms attribute
-
addAlgorithm
Add an algorithm to the pool.- Parameters:
algorithm- The feature to be added to the Algorithm attribute
-
removeAlgorithm
Remove an algorithm from the pool.- Parameters:
algorithm- the algorithm to remove from the pool
-
removeAlgorithms
Remove the specified algorithms.- Parameters:
algorithms- the algorithms to remove
-
removeAllAlgorithms
public void removeAllAlgorithms()Remove all algorithms. -
getAlgorithms
Get a copy of the algorithms.- Returns:
- The list of algorithms.
-
getAvailableAlgorithms
Get the available algorithms.- Returns:
- The list of available algorithm.
-
trialScored
Send a message that a trial has been scored.- Specified by:
trialScoredin interfaceAlgorithmScheduleListener- Parameters:
algorithmSchedule- The algorithm schedule that holds the trial scored.trial- The trial that was scored.
-
trialVetoed
Send a message that a trial has been vetoed.- Specified by:
trialVetoedin interfaceAlgorithmScheduleListener- Parameters:
algorithmSchedule- The algorithm schedule that holds the trial vetoed.trial- The trial that was vetoed.
-
algorithmRunWillExecute
public void algorithmRunWillExecute(AlgorithmSchedule schedule, SearchAlgorithm algorithm, ScoreBoard scoreBoard) Handle an event where a new algorithm run stack will start.- Specified by:
algorithmRunWillExecutein interfaceAlgorithmScheduleListener- Parameters:
schedule- the schedule posting the eventalgorithm- the algorithm which will executescoreBoard- the scoreboard
-
algorithmRunExecuted
public void algorithmRunExecuted(AlgorithmSchedule schedule, SearchAlgorithm algorithm, ScoreBoard scoreBoard) Handle an event where a new algorithm run stack has completed.- Specified by:
algorithmRunExecutedin interfaceAlgorithmScheduleListener- Parameters:
schedule- the schedule posting the eventalgorithm- the algorithm that has executedscoreBoard- the scoreboard
-
algorithmAvailable
Send a message that an algorithm is available. An algorithm is available if it has all the data it needs to propose a new trial.- Specified by:
algorithmAvailablein interfaceSearchAlgorithmListener- Parameters:
source- The source of the available algorithm.
-
foundNewOptimalSolution
Event indicating that a new optimal solution has been found.- Specified by:
foundNewOptimalSolutionin interfaceSolutionJudgeListener- Parameters:
source- The source of the new optimal solution.solutions- The list of solutions.solution- The new optimal solution.
-