The interface of OnlineEngine which the agent can utilize can be found in the Alchemy API. In this section, we explain, using a small example, how to use the API to perform online inference.
An OnlineEngine is constructed based on a string containing the options for the underlying inference. The form of the string is the same as the options available in the batch mode executable infer (see Section ). A simple example of an agent exists in the file online.cpp in the online directory.
After constructing the OnlineEngine, the agent should call the init() method which initializes the underlying inference procedure. Then, in each time step, the agent asks the OnlineEngine to perform inference and return the true atoms (if performing MAP inference) or the atoms with non-zero probability (if performing probabilistic inference). This is achieved with the infer() method. The agent can then change the evidence and/or query predicates and inform the OnlineEngine about these changes with the methods addTrueEvidence(), addFalseEvidence() and removeEvidence(). Evidence to be removed or added needs to be in string form (as in a .db file) and put in a vector of with elements of type string.
For most agents, it is often the case that the state will not change drastically from one time step to the next. If this is the case, we don't want our inference engine to perform full inference in each iteration. When using MaxWalkSat as the underlying inference procedure, the OnlineEngine can vary the number of maximum steps which MaxWalkSat will perform. For time step , inference begins in the state in which time step left off. Therefore, it is advisable that the agent reduce the maximum number of inference steps after the first time step by using the setMaxInferenceSteps() method. For probabilistic inference, this option is not available.