com.evelopers.unimod.analysis
Class TermSimplifier

java.lang.Object
  extended bycom.evelopers.unimod.analysis.TermSimplifier
Direct Known Subclasses:
ASTTermSimplifier

class TermSimplifier
extends java.lang.Object

TermSimplifier represents a term. Different types of literals may be put using method put(). TermSimplifier controls:

To get if term considered to be identical false use isIdenticalFalse. To iterate boolean and interval variables use booleanVariablesIterator() and intervalVariablesIterator(). To find out if boolean variable enters with negation use isNegated(). To get range of interval variable use getIntervals().


Nested Class Summary
protected  class TermSimplifier.BooleanLiteral
           
protected  class TermSimplifier.IntervalLiteral
           
 
Constructor Summary
TermSimplifier()
          Default constructor
TermSimplifier(TermSimplifier that)
          Copy constuctor
 
Method Summary
 java.util.Iterator booleanVariablesIterator()
           
protected  void checkIdenticalFalse(boolean identicalFalse)
           
 boolean dependsOn(Action action)
           
 Range getRange(Action var)
          Gets the array of intervals for variable action.
 java.util.Iterator intervalVariablesIterator()
           
 boolean isIdenticalFalse()
           
 boolean isIdenticalTrue()
           
 boolean isNegated(Action var)
          Checks if variable action is in the term with negation
 boolean put(Action var, boolean isNegated)
          Puts variable action or it's nigation
 boolean put(Action var, int relation, int value)
          Intersects interval of action with it's current interval.
 boolean put(int booleanConst)
          Tests if booleanConst is true or false.
 boolean put(int value, int relation, Action var)
          Reverse version of put(Action, boolean)
 boolean put(int leftConst, int relation, int rightConst)
          Tests relation between two consts.
 java.lang.String toString()
           
 java.util.Iterator variablesIterator()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TermSimplifier

public TermSimplifier()
Default constructor


TermSimplifier

public TermSimplifier(TermSimplifier that)
Copy constuctor

Parameters:
that - instance to copy
Method Detail

put

public boolean put(Action var,
                   boolean isNegated)
            throws InterpreterException
Puts variable action or it's nigation

Parameters:
var - variable to put
isNegated - if it is true then negation of action will be putted
Returns:
true if this term is identical false
Throws:
InterpreterException

put

public boolean put(Action var,
                   int relation,
                   int value)
            throws InterpreterException
Intersects interval of action with it's current interval. By default an interval of each variable is [Interval.MIN, Interval.MAX].

Parameters:
var - name of interval variable
relation - type of relation of action with value. Should be one of:
  • ExprTokenTypes.GT
  • ExprTokenTypes.LT
  • ExprTokenTypes.GE
  • ExprTokenTypes.LE
  • ExprTokenTypes.EQUAL
  • ExprTokenTypes.NEQUAL
value - limit of interval for action
Returns:
true if this term is identical false
Throws:
InterpreterException

put

public boolean put(int value,
                   int relation,
                   Action var)
            throws InterpreterException
Reverse version of put(Action, boolean)

Throws:
InterpreterException

put

public boolean put(int booleanConst)
Tests if booleanConst is true or false. If it is true it is skipped. If it is false then whole term should be false.

Parameters:
booleanConst - boolean constant to test
Returns:
true if this term is identical false

put

public boolean put(int leftConst,
                   int relation,
                   int rightConst)
            throws InterpreterException
Tests relation between two consts. If it is identical true it is skipped. If it is identical false

Parameters:
leftConst - constant on the left side of the relation
relation - relation to test
rightConst - constant on the right side of the relation
Returns:
true if this term is identical false
Throws:
InterpreterException

booleanVariablesIterator

public java.util.Iterator booleanVariablesIterator()
Returns:
Boolean variables list iterator
See Also:
isNegated(com.evelopers.unimod.core.stateworks.Action)

intervalVariablesIterator

public java.util.Iterator intervalVariablesIterator()
Returns:
Interval variables list iterator
See Also:
getRange(com.evelopers.unimod.core.stateworks.Action action)

variablesIterator

public java.util.Iterator variablesIterator()
Returns:
Any variables list iterator
See Also:
getRange(com.evelopers.unimod.core.stateworks.Action action)

dependsOn

public boolean dependsOn(Action action)

isIdenticalFalse

public boolean isIdenticalFalse()

isIdenticalTrue

public boolean isIdenticalTrue()

isNegated

public boolean isNegated(Action var)
                  throws java.lang.IndexOutOfBoundsException,
                         InterpreterException
Checks if variable action is in the term with negation

Returns:
true if variable action is in the term with negation
Throws:
java.lang.IndexOutOfBoundsException - if action is not in the term
InterpreterException - if action is not boolean variable
See Also:
booleanVariablesIterator()

getRange

public Range getRange(Action var)
               throws java.lang.IndexOutOfBoundsException,
                      InterpreterException
Gets the array of intervals for variable action. This interval represent range for variable var.

Returns:
An array of intervals
Throws:
java.lang.IndexOutOfBoundsException - if there is no variable action in this term
InterpreterException - if action is not interval variable
See Also:
intervalVariablesIterator()

toString

public java.lang.String toString()

checkIdenticalFalse

protected void checkIdenticalFalse(boolean identicalFalse)