Class RandomShrinkSearch.RandomSearcher

java.lang.Object
xal.extension.solver.algorithm.RandomShrinkSearch.RandomSearcher
All Implemented Interfaces:
RandomShrinkSearch.Searcher
Direct Known Subclasses:
RandomShrinkSearch.ComboSearcher, RandomShrinkSearch.ShrinkSearcher
Enclosing class:
RandomShrinkSearch

protected class RandomShrinkSearch.RandomSearcher extends Object implements RandomShrinkSearch.Searcher
A searcher that performs a simple random search in the entire search space.
  • Field Details

    • numVariables

      protected final int numVariables
      Description of the Field
    • randomGenerator

      protected Random randomGenerator
      Description of the Field
    • changeProbabilityBase

      protected double changeProbabilityBase
      Description of the Field
    • values

      protected Map<Variable,Number> values
      Map of values keyed by variable
  • Constructor Details

    • RandomSearcher

      public RandomSearcher()
      Constructor
  • Method Details

    • shouldShift

      public void shouldShift()
      turns shouldShift on
      Specified by:
      shouldShift in interface RandomShrinkSearch.Searcher
    • reset

      public void reset()
      reset for searching from scratch; forget history
      Specified by:
      reset in interface RandomShrinkSearch.Searcher
    • newTopSolution

      public void newTopSolution(TrialPoint oldPoint, TrialPoint newPoint)
      An event indicating that a new solution has been found which is better than the previous best solution according to the score given by the evaluator.
      Specified by:
      newTopSolution in interface RandomShrinkSearch.Searcher
      Parameters:
      oldPoint - The old best point.
      newPoint - The new best point.
    • nextTrialPoint

      public TrialPoint nextTrialPoint()
      Get the next trial point. Simply returns nextPoint().
      Specified by:
      nextTrialPoint in interface RandomShrinkSearch.Searcher
      Returns:
      the next trial point.
    • nextPoint

      public TrialPoint nextPoint()
      Get the next trial point.
      Returns:
      the next trial point.
    • nextPoint

      public TrialPoint nextPoint(int expectedNumToChange)
      Get the next trial point given the expected number of variables to change. Randomly pick the number of variables to vary by weighing it based on the average number we expect to vary. If no variables get selected to change then we pick the number of variables to change randomly from 1 to the total number of variables available. For each variable that was selected to change, we randomly select a value within the target domain for the variable.
      Parameters:
      expectedNumToChange - The average number of variables that we expect to change.
      Returns:
      the next trial point.
    • proposeValue

      protected double proposeValue(Variable variable)
      Propose a new value for the variable by selecting a random value in the variable's search range.
      Parameters:
      variable - the variable for which to propose a new value
      Returns:
      the new value to propose for the variable