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.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.getTier(int tier) getTier.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) 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) isOnlyCanCauseNextTier.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) 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.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) Legacy, do not use.voidsetOnlyCanCauseNextTier(int tier, boolean onlyCausesNext) setOnlyCanCauseNextTier.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()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. Legacy method, replaced by setForbidden, setRequired with cpdags. Needed for the interface.- 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.- Parameters:
index- a int
-
requiredEdgesIterator
Iterator over the KnowledgeEdge's representing required edges.- Returns:
- a
Iteratorobject
-
setForbidden
-
removeForbidden
-
setRequired
-
removeRequired
-
setKnowledgeGroup
Legacy, do not use.- 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
-
hashCode
-
equals
-
toString
-