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 Details

    • AlgorithmMarket

      public AlgorithmMarket(AlgorithmPool pool)
      Primary Constructor
      Parameters:
      pool - the pool of algorithms
    • AlgorithmMarket

      public AlgorithmMarket(SearchAlgorithm algorithm)
      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

      public void addAlgorithmMarketListener(AlgorithmMarketListener listener)
      Add a listener to receive AlgorithmMarket events.
      Parameters:
      listener - the listener to add for receiving algorithm market events
    • removeAlgorithmMarketListener

      public void removeAlgorithmMarketListener(AlgorithmMarketListener listener)
      Remove the listener from receiving AlgorithmMarket events.
      Parameters:
      listener - the listener to remove from receiving algorithm market events
    • setProblem

      public void setProblem(Problem problem)
      Assign a new problem.
      Parameters:
      problem - the new problem
    • getAlgorithmPool

      public AlgorithmPool getAlgorithmPool()
      Get the algorithm pool.
      Returns:
      The algorithm pool.
    • getAlgorithms

      public List<SearchAlgorithm> getAlgorithms()
      Get the algorithm List.
      Returns:
      The list of algorithms.
    • setAlgorithmPool

      public void setAlgorithmPool(AlgorithmPool pool)
      Set the algorithm pool.
      Parameters:
      pool - The algorithm pool used to set the local algorithm pool.
    • nextAlgorithm

      public SearchAlgorithm 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 interface AlgorithmScheduleListener
      Parameters:
      schedule - the schedule posting the event
      algorithm - the algorithm which will execute
      scoreBoard - 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 interface AlgorithmScheduleListener
      Parameters:
      schedule - the schedule posting the event
      algorithm - the algorithm that has executed
      scoreBoard - the scoreboard
    • trialScored

      public void trialScored(AlgorithmSchedule algorithmSchedule, Trial trial)
      Handle a message that a trial has been scored.
      Specified by:
      trialScored in interface AlgorithmScheduleListener
      Parameters:
      algorithmSchedule - The algorithm schedule that holds the trial scored.
      trial - The trial that was scored.
    • trialVetoed

      public void trialVetoed(AlgorithmSchedule algorithmSchedule, Trial trial)
      Handle a message that a trial has been vetoed.
      Specified by:
      trialVetoed in interface AlgorithmScheduleListener
      Parameters:
      algorithmSchedule - The algorithm schedule that holds the trial vetoed.
      trial - The trial that was vetoed.
    • foundNewOptimalSolution

      public void foundNewOptimalSolution(SolutionJudge source, List<Trial> solutions, Trial solution)
      Event indicating that a new optimal solution has been found.
      Specified by:
      foundNewOptimalSolution in interface SolutionJudgeListener
      Parameters:
      source - The source of the new optimal solution.
      solutions - The list of solutions.
      solution - The new optimal solution.