Class Knowledge
- All Implemented Interfaces:
TetradSerializable, Serializable
For this class, all variable names are referenced by name only. This is because the same Knowledge object is intended to plug into different graphs with MyNodes that possibly have the same names. Thus, if the Knowledge object forbids the edge X --> Y, then it forbids any edge which connects a MyNode named "X" to a MyNode named "Y", even if the underlying MyNodes themselves named "X" and "Y", respectively, are not the same.
In place of variable names, wildcard expressions containing the wildcard '*' may be substituted. These will be matched to as many myNodes as possible. The '*' wildcard matches any string of consecutive characters up until the following character is encountered. Thus, "X*a" will match "X123a" and "X45a".
- Version:
- $Id: $Id
- Author:
- josephramsey, Kevin V. Bui (kvb2@pitt.edu)
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddKnowledgeGroup(KnowledgeGroup group) Adds a knowledge group.voidaddTierStructure(KnowledgeTierStructure structure) Adds an additional tier structure.voidAdds the given variable or wildcard cpdag to the given tier.voidaddToTiersByVarNames(List<String> varNames) Puts a variable into tier i if its name is xxx:ti for some xxx and some i.voidaddVariable(String varName) addVariable.voidclear()Removes explicit knowledge and tier information.copy()Makes a shallow copy.booleanCompares this Knowledge object with the specified object for equality.Iterator over the KnowledgeEdge's representing forbidden edges.Getter for the fieldknowledgeGroups.getListOfExplicitlyForbiddenEdges.getListOfExplicitlyRequiredEdges.getListOfForbiddenEdges.getListOfRequiredEdges.intgetMaxTierForbiddenWithin.intgetNumTiers.intReturns the number of additional tier structures.Retrieves the testing dataset.getTier(int tier) getTier.Returns the additional tier structures, in order, as a shallow copy of the list.Get a list of variables.getVariablesNotInTiers.inthashCode()Computes a hashcode.booleanisDefaultToKnowledgeLayout.booleanisEmpty()true if there is no background knowledge recorded.booleanisForbidden(String var1, String var2) Determines whether the edge var1 --> var2 is forbidden.booleanisForbiddenByGroups(String var1, String var2) Determines whether the edge var1 --> var2 is forbidden by some forbidden knowledge group.booleanisForbiddenByTiers(String var1, String var2) Determines whether the edge var1 --> var2 is forbidden by the temporal tiers.intisInWhichTier(Node node) Returns the index of the tier of node if it's in a tier, otherwise -1.booleanisOnlyCanCauseNextTier(int tier) isOnlyCanCauseNextTier.booleanisRequired(String var1, String var2) Determines whether the edge var1 --> var2 is required.booleanisRequiredByGroups(String var1, String var2) Determines whether the edge var1 --> var2 is required by some required knowledge group.booleanisTierForbiddenWithin(int tier) Checks whether it is the case that any variable is forbidden by any other variable within a given tier.booleanisViolatedBy(Graph graph) isViolatedBy.booleannoEdgeRequired(String x, String y) noEdgeRequired.voidremoveForbidden(String var1, String var2) Marks the edge var1 --> var2 as not forbid.voidremoveFromTiers(String spec) Removes the given variable by name or search string from all tiers.voidremoveKnowledgeGroup(int index) Removes the knowledge group at the given index.voidremoveRequired(String var1, String var2) Marks the edge var1 --> var2 as not required.voidremoveTierStructure(int index) Removes the additional tier structure at the given index.Iterator over the KnowledgeEdge's representing required edges.static KnowledgeGenerates a simple exemplar of this class to test serialization.voidsetDefaultToKnowledgeLayout(boolean defaultToKnowledgeLayout) Setter for the fielddefaultToKnowledgeLayout.voidsetForbidden(String var1, String var2) Marks the edge var1 --> var2 as forbid.voidsetKnowledgeGroup(int index, KnowledgeGroup group) Replaces the knowledge group at the given index.voidsetOnlyCanCauseNextTier(int tier, boolean onlyCausesNext) setOnlyCanCauseNextTier.voidsetRequired(String var1, String var2) Marks the edge var1 --> var2 as required.voidSets the testing data for this instance.voidSets the variable in a given tier to the specified list.voidsetTierForbiddenWithin(int tier, boolean forbidden) Forbids any variable from being parent of any other variable within the given tier, or cancels this forbidding.toString()toString.
-
Constructor Details
-
Knowledge
public Knowledge()Constructor for Knowledge.
-
Knowledge
Constructor for Knowledge.
- Parameters:
nodes- aCollectionobject
-
Knowledge
-
-
Method Details
-
serializableInstance
-
addToTier
-
addToTiersByVarNames
-
addKnowledgeGroup
Adds a knowledge group. The group is enforced directly byisForbidden(String, String)andisRequired(String, String); nothing is compiled into the pairwise rule lists. Plain (non-wildcard) member names are added as variables, so a group over names the object has not seen is not silently inert.- Parameters:
group- aKnowledgeGroupobject
-
addVariable
-
clear
public void clear()Removes explicit knowledge and tier information. -
forbiddenEdgesIterator
Iterator over the KnowledgeEdge's representing forbidden edges.- Returns:
- a
Iteratorobject
-
getKnowledgeGroups
Getter for the field
knowledgeGroups.- Returns:
- a shallow copy of the list of group rules.
-
getVariables
-
getVariablesNotInTiers
-
getTier
-
getNumTiers
public int getNumTiers()getNumTiers.
- Returns:
- the number of temporal tiers
-
isDefaultToKnowledgeLayout
public boolean isDefaultToKnowledgeLayout()isDefaultToKnowledgeLayout.
- Returns:
- a boolean
-
setDefaultToKnowledgeLayout
public void setDefaultToKnowledgeLayout(boolean defaultToKnowledgeLayout) Setter for the field
defaultToKnowledgeLayout.- Parameters:
defaultToKnowledgeLayout- a boolean
-
isForbidden
-
isForbiddenByGroups
-
isForbiddenByTiers
-
isRequired
-
isRequiredByGroups
-
isEmpty
public boolean isEmpty()true if there is no background knowledge recorded.- Returns:
- a boolean
-
isTierForbiddenWithin
public boolean isTierForbiddenWithin(int tier) Checks whether it is the case that any variable is forbidden by any other variable within a given tier.- Parameters:
tier- a int- Returns:
- a boolean
-
isViolatedBy
-
noEdgeRequired
-
removeFromTiers
-
removeKnowledgeGroup
public void removeKnowledgeGroup(int index) Removes the knowledge group at the given index. Explicitly set rules and tiers are untouched, even where they coincide with the group.- Parameters:
index- a int
-
requiredEdgesIterator
Iterator over the KnowledgeEdge's representing required edges.- Returns:
- a
Iteratorobject
-
setForbidden
-
removeForbidden
-
setRequired
-
removeRequired
-
setKnowledgeGroup
Replaces the knowledge group at the given index. Explicitly set rules and tiers are untouched.- Parameters:
index- a intgroup- aKnowledgeGroupobject
-
setTier
-
setTierForbiddenWithin
public void setTierForbiddenWithin(int tier, boolean forbidden) Forbids any variable from being parent of any other variable within the given tier, or cancels this forbidding.- Parameters:
tier- a intforbidden- a boolean
-
getMaxTierForbiddenWithin
public int getMaxTierForbiddenWithin()getMaxTierForbiddenWithin.
- Returns:
- the largest indes of a tier in which every variable is forbidden by every other variable, or -1 if there is not such tier.
-
copy
-
isInWhichTier
-
getListOfRequiredEdges
-
getListOfExplicitlyRequiredEdges
getListOfExplicitlyRequiredEdges.
- Returns:
- a
Listobject
-
getListOfForbiddenEdges
getListOfForbiddenEdges.
- Returns:
- a
Listobject
-
getListOfExplicitlyForbiddenEdges
getListOfExplicitlyForbiddenEdges.
- Returns:
- a
Listobject
-
isOnlyCanCauseNextTier
public boolean isOnlyCanCauseNextTier(int tier) isOnlyCanCauseNextTier.
- Parameters:
tier- a int- Returns:
- a boolean
-
setOnlyCanCauseNextTier
public void setOnlyCanCauseNextTier(int tier, boolean onlyCausesNext) setOnlyCanCauseNextTier.
- Parameters:
tier- a intonlyCausesNext- a boolean
-
getTierStructures
Returns the additional tier structures, in order, as a shallow copy of the list. The structures themselves are the live objects, and editing one in place edits this knowledge; seeKnowledgeTierStructure.- Returns:
- a copy of the list of tier structures
-
addTierStructure
Adds an additional tier structure. Its member variable names are added as variables of this knowledge.- Parameters:
structure- aKnowledgeTierStructureobject
-
removeTierStructure
public void removeTierStructure(int index) Removes the additional tier structure at the given index.- Parameters:
index- a int
-
getNumTierStructures
public int getNumTierStructures()Returns the number of additional tier structures.- Returns:
- the number of tier structures
-
setTestingData
Sets the testing data for this instance. Can be null.- Parameters:
ds- the DataSet object to be used as testing data
-
getTestingData
Retrieves the testing dataset. Can be null.- Returns:
- the DataSet object representing the testing data
-
hashCode
-
equals
-
toString
-