Class Solver

java.lang.Object
xal.extension.solver.Solver
All Implemented Interfaces:
AlgorithmPoolListener, AlgorithmMarketListener

public class Solver extends Object implements AlgorithmPoolListener, AlgorithmMarketListener
Solver is the primary class for setting up and running an optimization.
Author:
ky6, t6p
  • Field Details

    • problem

      protected Problem problem
      The problem to solve
    • scoreboard

      protected ScoreBoard scoreboard
      The score board for keeping track of the solver status
    • schedule

      protected AlgorithmSchedule schedule
      The schedule of algorithms to run
  • Constructor Details

    • Solver

      public Solver(AlgorithmMarket market, Stopper stopper, SolutionJudge solutionJudge)
      Primary Constructor
      Parameters:
      stopper - Determines when the solving is finished
      solutionJudge - Decides if a solution is optimal.
      market - The market of algorithms to use
    • Solver

      public Solver(SearchAlgorithm algorithm, Stopper stopper, SolutionJudge solutionJudge)
      Constructor using the specified stopper, solution judge and only the specified algorithm.
      Parameters:
      stopper - Determines when the solving is finished
      solutionJudge - Decides if a solution is optimal.
      algorithm - The algorithm to use.
    • Solver

      public Solver(SearchAlgorithm algorithm, Stopper stopper)
      Constructor using the specified stopper and only the specified algorithm.
      Parameters:
      stopper - Determines when the solving is finished
      algorithm - The algorithm to use.
    • Solver

      public Solver(Stopper stopper, SolutionJudge solutionJudge)
      Constructor using the specified stopper and solution judge.
      Parameters:
      stopper - Determines when the solving is finished
      solutionJudge - Decides if a solution is optimal
    • Solver

      public Solver(Stopper stopper)
      Constructor using the default solution judge and the specified stopper.
      Parameters:
      stopper - Determines when the solving is finished
  • Method Details

    • reset

      public void reset()
      Reset the solver.
    • solve

      public void solve(Problem problem) throws InvalidConfigurationException
      Solve the problem.
      Parameters:
      problem - Description of the Parameter
      Throws:
      InvalidConfigurationException - if the problem is ill defined
    • setProblem

      public void setProblem(Problem problem)
      Set the problem.
      Parameters:
      problem - The new problem value
    • getProblem

      public Problem getProblem()
      Get the problem.
      Returns:
      The problem.
    • stopSolving

      public void stopSolving()
      Stop the solver immediately.
    • setStopper

      public void setStopper(Stopper stopper)
      Set the stopper.
      Parameters:
      stopper - The new stopper value
    • getSolutionJudge

      public SolutionJudge getSolutionJudge()
      Get the solution judge.
      Returns:
      The solutionJudge value
    • setSolutionJudge

      public void setSolutionJudge(SolutionJudge solutionJudge)
      Set the solution judge.
      Parameters:
      solutionJudge - The new solutionJudge value
    • getScoreBoard

      public ScoreBoard getScoreBoard()
      Get the scoreboard that shows the present state of solving. It shows the best solution found so far and the time elapsed since solving started.
      Returns:
      The scoreboard that shows the present state of solving.
    • judge

      protected void judge(Trial trial)
      Judge the specified trial.
      Parameters:
      trial - the trial to judge
    • getAlgorithmSchedule

      public AlgorithmSchedule getAlgorithmSchedule()
      Get the algorithm schedule.
      Returns:
      The algorithm schedule.
    • setAlgorithmPool

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

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

      public AlgorithmMarket getAlgorithmMarket()
      Get the algorithm market.
      Returns:
      The algorithm market.
    • algorithmAdded

      public void algorithmAdded(AlgorithmPool source, SearchAlgorithm algorithm)
      Send a message that an algorithm. was added to the pool.
      Specified by:
      algorithmAdded in interface AlgorithmPoolListener
      Parameters:
      source - The source of the added algorithm.
      algorithm - Description of the Parameter
    • algorithmRemoved

      public void algorithmRemoved(AlgorithmPool source, SearchAlgorithm algorithm)
      Send a message that an algorithm was removed from the pool.
      Specified by:
      algorithmRemoved in interface AlgorithmPoolListener
      Parameters:
      source - The source of the removed algorithm.
      algorithm - Description of the Parameter
    • algorithmAvailable

      public void algorithmAvailable(AlgorithmPool source, SearchAlgorithm algorithm)
      Send a message that an algorithm is available.
      Specified by:
      algorithmAvailable in interface AlgorithmPoolListener
      Parameters:
      source - The source of the available algorithm.
      algorithm - Description of the Parameter
    • algorithmUnavailable

      public void algorithmUnavailable(AlgorithmPool source, SearchAlgorithm algorithm)
      Send a message that an algorithm is unavailable.
      Specified by:
      algorithmUnavailable in interface AlgorithmPoolListener
      Parameters:
      source - The source of the unavailable algorithm.
      algorithm - Description of the Parameter
    • poolChanged

      public void poolChanged(AlgorithmMarket market, AlgorithmPool oldPool, AlgorithmPool newPool)
      Event indicating that the algorithm pool changed.
      Specified by:
      poolChanged in interface AlgorithmMarketListener
      Parameters:
      market - The market whose pool has changed.
      oldPool - Description of the Parameter
      newPool - Description of the Parameter
    • recordEfficiency

      public void recordEfficiency(int evaluations)