Package xal.extension.solver.algorithm
Class DirectedStep
java.lang.Object
xal.extension.solver.algorithm.SearchAlgorithm
xal.extension.solver.algorithm.DirectedStep
- All Implemented Interfaces:
AlgorithmScheduleListener
,SolutionJudgeListener
Based on the acceleration-step of Forsythe and Motzkin
-
Field Summary
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.protected double[]
calculateGradient
(Trial originTrial) Calculate the gradient for the specified pointprotected double[]
calculateVector
(TrialPoint originPoint, TrialPoint targetPoint) Calculate the vector from the origin point to the target pointvoid
foundNewOptimalSolution
(SolutionJudge source, List<Trial> solutions, Trial solution) Handle a message that a new optimal solution has been found.getLabel()
Return the label for a search algorithm.int
Get the minimum number of evaluations per run.int
Returns the global rating which in an integer between 0 and 10.int
Returns the local rating which is an integer between 0 and 10.protected Trial
performAcceleratedSearch
(Trial originTrial) Perform an accelerated search.protected Trial
performGradientAndLinearSearch
(Trial originTrial) Perform a gradient calculation followed by a linear search along the gradient.void
performRun
(AlgorithmSchedule algorithmSchedule) Calculate the next few trial points.void
reset()
reset the algorithm for searching from scratchprotected Trial
searchAlongGradient
(double[] gradient, Trial originTrial) Search along the gradient from the origin point.protected static TrialPoint
trialPointAlongGradient
(double[] gradient, TrialPoint originPoint, double scale, List<Variable> variables) Get a new trial point along the gradient.void
trialScored
(AlgorithmSchedule schedule, Trial trial) Handle a message that a trial has been scored.void
trialVetoed
(AlgorithmSchedule schedule, Trial trial) Handle a message that a trial has been vetoed.Methods inherited from class xal.extension.solver.algorithm.SearchAlgorithm
addSearchAlgorithmListener, algorithmRunExecuted, algorithmRunWillExecute, evaluateTrialPoint, executeRun, getEfficiency, getEvaluationsLeft, getMaxEvaluationsPerRun, removeSearchAlgorithmListener, setProblem, setProposedEvaluations
-
Constructor Details
-
DirectedStep
public DirectedStep()
-
-
Method Details
-
reset
public void reset()reset the algorithm for searching from scratch- Overrides:
reset
in classSearchAlgorithm
-
getLabel
Return the label for a search algorithm.- Specified by:
getLabel
in classSearchAlgorithm
- Returns:
- The trial point.
-
performRun
Calculate the next few trial points.- Specified by:
performRun
in classSearchAlgorithm
-
performAcceleratedSearch
Perform an accelerated search. -
performGradientAndLinearSearch
Perform a gradient calculation followed by a linear search along the gradient. -
calculateGradient
Calculate the gradient for the specified point- Returns:
- the gradient at the specified point
-
calculateVector
Calculate the vector from the origin point to the target point- Returns:
- the vector from the origin point to the target point
-
searchAlongGradient
Search along the gradient from the origin point. -
trialPointAlongGradient
protected static TrialPoint trialPointAlongGradient(double[] gradient, TrialPoint originPoint, double scale, List<Variable> variables) Get a new trial point along the gradient. -
getMinEvaluationsPerRun
public int getMinEvaluationsPerRun()Get the minimum number of evaluations per run. Subclasses may want to override this method.- Overrides:
getMinEvaluationsPerRun
in classSearchAlgorithm
- Returns:
- the minimum number of evaluation per run.
-
globalRating
public int globalRating()Returns the global rating which in an integer between 0 and 10.- Returns:
- The global rating for this algorithm.
-
localRating
public int localRating()Returns the local rating which is an integer between 0 and 10.- Returns:
- The local 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:
trial
- The trial that was scored.schedule
- the schedule providing this event
-
trialVetoed
Handle a message that a trial has been vetoed.- Specified by:
trialVetoed
in interfaceAlgorithmScheduleListener
- Overrides:
trialVetoed
in classSearchAlgorithm
- Parameters:
trial
- The trial that was vetoed.schedule
- the schedule providing this event
-
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.
-