Package edu.cmu.tetrad.data
Class Knowledge
java.lang.Object
edu.cmu.tetrad.data.Knowledge
- All Implemented Interfaces:
- TetradSerializable,- Serializable
Stores information about required and forbidden edges and common causes for
 use in algorithm. This information can be set edge by edge or else globally
 via temporal tiers. When setting temporal tiers, all edges from later tiers
 to earlier tiers are forbidden.
 
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".
- Author:
- Joseph Ramsey, Kevin V. Bui (kvb2@pitt.edu)
- See Also:
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddKnowledgeGroup(KnowledgeGroup group) Adds a knowledge group.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) voidclear()Removes explicit knowledge and tier information.copy()Makes a shallow copy.booleanTwo Knowledge objects are equal just in case their forbidden and required edges are equal, and their tiers are equal.Iterator over the KnowledgeEdge's representing forbidden edges.intintgetTier(int tier) Get a list of variables.inthashCode()Computes a hashcode.booleanbooleanisEmpty()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) Legacy.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) booleanisRequired(String var1, String var2) Determines whether the edge var1 --> var2 is required.booleanisRequiredByGroups(String var1, String var2) Legacy.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) booleannoEdgeRequired(String x, String y) 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.Iterator over the KnowledgeEdge's representing required edges.static KnowledgeGenerates a simple exemplar of this class to test serialization.voidsetDefaultToKnowledgeLayout(boolean defaultToKnowledgeLayout) voidsetForbidden(String var1, String var2) Marks the edge var1 --> var2 as forbid.voidsetKnowledgeGroup(int index, KnowledgeGroup group) Legacy, do not use.voidsetOnlyCanCauseNextTier(int tier, boolean onlyCausesNext) voidsetRequired(String var1, String var2) Marks the edge var1 --> var2 as required.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()
- 
Constructor Details- 
Knowledgepublic Knowledge()
- 
Knowledge
- 
Knowledge
 
- 
- 
Method Details- 
serializableInstanceGenerates a simple exemplar of this class to test serialization.
- 
addToTierAdds the given variable or wildcard cpdag to the given tier. The tier is a non-negative integer.
- 
addToTiersByVarNamesPuts a variable into tier i if its name is xxx:ti for some xxx and some i.
- 
addKnowledgeGroupAdds a knowledge group. Legacy method, replaced by setForbidden, setRequired with cpdags. Needed for the interface.
- 
addVariable
- 
clearpublic void clear()Removes explicit knowledge and tier information.
- 
forbiddenEdgesIteratorIterator over the KnowledgeEdge's representing forbidden edges.
- 
getKnowledgeGroups- Returns:
- a shallow copy of the list of group rules.
 
- 
getVariablesGet a list of variables.- Returns:
- a copy of the list of variable, in alphabetical order.
 
- 
getVariablesNotInTiers- Returns:
- the list of edges not in any tier.
 
- 
getTier- Parameters:
- tier- the index of the desired tier
- Returns:
- a copy of this tier
 
- 
getNumTierspublic int getNumTiers()- Returns:
- the number of temporal tiers
 
- 
isDefaultToKnowledgeLayoutpublic boolean isDefaultToKnowledgeLayout()
- 
setDefaultToKnowledgeLayoutpublic void setDefaultToKnowledgeLayout(boolean defaultToKnowledgeLayout) 
- 
isForbiddenDetermines whether the edge var1 --> var2 is forbidden.
- 
isForbiddenByGroupsLegacy.
- 
isForbiddenByTiersDetermines whether the edge var1 --> var2 is forbidden by the temporal tiers.
- 
isRequiredDetermines whether the edge var1 --> var2 is required.
- 
isRequiredByGroupsLegacy.
- 
isEmptypublic boolean isEmpty()true if there is no background knowledge recorded.
- 
isTierForbiddenWithinpublic boolean isTierForbiddenWithin(int tier) Checks whether it is the case that any variable is forbidden by any other variable within a given tier.
- 
isViolatedBy
- 
noEdgeRequired
- 
removeFromTiersRemoves the given variable by name or search string from all tiers.
- 
removeKnowledgeGrouppublic void removeKnowledgeGroup(int index) Removes the knowledge group at the given index.
- 
requiredEdgesIteratorIterator over the KnowledgeEdge's representing required edges.
- 
setForbiddenMarks the edge var1 --> var2 as forbid.
- 
removeForbiddenMarks the edge var1 --> var2 as not forbid.
- 
setRequiredMarks the edge var1 --> var2 as required.
- 
removeRequiredMarks the edge var1 --> var2 as not required.
- 
setKnowledgeGroupLegacy, do not use.
- 
setTierSets the variable in a given tier to the specified list.
- 
setTierForbiddenWithinpublic void setTierForbiddenWithin(int tier, boolean forbidden) Forbids any variable from being parent of any other variable within the given tier, or cancels this forbidding.
- 
getMaxTierForbiddenWithinpublic int 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.
 
- 
copyMakes a shallow copy.
- 
isInWhichTierReturns the index of the tier of node if it's in a tier, otherwise -1.
- 
getListOfRequiredEdges
- 
getListOfExplicitlyRequiredEdges
- 
getListOfForbiddenEdges
- 
getListOfExplicitlyForbiddenEdges
- 
isOnlyCanCauseNextTierpublic boolean isOnlyCanCauseNextTier(int tier) 
- 
setOnlyCanCauseNextTierpublic void setOnlyCanCauseNextTier(int tier, boolean onlyCausesNext) 
- 
hashCodepublic int hashCode()Computes a hashcode.
- 
equalsTwo Knowledge objects are equal just in case their forbidden and required edges are equal, and their tiers are equal.
- 
toString
 
-