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 TypeMethodDescriptionvoid
addAlgorithm
(SearchAlgorithm algorithm) Add an algorithm to the pool.void
Add an algorithm pool listener.void
addAlgorithms
(Collection<SearchAlgorithm> algorithms) Add existing algorithms to the algorithm list.void
algorithmAvailable
(SearchAlgorithm source) Send a message that an algorithm is available.void
algorithmRunExecuted
(AlgorithmSchedule schedule, SearchAlgorithm algorithm, ScoreBoard scoreBoard) Handle an event where a new algorithm run stack has completed.void
algorithmRunWillExecute
(AlgorithmSchedule schedule, SearchAlgorithm algorithm, ScoreBoard scoreBoard) Handle an event where a new algorithm run stack will start.void
algorithmUnavailable
(SearchAlgorithm source) Send a message that an algorithm is not available.void
foundNewOptimalSolution
(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.void
removeAlgorithm
(SearchAlgorithm algorithm) Remove an algorithm from the pool.void
Remove a algorithm pool listener.void
removeAlgorithms
(Collection<SearchAlgorithm> algorithms) Remove the specified algorithms.void
Remove all algorithms.void
reset()
Reset the algorithm pool by resetting all the algorithms.void
setAlgorithm
(SearchAlgorithm algorithm) Set the algorithm as the sole algorithm in the pool.void
setProblem
(Problem problem) Assign the problem to each algorithm in the pool.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.
-
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:
trialScored
in 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:
trialVetoed
in 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:
algorithmRunWillExecute
in 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:
algorithmRunExecuted
in 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:
algorithmAvailable
in interfaceSearchAlgorithmListener
- Parameters:
source
- The source of the available algorithm.
-
foundNewOptimalSolution
Event indicating that a new optimal solution has been found.- Specified by:
foundNewOptimalSolution
in interfaceSolutionJudgeListener
- Parameters:
source
- The source of the new optimal solution.solutions
- The list of solutions.solution
- The new optimal solution.
-