UnitPropagation Class Reference

Inheritance diagram for UnitPropagation:

Inference List of all members.

Public Member Functions

 UnitPropagation (VariableState *state, long int seed, const bool &trackClauseTrueCnts)
 There is nothing to do in the constructor for unit propagation.
 ~UnitPropagation ()
void init ()
 There is nothing to initialize in unit propagation.
void infer ()
 Perform unit propagation on the clauses in the state.
void printProbabilities (ostream &out)
 Prints the best state found.
void getChangedPreds (vector< string > &changedPreds, vector< float > &probs, vector< float > &oldProbs, const float &probDelta)
 Puts the predicates whose truth value has changed with respect to the reference vector oldProbs in string form and the corresponding probabilities of each predicate (1 or 0) in two vectors.
double getProbability (GroundPredicate *const &gndPred)
 Gets the truth value of a ground predicate in the best state found.
void printTruePreds (ostream &out)
 Prints the predicates set to true in the best state to a stream.

Detailed Description

Definition at line 73 of file unitpropagation.h.


Member Function Documentation

void UnitPropagation::getChangedPreds ( vector< string > &  changedPreds,
vector< float > &  probs,
vector< float > &  oldProbs,
const float &  probDelta 
) [inline, virtual]

Puts the predicates whose truth value has changed with respect to the reference vector oldProbs in string form and the corresponding probabilities of each predicate (1 or 0) in two vectors.

Parameters:
changedPreds Predicates whose truth values have changed are put here.
probs The probabilities corresponding to the predicates in nonZeroPreds are put here (the number 1 or 0).
oldProbs Reference truth values for checking for changes.
probDelta This parameter is ignored for MAP inference (either the truth value has changed or it hasn't).

Implements Inference.

Definition at line 170 of file unitpropagation.h.

References VariableState::getNumAtoms(), VariableState::getValueOfLowAtom(), VariableState::printGndPred(), and Inference::state_.

00172   {
00173     changedPreds.clear();
00174     probs.clear();
00175     int numAtoms = state_->getNumAtoms();
00176       // Atoms may have been added to the state, previous tv was 0
00177     oldProbs.resize(numAtoms, 0);
00178     for (int i = 0; i < numAtoms; i++)
00179     {
00180       int tv = state_->getValueOfLowAtom(i + 1);
00181       if (tv != oldProbs[i])
00182       {
00183           // Truth value has changed: Store new value in oldProbs and add to
00184           // two return vectors
00185         oldProbs[i] = tv;
00186         ostringstream oss(ostringstream::out);
00187         state_->printGndPred(i, oss);
00188         changedPreds.push_back(oss.str());
00189         probs.push_back(tv);
00190       }
00191     }
00192   }


The documentation for this class was generated from the following file:
Generated on Sun Jun 7 11:55:29 2009 for Alchemy by  doxygen 1.5.1