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.Retrieves the testing dataset.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 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
Constructor for Knowledge.
- Parameters:
knowledge- aKnowledgeobject
-
-
Method Details
-
serializableInstance
Generates a simple exemplar of this class to test serialization.- Returns:
- a
Knowledgeobject
-
addToTier
Adds the given variable or wildcard cpdag to the given tier. The tier is a non-negative integer.- Parameters:
tier- a intspec- aStringobject
-
addToTiersByVarNames
Puts a variable into tier i if its name is xxx:ti for some xxx and some i.- Parameters:
varNames- aListobject
-
addKnowledgeGroup
Adds a knowledge group. Legacy method, replaced by setForbidden, setRequired with cpdags. Needed for the interface.- Parameters:
group- aKnowledgeGroupobject
-
addVariable
addVariable.
- Parameters:
varName- aStringobject
-
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
Get a list of variables.- Returns:
- a copy of the list of variable, in alphabetical order.
-
getVariablesNotInTiers
getVariablesNotInTiers.
- Returns:
- the list of edges not in any tier.
-
getTier
getTier.
- Parameters:
tier- the index of the desired tier- Returns:
- a copy of this tier
-
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
Determines whether the edge var1 --> var2 is forbidden. -
isForbiddenByGroups
Legacy. -
isForbiddenByTiers
Determines whether the edge var1 --> var2 is forbidden by the temporal tiers. -
isRequired
Determines whether the edge var1 --> var2 is required. -
isRequiredByGroups
Legacy. -
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
isViolatedBy.
- Parameters:
graph- aGraphobject- Returns:
- a boolean
-
noEdgeRequired
noEdgeRequired.
-
removeFromTiers
Removes the given variable by name or search string from all tiers.- Parameters:
spec- aStringobject
-
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
Marks the edge var1 --> var2 as forbid. -
removeForbidden
Marks the edge var1 --> var2 as not forbid. -
setRequired
Marks the edge var1 --> var2 as required. -
removeRequired
Marks the edge var1 --> var2 as not required. -
setKnowledgeGroup
Legacy, do not use.- Parameters:
index- a intgroup- aKnowledgeGroupobject
-
setTier
Sets the variable in a given tier to the specified list.- Parameters:
tier- a intvars- aListobject
-
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
Makes a shallow copy.- Returns:
- a
Knowledgeobject
-
isInWhichTier
Returns the index of the tier of node if it's in a tier, otherwise -1.- Parameters:
node- aNodeobject- Returns:
- a int
-
getListOfRequiredEdges
getListOfRequiredEdges.
- Returns:
- a
Listobject
-
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
-
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
public int hashCode()Computes a hashcode. -
equals
Compares this Knowledge object with the specified object for equality. -
toString
toString.
-