edu.cs.ai.kreator.logic
Class AtomExpression

java.lang.Object
  extended by edu.cs.ai.kreator.logic.AtomExpression
All Implemented Interfaces:
Latexable, java.lang.Comparable<AtomExpression>

public class AtomExpression
extends java.lang.Object
implements Latexable, java.lang.Comparable<AtomExpression>

This class models an atom expression in bayesian logic. In general, bayesian atoms are not restricted to the range {true,false} and in order to express the value of a bayesian atom, an atom expression is needed. Given a bayesian atom "A" and a value "a" of "A" an atom expression is "A=a". For boolean predicates, this can be abbreviated by "A" or "-A", respectively.

Author:
Matthias Thimm

Constructor Summary
AtomExpression(GeneralizedAtom atom)
          Constructs a boolean atom expression "atom=true"
AtomExpression(GeneralizedAtom atom, java.lang.String value)
          Construct an atom expression "atom=value"
 
Method Summary
 int compareTo(AtomExpression other)
           
static boolean containsWithValue(GeneralizedAtom a, java.util.Collection<? extends AtomExpression> data)
          Checks whether the given atom is contained with some value in the given set of atom expressions
 boolean equals(java.lang.Object obj)
           
 GeneralizedAtom getAtom()
           
 java.util.Set<Constant> getConstants()
          returns the set of constants, that appear in this atom expression.
static java.util.Set<Constant> getConstants(java.util.Collection<? extends AtomExpression> data)
           
static java.util.List<GeneralizedPredicate> getPredicates(java.util.Collection<? extends AtomExpression> data)
          For a set {p1(...)
 java.lang.String getValue()
           
 int hashCode()
           
static java.util.Set<Literal> removeValues(java.util.Collection<? extends AtomExpression> data)
          For a set {A1=a1,...
static java.util.Set<Literal> removeValues(java.util.Collection<? extends AtomExpression> data, boolean preserveNegation)
          For a set {A1=a1,...
 void setAtom(GeneralizedAtom atom)
           
 void setValue(java.lang.String value)
           
 java.lang.String toLatex()
          Returns a Latex grammar conform string to generate variables, rules (conditionals) etc.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AtomExpression

public AtomExpression(GeneralizedAtom atom)
Constructs a boolean atom expression "atom=true"

Parameters:
atom - a bayesian atom

AtomExpression

public AtomExpression(GeneralizedAtom atom,
                      java.lang.String value)
Construct an atom expression "atom=value"

Parameters:
atom - a bayesian atom
value - the value of the bayesian atom
Method Detail

getConstants

public java.util.Set<Constant> getConstants()
returns the set of constants, that appear in this atom expression.

Returns:
the set of constants, that appear in this atom expression.

containsWithValue

public static boolean containsWithValue(GeneralizedAtom a,
                                        java.util.Collection<? extends AtomExpression> data)
Checks whether the given atom is contained with some value in the given set of atom expressions

Parameters:
data - a collection of atom expressions
Returns:
"true" if the given atom is contained in the given set.

removeValues

public static java.util.Set<Literal> removeValues(java.util.Collection<? extends AtomExpression> data)
For a set {A1=a1,...,An=an} of atom expressions this method returns the set {A1,...,An} of generalized atoms.

Parameters:
data - a collection of atom expressions.
Returns:
a set of literals.

removeValues

public static java.util.Set<Literal> removeValues(java.util.Collection<? extends AtomExpression> data,
                                                  boolean preserveNegation)
For a set {A1=a1,...,An=an} of atom expressions this method returns the set {A1,...,An} of generalized atoms.

Parameters:
data - a collection of atom expressions.
preserveNegation - whether an atom expression of the form A1=false (with A1 having a boolean predicate) is converted to !A1 instead of just A1.
Returns:
a set of literals.

getPredicates

public static java.util.List<GeneralizedPredicate> getPredicates(java.util.Collection<? extends AtomExpression> data)
For a set {p1(...)=a1,...,pn(...)=an} of atom expressions this method returns the set {p1,...,pn} of generalized predicates.

Parameters:
data -
Returns:

getConstants

public static java.util.Set<Constant> getConstants(java.util.Collection<? extends AtomExpression> data)

getAtom

public GeneralizedAtom getAtom()

setAtom

public void setAtom(GeneralizedAtom atom)
             throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

getValue

public java.lang.String getValue()

setValue

public void setValue(java.lang.String value)
              throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toLatex

public java.lang.String toLatex()
Description copied from interface: Latexable
Returns a Latex grammar conform string to generate variables, rules (conditionals) etc.

Specified by:
toLatex in interface Latexable
Returns:
a Latex grammar conform string.

compareTo

public int compareTo(AtomExpression other)
Specified by:
compareTo in interface java.lang.Comparable<AtomExpression>

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object