edu.duke.cs.banjo.learner
Class Searcher

java.lang.Object
  extended byedu.duke.cs.banjo.learner.Searcher
All Implemented Interfaces:
SearcherI
Direct Known Subclasses:
SearcherGreedy, SearcherSimAnneal, SearcherSkip

public abstract class Searcher
extends java.lang.Object
implements SearcherI

Combines common code shared by the different searcher implementations.

Details:

Change History:
Created on Apr 14, 2004

10/18/2005 (v2.0) hjs Scope change of several variables.
Code cleanup as part of initial setting up of version 1.5.

Author:
Jurgen Sladeczek (hjs)
For the latest info, please visit www.cs.duke.edu.

Nested Class Summary
protected  class Searcher.HighScoreSetUpdater
          Base class of inner classes for updating the score info for a search.
protected  class Searcher.SearchExecuter
          Base class of inner classes for executing a search.
protected  class Searcher.SearchMultipleTerminator
          Subclass class of inner classes for terminating a search using possibly multiple criteria.
protected  class Searcher.SearchTerminator
          Base class of inner classes for terminating a search.
 
Field Summary
protected  BayesNetManagerI bayesNetManager
           
protected  double currentBestScoreSinceRestart
           
protected  CycleCheckerI cycleChecker
           
protected  DeciderI decider
           
protected  boolean displayFeedbackByTime
           
protected  java.lang.String displayMemoryInfo
           
protected  long elapsedTime
           
protected  EquivalenceCheckerI equivalenceChecker
           
protected  long estimatedTime
           
protected  EvaluatorI evaluator
           
protected  java.lang.String feedbackRestarts
           
protected  double feedbackTimeDelta
           
protected  double fileReportInterval
           
protected  double fileReportTimeDelta
           
protected  Searcher.HighScoreSetUpdater highScoreSetUpdater
           
protected  java.util.TreeSet highScoreStructureSet
           
protected  BayesNetStructureI highScoreStructureSinceRestart
           
protected  long intermediateTime
           
protected  boolean isEquivalent
           
protected  int lineLength
           
protected  java.lang.String linePostfix
           
protected  int loopPaddingLength
           
protected  int maxMarkovLag
           
protected  long maxNetworksVisitedInInnerLoop
           
protected  long maxRestarts
           
protected  long maxSearchLoops
           
protected  long maxSearchTime
           
protected  int minMarkovLag
           
protected  long nBestCount
           
protected  long nBestMax
           
protected  double nBestThresholdScore
           
protected  long networksVisitedGlobalCounter
           
protected  long networksVisitedInnerLoopCounter
           
protected  java.lang.String newLinePlusPrefix
           
protected  double nextFeedbackTime
           
protected  double nextFileReportTime
           
protected  double nextScreenReportTime
           
protected  java.util.TreeSet nonEquivalentHighScoreStructureSet
           
protected  int numberOfDecimals
           
protected  java.lang.StringBuffer optionalThreadLabel
           
protected  int percentLevel
           
protected  int percentPaddingLength
           
protected  java.lang.String prefix
           
protected  Settings processData
           
protected  ProposerI proposer
           
protected  long restartCount
           
protected  int restartPaddingLength
           
protected  java.lang.StringBuffer restartsAtCounts
           
protected  boolean restartWithRandomNetwork
           
protected  double screenReportInterval
           
protected  double screenReportTimeDelta
           
protected  RecorderI searcherStatistics
           
protected  java.lang.StringBuffer searcherStats
           
protected  Searcher.SearchExecuter searchExecuter
           
protected  Searcher.SearchTerminator searchTerminator
           
protected  long startTime
           
protected  BayesNetChangeI suggestedBayesNetChange
           
(package private)  java.util.List suggestedChangeList
           
protected  Searcher.SearchTerminator[] terminator
           
protected  java.text.DateFormat timeFormat
           
protected  int timePaddingLength
           
protected  boolean trackIntermediateResults
           
protected  double unreachableScore
           
protected  int varCount
           
 
Constructor Summary
Searcher(Settings _processData)
          Constructor for instantiating the objects shared between searcher implementations.
 
Method Summary
protected  boolean askToVerifySettings()
          (Optional) Lets user verify the selected search parameters before running a search.
abstract  void executeSearch()
          Executes the search based on the particular search algorithm.
