Class Proposition

java.lang.Object
edu.cmu.tetrad.bayes.Proposition
All Implemented Interfaces:
TetradSerializable, Serializable

public final class Proposition extends Object implements TetradSerializable
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.
Author:
josephramsey
See Also:
  • Constructor Details

    • Proposition

      public Proposition(VariableSource variableSource, Proposition proposition)
      Copies the info out of the old proposition into a new proposition for the new BayesIm.
    • Proposition

      public Proposition(Proposition proposition)
      Copies the info out of the old proposition into a new proposition for the new BayesIm.
  • Method Details

    • tautology

      public static Proposition tautology(VariableSource variableSource)
    • serializableInstance

      public static Proposition serializableInstance()
      Generates a simple exemplar of this class to test serialization.
    • getNumAllowedCategories

      public int getNumAllowedCategories(int i)
    • removeCategory

      public void removeCategory(int variable, int category)
    • disallowComplement

      public void disallowComplement(int variable, int category)
      Without changing the status of the specified category, disallows all other categories for the given variable.
    • setCategory

      public void setCategory(int variable, int category)
      Sets the given value to true and all other values to false for the given variable.
    • isPermissibleCombination

      public boolean isPermissibleCombination(int[] point)
      Returns:
      true iff the given point is true for this proposition.
    • existsCombination

      public boolean 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)
    • getSingleCategory

      public int getSingleCategory(int variable)
      Returns:
      the single category selected for the given variable, or -1 if it is not the case that a single value is selected.
    • restrictToProposition

      public void restrictToProposition(Proposition proposition)
      Restricts this proposition to the categories for each variable that are true in the given proposition.
    • getNodeIndex

      public int getNodeIndex(String name)
      Returns:
      the index of the variable with the given name, or -1 if such a variable does not exist.
    • getCategoryIndex

      public int getCategoryIndex(String nodeName, String category)
    • addCategory

      public void addCategory(int variable, int category)
    • getVariableSource

      public VariableSource getVariableSource()
      Returns:
      the Bayes IM that this is a proposition for.
    • getNumVariables

      public int getNumVariables()
      Returns:
      the number of variables for the proposition.
    • getNumCategories

      public int getNumCategories(int variable)
      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).
    • 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)
      Returns:
      true iff the given category for the given variable is allowed.
    • isConditioned

      public boolean isConditioned(int variable)
      Returns:
      true iff some category for the given variable is disallowed.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object