next up previous
Up: The Alchemy Lite Tutorial Previous: 5 Probabilistic Relational Modeling


Overview of Code

We are working on adding more functionality into Alchemy Lite. Current lines of research include
  1. Learning TPKBs
  2. Parsing
However, if you are inclined to add your own functionality, this can serve as a rough guide to the Alchemy Lite source files. Understanding the code, however, is not necessary to using Alchemy Lite out of the box. :)

  1. High-level Overview

    Alchemy Lite takes in a rule file and an evidence file. The rule file contains information about the classes in the model; the evidence file contains information about particular objects. (Note: The evidence file can be blank.) The main data structure, the TMLKB, reads in the information from the files and runs inference.

    The rule file is read in first (function: readInTMLRules). Afterwards, the TMLKB holds an array of TMLClass objects that store the information about each of the classes. If a TML constraint is violated by the information in the rule file, an error message is presented and Alchemy Lite exited.

    The evidence file is read second (function: readInTMLFacts). As information is read in about objects, the structure of object:class nodes that represents the KB is created. After all the evidence about objects has been read in, the KB structure is fleshed out for object:class pairs that were not mentioned in the KB file. The function that does this, fillOutSPN, also computes the partition function of the KB given the evidence in the evidence file.

    If a query was specified on the command line (using the -q flag) or if MAP inference was specified (using the -map flag), the TMLKB object runs the inference and returns an answer. For query inference, the function computeQueryOrAddEvidence is called. (This function can also be used to add new evidence in the interactive mode.) For MAP inference, first the computeMAPState function is called; this function runs the upwards pass of the dynamic programming algorithm. Sum nodes are replaced by max nodes, and pointers to the highest-weighted children are set. The printMAPState function runs a downwards pass through the KB and prints the MAP subclasses and relations of objects, for which evidence is not known.

    If interactive mode begins, the user can specify simple facts to add (i.e., new subclass information, names for subparts, or relation evidence) or query the KB. The interactive mode also allows the user to print out a new version of the evidence file if new facts were added during the interactive mode.

    For all queries (MAP and otherwise), both the command line and interactive mode all the user to specify a file to save the results of the inference. If not specified, Alchemy Lite just prints the results to the screen.

  2. Middle-level overview

    The parsing functions take advantage of the getLineToSemicolon() function which reads in the next "line" of the file (i.e., until the next semicolon or end bracket). This function ignores comments at the ends of line and lines that are just spaces or comments. If more than one semantic line occurs before a carriage return, this function stores the rest of the line in a char* that is owned by the parsing function.

  3. Low-level overview

TODO


next up previous
Up: The Alchemy Lite Tutorial Previous: 5 Probabilistic Relational Model
Chloe Kiddon 2013-04-01