protected  java.lang.StringBuffer feedbackBasedOnTime()
           
protected  void finalCleanup()
          Gathers the final set of data produced by the search, collected from the core components.
 java.lang.Object getBayesNetManager()
           
protected  long getElapsedTime()
           
 double getHighScore()
           
 java.lang.Object getHighScoreStructure()
           
 java.util.Collection getHighScoreStructureSet()
           
 long getNetworksVisitedGlobalCounter()
           
 RecorderI getSearcherStatistics()
           
protected  void handleOutOfMemory()
           
protected  java.lang.StringBuffer listScores()
           
 java.lang.StringBuffer provideCollectedStatistics()
           
protected  void pruneEquivalentNetworks()
          Prunes the set of "current" high-scoring networks into the set of non-equivalent ones
protected  java.lang.StringBuffer trackIntermediateResults()
          Method used by terminator inner classes, for providing a display of the intermediate results (networks and their scores).
private  boolean validateRequiredData()
          Validates the settings values required for the searcher base class (a multitude of settings including the variable count, min and max Markov orders, max parent counts, and more).
 java.lang.Object validChoices()
          Provides the valid choices for this class, here: for the recorders.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface edu.duke.cs.banjo.learner.SearcherI
updateProcessData
 

Field Detail

proposer

protected ProposerI proposer

evaluator

protected EvaluatorI evaluator

decider

protected DeciderI decider

cycleChecker

protected CycleCheckerI cycleChecker

searchExecuter

protected Searcher.SearchExecuter searchExecuter

searchTerminator

protected Searcher.SearchTerminator searchTerminator

highScoreSetUpdater

protected Searcher.HighScoreSetUpdater highScoreSetUpdater

terminator

protected Searcher.SearchTerminator[] terminator

varCount

protected final int varCount

minMarkovLag

protected final int minMarkovLag

maxMarkovLag

protected final int maxMarkovLag

networksVisitedGlobalCounter

protected long networksVisitedGlobalCounter

networksVisitedInnerLoopCounter

protected long networksVisitedInnerLoopCounter

maxNetworksVisitedInInnerLoop

protected long maxNetworksVisitedInInnerLoop

unreachableScore

protected final double unreachableScore
See Also:
Constant Field Values

maxSearchTime

protected long maxSearchTime

maxSearchLoops

protected long maxSearchLoops

maxRestarts

protected long maxRestarts

restartCount

protected long restartCount

restartsAtCounts

protected java.lang.StringBuffer restartsAtCounts

processData

protected Settings processData

searcherStatistics

protected volatile RecorderI searcherStatistics

equivalenceChecker

protected final EquivalenceCheckerI equivalenceChecker

isEquivalent

protected boolean isEquivalent

searcherStats

protected volatile java.lang.StringBuffer searcherStats

bayesNetManager

protected BayesNetManagerI bayesNetManager

suggestedBayesNetChange

protected BayesNetChangeI suggestedBayesNetChange

currentBestScoreSinceRestart

protected double currentBestScoreSinceRestart

highScoreStructureSinceRestart

protected BayesNetStructureI highScoreStructureSinceRestart

highScoreStructureSet

protected volatile java.util.TreeSet highScoreStructureSet

nonEquivalentHighScoreStructureSet

protected volatile java.util.TreeSet nonEquivalentHighScoreStructureSet

nBestCount

protected long nBestCount

nBestMax

protected final long nBestMax

nBestThresholdScore

protected double nBestThresholdScore

suggestedChangeList

java.util.List suggestedChangeList

percentLevel

protected int percentLevel

displayFeedbackByTime

protected boolean displayFeedbackByTime

feedbackTimeDelta

protected final double feedbackTimeDelta

nextFeedbackTime

protected double nextFeedbackTime

trackIntermediateResults

protected final boolean trackIntermediateResults

screenReportTimeDelta

protected final double screenReportTimeDelta

nextScreenReportTime

protected double nextScreenReportTime

screenReportInterval

protected final double screenReportInterval

fileReportTimeDelta

protected final double fileReportTimeDelta

nextFileReportTime

protected double nextFileReportTime

fileReportInterval

protected final double fileReportInterval

displayMemoryInfo

protected java.lang.String displayMemoryInfo

startTime

protected volatile long startTime

elapsedTime

