gov.sns.tools.optimization
Class RandomSearchAlgorithm.RandomSearcher

java.lang.Object
  |
  +--gov.sns.tools.optimization.RandomSearchAlgorithm.RandomSearcher
All Implemented Interfaces:
RandomSearchAlgorithm.Searcher, gov.sns.tools.optimization.ScoreMonitor
Direct Known Subclasses:
RandomSearchAlgorithm.ComboSearcher, RandomSearchAlgorithm.ShrinkSearcher
Enclosing class:
RandomSearchAlgorithm

protected class RandomSearchAlgorithm.RandomSearcher
extends java.lang.Object
implements RandomSearchAlgorithm.Searcher

A searcher that performs a simple random search in the entire search space.


Field Summary
protected  double changeProbabilityBase
           
protected  java.util.Random randomGenerator
           
protected  java.util.Map values
           
 
Constructor Summary
RandomSearchAlgorithm.RandomSearcher()
          Constructor
 
Method Summary
 void newScore(java.lang.Object sender, Solution solution)
          Notifies the receiver of a new score event.
 void 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.
 TrialPoint nextPoint()
          Get the next trial point.
 TrialPoint nextPoint(int expectedNumToChange)
          Get the next trial point given the expected number of variables to change.
 TrialPoint nextTrialPoint()
          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 history
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

randomGenerator

protected java.util.Random randomGenerator

changeProbabilityBase

protected double changeProbabilityBase

values

protected java.util.Map values
Constructor Detail

RandomSearchAlgorithm.RandomSearcher

public RandomSearchAlgorithm.RandomSearcher()
Constructor

Method Detail

reset

public void reset()
reset for searching from scratch; forget history

Specified by:
reset in interface RandomSearchAlgorithm.Searcher

newTopSolution

public void 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.

Specified by:
newTopSolution in interface RandomSearchAlgorithm.Searcher
Parameters:
oldPoint - The old best point.
newPoint - The new best point.

nextTrialPoint

public TrialPoint nextTrialPoint()
Get the next trial point. Simply returns nextPoint().

Specified by:
nextTrialPoint in interface RandomSearchAlgorithm.Searcher
Returns:
the next trial point.

nextPoint

public TrialPoint nextPoint()
Get the next trial point.

Returns:
the next trial point.

nextPoint

public TrialPoint nextPoint(int expectedNumToChange)
Get the next trial point given the expected number of variables to change. Randomly pick the number of variables to vary by weighting 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

protected double proposeValue(Variable variable)
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

newScore

public void newScore(java.lang.Object sender,
                     Solution solution)
Notifies the receiver of a new score event.

Specified by:
newScore in interface gov.sns.tools.optimization.ScoreMonitor
Parameters:
sender - The object posting the event.
solution - The solution posted.