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 TypeMethodDescriptionvoidAdd a listener to receive AlgorithmMarket events.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.voidfoundNewOptimalSolution(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.voidRemove the listener from receiving AlgorithmMarket events.voidreset()reset the marketvoidSet the algorithm pool.voidsetProblem(Problem problem) Assign a new problem.voidtrialScored(AlgorithmSchedule algorithmSchedule, Trial trial) Handle a message that a trial has been scored.voidtrialVetoed(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:
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
-
trialScored
Handle 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
Handle 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.
-
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.
-