|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectinfer.MRF
public class MRF
In-memory data structure representing an MRF.
Field Summary | |
---|---|
protected java.util.HashMap<java.lang.Integer,java.util.ArrayList<GClause>> |
adj
Index from GAtom ID to GClause. |
java.util.HashMap<java.lang.Integer,GAtom> |
atoms
Map from GAtom ID to GAtom object. |
java.util.ArrayList<GClause> |
clauses
Array of all GClause objects in this MRF. |
protected java.util.HashSet<java.lang.Integer> |
dirtyAtoms
|
java.lang.String |
fout
Name of output file. |
long |
inferOps
|
double |
lowCost
Lowest cost ever seen. |
MarkovLogicNetwork |
mln
The MLN object. |
protected boolean |
sampleSatMode
The flag indicating whether MCSAT is running WalkSAT or SampleSAT. |
protected int |
totalAlive
Number of GClauses that is selected, and therefore must be satisfied by next SampleSAT invocation of MCSAT. |
protected double |
totalCost
The total cost of this MRF under current atoms' truth setting. |
protected HashArray<GClause> |
unsat
Array of unsatisfied GClauses under current atoms' truth setting. |
Constructor Summary | |
---|---|
MRF()
Default constructor. |
|
MRF(int id,
java.util.HashMap<java.lang.Integer,GAtom> gatoms)
|
Method Summary | |
---|---|
void |
addAtom(int aid)
Add an atom into this MRF. |
void |
auditClauseViolations()
Track ground clause violations to fo-clauses. |
void |
buildIndices()
Build literal-->clauses index. |
double |
calcCosts()
Compute total cost and per-atom delta cost. |
void |
discard()
Discard all data structures, in hope of facilitating faster GC. |
protected void |
enableAllClauses()
Reset all clauses to be alive. |
protected void |
fixAtom(int aid,
boolean t)
Fix the truth value of an atom. |
void |
flushLowTruth(RDB db)
Flush lowest-cost truth assignment to the database. |
void |
inferSweepSAT(int nTries,
int nSteps)
Run SweepSAT for MAP inference. |
void |
inferWalkSAT(int nTries,
int nSteps)
Run WalkSAT. |
void |
initMRF()
Initialize the state of the MRF. |
void |
invalidateLowCost()
Reset low-cost to infinity. |
protected boolean |
isAlwaysTrue(GClause gc)
Test if a clause is always true no matter how we flip flippable atoms. |
protected boolean |
isTrueLit(int lit)
Check if a given literal is true under current truth assignment. |
void |
loadMRF(RDB db)
Load the entire grounding result into memory as an MRF. |
protected boolean |
ownsAtom(int aid)
Test if a given atom is "owned" by this MRF. |
double |
recalcCost()
Recalculate total cost. |
protected void |
restoreLowTruth()
Assign the recorded low-cost truth values to current truth values. |
protected int |
retainSomeGoodClauses()
Retain a subset of currently satisfied clauses, according to the sampling method of MC-SAT. |
void |
saveLowTruth(double cost)
If current truths have the lowest cost, save them. |
protected boolean |
testChance(double p)
Coin flipping. |
protected void |
unfixAllAtoms()
Unfix all atoms. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.HashMap<java.lang.Integer,java.util.ArrayList<GClause>> adj
public java.util.HashMap<java.lang.Integer,GAtom> atoms
public java.util.ArrayList<GClause> clauses
protected java.util.HashSet<java.lang.Integer> dirtyAtoms
public java.lang.String fout
public long inferOps
public double lowCost
public MarkovLogicNetwork mln
protected boolean sampleSatMode
protected int totalAlive
protected double totalCost
protected HashArray<GClause> unsat
Constructor Detail |
---|
public MRF()
public MRF(int id, java.util.HashMap<java.lang.Integer,GAtom> gatoms)
id
- id of this MRFgatoms
- ground atomsMethod Detail |
---|
public void addAtom(int aid)
aid
- id of the atompublic void auditClauseViolations()
Stats.reportMostViolatedClauses(infer.MRF, int)
public void buildIndices()
public double calcCosts()
public void discard()
protected void enableAllClauses()
protected void fixAtom(int aid, boolean t)
aid
- id of the atomt
- truth value to be fixedpublic void flushLowTruth(RDB db)
db
- public void inferSweepSAT(int nTries, int nSteps)
nTries
- number of triesnSteps
- number of steps per trypublic void inferWalkSAT(int nTries, int nSteps)
nTries
- number of triesnSteps
- number of steps per trypublic void initMRF()
public void invalidateLowCost()
protected boolean isAlwaysTrue(GClause gc)
gc
- the clauseprotected boolean isTrueLit(int lit)
lit
- the literal represented as an integerpublic void loadMRF(RDB db)
db
- the DB connection where the data residesprotected boolean ownsAtom(int aid)
aid
- id of the atompublic double recalcCost()
protected void restoreLowTruth()
protected int retainSomeGoodClauses()
public void saveLowTruth(double cost)
cost
- the current costprotected boolean testChance(double p)
p
- probability of returning trueprotected void unfixAllAtoms()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |