net.sf.bddbddb
Class FindBestDomainOrder

java.lang.Object
  extended by net.sf.bddbddb.FindBestDomainOrder

public class FindBestDomainOrder
extends java.lang.Object

FindBestDomainOrder Design: TrialInfo : order, cost EpisodeCollection : collection of TrialInfo, best time, worst time Constraint: a ConstraintInfo collection Rule -> ConstraintInfo collection EpisodeCollection -> ConstraintInfo collection Algorithm to compute best order: - Combine and sort single constraints from relation, rule, trials so far. Sort by score*confidence (?) Combine and adjust opposite constraints (?) Sort by difference between opposite constraints (?) - Do an A* search. Keep track of the current score/confidence as we add constraints. As we add new constraints, flag conflicting ones. Predict final score by combining top n non-conflicting constraints (?) If prediction is worse than current best score, return immediately.

Version:
$Id: FindBestDomainOrder.java 645 2006-07-17 05:20:20Z joewhaley $
Author:
John Whaley

Nested Class Summary
static class FindBestDomainOrder.ConstraintInfoCollection
           
static class FindBestDomainOrder.OrderInfo
          Calculated information about an order.
static class FindBestDomainOrder.OrderSearchElem
           
 
Field Summary
static double ACENT
           
static int AMEAN_INDEX
           
 double attrClassWeight
           
static int CANDIDATE_SET_SIZE
           
static java.lang.String CLASSIFIER1
           
static java.lang.String CLASSIFIER2
           
static java.lang.String CLASSIFIER3
           
static java.text.SimpleDateFormat dateFormat
           
static double DCENT
           
static double DECAY_FACTOR
           
static boolean DISCRETIZE1
           
static boolean DISCRETIZE2
           
static boolean DISCRETIZE3
           
static int DMEAN_INDEX
           
static int DOMAIN_THRESHOLD
           
 double domClassWeight
           
static boolean DUMP_CLASSIFIER_INFO
           
static int INITIAL_ATTRIB_SET
           
static int INITIAL_DOM_SET
           
static int INITIAL_VAR_SET
           
static int NO_CLASS
           
static int NO_CLASS_SCORE
           
static int NUM_CV_FOLDS
           
static java.io.PrintStream out
           
static java.io.PrintStream out_t
           
static boolean PER_RULE_CONSTRAINTS
          Whether we should keep track of per-rule constraints, in addition to global constraints.
 boolean PROBABILITY
           
static int SAMPLE_SIZE
           
static int TRACE
           
static double UNCERTAINTY_THRESHOLD
           
 double varClassWeight
           
static double VCENT
           
static int VMEAN_INDEX
           
static boolean WEIGHT_UNCERTAINTY_SAMPLE
           
static int WEIGHT_WINDOW_SIZE
           
 
Constructor Summary
FindBestDomainOrder(Solver s)
          Construct a new empty FindBestDomainOrder object.
 
Method Summary
 void adjustWeights(TrialInstances vData, TrialInstances aData, TrialInstances dData)
           
 java.lang.String bestOrders(BDDInferenceRule rule, int k)
          Generate the k best orders for the given inference rule and put the result in a string.
static int compare(double d1, double d2)
           
 double computeWeight(int type, TrialInstances instances)
           
 double constFoldCV(weka.core.Instances data, java.lang.String cClassName)
           
 void dump()
          Dump the collected order info for rules and relations to standard output.
 EpisodeCollection findEpisodeCollection(BDDInferenceRule rule, int opNumber)
           
static java.lang.String format(double d)
          Format a double in a nice way.
static java.lang.String format(double d, int numFracDigits)
           
static java.util.List generateAllOrders(java.util.List vars)
          Generate all orders of a given list of variables.
 java.lang.Object generateCandidateSet(InferenceRule ir, java.util.List allVars, double[][] means, TrialDataRepository.TrialDataGroup vDataGroup, TrialDataRepository.TrialDataGroup aDataGroup, TrialDataRepository.TrialDataGroup dDataGroup, java.util.Collection triedOrders, boolean returnBest)
           
 double[][] getBucketMeans(Discretization vDis, Discretization aDis, Discretization dDis)
           
 int getCombos(double[][] combos, int start, int numV, int numA, int numD, double vBuckets, double aBuckets, double dBuckets, double[][] means, double maxScore)
           
 EpisodeCollection.Episode getNewEpisode(BDDInferenceRule rule, int opNumber, long timeStamp, boolean newCollection)
          Starts a new trial collection and returns it.
 int getNumberOfTrials()
           
 java.util.Set getVisitedRules()
           
 boolean hasOrdersToTry(java.util.List allVars, BDDInferenceRule ir)
           
