Class LogOp
- java.lang.Object
-
- org.chocosolver.solver.constraints.nary.cnf.LogOp
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLogOp.Operatorstatic classLogOp.Type
-
Field Summary
Fields Modifier and Type Field Description protected ILogical[]childrenprotected LogOp.Operatoroperatorprotected LogOp.Typetypeprotected BoolVar[]varsAsArray
-
Constructor Summary
Constructors Modifier Constructor Description protectedLogOp(LogOp.Operator operator, LogOp.Type type, ILogical... children)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChild(ILogical child)Addschildto the current list of children ofthisstatic LogOpand(ILogical... op)Create a conjunction, results in true if all of its operands are truevoidcleanFlattenBoolVar()LogOpclone()voiddeny()Flip the boolean operator ofthis(recursive).BoolVar[]flattenBoolVar()Extracts and returns the flatten array of BoolVar contained inthis.voidflip()Flip the boolean evaluation ofthis(recursive).ILogicalgetAndChild()Returns the first AND logic tree within the list of children.ILogicalgetChildBut(ILogical child)Returns the first child within the list of children, different fromchild.ILogical[]getChildren()Returns the array of children ofthis.protected intgetNbChildren()Returns the number of direct children ofthisprotected booleanhasAndChild()Checks if at least one children is an AND logic treeprotected booleanhasOrChild()Check if at least one children is an OR logic treestatic LogOpifOnlyIf(ILogical a, ILogical b)Create a biconditional, results in true if and only if both operands are false or both operands are truestatic LogOpifThenElse(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 LogOpimplies(ILogical a, ILogical b)Create an implication, results in true if a is false or b is true.booleanis(LogOp.Operator op)Current tree is rooted with the logical operatoropbooleanisLit()Current tree is a literalbooleanisNot()Current tree is rooted with NOT logical operatorstatic LogOpnand(ILogical... op)Create an alternative denial, results in if at least one of its operands is false.static LogOpnor(ILogical... op)Create a joint denial, results in `true` if all of its operands are false.static LogOpor(ILogical... op)Create a disjunction, results in true whenever one or more of its operands are truestatic LogOpreified(BoolVar b, ILogical tree)create a logical connection between ``b`` and ``tree``.voidremoveChild(ILogical child)Removeschildfrom the current list of children ofthisvoidsetNot(boolean isNot)States whether or not this variable is the negation of another.StringtoString()static LogOpxor(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:
trueifthisisop
-
isNot
public boolean isNot()
Current tree is rooted with NOT logical operator
-
isLit
public boolean isLit()
Description copied from interface:ILogicalCurrent tree is a literal
-
setNot
public void setNot(boolean isNot)
Description copied from interface:ILogicalStates 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:
trueifthiscontains one OR logic tree
-
hasAndChild
protected boolean hasAndChild()
Checks if at least one children is an AND logic tree- Returns:
trueifthiscontains one AND logic tree
-
addChild
public void addChild(ILogical child)
Addschildto the current list of children ofthis- Parameters:
child- the logic tree to add
-
removeChild
public void removeChild(ILogical child)
Removeschildfrom the current list of children ofthis- Parameters:
child- the logic tree to remove
-
getChildren
public ILogical[] getChildren()
Returns the array of children ofthis.nullis a valid return value.- Returns:
- an array of logic trees,
nullotherwise
-
getAndChild
public ILogical getAndChild()
Returns the first AND logic tree within the list of children.nullis a valid return value.- Returns:
- a AND logic tree if exists,
nullotherwise
-
getChildBut
public ILogical getChildBut(ILogical child)
Returns the first child within the list of children, different fromchild.nullis a valid return value.- Parameters:
child- node to avoid- Returns:
- the first logic tree different from
childif exists,nullotherwise
-
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:
clonein 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()
-
-