Package xal.extension.solver.algorithm
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 Summary
FieldsModifier and TypeFieldDescriptionprotected double
Description of the Fieldprotected final int
Description of the Fieldprotected Random
Description of the FieldMap of values keyed by variable -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.Get the next trial point.nextPoint
(int expectedNumToChange) Get the next trial point given the expected number of variables to change.Get the next trial point.protected double
proposeValue
(Variable variable) Propose a new value for the variable by selecting a random value in the variable's search range.void
reset()
reset for searching from scratch; forget historyvoid
turns shouldShift on
-
Field Details
-
numVariables
protected final int numVariablesDescription of the Field -
randomGenerator
Description of the Field -
changeProbabilityBase
protected double changeProbabilityBaseDescription of the Field -
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 interfaceRandomShrinkSearch.Searcher
-
reset
public void reset()reset for searching from scratch; forget history- Specified by:
reset
in interfaceRandomShrinkSearch.Searcher
-
newTopSolution
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 interfaceRandomShrinkSearch.Searcher
- Parameters:
oldPoint
- The old best point.newPoint
- The new best point.
-
nextTrialPoint
Get the next trial point. Simply returns nextPoint().- Specified by:
nextTrialPoint
in interfaceRandomShrinkSearch.Searcher
- Returns:
- the next trial point.
-
nextPoint
Get the next trial point.- Returns:
- the next trial point.
-
nextPoint
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
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
-