Class Grounding

  extended by tuffy.ground.Grounding

public class Grounding
extends java.lang.Object

This class handles the grounding process of MLN inference/learning with SQL queries. See our technical report at http://tuffguy.cs.wisc.edu/tuffy/tuffy-tech-report.pdf as well as prior works: http://alchemy.cs.washington.edu/papers/singla06a/singla06a.pdf http://alchemy.cs.washington.edu/papers/pdfs/shavlik-natarajan09.pdf Alchemy implements "lazy inference" with a one-step look-ahead strategy for initial groundings; we generalize it into a closure algorithm that avoid incremental "activation" altogether.

Field Summary
private  RDB db
          Relational database used for grounding.
private  MarkovLogicNetwork mln
          MLN to be grounded.
private  int numAtoms
          Number of active atoms.
private  int numClauses
          Number of active clauses.
Constructor Summary
Grounding(MarkovLogicNetwork mln)
          Create a grounding worker for an MLN.
Method Summary
private  void activateQueryAtoms()
          Activate all the query atoms that are true in the training data.
private  void activateSoftEvidence()
          Activate "soft evidence" atoms.
private  void activateUnknownAtoms()
private  void addKeyConstraintClauses(java.lang.String relAtoms, java.lang.String cbuffer)
private  void addSoftEvidClauses(java.lang.String relAtoms, java.lang.String cbuffer)
private  void bindDB(RDB adb)
          Bind to a database connection, and initialize global database objects.
private  void computeActiveAtoms()
          Compute the closure of active atoms.
private  void computeActiveClauses(java.lang.String cbuffer)
          Computes ground clauses activated by the current set of active atoms.
private  void computeIncidenceTable(java.lang.String relClauses, java.lang.String relIncidence)
          Create the atom-clause incidence relation.
private  int consolidateClauses(java.lang.String cbuffer, java.lang.String relClauses)
 void constructMRF()
          Construct the MRF.
private  void createActTables()
private  void createAtomTable(java.lang.String rel)
private  void createClauseTable(java.lang.String rel)
private  void destroyActTables()
 MarkovLogicNetwork getMLN()
          Get the MLN object used for grounding.
 int getNumAtoms()
          Return the number of active atoms in the grounding result.
 int getNumClauses()
          Return the number of active clauses in the grounding result.
private  int populateAtomTable(java.lang.String relAtoms)
private  void reportCostStats(java.lang.String relClauses)
          An attempt of computing cost lower bounds with the probabilistic method.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail


private RDB db
Relational database used for grounding.


private MarkovLogicNetwork mln
MLN to be grounded.


private int numAtoms
Number of active atoms.


private int numClauses
Number of active clauses.

Constructor Detail


public Grounding(MarkovLogicNetwork mln)
Create a grounding worker for an MLN.

Method Detail


public MarkovLogicNetwork getMLN()
Get the MLN object used for grounding.


public int getNumAtoms()
Return the number of active atoms in the grounding result.


public int getNumClauses()
Return the number of active clauses in the grounding result.


private void createAtomTable(java.lang.String rel)


private void createClauseTable(java.lang.String rel)


private void createActTables()


private void destroyActTables()


private void activateSoftEvidence()
Activate "soft evidence" atoms.


private void activateQueryAtoms()
Activate all the query atoms that are true in the training data. Used by learning.


private void activateUnknownAtoms()


private void bindDB(RDB adb)
Bind to a database connection, and initialize global database objects.


public void constructMRF()
Construct the MRF. First compute the closure of active atoms, then active clauses.


private int populateAtomTable(java.lang.String relAtoms)


private void computeActiveAtoms()
Compute the closure of active atoms. For a positive clause, active atoms are those with positive sense, plus those with negative sense but truth value may not be the default FALSE. Those with negative sense and default truth value will be true if we set default value of atoms as false, and therefore do not generate violated grounded clauses. For a negative clause, active atoms are those with negative sense. There are multiple rounds in this function. The goal of multiple rounds is compute a closure for all possible active atoms. For example, say we assume the default truth for atom is FALSE. Although at first round, we do not need to compute the groundings for negative literature $!p$ in a positive clause except those positive evidences (because they do not introduce any violations), other clauses may introduce active atoms with the same predicate $p$ in the active set. In this case, these introduced atoms can be flipped, so their truth values are not necessarily FALSE. Under this circumstance, the negative literals may also be FALSE. So there may be more groundings for the first clause, and therefore, more than one rounds is necessary to adjust that. If in the first round, no more atoms of predicate $p$ is introduced in active table, then according to the previous analysis, re-grounding of this clause is not necessary.


private void computeIncidenceTable(java.lang.String relClauses,
                                   java.lang.String relIncidence)
Create the atom-clause incidence relation.


private void computeActiveClauses(java.lang.String cbuffer)
Computes ground clauses activated by the current set of active atoms. Grounding the clause using set of active atoms. Then merge the weight of clauses with the same atom set. Another optimization is merging clauses with only one active atom whose sense is opposite. This is by reverse the sense of negative clause, together with the sense of the only literal. The grounding result is saved in table . With the schema like
| lit | weight | (posWt) | (negWt) | fcid | ffcid |

where posWt and negWt depend on Config#calcCostOffset, and fcid Config.track_clause_provenance.

retainInactiveAtoms - set this to true when the original lazy inference is in use. Otherwise, i.e. the closure algorithm is in use, set it to false.


private int consolidateClauses(java.lang.String cbuffer,
                               java.lang.String relClauses)


private void addSoftEvidClauses(java.lang.String relAtoms,
                                java.lang.String cbuffer)


private void addKeyConstraintClauses(java.lang.String relAtoms,
                                     java.lang.String cbuffer)


private void reportCostStats(java.lang.String relClauses)
An attempt of computing cost lower bounds with the probabilistic method.