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 | getPredsWithNonZeroProb (vector< string > &nonZeroPreds, vector< float > &probs) |
Puts the predicates non-zero probability (those set to true) in string form and the corresponding probabilities of each predicate (the number 1) 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::getPredsWithNonZeroProb | ( | vector< string > & | nonZeroPreds, | |
vector< float > & | probs | |||
) | [inline, virtual] |
Puts the predicates non-zero probability (those set to true) in string form and the corresponding probabilities of each predicate (the number 1) in two vectors.
nonZeroPreds | Predicates set to true are put here. | |
probs | The probabilities corresponding to the predicates in nonZeroPreds are put here (the number 1). |
Implements Inference.
Definition at line 166 of file unitpropagation.h.
References VariableState::getNumAtoms(), VariableState::getValueOfLowAtom(), VariableState::printGndPred(), and Inference::state_.
00168 { 00169 nonZeroPreds.clear(); 00170 probs.clear(); 00171 for (int i = 0; i < state_->getNumAtoms(); i++) 00172 { 00173 if (state_->getValueOfLowAtom(i + 1)) 00174 { 00175 ostringstream oss(ostringstream::out); 00176 state_->printGndPred(i, oss); 00177 nonZeroPreds.push_back(oss.str()); 00178 probs.push_back(1); 00179 } 00180 } 00181 }