|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object tuffy.mln.Predicate
public class Predicate
Predicate in First Order Logic.
Nested Class Summary | |
---|---|
private class |
Predicate.FunctionalDependency
TODO: look into the implications of FDs |
Field Summary | |
---|---|
private java.util.ArrayList<java.lang.String> |
argNameList
|
private java.util.HashMap<java.lang.String,java.lang.Integer> |
argNameMap
|
private java.util.ArrayList<java.lang.String> |
args
The list of arguments of this predicate. |
private static java.util.HashMap<java.lang.String,Predicate> |
builtInMap
Map from name to built-in predicates, e.g., same. |
private boolean |
closedWorld
Whether this predicate obeys closed-world assumption. |
private RDB |
db
DB object associated with this predicate. |
private java.util.ArrayList<java.lang.Integer> |
dependentAttributes
|
private java.util.ArrayList<Predicate.FunctionalDependency> |
fds
Functional dependencies for this predicate. |
private boolean |
hasSoftEvidence
|
private java.util.HashSet<Clause> |
iclauses
Set of clauses referencing this predicate. |
private int |
id
The assigned ID for this predicate in its parent MLN mln . |
private boolean |
isAllQuery
Whether all unknown atoms of this predicate are queries. |
private boolean |
isBuiltIn
Whether this predicate is a built-in predicate. |
private boolean |
isCompletelySpecified
|
boolean |
isCurrentlyView
|
private java.io.File |
loadingFile
The file object used to load evidence to DB |
private java.io.BufferedWriter |
loadingFileWriter
The buffer writer object used to flush evidence to file |
private MarkovLogicNetwork |
mln
The parent MLN containing this predicate. |
private java.lang.String |
name
Name of this predicate. |
private java.util.ArrayList<Atom> |
queries
Set of queries referencing this predicate. |
private java.lang.String |
relName
Name of the table of this predicate in DB. |
private boolean |
safeRefOnly
TODO: if unsat then {if scope then do scope, else do cross product} |
private java.util.ArrayList<Type> |
types
List of argument types of this predicate. |
Constructor Summary | |
---|---|
Predicate(MarkovLogicNetwork mln,
java.lang.String aname,
boolean aClosedWorld)
Constructor of Predicate. |
Method Summary | |
---|---|
void |
addDependentAttrPosition(int i)
Set the attribute at position i to be dependent. |
void |
addEvidence(Atom a)
Store an evidence in the "buffer". |
private void |
addEvidenceTuple(Atom a)
Add evidence tuple related to this predicate. |
void |
addFunctionalDependency(java.util.List<java.lang.String> determinant,
java.lang.String dependent)
Add a functional dependency for the attributes of this predicate |
void |
addQuery(Atom q)
Register a query atom. |
void |
addRelatedClause(Clause c)
Register a clause referencing this predicate |
void |
appendArgument(Type t)
Append a new argument without a user-provided name. |
void |
appendArgument(Type t,
java.lang.String name)
Append a new argument with a user provided name. |
int |
arity()
Return the arity of this predicate. |
void |
closeFiles()
Close all file handles. |
private void |
createTable()
Create table for storing groundings of this predicate. |
void |
flushEvidence()
Flush the evidence buffer to the predicate table, using the COPY statement in PostgreSQL. |
int |
getArgPositionByName(java.lang.String aname)
Return the position of the given argument name. |
java.util.ArrayList<java.lang.String> |
getArgs()
Return argument names of this predicate. |
static Predicate |
getBuiltInPredByName(java.lang.String s)
Return the predicate object with the name as the argument string. |
java.util.ArrayList<java.lang.Integer> |
getDependentAttrPositions()
|
java.util.ArrayList<java.lang.String> |
getDependentAttrs()
Get attributes whose value depend on other attributes in any possible world. |
int |
getID()
Return the assigned ID of this predicate in its parent MLN. |
java.util.ArrayList<java.lang.Integer> |
getKeyAttrPositions()
|
java.util.ArrayList<java.lang.String> |
getKeyAttrs()
Get attributes that form a possible world key. |
java.lang.String |
getName()
Return the name of this predicate. |
java.util.ArrayList<Atom> |
getQueryAtoms()
Return query atoms of this predicate. |
java.lang.String |
getRelAct()
Return the name of relational table containing the ID of active atoms associated with this predicate. |
java.util.HashSet<Clause> |
getRelatedClauses()
Return clauses referencing this predicate. |
java.lang.String |
getRelName()
Return the relational table name of this predicate.. |
Type |
getTypeAt(int k)
Return the type of the k-th argument. |
void |
groundAndStoreAtom(Atom a)
Ground an atom and store the result in the database. |
boolean |
hasDependentAttributes()
|
boolean |
hasMoreToGround()
Determine whether this predicate can ground more atoms. |
boolean |
hasQuery()
Checks if there are any queries associated with this predicate. |
boolean |
hasSoftEvidence()
|
boolean |
isBuiltIn()
|
static boolean |
isBuiltInPredName(java.lang.String s)
Return true if the argument is the name of a built-in predicate. |
boolean |
isClosedWorld()
Check if this predicate makes the closed-world assumption. |
boolean |
isCompletelySepcified()
|
boolean |
isImmutable()
|
boolean |
isSafeRefOnly()
|
boolean |
noNeedToGround()
Check if we need to ground this predicate on top of its evidence. |
void |
prepareDB(RDB adb)
Initialize database objects for this predicate. |
void |
sealDefinition()
Mark the point when all arguments have been given. |
void |
setAllQuery()
Specify that all atoms of this predicate are queries. |
void |
setClosedWorld(boolean t)
Specify whether this predicate obeys the closed world assumption. |
void |
setCompeletelySpecified(boolean t)
|
void |
setDB(RDB adb)
|
void |
setHasSoftEvidence(boolean hasSoftEvidence)
|
void |
setID(int aid)
Assign an ID for this predicate. |
void |
setMLN(MarkovLogicNetwork _mln)
|
void |
setSafeRefOnly(boolean safeRefOnly)
Set whether all references to this predicate are safe; i.e., all variables in corresponding positive literals are bound to other literals in the same clause. |
void |
storeQueries()
Ground query atoms and store the result in the database. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private boolean isCompletelySpecified
public boolean isCurrentlyView
private java.util.ArrayList<java.lang.Integer> dependentAttributes
private static java.util.HashMap<java.lang.String,Predicate> builtInMap
private java.lang.String name
private boolean closedWorld
private boolean hasSoftEvidence
private java.util.ArrayList<Type> types
private boolean safeRefOnly
private boolean isBuiltIn
private RDB db
private java.lang.String relName
private java.util.ArrayList<java.lang.String> args
private int id
mln
.
private java.io.File loadingFile
private java.io.BufferedWriter loadingFileWriter
private MarkovLogicNetwork mln
private java.util.HashSet<Clause> iclauses
private java.util.ArrayList<Atom> queries
private boolean isAllQuery
private java.util.HashMap<java.lang.String,java.lang.Integer> argNameMap
private java.util.ArrayList<java.lang.String> argNameList
private java.util.ArrayList<Predicate.FunctionalDependency> fds
Constructor Detail |
---|
public Predicate(MarkovLogicNetwork mln, java.lang.String aname, boolean aClosedWorld)
mln
- the parent MLN that hosts this predicateaname
- the name; must be uniqueaClosedWorld
- indicates whether to make the closed-world asssumptionMethod Detail |
---|
public void setCompeletelySpecified(boolean t)
public boolean isCompletelySepcified()
public void addDependentAttrPosition(int i)
i
- public java.util.ArrayList<java.lang.Integer> getDependentAttrPositions()
public java.util.ArrayList<java.lang.Integer> getKeyAttrPositions()
public boolean hasDependentAttributes()
public java.util.ArrayList<java.lang.String> getDependentAttrs()
getKeyAttrs()
public java.util.ArrayList<java.lang.String> getKeyAttrs()
getDependentAttrs()
public static boolean isBuiltInPredName(java.lang.String s)
s
- name of queried predicate
public static Predicate getBuiltInPredByName(java.lang.String s)
s
- name of queried predicate
public boolean isImmutable()
public java.lang.String getRelAct()
public void setAllQuery()
public void setClosedWorld(boolean t)
public int getID()
public java.util.ArrayList<java.lang.String> getArgs()
public boolean noNeedToGround()
public void setID(int aid)
public java.util.ArrayList<Atom> getQueryAtoms()
public java.util.HashSet<Clause> getRelatedClauses()
public void addQuery(Atom q)
q
- the query atom; could contain variablesstoreQueries()
public void storeQueries()
public void groundAndStoreAtom(Atom a)
public void addEvidence(Atom a)
a
- the evidence; following Alchemy, it must be a ground atomflushEvidence()
public boolean hasMoreToGround()
private void addEvidenceTuple(Atom a)
a
- the atom as evidence. This atom need to be a grounded atom.public void closeFiles()
public void flushEvidence()
addEvidence(Atom)
public boolean hasQuery()
public void setDB(RDB adb)
public void prepareDB(RDB adb)
private void createTable()
public int arity()
public void addRelatedClause(Clause c)
c
- a clause referencing this predicatepublic void appendArgument(Type t)
t
- the type of the new argumentpublic void appendArgument(Type t, java.lang.String name)
t
- the type of the new argumentname
- user-provided name for this argument/attributepublic int getArgPositionByName(java.lang.String aname)
aname
- argument namepublic void sealDefinition()
public void setMLN(MarkovLogicNetwork _mln)
public void addFunctionalDependency(java.util.List<java.lang.String> determinant, java.lang.String dependent)
determinant
- dependent
- public Type getTypeAt(int k)
public boolean isClosedWorld()
public java.lang.String getName()
public java.lang.String getRelName()
public void setSafeRefOnly(boolean safeRefOnly)
safeRefOnly
- public boolean isSafeRefOnly()
public void setHasSoftEvidence(boolean hasSoftEvidence)
public boolean hasSoftEvidence()
public boolean isBuiltIn()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |