#include <onlineengine.h>
Public Member Functions | |
OnlineEngine (const string &inferString) | |
Constructs an OnlineEngine from a string of inference options. | |
OnlineEngine (Inference *inference) | |
Constructs an OnlineEngine from an Inference object. | |
~OnlineEngine () | |
Destroys the Inference pointer associated with this OnlineEngine. | |
void | init () |
Initializes the underlying inference procedure. | |
void | infer (vector< string > &nonZeroAtoms, vector< float > &probs) |
Perform inference given the current evidence and queries. | |
void | addTrueEvidence (const vector< string > &evidence) |
Add true evidence to the underlying state. | |
void | addFalseEvidence (const vector< string > &evidence) |
Add false evidence to the underlying state. | |
void | removeEvidence (const vector< string > &oldEvidence) |
Remove evidence from the underlying state. | |
void | setInference (Inference *inference) |
Sets the inference procedure for this OnlineEngine. | |
void | setMaxInferenceSteps (const int &inferenceSteps) |
Sets the max number of steps for the inference procedure if using MaxWalkSat. |
This class is designed to be used with an external agent which initializes the engine with an mln, evidence predicates, a set of queries and parameters for the inference procedure as a string in the same form used by the infer executable. The agent then sends the engine changes in evidence and asks the engine to perform inference and/or learning.
Definition at line 268 of file onlineengine.h.
OnlineEngine::OnlineEngine | ( | const string & | inferString | ) | [inline] |
Constructs an OnlineEngine from a string of inference options.
inferString | string containing parameters for the inference procedure. The form is identical to that given to the infer executable. |
Definition at line 278 of file onlineengine.h.
References setInference().
00279 { 00280 Inference* inference = NULL; 00281 parseInferString(inferString, inference); 00282 setInference(inference); 00283 }
OnlineEngine::OnlineEngine | ( | Inference * | inference | ) | [inline] |
Constructs an OnlineEngine from an Inference object.
inference | Inference used in the OnlineEngine |
Definition at line 290 of file onlineengine.h.
References setInference().
00291 { 00292 setInference(inference); 00293 }
void OnlineEngine::infer | ( | vector< string > & | nonZeroAtoms, | |
vector< float > & | probs | |||
) | [inline] |
Perform inference given the current evidence and queries.
nonZeroAtoms | For MAP inference, this contains the query atoms inferred to be true; for prob. inference, this contains the query atoms with non-zero probability. | |
probs | For MAP inference, this is a vector of ones; for prob. inference, this contains the probabilities corresponding to the atoms in trueAtoms. |
Definition at line 321 of file onlineengine.h.
References Inference::infer().
00322 { 00323 nonZeroAtoms.clear(); 00324 probs.clear(); 00325 inference_->infer(); 00326 // Fill in vectors 00327 inference_->getPredsWithNonZeroProb(nonZeroAtoms, probs); 00328 assert(nonZeroAtoms.size() == probs.size()); 00329 }
void OnlineEngine::addTrueEvidence | ( | const vector< string > & | evidence | ) | [inline] |
Add true evidence to the underlying state.
The given atoms are marked as true evidence in the database.
evidence | Atoms, in string form, to be added to the evidence. |
Definition at line 337 of file onlineengine.h.
void OnlineEngine::addFalseEvidence | ( | const vector< string > & | evidence | ) | [inline] |
Add false evidence to the underlying state.
The given atoms are marked as false evidence in the database.
evidence | Atoms, in string form, to be added to the evidence. |
Definition at line 348 of file onlineengine.h.
void OnlineEngine::removeEvidence | ( | const vector< string > & | oldEvidence | ) | [inline] |
Remove evidence from the underlying state.
The given atoms are marked as unknown in the database.
oldEvidence | Atoms, in string form, to be removed from the evidence. |
Definition at line 359 of file onlineengine.h.
void OnlineEngine::setInference | ( | Inference * | inference | ) | [inline] |
Sets the inference procedure for this OnlineEngine.
inference | Inference procedure for this OnlineEngine. |
Definition at line 369 of file onlineengine.h.
Referenced by OnlineEngine().
void OnlineEngine::setMaxInferenceSteps | ( | const int & | inferenceSteps | ) | [inline] |
Sets the max number of steps for the inference procedure if using MaxWalkSat.
It is typical to set the number of steps to a lower value after the first step.
inferenceSteps | Number of maximum steps MaxWalkSat should perform. |
Definition at line 381 of file onlineengine.h.
00382 { 00383 // Check if using MWS 00384 if (MaxWalkSat* mws = dynamic_cast<MaxWalkSat*>(inference_)) 00385 { 00386 mws->setMaxSteps(inferenceSteps); 00387 } 00388 }