OnlineEngine Class Reference

Engine for performing inference and learning online. More...

#include <onlineengine.h>

List of all members.

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.


Detailed Description

Engine for performing inference and learning online.

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.


Constructor & Destructor Documentation

OnlineEngine::OnlineEngine ( const string &  inferString  )  [inline]

Constructs an OnlineEngine from a string of inference options.

Parameters:
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.

Parameters:
inference Inference used in the OnlineEngine

Definition at line 290 of file onlineengine.h.

References setInference().

00291   {
00292     setInference(inference);
00293   }


Member Function Documentation

void OnlineEngine::infer ( vector< string > &  nonZeroAtoms,
vector< float > &  probs 
) [inline]

Perform inference given the current evidence and queries.

Parameters:
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.

Parameters:
evidence Atoms, in string form, to be added to the evidence.

Definition at line 337 of file onlineengine.h.

00338   {
00339     addRemoveEvidenceHelper(evidence, true, true);
00340   }

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.

Parameters:
evidence Atoms, in string form, to be added to the evidence.

Definition at line 348 of file onlineengine.h.

00349   {
00350     addRemoveEvidenceHelper(evidence, true, false);
00351   }

void OnlineEngine::removeEvidence ( const vector< string > &  oldEvidence  )  [inline]

Remove evidence from the underlying state.

The given atoms are marked as unknown in the database.

Parameters:
oldEvidence Atoms, in string form, to be removed from the evidence.

Definition at line 359 of file onlineengine.h.

00360   {
00361     addRemoveEvidenceHelper(oldEvidence, false, false);
00362   }

void OnlineEngine::setInference ( Inference inference  )  [inline]

Sets the inference procedure for this OnlineEngine.

Parameters:
inference Inference procedure for this OnlineEngine.

Definition at line 369 of file onlineengine.h.

Referenced by OnlineEngine().

00370   {
00371     inference_ = inference;
00372   }

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.

Parameters:
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   }


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