static void main(java.lang.String[] args)
           
 void neverTryAgain(InferenceRule ir, Order o)
           
 FindBestDomainOrder.OrderInfo predict(Order o, OrderTranslator trans)
           
 void printBestBDDOrders()
           
 void printBestTrials()
           
 void printTrialsDistro()
           
static void printTrialsDistro(java.util.Collection trials, Solver solver)
           
 java.util.Collection selectOrder(java.util.Collection orders, TrialInstances vData, TrialInstances aData, TrialInstances dData, InferenceRule ir, boolean force)
           
static int signum(double d)
           
static int signum(long d)
           
 org.jdom.Element toXMLElement()
          Returns this FindBestDomainOrder as an XML element.
 org.jdom.Element trialsToXMLElement()
          Returns the set of all trials performed so far as an XML element.
 TrialGuess tryNewGoodOrder(EpisodeCollection.Episode ep, java.util.List allVars, InferenceRule ir, int opNum, boolean returnBest)
           
 TrialGuess tryNewGoodOrder(EpisodeCollection ec, java.util.List allVars, InferenceRule ir, int opNum, Order chosenOne, boolean returnBest)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRACE

public static int TRACE

out

public static java.io.PrintStream out

out_t

public static java.io.PrintStream out_t

dateFormat

public static final java.text.SimpleDateFormat dateFormat

PER_RULE_CONSTRAINTS

public static boolean PER_RULE_CONSTRAINTS
Whether we should keep track of per-rule constraints, in addition to global constraints.


DUMP_CLASSIFIER_INFO

public static boolean DUMP_CLASSIFIER_INFO

WEIGHT_WINDOW_SIZE

public static final int WEIGHT_WINDOW_SIZE
See Also:
Constant Field Values

DECAY_FACTOR

public static final double DECAY_FACTOR
See Also:
Constant Field Values

NUM_CV_FOLDS

public static int NUM_CV_FOLDS

DISCRETIZE1

public static boolean DISCRETIZE1

DISCRETIZE2

public static boolean DISCRETIZE2

DISCRETIZE3

public static boolean DISCRETIZE3

CLASSIFIER1

public static java.lang.String CLASSIFIER1

CLASSIFIER2

public static java.lang.String CLASSIFIER2

CLASSIFIER3

public static java.lang.String CLASSIFIER3

varClassWeight

public double varClassWeight

attrClassWeight

public double attrClassWeight

domClassWeight

public double domClassWeight

DOMAIN_THRESHOLD

public static int DOMAIN_THRESHOLD

NO_CLASS

public static int NO_CLASS

NO_CLASS_SCORE

public static int NO_CLASS_SCORE

PROBABILITY

public boolean PROBABILITY

INITIAL_VAR_SET

public static int INITIAL_VAR_SET

INITIAL_ATTRIB_SET

public static int INITIAL_ATTRIB_SET

INITIAL_DOM_SET

public static int INITIAL_DOM_SET

VMEAN_INDEX

public static final int VMEAN_INDEX
See Also:
Constant Field Values

AMEAN_INDEX

public static final int AMEAN_INDEX
See Also:
Constant Field Values

DMEAN_INDEX

public static final int DMEAN_INDEX
See Also:
Constant Field Values

CANDIDATE_SET_SIZE

public static int CANDIDATE_SET_SIZE

SAMPLE_SIZE

public static int SAMPLE_SIZE

UNCERTAINTY_THRESHOLD

public static double UNCERTAINTY_THRESHOLD

WEIGHT_UNCERTAINTY_SAMPLE

public static boolean WEIGHT_UNCERTAINTY_SAMPLE

VCENT

public static double VCENT

ACENT

public static double ACENT

DCENT

public static double DCENT
Constructor Detail

FindBestDomainOrder

public FindBestDomainOrder(Solver s)
Construct a new empty FindBestDomainOrder object.

Method Detail

dump

public void dump()
Dump the collected order info for rules and relations to standard output.


