#include <inference.h>
Inheritance diagram for Inference:

Public Member Functions | |
| Inference (VariableState *state, long int seed, const bool &trackClauseTrueCnts) | |
| Constructor: Every inference algorithm is required to have a VariableState representing the state of variables and clauses and a seed for any randomization in the algorithm. | |
| virtual | ~Inference () |
| Virtual destructor. | |
| virtual void | init ()=0 |
| Initializes the inference algorithm. | |
| virtual void | infer ()=0 |
| Performs the inference algorithm. | |
| virtual void | printProbabilities (ostream &out)=0 |
| Prints the probabilities of each predicate to a stream. | |
| virtual void | getPredsWithNonZeroProb (vector< string > &nonZeroPreds, vector< float > &probs)=0 |
| Puts the predicates with non-zero probability in string form and the corresponding probabilities of each predicate in two vectors (for MAP inference, this is exactly the atoms inferred to be true. | |
| virtual void | printTruePreds (ostream &out)=0 |
| Prints the predicates inferred to be true to a stream. | |
| virtual double | getProbability (GroundPredicate *const &gndPred)=0 |
| Gets the probability of a ground predicate. | |
| long int | getSeed () |
| void | setSeed (long int s) |
| VariableState * | getState () |
| void | setState (VariableState *s) |
| const Array< double > * | getClauseTrueCnts () |
Protected Attributes | |
| long int | seed_ |
| VariableState * | state_ |
| Array< double > * | clauseTrueCnts_ |
| bool | trackClauseTrueCnts_ |
At least one function is pure virtual making this an abstract class (it can not be instantiated).
Definition at line 76 of file inference.h.
| Inference::Inference | ( | VariableState * | state, | |
| long int | seed, | |||
| const bool & | trackClauseTrueCnts | |||
| ) | [inline] |
Constructor: Every inference algorithm is required to have a VariableState representing the state of variables and clauses and a seed for any randomization in the algorithm.
If there is no randomization, seed is not used.
| state | State of the variables and clauses of the inference. | |
| seed | Seed used to initialize randomization in the algorithm. | |
| trackClauseTrueCnts | Indicates if true counts for each first-order clause are being kept |
Definition at line 91 of file inference.h.
References clauseTrueCnts_, VariableState::getMLN(), MLN::getNumClauses(), Array< Type >::growToSize(), seed_, state_, and trackClauseTrueCnts_.
00093 { 00094 this->state_ = state; 00095 this->seed_ = seed; 00096 if (seed_ <= 0) 00097 { 00098 struct timeval tv; 00099 struct timezone tzp; 00100 gettimeofday(&tv, &tzp); 00101 seed_ = (long int)((( tv.tv_sec & 0177 ) * 1000000) + tv.tv_usec); 00102 } 00103 srandom(seed_); 00104 00105 trackClauseTrueCnts_ = trackClauseTrueCnts; 00106 if (trackClauseTrueCnts_) 00107 { 00108 // clauseTrueCnts_ will hold the true counts for each first-order clause 00109 clauseTrueCnts_ = new Array<double>; 00110 clauseTrueCnts_->growToSize(state_->getMLN()->getNumClauses(), 0); 00111 } 00112 }
1.5.1