Package edu.cmu.tetrad.bayes
Class Proposition
java.lang.Object
edu.cmu.tetrad.bayes.Proposition
- All Implemented Interfaces:
TetradSerializable,Serializable
Represents propositions over the variables of a particular BayesIm describing an event of a fairly general
sort--namely, conjunctions of propositions that particular variables take on values from a particular disjunctive
list of categories. For example, X1 = 1 or 2 and X2 = 3 and X3 = 1 or 3 and X4 = 2 or 3 or 5. The proposition is
created by allowing or disallowing particular categories. Notice that "knowing nothing" about a variable is the same
as saying that all categories for that variable are allowed, so the proposition by default allows all categories for
all variables--i.e. it is a tautology.
- Version:
- $Id: $Id
- Author:
- josephramsey
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionProposition(Proposition proposition) Copies the info out of the old proposition into a new proposition for the new BayesIm.Proposition(VariableSource variableSource, Proposition proposition) Copies the info out of the old proposition into a new proposition for the new BayesIm. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCategory(int variable, int category) addCategory.voiddisallowComplement(int variable, int category) Without changing the status of the specified category, disallows all other categories for the given variable.booleanbooleanexistsCombination.intgetCategoryIndex(String nodeName, String category) getCategoryIndex.intgetNodeIndex(String name) getNodeIndex.intgetNumAllowed(int variable) getNumAllowed.intgetNumAllowedCategories(int i) getNumAllowedCategories.intgetNumCategories(int variable) getNumCategories.intgetNumVariables.intgetSingleCategory(int variable) getSingleCategory.Getter for the fieldvariableSource.inthashCode()hashCode.booleanisAllowed(int variable, int category) isAllowed.booleanisConditioned(int variable) isConditioned.booleanisPermissibleCombination(int[] point) isPermissibleCombination.voidremoveCategory(int variable, int category) removeCategory.voidrestrictToProposition(Proposition proposition) Restricts this proposition to the categories for each variable that are true in the given proposition.static PropositionGenerates a simple exemplar of this class to test serialization.voidsetCategory(int variable, int category) Sets the given value to true and all other values to false for the given variable.voidSpecifies that all variables in the proposition are either completely allowed (true) or completely disallowed (false) for all of their categories.voidsetVariable(int variable, boolean allowed) Specifies that all categories for the given variable are either all allowed (true) or all disallowed (false).static Propositiontautology(VariableSource variableSource) tautology.toString()toString.
-
Constructor Details
-
Proposition
Copies the info out of the old proposition into a new proposition for the new BayesIm.- Parameters:
variableSource- aVariableSourceobjectproposition- aPropositionobject
-
Proposition
Copies the info out of the old proposition into a new proposition for the new BayesIm.- Parameters:
proposition- aPropositionobject
-
-
Method Details
-
tautology
tautology.
- Parameters:
variableSource- aVariableSourceobject- Returns:
- a
Propositionobject
-
serializableInstance
Generates a simple exemplar of this class to test serialization.- Returns:
- a
Propositionobject
-
getNumAllowedCategories
public int getNumAllowedCategories(int i) getNumAllowedCategories.
- Parameters:
i- a int- Returns:
- a int
-
removeCategory
public void removeCategory(int variable, int category) removeCategory.
- Parameters:
variable- a intcategory- a int
-
disallowComplement
public void disallowComplement(int variable, int category) Without changing the status of the specified category, disallows all other categories for the given variable.- Parameters:
variable- a intcategory- a int
-
setCategory
public void setCategory(int variable, int category) Sets the given value to true and all other values to false for the given variable.- Parameters:
variable- a intcategory- a int
-
isPermissibleCombination
public boolean isPermissibleCombination(int[] point) isPermissibleCombination.
- Parameters:
point- an array of objects- Returns:
- true iff the given point is true for this proposition.
-
existsCombination
public boolean existsCombination()existsCombination.
- Returns:
- true iff there is some combination of categories for all the variables of the proposition that is allowed.
-
getNumAllowed
public int getNumAllowed(int variable) getNumAllowed.
- Parameters:
variable- a int- Returns:
- a int
-
getSingleCategory
public int getSingleCategory(int variable) getSingleCategory.
- Parameters:
variable- a int- Returns:
- the single category selected for the given variable, or -1 if it is not the case that a single value is selected.
-
restrictToProposition
Restricts this proposition to the categories for each variable that are true in the given proposition.- Parameters:
proposition- aPropositionobject
-
getNodeIndex
getNodeIndex.
- Parameters:
name- aStringobject- Returns:
- the index of the variable with the given name, or -1 if such a variable does not exist.
-
getCategoryIndex
getCategoryIndex.
-
addCategory
public void addCategory(int variable, int category) addCategory.
- Parameters:
variable- a intcategory- a int
-
getVariableSource
Getter for the field
variableSource.- Returns:
- the Bayes IM that this is a proposition for.
-
getNumVariables
public int getNumVariables()getNumVariables.
- Returns:
- the number of variables for the proposition.
-
getNumCategories
public int getNumCategories(int variable) getNumCategories.
- Parameters:
variable- a int- Returns:
- the number of categories for the given variable.
-
setVariable
public void setVariable(int variable, boolean allowed) Specifies that all categories for the given variable are either all allowed (true) or all disallowed (false).- Parameters:
variable- a intallowed- a boolean
-
setToTautology
public void setToTautology()Specifies that all variables in the proposition are either completely allowed (true) or completely disallowed (false) for all of their categories. -
isAllowed
public boolean isAllowed(int variable, int category) isAllowed.
- Parameters:
variable- a intcategory- a int- Returns:
- true iff the given category for the given variable is allowed.
-
isConditioned
public boolean isConditioned(int variable) isConditioned.
- Parameters:
variable- a int- Returns:
- true iff some category for the given variable is disallowed.
-
equals
-
hashCode
public int hashCode()hashCode.
-
toString
toString.
-