getNumberOfTrials

public int getNumberOfTrials()

getNewEpisode

public EpisodeCollection.Episode getNewEpisode(BDDInferenceRule rule,
                                               int opNumber,
                                               long timeStamp,
                                               boolean newCollection)
Starts a new trial collection and returns it.

Parameters:
rule - inference rule of trial collection
opNumber - operation number of trial collection
timeStamp - time of trial collection
newCollection - whether to always return a new collection
Returns:
new trial collection

findEpisodeCollection

public EpisodeCollection findEpisodeCollection(BDDInferenceRule rule,
                                               int opNumber)

generateAllOrders

public static java.util.List generateAllOrders(java.util.List vars)
Generate all orders of a given list of variables.

Parameters:
vars - list of variables
Returns:
list of all orders of those variables

format

public static java.lang.String format(double d)
Format a double in a nice way.

Parameters:
d - double
Returns:
string representation

format

public static java.lang.String format(double d,
                                      int numFracDigits)

signum

public static int signum(long d)

signum

public static int signum(double d)

predict

public FindBestDomainOrder.OrderInfo predict(Order o,
                                             OrderTranslator trans)

toXMLElement

public org.jdom.Element toXMLElement()
Returns this FindBestDomainOrder as an XML element.

Returns:
XML element

trialsToXMLElement

public org.jdom.Element trialsToXMLElement()
Returns the set of all trials performed so far as an XML element.

Returns:
XML element

hasOrdersToTry

public boolean hasOrdersToTry(java.util.List allVars,
                              BDDInferenceRule ir)

compare

public static final int compare(double d1,
                                double d2)

computeWeight

public double computeWeight(int type,
                            TrialInstances instances)

adjustWeights

public void adjustWeights(TrialInstances vData,
                          TrialInstances aData,
                          TrialInstances dData)

constFoldCV

public double constFoldCV(weka.core.Instances data,
                          java.lang.String cClassName)
Parameters:
data -
cClassName -
Returns:
Cross validation with number of folds as set by NUM_CV_FOLDS;

neverTryAgain

public void neverTryAgain(InferenceRule ir,
                          Order o)

tryNewGoodOrder

public TrialGuess tryNewGoodOrder(EpisodeCollection.Episode ep,
                                  java.util.List allVars,
                                  InferenceRule ir,
                                  int opNum,
                                  boolean returnBest)

tryNewGoodOrder

public TrialGuess tryNewGoodOrder(EpisodeCollection ec,
                                  java.util.List allVars,
                                  InferenceRule ir,
                                  int opNum,
                                  Order chosenOne,
                                  boolean returnBest)

getBucketMeans

public double[][] getBucketMeans(Discretization vDis,
                                 Discretization aDis,
                                 Discretization dDis)

getCombos

public int getCombos(double[][] combos,
                     int start,
                     int numV,
                     int numA,
                     int numD,
                     double vBuckets,
                     double aBuckets,
                     double dBuckets,
                     double[][] means,
                     double maxScore)

generateCandidateSet

public java.lang.Object generateCandidateSet(InferenceRule ir,
                                             java.util.List allVars,
                                             double[][] means,
                                             TrialDataRepository.TrialDataGroup vDataGroup,
                                             TrialDataRepository.TrialDataGroup aDataGroup,
                                             TrialDataRepository.TrialDataGroup dDataGroup,
                                             java.util.Collection triedOrders,
                                             boolean returnBest)

selectOrder

public java.util.Collection selectOrder(java.util.Collection orders,
                                        TrialInstances vData,
                                        TrialInstances aData,
                                        TrialInstances dData,
                                        InferenceRule ir,
                                        boolean force)

getVisitedRules

public java.util.Set getVisitedRules()

printBestBDDOrders

public void printBestBDDOrders()

bestOrders

public java.lang.String bestOrders(BDDInferenceRule rule,
                                   int k)
Generate the k best orders for the given inference rule and put the result in a string.

Parameters:
rule - inference rule
k - number of orders
Returns:
string result

printBestTrials

public void printBestTrials()

printTrialsDistro

public void printTrialsDistro()

printTrialsDistro

public static void printTrialsDistro(java.util.Collection trials,
                                     Solver solver)

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception


Copyright © 2004-2008 Stanford SUIF Compiler Group. All Rights Reserved.