Package io.jenetics.prog.op
Enum BoolOp
- java.lang.Object
-
- java.lang.Enum<BoolOp>
-
- io.jenetics.prog.op.BoolOp
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Boolean
apply(Boolean[] args)
int
arity()
Return the arity of the operation function.boolean
eval(boolean... args)
Evaluates the operation with the given arguments.static Op<Boolean>
toBoolOp(String string)
Converts the string representation of an operation to the operation object.String
toString()
static BoolOp
valueOf(String name)
Returns the enum constant of this type with the specified name.static BoolOp[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.-
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOf
-
Methods inherited from interface io.jenetics.prog.op.Op
get, isTerminal, name
-
-
-
-
Method Detail
-
values
public static BoolOp[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (BoolOp c : BoolOp.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static BoolOp valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
arity
public int arity()
Description copied from interface:Op
Return the arity of the operation function. If the arity is zero, the operation is terminal operation.
-
eval
public boolean eval(boolean... args)
Evaluates the operation with the given arguments.- Parameters:
args
- the operation arguments- Returns:
- the evaluated operation
- See Also:
apply(Boolean[])
-
toBoolOp
public static Op<Boolean> toBoolOp(String string)
Converts the string representation of an operation to the operation object. It is used for converting the string representation of a tree to an operation tree. If you use it that way, you should not forget to re-index the tree variables.final TreeNode<Op<Boolean>> tree = TreeNode.parse( "and(or(x,y),not(y))", BoolOp::toBoolOp ); assert Program.eval(tree, false, false) == false; Var.reindex(tree); assert Program.eval(tree, false, false) == true;
- Parameters:
string
- the string representation of an operation which should be converted- Returns:
- the operation, converted from the given string
- Throws:
IllegalArgumentException
- if the givenvalue
doesn't represent a mathematical expressionNullPointerException
- if the given stringvalue
isnull
- Since:
- 5.0
- See Also:
Var.reindex(TreeNode)
,Program.eval(Tree, Object[])
-
-