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 TypeClassDescriptionclass
Use a combination of search engines to search for the best solution.protected class
A searcher that performs a simple random search in the entire search space.protected static interface
Interface for classes that search for solutions.protected class
ShrinkSearcher 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 TrialPoint
The current best point.protected double
keeps track of internal best Satisfactionprotected boolean
keeps track if the last run is being executedprotected RandomShrinkSearch.Searcher
The 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 TypeMethodDescriptionvoid
algorithmAvailable
(SearchAlgorithm source) Handle a message that an algorithm is available.void
algorithmUnavailable
(SearchAlgorithm source) Handle a message that an algorithm is not available.void
foundNewOptimalSolution
(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.int
Get the rating for this algorithm which in an integer between 0 and 10 and indicates how well this algorithm performs on global searches.int
Get 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.void
performRun
(AlgorithmSchedule algorithmSchedule) Calculate the next few trial points.void
reset()
reset for searching from scratch; forget historyprotected void
Reset the trial point's variables to their starting values.void
trialScored
(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:
getLabel
in classSearchAlgorithm
- Returns:
- The label for this algorithm
-
reset
public void reset()reset for searching from scratch; forget history- Overrides:
reset
in classSearchAlgorithm
-
resetBestPoint
protected void resetBestPoint()Reset the trial point's variables to their starting values. -
performRun
Calculate the next few trial points.- Specified by:
performRun
in 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:
trialScored
in interfaceAlgorithmScheduleListener
- Overrides:
trialScored
in 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:
foundNewOptimalSolution
in interfaceSolutionJudgeListener
- Overrides:
foundNewOptimalSolution
in classSearchAlgorithm
- Parameters:
source
- The source of the new optimal solution.solutions
- The list of solutions.solution
- The new optimal solution.
-