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 doubleDescription of the Fieldprotected final intDescription of the Fieldprotected RandomDescription of the FieldMap of values keyed by variable -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidnewTopSolution(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 doubleproposeValue(Variable variable) Propose a new value for the variable by selecting a random value in the variable's search range.voidreset()reset for searching from scratch; forget historyvoidturns 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:
shouldShiftin interfaceRandomShrinkSearch.Searcher
-
reset
public void reset()reset for searching from scratch; forget history- Specified by:
resetin 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:
newTopSolutionin interfaceRandomShrinkSearch.Searcher- Parameters:
oldPoint- The old best point.newPoint- The new best point.
-
nextTrialPoint
Get the next trial point. Simply returns nextPoint().- Specified by:
nextTrialPointin 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
-