Package jsl.utilities.rootfinding
Class StochasticApproximationRootFinder
- java.lang.Object
-
- jsl.simulation.IterativeProcess<RootFinderStep>
-
- jsl.utilities.rootfinding.IPRootFinder
-
- jsl.utilities.rootfinding.StochasticApproximationRootFinder
-
- All Implemented Interfaces:
ObservableIfc
,IterativeProcessIfc
,GetNameIfc
public class StochasticApproximationRootFinder extends IPRootFinder
This class implements a basic 1-D stochastic approximation algorithm Robbins, H., and S. Monroe(1951). On a Stochastic Approximation Technique. Annals of Mathematical Statistics 22, pp 400-407. Kesten, H.(1958). Accelerated Stochastic Approximation. Annals of Mathematical Statistics 29, pp 41-59. Kesten, H.(1958). Accelerated Stochastic Approximation. Annals of Mathematical Statistics 29, pp 41-59. Suri, R., and Y. T.Leung(1987). Single Run Optimization of Discrete Event Simulation: An Empirical Study Using the M/M/1 Queue. Technical Report No. 87-3, Department of Industrial Engineering, University of Wisconsin, at Madison. Suri, R., and Y. T.Leung(1987). Single Run Optimization of a Siman Model for Closed Loop Flexible Assembly Systems. In the Proceedings of the 1987 Winter Simulation Conference. Rossetti M. D. and Clark G. M. (1998) Evaluating an Approximation for the Two Type Stoppage Machine Interference Model Via Simulation Optimization, Computers and Industrial Engineering, Vol. 34, No. 3, pp. 655-688. This implementation uses a stopping criteria suggested by Suri and Leung and uses the suggested acceleration method proposed by Kesten.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jsl.simulation.IterativeProcess
IterativeProcess.Created, IterativeProcess.Ended, IterativeProcess.Initialized, IterativeProcess.IterativeState, IterativeProcess.ShowElapsedTimeTask, IterativeProcess.StepCompleted
-
-
Field Summary
Fields Modifier and Type Field Description static double
DEFAULT_ALPHA
static int
DEFAULT_MAX_ITER
static double
DEFAULT_PREC
static double
DEFAULT_SCALE_FACTOR
protected double
myAlpha
The smoothing parameterprotected double
myDesiredPrecision
Desired precision.protected double
myPrevFofX
Used to remember the last evaluationprotected double
myPrevX
Used to remember the last rootprotected double
myRMSeries
The stepping seriesprotected double
myRSC
Used in the exponentially weighted stopping criteriaprotected double
myScaleFactor
Scale addFactor can be used in accelerated procedure-
Fields inherited from class jsl.utilities.rootfinding.IPRootFinder
f, myInitialPt, myInterval, myMaxIterations, numIterations, searchFactor
-
Fields inherited from class jsl.simulation.IterativeProcess
COMPLETED_ALL_STEPS, COMPLETED_ALL_STEPS_MSG, EXCEEDED_EXECUTION_TIME, EXCEEDED_EXECUTION_TIME_MSG, MET_STOPPING_CONDITION, MET_STOPPING_CONDITION_MSG, myBeginExecutionTime, myCreatedState, myCurrentStep, myDoneFlag, myEndedState, myEndExecutionTime, myEndingStateIndicator, myId, myInitFlag, myInitializedState, myIPLogReport, myMaxAllowedExecutionTime, myName, myObservableComponent, myRunningFlag, myRunningStepFlag, mySaveStepOption, myState, myStepCompletedState, myStepCounter, mySteps, myTBConsoleUpdates, myTimer, myTimerTask, NO_STEPS_EXECUTED, NO_STEPS_EXECUTED_MSG, UNFINISHED, UNFINISHED_MSG
-
-
Constructor Summary
Constructors Constructor Description StochasticApproximationRootFinder(FunctionIfc func, double xLower, double xUpper)
Constructs a stochastic approximation root finder for the function, using default scale addFactor and mid-point of interval as initial pointStochasticApproximationRootFinder(FunctionIfc func, double initialPt, double xLower, double xUpper)
Constructs a stochastic approximation root finder for the function, using default scale addFactorStochasticApproximationRootFinder(FunctionIfc func, double initialPt, double scaleFactor, double xLower, double xUpper)
Constructs a stochastic approximation root finder for the functionStochasticApproximationRootFinder(FunctionIfc func, Interval interval)
Constructs a stochastic approximation root finder for the function, using default scale addFactor and mid-point of interval as initial point
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
getDesiredPrecision()
Returns the desired precision.double
getScaleFactor()
Gets the current scale addFactor valuedouble
getSmoothingParameter()
Returns the smoothing parameterdouble
getStoppingCriteria()
Gets the stopping criteria of the searchboolean
hasConverged()
Check to see if the result has been attained.protected boolean
hasNext()
Continues until hasConverged() is true or max iterations is reachedprotected void
initializeIterations()
protected RootFinderStep
next()
Computes the next possible root value provided process has a valid step.double
recommendScalingFactor(double initialPt, double delta)
Uses a linear approximation to recommend a scaling addFactor that can be used during the searchprotected void
runStep()
Tells the process to run (execute) the current step.void
setDesiredPrecision(double prec)
Defines the desired precision.void
setScaleFactor(double scaleFactor)
Sets the scale addFactor used during the search processvoid
setSmoothingParameter(double alpha)
Sets the smoothing parameter.java.lang.String
toString()
Returns a String representation-
Methods inherited from class jsl.utilities.rootfinding.IPRootFinder
contains, findInterval, findInterval, getFunctionAtRoot, getInitialPoint, getLowerLimit, getMaxIterations, getRoot, getUpperLimit, hasIterations, hasRoot, hasRoot, hasRoot, recommendInitialPoint, recommendInitialPoint, relativePrecision, relativePrecision, setFunction, setInitialPoint, setInterval, setInterval, setInterval, setInterval, setMaxIterations, setRoot
-
Methods inherited from class jsl.simulation.IterativeProcess
addObserver, allStepsCompleted, checkStoppingCondition, checkStoppingCondition_, consoleOutput, contains, countObservers, deleteObserver, deleteObservers, end, end, endIterations, executionTimeExceeded, getBeginExecutionTime, getCurrentStateAsString, getCurrentStep, getElapsedExecutionTime, getEndExecutionTime, getEndingStateIndicator, getEndingStateIndicatorAsString, getId, getLogReport, getMaximumAllowedExecutionTime, getName, getNumberStepsCompleted, getSaveStepOption, getStepIterator, getStepList, getStoppingFlag, getStoppingMessage, initialize, isCreated, isDone, isEnded, isExecutionTimeExceeded, isInitialized, isRunning, isRunningStep, isStepCompleted, isUnfinished, noStepsExecuted, run, runAll_, runNext, runNext_, setId, setMaximumExecutionTime, setName, setSaveStepOption, setState, stop, stop, stoppedByCondition, turnOffLogReport, turnOnLogReport, turnOnTimer
-
-
-
-
Field Detail
-
DEFAULT_PREC
public static final double DEFAULT_PREC
- See Also:
- Constant Field Values
-
DEFAULT_ALPHA
public static final double DEFAULT_ALPHA
- See Also:
- Constant Field Values
-
DEFAULT_SCALE_FACTOR
public static final double DEFAULT_SCALE_FACTOR
- See Also:
- Constant Field Values
-
DEFAULT_MAX_ITER
public static final int DEFAULT_MAX_ITER
- See Also:
- Constant Field Values
-
myDesiredPrecision
protected double myDesiredPrecision
Desired precision.
-
myAlpha
protected double myAlpha
The smoothing parameter
-
myRSC
protected double myRSC
Used in the exponentially weighted stopping criteria
-
myScaleFactor
protected double myScaleFactor
Scale addFactor can be used in accelerated procedure
-
myRMSeries
protected double myRMSeries
The stepping series
-
myPrevX
protected double myPrevX
Used to remember the last root
-
myPrevFofX
protected double myPrevFofX
Used to remember the last evaluation
-
-
Constructor Detail
-
StochasticApproximationRootFinder
public StochasticApproximationRootFinder(FunctionIfc func, Interval interval)
Constructs a stochastic approximation root finder for the function, using default scale addFactor and mid-point of interval as initial point- Parameters:
func
-interval
-
-
StochasticApproximationRootFinder
public StochasticApproximationRootFinder(FunctionIfc func, double xLower, double xUpper)
Constructs a stochastic approximation root finder for the function, using default scale addFactor and mid-point of interval as initial point- Parameters:
func
-xLower
- - a lower limit on the search, initial point must be > xLowerxUpper
- - an upper limit on the search, initial point must be < xUpper
-
StochasticApproximationRootFinder
public StochasticApproximationRootFinder(FunctionIfc func, double initialPt, double xLower, double xUpper)
Constructs a stochastic approximation root finder for the function, using default scale addFactor- Parameters:
func
-initialPt
- the initial point for the searchxLower
- - a lower limit on the search, initial point must be > xLowerxUpper
- - an upper limit on the search, initial point must be < xUpper
-
StochasticApproximationRootFinder
public StochasticApproximationRootFinder(FunctionIfc func, double initialPt, double scaleFactor, double xLower, double xUpper)
Constructs a stochastic approximation root finder for the function- Parameters:
func
-initialPt
- the initial point for the searchscaleFactor
- - the scale addFactor used during the searchxLower
- - a lower limit on the search, initial point must be > xLowerxUpper
- - an upper limit on the search, initial point must be < xUpper
-
-
Method Detail
-
setScaleFactor
public void setScaleFactor(double scaleFactor)
Sets the scale addFactor used during the search process- Parameters:
scaleFactor
- , must be > 0.0
-
getScaleFactor
public double getScaleFactor()
Gets the current scale addFactor value- Returns:
-
getDesiredPrecision
public double getDesiredPrecision()
Returns the desired precision.
-
setDesiredPrecision
public void setDesiredPrecision(double prec)
Defines the desired precision.- Parameters:
prec
- , must be > 0.0
-
getSmoothingParameter
public final double getSmoothingParameter()
Returns the smoothing parameter- Returns:
-
setSmoothingParameter
public final void setSmoothingParameter(double alpha)
Sets the smoothing parameter.- Parameters:
alpha
- , must be in [0,1]
-
recommendScalingFactor
public double recommendScalingFactor(double initialPt, double delta)
Uses a linear approximation to recommend a scaling addFactor that can be used during the search- Parameters:
initialPt
-delta
- - defines an interval +/- delta around initialPt to make linear approximation- Returns:
-
initializeIterations
protected void initializeIterations()
- Overrides:
initializeIterations
in classIterativeProcess<RootFinderStep>
-
hasNext
protected boolean hasNext()
Continues until hasConverged() is true or max iterations is reached- Specified by:
hasNext
in classIterativeProcess<RootFinderStep>
- Returns:
- true if another step is present
-
hasConverged
public boolean hasConverged()
Check to see if the result has been attained.- Specified by:
hasConverged
in classIPRootFinder
- Returns:
- boolean
-
getStoppingCriteria
public double getStoppingCriteria()
Gets the stopping criteria of the search- Returns:
-
toString
public java.lang.String toString()
Returns a String representation- Overrides:
toString
in classIPRootFinder
- Returns:
- A String with basic results
-
next
protected RootFinderStep next()
Computes the next possible root value provided process has a valid step.- Specified by:
next
in classIterativeProcess<RootFinderStep>
- Returns:
- RootFinderStep or null if no more steps
-
runStep
protected void runStep()
Tells the process to run (execute) the current step. Moves to the next step if available and updates current step of the process- Specified by:
runStep
in classIterativeProcess<RootFinderStep>
-
-