infer
Class BDBStore

java.lang.Object
  extended by infer.BDBStore
Direct Known Subclasses:
BDBSweepSAT, BDBWalkSAT

public class BDBStore
extends java.lang.Object

Manager of the data used by inference. Using BDB JE.


Field Summary
 long inferOps
           
protected  double lowCost
           
protected  java.util.Random rand
           
 
Constructor Summary
BDBStore(Grounding grounding)
          Creates a BDB store to host inference algorithms.
 
Method Summary
protected  void activateAtom(java.lang.String relBuf, int oldID)
           
protected  void assignRandomTruthValues()
          Assigns random truth values to active atoms.
protected  double calcCosts()
           
 boolean close()
          Closes all opened handles.
 void dumpAtomProb(int numSamples, java.lang.String fout)
           
protected  void fixAtom(int id, boolean val)
           
 void flushTruthValues()
           
 void infer(int numTries, int maxIterations)
          Place holder for the actual inference algorithms in children classes.
protected  void initMRF()
          Initializes the states of the MRF.
static byte[] intToByteArray(int value)
          Converts an integer into a byte array.
protected  boolean isActive(int atomID)
          Tests if an atom ID is in the range of active ones.
protected  void resetDeadClauses()
           
protected  void resetFixedAtoms()
           
protected  void restoreLowTruth()
           
protected  int retainOnlyHardClauses()
           
protected  int retainSomeGoodClauses()
           
protected  boolean saveLowTruth(double cost)
          Saves the truth values if the current world has the lowest cost so far.
protected  void tallyAtomTrueCount()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inferOps

public long inferOps

lowCost

protected double lowCost

rand

protected java.util.Random rand
Constructor Detail

BDBStore

public BDBStore(Grounding grounding)
Creates a BDB store to host inference algorithms.

Parameters:
mln - the MLN
grounding - the grounding worker for this MLN
Method Detail

activateAtom

protected void activateAtom(java.lang.String relBuf,
                            int oldID)

assignRandomTruthValues

protected void assignRandomTruthValues()
Assigns random truth values to active atoms.


calcCosts

protected double calcCosts()

close

public boolean close()
Closes all opened handles.


dumpAtomProb

public void dumpAtomProb(int numSamples,
                         java.lang.String fout)

fixAtom

protected void fixAtom(int id,
                       boolean val)

flushTruthValues

public void flushTruthValues()

infer

public void infer(int numTries,
                  int maxIterations)
Place holder for the actual inference algorithms in children classes.

Parameters:
maxIterations -

initMRF

protected void initMRF()
Initializes the states of the MRF.


intToByteArray

public static final byte[] intToByteArray(int value)
Converts an integer into a byte array.


isActive

protected boolean isActive(int atomID)
Tests if an atom ID is in the range of active ones.

Parameters:
atomID -
Returns:
true if it's active

resetDeadClauses

protected void resetDeadClauses()

resetFixedAtoms

protected void resetFixedAtoms()

restoreLowTruth

protected void restoreLowTruth()

retainOnlyHardClauses

protected int retainOnlyHardClauses()
Returns:
the number of hard clauses

retainSomeGoodClauses

protected int retainSomeGoodClauses()
Returns:
the number of living clauses

saveLowTruth

protected boolean saveLowTruth(double cost)
Saves the truth values if the current world has the lowest cost so far.

Parameters:
cost - the cost of current world
Returns:
true if it's a better world

tallyAtomTrueCount

protected void tallyAtomTrueCount()