protected volatile long elapsedTime

intermediateTime

protected volatile long intermediateTime

timeFormat

protected java.text.DateFormat timeFormat

estimatedTime

protected long estimatedTime

numberOfDecimals

protected int numberOfDecimals

percentPaddingLength

protected int percentPaddingLength

timePaddingLength

protected int timePaddingLength

loopPaddingLength

protected int loopPaddingLength

restartPaddingLength

protected int restartPaddingLength

newLinePlusPrefix

protected java.lang.String newLinePlusPrefix

linePostfix

protected java.lang.String linePostfix

prefix

protected java.lang.String prefix

lineLength

protected int lineLength

feedbackRestarts

protected java.lang.String feedbackRestarts

restartWithRandomNetwork

protected final boolean restartWithRandomNetwork

optionalThreadLabel

protected java.lang.StringBuffer optionalThreadLabel
Constructor Detail

Searcher

public Searcher(Settings _processData)
         throws java.lang.Exception
Constructor for instantiating the objects shared between searcher implementations.

Parameters:
_processData - The special container for the initial, validated, and dynamically updated settings.
Method Detail

validateRequiredData

private boolean validateRequiredData()
                              throws java.lang.Exception
Validates the settings values required for the searcher base class (a multitude of settings including the variable count, min and max Markov orders, max parent counts, and more).

Returns:
Returns the boolean flag that indicates whether a crucial setting could not be validated.
Throws:
java.lang.Exception

finalCleanup

protected void finalCleanup()
                     throws java.lang.Exception
Gathers the final set of data produced by the search, collected from the core components.

Throws:
java.lang.Exception

pruneEquivalentNetworks

protected void pruneEquivalentNetworks()
                                throws java.lang.Exception
Prunes the set of "current" high-scoring networks into the set of non-equivalent ones

Throws:
java.lang.Exception

getNetworksVisitedGlobalCounter

public long getNetworksVisitedGlobalCounter()
Returns:
Returns the networksVisitedGlobalCounter.

getSearcherStatistics

public RecorderI getSearcherStatistics()
Returns:
Returns the searcherStatistics.

getBayesNetManager

public java.lang.Object getBayesNetManager()
Returns:
Returns the bayesNetManager.

getHighScore

public double getHighScore()
Returns:
Returns the currentBestScoreSinceRestart.

getHighScoreStructure

public java.lang.Object getHighScoreStructure()
Returns:
Returns the highScoreStructureSinceRestart.

getHighScoreStructureSet

public java.util.Collection getHighScoreStructureSet()
Returns:
Returns the highScoreStructureSet.

getElapsedTime

protected long getElapsedTime()
Returns:
Returns the elapsedTime that the search has been running.

listScores

protected java.lang.StringBuffer listScores()
Returns:
Returns the top scoring network(s) that the search found so far.

askToVerifySettings

protected boolean askToVerifySettings()
                               throws java.lang.Exception
(Optional) Lets user verify the selected search parameters before running a search.

Returns:
Returns the boolean value of the user's choice.
Throws:
java.lang.Exception

provideCollectedStatistics

public java.lang.StringBuffer provideCollectedStatistics()
                                                  throws java.lang.Exception
Specified by:
provideCollectedStatistics in interface SearcherI
Returns:
Returns the statistics about the particular searcher implementation.
Throws:
java.lang.Exception

feedbackBasedOnTime

protected java.lang.StringBuffer feedbackBasedOnTime()
                                              throws java.lang.Exception
Returns:
Prepares a feedback string about the search progress, based on the screen report interval. Used by the terminator inner classes.
Throws:
java.lang.Exception

trackIntermediateResults

protected java.lang.StringBuffer trackIntermediateResults()
                                                   throws java.lang.Exception
Method used by terminator inner classes, for providing a display of the intermediate results (networks and their scores).

Throws:
java.lang.Exception

handleOutOfMemory

protected void handleOutOfMemory()
                          throws java.lang.Exception
Throws:
java.lang.Exception

validChoices

public java.lang.Object validChoices()
Provides the valid choices for this class, here: for the recorders.


executeSearch

public abstract void executeSearch()
                            throws java.lang.Exception
Executes the search based on the particular search algorithm.

Specified by:
executeSearch in interface SearcherI
Throws:
java.lang.Exception