Package xal.extension.solver.market
Class AlgorithmMarket
java.lang.Object
xal.extension.solver.market.AlgorithmMarket
- All Implemented Interfaces:
AlgorithmScheduleListener
,SolutionJudgeListener
public class AlgorithmMarket
extends Object
implements AlgorithmScheduleListener, SolutionJudgeListener
AlgorithmMarket keeps track of algorithms.
- Author:
- ky6, t6p
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor using the default algorithm pool and the default algorithms List.AlgorithmMarket
(SearchAlgorithm algorithm) ConstructorAlgorithmMarket
(AlgorithmPool pool) Primary Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a listener to receive AlgorithmMarket events.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
foundNewOptimalSolution
(SolutionJudge source, List<Trial> solutions, Trial solution) Event indicating that a new optimal solution has been found.Get the algorithm pool.Get the algorithm List.Get the next algorithm to execute by sorting algorithms by efficiency and then picking a algorithm randomly but weighted by the probability ratio for each successive algorithm.void
Remove the listener from receiving AlgorithmMarket events.void
reset()
reset the marketvoid
Set the algorithm pool.void
setProblem
(Problem problem) Assign a new problem.void
trialScored
(AlgorithmSchedule algorithmSchedule, Trial trial) Handle a message that a trial has been scored.void
trialVetoed
(AlgorithmSchedule algorithmSchedule, Trial trial) Handle a message that a trial has been vetoed.
-
Constructor Details
-
AlgorithmMarket
Primary Constructor- Parameters:
pool
- the pool of algorithms
-
AlgorithmMarket
Constructor- Parameters:
algorithm
- the only algorithm to use which also implies the single algorithm
-
AlgorithmMarket
public AlgorithmMarket()Constructor using the default algorithm pool and the default algorithms List.
-
-
Method Details
-
reset
public void reset()reset the market -
addAlgorithmMarketListener
Add a listener to receive AlgorithmMarket events.- Parameters:
listener
- the listener to add for receiving algorithm market events
-
removeAlgorithmMarketListener
Remove the listener from receiving AlgorithmMarket events.- Parameters:
listener
- the listener to remove from receiving algorithm market events
-
setProblem
Assign a new problem.- Parameters:
problem
- the new problem
-
getAlgorithmPool
Get the algorithm pool.- Returns:
- The algorithm pool.
-
getAlgorithms
Get the algorithm List.- Returns:
- The list of algorithms.
-
setAlgorithmPool
Set the algorithm pool.- Parameters:
pool
- The algorithm pool used to set the local algorithm pool.
-
nextAlgorithm
Get the next algorithm to execute by sorting algorithms by efficiency and then picking a algorithm randomly but weighted by the probability ratio for each successive algorithm.- Returns:
- the next algorithm
-
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
-
trialScored
Handle 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
Handle 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.
-
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.
-