felix.dstruct
Class StatOperator

java.lang.Object
  extended by java.lang.Thread
      extended by felix.dstruct.StatOperator
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Runnable
Direct Known Subclasses:
COREFOperator, CRFOperator, LROperator, TUFFYOperator

public abstract class StatOperator
extends java.lang.Thread
implements java.lang.Cloneable

Abstract class of a statistical operator (e.g., Tuffy, Coref, CRF etc. ). A valid Felix operator should extend this class and implement methods like run(), prepare(), etc.

Author:
Ce Zhang

Nested Class Summary
static class StatOperator.OPType
          Type of StatOperator.
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 java.util.HashSet<FelixClause> allRelevantFelixClause
          Set of clauses assigned to this operator.
 ConcurrentOperatorsBucket belongsToBucket
          The ConcurrentOperatorsBucket this StatOperator belongs to.
 java.util.HashMap<FelixClause,java.util.HashSet<tuffy.ra.Expression>> clauseConstraints
          Map from clauses to expressions partitioning the data.
 java.util.HashSet<FelixPredicate> commonCandidate
          Set of predicates that can potentially be shared with other operators via dual decomposition.
 boolean currentState
          Deprecated.  
 java.lang.String dataCrackerSignature
          The human-readable representation of data partitions.
 tuffy.db.RDB db
          Database connection.
 java.util.HashSet<FelixClause> dd_PriorClauses
          Rules for Lagrangian Multipliers.
 FelixQuery fq
          Felix query.
 java.util.HashSet<FelixPredicate> inputPredicates
          Set of predicates whose values are used by this operator as inputs.
 boolean isBinaryArbLR
          Deprecated.  
 boolean isMarginal
          Whether this operator works in marginal or MAP mode.
 int nStartingRules
          See ConcurrentOperatorsBucket.nStartingRule.
 java.util.HashSet<FelixPredicate> outputPredicates
          Set of predicates whose values are output by this operator.
 int partitionedInto
          Parameter assigning the degree of data partitioning.
 java.util.HashSet<java.lang.String> throwAwayPredicatesNames
          Deprecated.  
 StatOperator.OPType type
          Type of this operator.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
StatOperator(FelixQuery _fq, java.util.HashSet<FelixPredicate> _goalPredicates, FelixCommandOptions _opt)
          the constructor.
 
Method Summary
 StatOperator clone()
          Returns a clone of this statistical operator.
abstract  java.lang.String explain()
          Human-readable representation of the logic plan.
 java.util.List<DataMovementOperator> getAllDMOs()
          Get all DMOs used by this operator.
 int getPrecedence()
          Get the precedence of this operator.
 FelixPredicate getTargetPredicateIfHasOnlyOne()
          Get the target predicate of this StatOperator if this operator is CRF, LR or COREF.
abstract  void learn()
          Deprecated.  
abstract  void prepare()
          Generate the operator-specified logic plan, i.e., all data movement operators that will be used for inference.
 void pushPredicateScopes(java.util.HashSet<java.lang.String> _predicates)
          Deprecated.  
 void registerRelevantClause(FelixClause fc)
          Registers clause to this statistical operator.
abstract  void run()
          Method that executes this operator.
 void sealDefinition()
          According to the clauses added via registerRelevantClause(FelixClause), parse outputPredicates, inputPredicates, nStartingRules, and commonCandidate.
 void setPrecedence(int _value)
          Sets precedence of this statistical operator.
 java.lang.String toNoParString()
           
 java.lang.String toString()
           
 java.util.HashSet<tuffy.ra.ConjunctiveQuery> translateFelixClasesIntoFactorGraphEdgeQueries(FelixPredicate target, boolean forceRecursive, java.util.HashSet<java.lang.String> allowedOpenPredicates, FelixPredicate.FPProperty... props)
          Given a first order logic clause and a target predicate, translate it into a conjunctive query with properly assigned weight.
 java.util.HashSet<tuffy.ra.ConjunctiveQuery> translateFelixClasesIntoLearningQueriesForVictor(FelixPredicate target, FelixPredicate.FPProperty... props)
          Deprecated. Given a first order logic clause and a target predicate, translate it into a conjunctive query with properly assigned weight.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, yield
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

partitionedInto

public int partitionedInto
Parameter assigning the degree of data partitioning.


currentState

public boolean currentState
Deprecated. 

dataCrackerSignature

public java.lang.String dataCrackerSignature
The human-readable representation of data partitions. This is only used in toString()


dd_PriorClauses

public java.util.HashSet<FelixClause> dd_PriorClauses
Rules for Lagrangian Multipliers.


clauseConstraints

public java.util.HashMap<FelixClause,java.util.HashSet<tuffy.ra.Expression>> clauseConstraints
Map from clauses to expressions partitioning the data.


