Inheritance diagram for UnitPropagation:
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. |
Definition at line 73 of file unitpropagation.h.
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.
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 }