Class LogOp

  • All Implemented Interfaces:
    Cloneable, ILogical

    public final class LogOp
    extends Object
    implements ILogical
    Logical Operator, to ease clause definition.
    Since:
    23 nov. 2010
    Author:
    Charles Prud'homme
    • Method Detail

      • and

        public static LogOp and​(ILogical... op)
        Create a conjunction, results in true if all of its operands are true
        Parameters:
        op - operands
        Returns:
        a new logical operator
      • ifOnlyIf

        public static LogOp ifOnlyIf​(ILogical a,
                                     ILogical b)
        Create a biconditional, results in true if and only if both operands are false or both operands are true
        Parameters:
        a - operand
        b - operand
        Returns:
        a new logical operator
      • ifThenElse

        public static LogOp ifThenElse​(ILogical a,
                                       ILogical b,
                                       ILogical c)
        Create an implication, results in true if a is true` and b is true or a is false and c is true.
        Parameters:
        a - operand
        b - operand
        c - operand
        Returns:
        a new logical operator
      • implies

        public static LogOp implies​(ILogical a,
                                    ILogical b)
        Create an implication, results in true if a is false or b is true.
        Parameters:
        a - operand
        b - operand
        Returns:
        a new logical operator
      • reified

        public static LogOp reified​(BoolVar b,
                                    ILogical tree)
        create a logical connection between ``b`` and ``tree``.
        Parameters:
        b - operand
        tree - operand
        Returns:
        a logical operator
      • or

        public static LogOp or​(ILogical... op)
        Create a disjunction, results in true whenever one or more of its operands are true
        Parameters:
        op - operands
        Returns:
        a new logical operator
      • nand

        public static LogOp nand​(ILogical... op)
        Create an alternative denial, results in if at least one of its operands is false.
        Parameters:
        op - operands
        Returns:
        a new logical operator
      • nor

        public static LogOp nor​(ILogical... op)
        Create a joint denial, results in `true` if all of its operands are false.
        Parameters:
        op - operands
        Returns:
        a new logical operator
      • xor

        public static LogOp xor​(ILogical a,
                                ILogical b)
        Create an exclusive disjunction, results in true whenever both operands differ.
        Parameters:
        a - operand
        b - operand
        Returns:
        a new logical operator
      • is

        public boolean is​(LogOp.Operator op)
        Current tree is rooted with the logical operator op
        Parameters:
        op - operator checked
        Returns:
        true if this is op
      • isNot

        public boolean isNot()
        Current tree is rooted with NOT logical operator
        Specified by:
        isNot in interface ILogical
        Returns:
        true if this is NOT
      • isLit

        public boolean isLit()
        Description copied from interface: ILogical
        Current tree is a literal
        Specified by:
        isLit in interface ILogical
        Returns:
        true if this is a literal
      • setNot

        public void setNot​(boolean isNot)
        Description copied from interface: ILogical
        States whether or not this variable is the negation of another. This is a one way relationship: in case a = not(b) a.isNot() returns true whereas b.isNot() returns false (unless b = not(c)...)
        Specified by:
        setNot in interface ILogical
        Parameters:
        isNot - true iff this variable is the negation of another
      • getNbChildren

        protected int getNbChildren()
        Returns the number of direct children of this
        Returns:
        number of children
      • hasOrChild

        protected boolean hasOrChild()
        Check if at least one children is an OR logic tree
        Returns:
        true if this contains one OR logic tree
      • hasAndChild

        protected boolean hasAndChild()
        Checks if at least one children is an AND logic tree
        Returns:
        true if this contains one AND logic tree
      • addChild

        public void addChild​(ILogical child)
        Adds child to the current list of children of this
        Parameters:
        child - the logic tree to add
      • removeChild

        public void removeChild​(ILogical child)
        Removes child from the current list of children of this
        Parameters:
        child - the logic tree to remove
      • getChildren

        public ILogical[] getChildren()
        Returns the array of children of this. null is a valid return value.
        Returns:
        an array of logic trees, null otherwise
      • getAndChild

        public ILogical getAndChild()
        Returns the first AND logic tree within the list of children. null is a valid return value.
        Returns:
        a AND logic tree if exists, null otherwise
      • getChildBut

        public ILogical getChildBut​(ILogical child)
        Returns the first child within the list of children, different from child. null is a valid return value.
        Parameters:
        child - node to avoid
        Returns:
        the first logic tree different from child if exists, null otherwise
      • flip

        public void flip()
        Flip the boolean evaluation of this (recursive).
      • deny

        public void deny()
        Flip the boolean operator of this (recursive).
      • flattenBoolVar

        public BoolVar[] flattenBoolVar()
        Extracts and returns the flatten array of BoolVar contained in this. WARNING : a variable may appear more than once, redundancy is not checked!
        Returns:
        array of bool variables
      • cleanFlattenBoolVar

        public void cleanFlattenBoolVar()