choco.kernel.model.constraints.cnf
Class Literal

java.lang.Object
  extended by choco.kernel.model.constraints.cnf.ALogicTree
      extended by choco.kernel.model.constraints.cnf.Literal
All Implemented Interfaces:
Cloneable, Comparable<Literal>

public final class Literal
extends ALogicTree
implements Comparable<Literal>


Since:
21/12/10
Author:
Charles Prud'homme

Nested Class Summary
 
Nested classes/interfaces inherited from class choco.kernel.model.constraints.cnf.ALogicTree
ALogicTree.Operator, ALogicTree.Type
 
Constructor Summary
protected Literal(IntegerVariable var, ALogicTree.Type type)
           
 
Method Summary
 void addChild(ALogicTree child)
          Adds child to the current list of children of this
 Literal clone()
           
 int compareTo(Literal o)
           
 IntegerVariable[] flattenBoolVar()
          Extracts and returns the flatten array of BoolVar contained in this.
 ALogicTree getAndChild()
          Returns the first AND logic tree within the list of children.
 ALogicTree getChildBut(ALogicTree child)
          Returns the first child within the list of children, different from child.
 ALogicTree[] getChildren()
          Returns the array of children of this.
 int getNbPositiveLiterals()
          Computes and returns the number of positive literals contained in the direct level.
 boolean hasAndChild()
          Checks if at least one children is an AND logic tree
 boolean hasOrChild()
          Check if at least one children is an OR logic tree
 boolean is(ALogicTree.Operator op)
          Current tree is rooted with the logical operator op
 boolean isLit()
          Current tree is a literal
 boolean isNot()
          Current tree is rooted with NOT logical operator
static Literal neg(IntegerVariable var)
           
static Literal[] neg(IntegerVariable[] vars)
           
static Literal pos(IntegerVariable var)
           
static Literal[] pos(IntegerVariable[] vars)
           
 void removeChild(ALogicTree child)
          Removes child from the current list of children of this
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Literal

protected Literal(IntegerVariable var,
                  ALogicTree.Type type)
Method Detail

pos

public static Literal pos(IntegerVariable var)

pos

public static Literal[] pos(IntegerVariable[] vars)

neg

public static Literal neg(IntegerVariable var)

neg

public static Literal[] neg(IntegerVariable[] vars)

is

public boolean is(ALogicTree.Operator op)
Description copied from class: ALogicTree
Current tree is rooted with the logical operator op

Specified by:
is in class ALogicTree
Parameters:
op - operator checked
Returns:
true if this is op

isNot

public boolean isNot()
Description copied from class: ALogicTree
Current tree is rooted with NOT logical operator

Returns:
true if this is NOT

isLit

public boolean isLit()
Description copied from class: ALogicTree
Current tree is a literal

Returns:
true if this is a literal

hasOrChild

public boolean hasOrChild()
Description copied from class: ALogicTree
Check if at least one children is an OR logic tree

Returns:
true if this contains one OR logic tree

hasAndChild

public boolean hasAndChild()
Description copied from class: ALogicTree
Checks if at least one children is an AND logic tree

Returns:
true if this contains one AND logic tree

addChild

public void addChild(ALogicTree child)
Description copied from class: ALogicTree
Adds child to the current list of children of this

Parameters:
child - the logic tree to add

removeChild

public void removeChild(ALogicTree child)
Description copied from class: ALogicTree
Removes child from the current list of children of this

Parameters:
child - the logic tree to remove

getChildren

public ALogicTree[] getChildren()
Description copied from class: ALogicTree
Returns the array of children of this. null is a valid return value.

Specified by:
getChildren in class ALogicTree
Returns:
an array of logic trees, null otherwise

getAndChild

public ALogicTree getAndChild()
Description copied from class: ALogicTree
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 ALogicTree getChildBut(ALogicTree child)
Description copied from class: ALogicTree
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

toString

public String toString()
Overrides:
toString in class Object

compareTo

public int compareTo(Literal o)
Specified by:
compareTo in interface Comparable<Literal>

clone

public Literal clone()
              throws CloneNotSupportedException
Overrides:
clone in class ALogicTree
Throws:
CloneNotSupportedException

flattenBoolVar

public IntegerVariable[] flattenBoolVar()
Description copied from class: ALogicTree
Extracts and returns the flatten array of BoolVar contained in this. WARNING : a variable may appear more than once, redundancy is not checked!

Specified by:
flattenBoolVar in class ALogicTree
Returns:
array of bool variables

getNbPositiveLiterals

public int getNbPositiveLiterals()
Description copied from class: ALogicTree
Computes and returns the number of positive literals contained in the direct level.

Specified by:
getNbPositiveLiterals in class ALogicTree
Returns:
number of positive literals


Copyright © 2012. All Rights Reserved.