- java.lang.Object
-
- org.chocosolver.solver.constraints.nary.cnf.LogOp
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LogOp.Operator
static class
LogOp.Type
-
Field Summary
Fields Modifier and Type Field Description protected ILogical[]
children
protected LogOp.Operator
operator
protected LogOp.Type
type
protected BoolVar[]
varsAsArray
-
Constructor Summary
Constructors Modifier Constructor Description protected
LogOp(LogOp.Operator operator, LogOp.Type type, ILogical... children)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChild(ILogical child)
Addschild
to the current list of children ofthis
static LogOp
and(ILogical... op)
Create a conjunction, results in true if all of its operands are truevoid
cleanFlattenBoolVar()
LogOp
clone()
void
deny()
Flip the boolean operator ofthis
(recursive).BoolVar[]
flattenBoolVar()
Extracts and returns the flatten array of BoolVar contained inthis
.void
flip()
Flip the boolean evaluation ofthis
(recursive).ILogical
getAndChild()
Returns the first AND logic tree within the list of children.ILogical
getChildBut(ILogical child)
Returns the first child within the list of children, different fromchild
.ILogical[]
getChildren()
Returns the array of children ofthis
.protected int
getNbChildren()
Returns the number of direct children ofthis
protected boolean
hasAndChild()
Checks if at least one children is an AND logic treeprotected boolean
hasOrChild()
Check if at least one children is an OR logic treestatic LogOp
ifOnlyIf(ILogical a, ILogical b)
Create a biconditional, results in true if and only if both operands are false or both operands are truestatic 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.static LogOp
implies(ILogical a, ILogical b)
Create an implication, results in true if a is false or b is true.boolean
is(LogOp.Operator op)
Current tree is rooted with the logical operatorop
boolean
isLit()
Current tree is a literalboolean
isNot()
Current tree is rooted with NOT logical operatorstatic LogOp
nand(ILogical... op)
Create an alternative denial, results in if at least one of its operands is false.static LogOp
nor(ILogical... op)
Create a joint denial, results in `true` if all of its operands are false.static LogOp
or(ILogical... op)
Create a disjunction, results in true whenever one or more of its operands are truestatic LogOp
reified(BoolVar b, ILogical tree)
create a logical connection between ``b`` and ``tree``.void
removeChild(ILogical child)
Removeschild
from the current list of children ofthis
void
setNot(boolean isNot)
States whether or not this variable is the negation of another.String
toString()
static LogOp
xor(ILogical a, ILogical b)
Create an exclusive disjunction, results in true whenever both operands differ.
-
-
-
Field Detail
-
type
protected LogOp.Type type
-
operator
protected LogOp.Operator operator
-
children
protected ILogical[] children
-
varsAsArray
protected BoolVar[] varsAsArray
-
-
Constructor Detail
-
LogOp
protected LogOp(LogOp.Operator operator, LogOp.Type type, ILogical... children)
-
-
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
- operandb
- 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
- operandb
- operandc
- 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
- operandb
- 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
- operandtree
- 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
- operandb
- operand- Returns:
- a new logical operator
-
is
public boolean is(LogOp.Operator op)
Current tree is rooted with the logical operatorop
- Parameters:
op
- operator checked- Returns:
true
ifthis
isop
-
isNot
public boolean isNot()
Current tree is rooted with NOT logical operator
-
isLit
public boolean isLit()
Description copied from interface:ILogical
Current tree 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)...)
-
getNbChildren
protected int getNbChildren()
Returns the number of direct children ofthis
- Returns:
- number of children
-
hasOrChild
protected boolean hasOrChild()
Check if at least one children is an OR logic tree- Returns:
true
ifthis
contains one OR logic tree
-
hasAndChild
protected boolean hasAndChild()
Checks if at least one children is an AND logic tree- Returns:
true
ifthis
contains one AND logic tree
-
addChild
public void addChild(ILogical child)
Addschild
to the current list of children ofthis
- Parameters:
child
- the logic tree to add
-
removeChild
public void removeChild(ILogical child)
Removeschild
from the current list of children ofthis
- Parameters:
child
- the logic tree to remove
-
getChildren
public ILogical[] getChildren()
Returns the array of children ofthis
.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 fromchild
.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 ofthis
(recursive).
-
deny
public void deny()
Flip the boolean operator ofthis
(recursive).
-
clone
public LogOp clone() throws CloneNotSupportedException
- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
-
flattenBoolVar
public BoolVar[] flattenBoolVar()
Extracts and returns the flatten array of BoolVar contained inthis
. WARNING : a variable may appear more than once, redundancy is not checked!- Returns:
- array of bool variables
-
cleanFlattenBoolVar
public void cleanFlattenBoolVar()
-
-