belongsToBucket

public ConcurrentOperatorsBucket belongsToBucket
The ConcurrentOperatorsBucket this StatOperator belongs to. StatOperators in one ConcurrentOperatorsBucket can be executed in parallel.


isMarginal

public boolean isMarginal
Whether this operator works in marginal or MAP mode.


commonCandidate

public java.util.HashSet<FelixPredicate> commonCandidate
Set of predicates that can potentially be shared with other operators via dual decomposition.


type

public StatOperator.OPType type
Type of this operator.


inputPredicates

public java.util.HashSet<FelixPredicate> inputPredicates
Set of predicates whose values are used by this operator as inputs.


outputPredicates

public java.util.HashSet<FelixPredicate> outputPredicates
Set of predicates whose values are output by this operator.


allRelevantFelixClause

public java.util.HashSet<FelixClause> allRelevantFelixClause
Set of clauses assigned to this operator.


db

public tuffy.db.RDB db
Database connection.


fq

public FelixQuery fq
Felix query.


isBinaryArbLR

public boolean isBinaryArbLR
Deprecated. 

nStartingRules

public int nStartingRules
See ConcurrentOperatorsBucket.nStartingRule.


throwAwayPredicatesNames

public java.util.HashSet<java.lang.String> throwAwayPredicatesNames
Deprecated. 
Constructor Detail

StatOperator

public StatOperator(FelixQuery _fq,
                    java.util.HashSet<FelixPredicate> _goalPredicates,
                    FelixCommandOptions _opt)
the constructor.

Parameters:
_oriMLN -
_opt -
Method Detail

pushPredicateScopes

public void pushPredicateScopes(java.util.HashSet<java.lang.String> _predicates)
Deprecated. 

Parameters:
_predicates -

clone

public StatOperator clone()
Returns a clone of this statistical operator.

Overrides:
clone in class java.lang.Thread

setPrecedence

public void setPrecedence(int _value)
Sets precedence of this statistical operator.

Parameters:
_value -

registerRelevantClause

public void registerRelevantClause(FelixClause fc)
Registers clause to this statistical operator.

Parameters:
fc -

sealDefinition

public void sealDefinition()
According to the clauses added via registerRelevantClause(FelixClause), parse outputPredicates, inputPredicates, nStartingRules, and commonCandidate.


prepare

public abstract void prepare()
Generate the operator-specified logic plan, i.e., all data movement operators that will be used for inference. This function should be invoked after a new instance of operator is created. Any valid Felix operator should implement this method.


run

public abstract void run()
Method that executes this operator. Any valid Felix operator should implement this method.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

learn

public abstract void learn()
Deprecated. 


explain

public abstract java.lang.String explain()
Human-readable representation of the logic plan. Any valid Felix operator should implement this method. TODO: need to think out a better to explain physical plan. (e.g., a graph?)


getTargetPredicateIfHasOnlyOne

public FelixPredicate getTargetPredicateIfHasOnlyOne()
Get the target predicate of this StatOperator if this operator is CRF, LR or COREF.

Returns:

translateFelixClasesIntoLearningQueriesForVictor

public java.util.HashSet<tuffy.ra.ConjunctiveQuery> translateFelixClasesIntoLearningQueriesForVictor(FelixPredicate target,
                                                                                                     FelixPredicate.FPProperty... props)
Deprecated. Given a first order logic clause and a target predicate, translate it into a conjunctive query with properly assigned weight.

Parameters:
target -
forceRecursive - If there are multiple literals of the given predicate, this parameter specifies whether the generated conjunctive queries are recursive. CRF will set this parameter as FALSE, while COREF will set it as TRUE.
props - The property selected for the target predicate.
Returns:

translateFelixClasesIntoFactorGraphEdgeQueries

public java.util.HashSet<tuffy.ra.ConjunctiveQuery> translateFelixClasesIntoFactorGraphEdgeQueries(FelixPredicate target,
                                                                                                   boolean forceRecursive,
                                                                                                   java.util.HashSet<java.lang.String> allowedOpenPredicates,
                                                                                                   FelixPredicate.FPProperty... props)
Given a first order logic clause and a target predicate, translate it into a conjunctive query with properly assigned weight.

Parameters:
target -
forceRecursive - If there are multiple literals of the given predicate, this parameter specifies whether the generated conjunctive queries are recursive. CRF will set this parameter as FALSE, while COREF will set it as TRUE.
props - The property selected for the target predicate.
Returns:

getAllDMOs

public java.util.List<DataMovementOperator> getAllDMOs()
Get all DMOs used by this operator.

Returns:

getPrecedence

public int getPrecedence()
Get the precedence of this operator.

Returns:

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Thread

toNoParString

public java.lang.String toNoParString()