Package xal.extension.solver.algorithm
Class RandomShrinkSearch
java.lang.Object
xal.extension.solver.algorithm.SearchAlgorithm
xal.extension.solver.algorithm.RandomShrinkSearch
- All Implemented Interfaces:
AlgorithmScheduleListener,SolutionJudgeListener
RandomSearchAlgorithm looks for points bounded by the specified variable
limits. Every iteration a subset of variables are randomly chosen to be
changed. The value chosen for each variable is randomly selected from a
uniform distribution within a window for that variable. The window begins as
the full limit range allowed by the variable. Whenever a better solution is
found, the window changes so that it is three times wider than the distance
between the last best point and the new best point. The window gets centered
around the new best points. Then the window gets clipped as necessary to
satisfy the variable limits. Note that the window may grow or shrink
depending on the distance between successive top points. As the optimal
solution is approached, the window should tend to shrink around the optimal
point. Note that each variable has its own window and the window
automatically adjusts to the variable according to the progress.
- Author:
- t6p
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassUse a combination of search engines to search for the best solution.protected classA searcher that performs a simple random search in the entire search space.protected static interfaceInterface for classes that search for solutions.protected classShrinkSearcher searches for the next trial point by adjusting the search domain per variable depending on how much a variable has changed between the best solutions found so far. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected TrialPointThe current best point.protected doublekeeps track of internal best Satisfactionprotected booleankeeps track if the last run is being executedprotected RandomShrinkSearch.SearcherThe active search technique (random or shrink).Fields inherited from class xal.extension.solver.algorithm.SearchAlgorithm
EFFICIENCY_COMPARATOR, problem -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidalgorithmAvailable(SearchAlgorithm source) Handle a message that an algorithm is available.voidalgorithmUnavailable(SearchAlgorithm source) Handle a message that an algorithm is not available.voidfoundNewOptimalSolution(SolutionJudge source, List<Trial> solutions, Trial solution) Handle a message that a new optimal solution has been found.getLabel()Get the label for this search algorithm.intGet the rating for this algorithm which in an integer between 0 and 10 and indicates how well this algorithm performs on global searches.intGet the rating for this algorithm which in an integer between 0 and 10 and indicates how well this algorithm performs on local searches.Calculate and get the next trial point to evaluate.voidperformRun(AlgorithmSchedule algorithmSchedule) Calculate the next few trial points.voidreset()reset for searching from scratch; forget historyprotected voidReset the trial point's variables to their starting values.voidtrialScored(AlgorithmSchedule schedule, Trial trial) Handle a message that a trial has been scored.Methods inherited from class xal.extension.solver.algorithm.SearchAlgorithm
addSearchAlgorithmListener, algorithmRunExecuted, algorithmRunWillExecute, evaluateTrialPoint, executeRun, getEfficiency, getEvaluationsLeft, getMaxEvaluationsPerRun, getMinEvaluationsPerRun, removeSearchAlgorithmListener, setProblem, setProposedEvaluations, trialVetoed
-
Field Details
-
bestPoint
The current best point. -
searcher
The active search technique (random or shrink). -
bestSatisfaction
protected double bestSatisfactionkeeps track of internal best Satisfaction -
isLastEvaluation
protected boolean isLastEvaluationkeeps track if the last run is being executed
-
-
Constructor Details
-
RandomShrinkSearch
public RandomShrinkSearch()
-
-
Method Details
-
getLabel
Get the label for this search algorithm.- Specified by:
getLabelin classSearchAlgorithm- Returns:
- The label for this algorithm
-
reset
public void reset()reset for searching from scratch; forget history- Overrides:
resetin classSearchAlgorithm
-
resetBestPoint
protected void resetBestPoint()Reset the trial point's variables to their starting values. -
performRun
Calculate the next few trial points.- Specified by:
performRunin classSearchAlgorithm- Parameters:
algorithmSchedule- the algorithm run to perform the evaluation
-
nextTrialPoint
Calculate and get the next trial point to evaluate.- Returns:
- The next trial point to evaluate.
-
globalRating
public int globalRating()Get the rating for this algorithm which in an integer between 0 and 10 and indicates how well this algorithm performs on global searches.- Returns:
- The global search rating for this algorithm.
-
localRating
public int localRating()Get the rating for this algorithm which in an integer between 0 and 10 and indicates how well this algorithm performs on local searches.- Returns:
- The local search rating for this algorithm.
-
algorithmAvailable
Handle a message that an algorithm is available.- Parameters:
source- The source of the available algorithm.
-
trialScored
Handle a message that a trial has been scored.- Specified by:
trialScoredin interfaceAlgorithmScheduleListener- Overrides:
trialScoredin classSearchAlgorithm- Parameters:
schedule- Description of the Parametertrial- Description of the Parameter This is for operating this algorithm completely independently of any other algorithm
-
foundNewOptimalSolution
Handle a message that a new optimal solution has been found.- Specified by:
foundNewOptimalSolutionin interfaceSolutionJudgeListener- Overrides:
foundNewOptimalSolutionin classSearchAlgorithm- Parameters:
source- The source of the new optimal solution.solutions- The list of solutions.solution- The new optimal solution.
-