public class AlgorithmMarket extends java.lang.Object implements AlgorithmScheduleListener, SolutionJudgeListener
Modifier and Type | Field and Description |
---|---|
protected AlgorithmPool |
_algorithmPool
the pool of algorithms from which to pick an algorithm
|
protected AlgorithmMarketListener |
_eventProxy
proxy which forwards events to registered listeners
|
protected MessageCenter |
_messageCenter
message center which dispatches events to registered listeners
|
protected java.util.List<AlgorithmStrategy> |
_strategies
the list of strategies in the market sorted by efficiency so the most efficient strategies appear first
|
Constructor and Description |
---|
AlgorithmMarket()
Constructor using the default algorithm pool and the default strategies.
|
AlgorithmMarket(AlgorithmPool pool)
Constructor
|
AlgorithmMarket(AlgorithmPool pool,
AlgorithmStrategy strategy)
Constructor
|
AlgorithmMarket(AlgorithmPool pool,
java.util.List<AlgorithmStrategy> strategies)
Primary Constructor
|
AlgorithmMarket(java.util.List<AlgorithmStrategy> strategies)
Constructor
|
AlgorithmMarket(SearchAlgorithm algorithm)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addAlgorithmMarketListener(AlgorithmMarketListener listener)
Add a listener to receive AlgorithmMarket events.
|
void |
addAlgorithmStrategy(AlgorithmStrategy strategy)
Add an algorithm strategy to the list of strategies.
|
void |
foundNewOptimalSolution(SolutionJudge source,
java.util.List<Trial> solutions,
Trial solution)
Event indicating that a new optimal solution has been found.
|
AlgorithmPool |
getAlgorithmPool()
Get the algorithm pool.
|
java.util.List<AlgorithmStrategy> |
getStrategies()
Get the algorithm strategies.
|
AlgorithmStrategy |
nextStrategy()
Get the next strategy to execute by sorting strategies by efficiency and then picking a strategy randomly but weighted by
the probability ratio for each successive strategy.
|
void |
removeAlgorithmMarketListener(AlgorithmMarketListener listener)
Remove the listener from receiving AlgorithmMarket events.
|
void |
reset()
reset the market
|
void |
setAlgorithmPool(AlgorithmPool pool)
Set the algorithm pool.
|
void |
setAlgorithmStrategies(java.util.List<AlgorithmStrategy> strategies)
Set the list of strategies.
|
void |
setAlgorithmStrategy(AlgorithmStrategy strategy)
Set the strategy.
|
void |
setProblem(Problem problem)
Assign a new problem.
|
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.
|
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.
|
protected java.util.List<AlgorithmStrategy> _strategies
protected AlgorithmPool _algorithmPool
protected MessageCenter _messageCenter
protected AlgorithmMarketListener _eventProxy
public AlgorithmMarket(AlgorithmPool pool, java.util.List<AlgorithmStrategy> strategies)
pool
- the pool of algorithmsstrategies
- the list of strategiespublic AlgorithmMarket(AlgorithmPool pool)
pool
- the pool of algorithmspublic AlgorithmMarket(AlgorithmPool pool, AlgorithmStrategy strategy)
pool
- the pool of algorithmsstrategy
- the only strategy to use in the marketpublic AlgorithmMarket(SearchAlgorithm algorithm)
algorithm
- the only algorithm to use which also implies the single algorithm strategypublic AlgorithmMarket(java.util.List<AlgorithmStrategy> strategies)
strategies
- the list of strategiespublic AlgorithmMarket()
public void reset()
public void addAlgorithmMarketListener(AlgorithmMarketListener listener)
listener
- the listener to add for receiving algorithm market eventspublic void removeAlgorithmMarketListener(AlgorithmMarketListener listener)
listener
- the listener to remove from receiving algorithm market eventspublic void setProblem(Problem problem)
problem
- the new problempublic AlgorithmPool getAlgorithmPool()
public java.util.List<AlgorithmStrategy> getStrategies()
public void setAlgorithmStrategies(java.util.List<AlgorithmStrategy> strategies)
strategies
- The list of strategies.public void setAlgorithmStrategy(AlgorithmStrategy strategy)
strategy
- The algorithm strategy to set the list with.public void addAlgorithmStrategy(AlgorithmStrategy strategy)
strategy
- The algorithm strategy to add.public void setAlgorithmPool(AlgorithmPool pool)
pool
- The algorithm pool used to set the local algorithm pool.public AlgorithmStrategy nextStrategy()
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 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 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.