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 TypeMethodDescriptionvoid
addCategory
(int variable, int category) addCategory.void
disallowComplement
(int variable, int category) Without changing the status of the specified category, disallows all other categories for the given variable.boolean
boolean
existsCombination.int
getCategoryIndex
(String nodeName, String category) getCategoryIndex.int
getNodeIndex
(String name) getNodeIndex.int
getNumAllowed
(int variable) getNumAllowed.int
getNumAllowedCategories
(int i) getNumAllowedCategories.int
getNumCategories
(int variable) getNumCategories.int
getNumVariables.int
getSingleCategory
(int variable) getSingleCategory.Getter for the fieldvariableSource
.int
hashCode()
hashCode.boolean
isAllowed
(int variable, int category) isAllowed.boolean
isConditioned
(int variable) isConditioned.boolean
isPermissibleCombination
(int[] point) isPermissibleCombination.void
removeCategory
(int variable, int category) removeCategory.void
restrictToProposition
(Proposition proposition) Restricts this proposition to the categories for each variable that are true in the given proposition.static Proposition
Generates a simple exemplar of this class to test serialization.void
setCategory
(int variable, int category) Sets the given value to true and all other values to false for the given variable.void
Specifies that all variables in the proposition are either completely allowed (true) or completely disallowed (false) for all of their categories.void
setVariable
(int variable, boolean allowed) Specifies that all categories for the given variable are either all allowed (true) or all disallowed (false).static Proposition
tautology
(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
- aVariableSource
objectproposition
- aProposition
object
-
Proposition
Copies the info out of the old proposition into a new proposition for the new BayesIm.- Parameters:
proposition
- aProposition
object
-
-
Method Details
-
tautology
tautology.
- Parameters:
variableSource
- aVariableSource
object- Returns:
- a
Proposition
object
-
serializableInstance
Generates a simple exemplar of this class to test serialization.- Returns:
- a
Proposition
object
-
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
- aProposition
object
-
getNodeIndex
-
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
-
toString
-