Class KnowledgeTierStructure
- All Implemented Interfaces:
TetradSerializable, Serializable
Knowledge
object, independent of the main temporal tiers and of every other tier structure. Within one
structure, edges from a later tier to an earlier tier are forbidden, and a tier may additionally
forbid edges within itself; variables of different structures (or of a structure and the main
tiers) constrain one another only through whatever other knowledge mentions them.
This exists for data sets whose variables carry several temporal orderings at once -- for example a course data set with one ordering over the exams, another over the module checkpoints, and another over the unit completions -- which a single tier list cannot represent without also forbidding edges between the orderings.
Unlike the main tiers, the within-tier and ordering constraints of a tier structure are stored
here directly, as the structure itself, and Knowledge consults the structure when asked
whether an edge is forbidden; nothing is compiled into pairwise rules.
A variable may belong to at most one tier of a given structure, but may appear in any number of structures and in the main tiers at the same time. Variable names are held as plain names; wildcards are not interpreted here.
Mutable; instances are shared with editors, which edit them in place.
- Author:
- josephramsey
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionKnowledgeTierStructure(String name) Constructs an empty tier structure with the given name. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the given variable to the given tier of this structure, removing it from any other tier of this structure first.voidensureTiers(int tier) Ensures that tiers 0..tier exist.booleanCompares this structure with the given object for equality of name, tiers, and within-tier flags.getName()Returns the display name of this structure.intReturns the number of tiers in this structure.getTier(int tier) Returns a copy of the given tier, in natural sort order.Returns the set of variable names appearing in some tier of this structure.inthashCode()Computes a hashcode.booleanisEmpty()Returns whether no tier of this structure contains a variable.booleanisForbidden(String var1, String var2) Returns whether the edge var1 --> var2 is forbidden by this structure: var1 lies in a later tier than var2, or they lie in the same tier and that tier forbids edges within itself.intisInWhichTier(String var) Returns the index of the tier of this structure containing the variable, or -1.booleanisTierForbiddenWithin(int tier) Returns whether edges within the given tier are forbidden.voidremoveFromTiers(String var) Removes the given variable from every tier of this structure.static KnowledgeTierStructureGenerates a simple exemplar of this class to test serialization.voidSets the display name of this structure.voidsetTierForbiddenWithin(int tier, boolean forbidden) Forbids edges within the given tier, or cancels this forbidding.toString()Returns a short description of this structure.voidRemoves empty tiers from the end of the structure, so that saved and rendered forms do not accumulate trailing blanks.
-
Constructor Details
-
KnowledgeTierStructure
Constructs an empty tier structure with the given name.- Parameters:
name- the display name; may contain spaces but not be null or blank
-
-
Method Details
-
serializableInstance
Generates a simple exemplar of this class to test serialization.- Returns:
- a
KnowledgeTierStructureobject
-
getName
-
setName
Sets the display name of this structure.- Parameters:
name- the new name; may contain spaces but not be null or blank
-
getNumTiers
public int getNumTiers()Returns the number of tiers in this structure.- Returns:
- the number of tiers
-
ensureTiers
public void ensureTiers(int tier) Ensures that tiers 0..tier exist.- Parameters:
tier- the largest tier index that must exist
-
addToTier
Adds the given variable to the given tier of this structure, removing it from any other tier of this structure first.- Parameters:
tier- the tier index, a non-negative integervar- the variable name
-
removeFromTiers
Removes the given variable from every tier of this structure.- Parameters:
var- the variable name
-
getTier
-
isInWhichTier
Returns the index of the tier of this structure containing the variable, or -1.- Parameters:
var- the variable name- Returns:
- the tier index, or -1 if the variable is in no tier of this structure
-
isTierForbiddenWithin
public boolean isTierForbiddenWithin(int tier) Returns whether edges within the given tier are forbidden.- Parameters:
tier- the tier index- Returns:
- true iff edges within the tier are forbidden
-
setTierForbiddenWithin
public void setTierForbiddenWithin(int tier, boolean forbidden) Forbids edges within the given tier, or cancels this forbidding.- Parameters:
tier- the tier indexforbidden- true to forbid edges within the tier
-
isForbidden
Returns whether the edge var1 --> var2 is forbidden by this structure: var1 lies in a later tier than var2, or they lie in the same tier and that tier forbids edges within itself. Distinct variables only; a variable never forbids itself.- Parameters:
var1- the name of the would-be parentvar2- the name of the would-be child- Returns:
- true iff the edge is forbidden by this structure
-
getVariables
-
isEmpty
public boolean isEmpty()Returns whether no tier of this structure contains a variable.- Returns:
- true iff every tier is empty
-
trimTrailingEmptyTiers
public void trimTrailingEmptyTiers()Removes empty tiers from the end of the structure, so that saved and rendered forms do not accumulate trailing blanks. Interior empty tiers are kept, since tier indices are meaningful. -
hashCode
-
equals
-
toString
-