From 83ee6fc8f03faa819a859919554a9d87963ab755 Mon Sep 17 00:00:00 2001 From: "ubjinn@gmail.com" Date: Tue, 30 Oct 2018 23:18:24 +1100 Subject: [PATCH 01/11] Default complexities set to 1 --- .../iconic/ea/operator/primitive/AbsoluteValue.java | 2 +- .../org/iconic/ea/operator/primitive/Addition.java | 2 +- .../java/org/iconic/ea/operator/primitive/And.java | 2 +- .../java/org/iconic/ea/operator/primitive/ArcCos.java | 2 +- .../java/org/iconic/ea/operator/primitive/ArcSin.java | 2 +- .../java/org/iconic/ea/operator/primitive/ArcTan.java | 2 +- .../ea/operator/primitive/ArithmeticPrimitive.java | 4 ++++ .../java/org/iconic/ea/operator/primitive/Ceiling.java | 2 +- .../org/iconic/ea/operator/primitive/Constant.java | 10 +++++----- .../java/org/iconic/ea/operator/primitive/Cos.java | 2 +- .../org/iconic/ea/operator/primitive/Division.java | 2 +- .../java/org/iconic/ea/operator/primitive/EqualTo.java | 2 +- .../org/iconic/ea/operator/primitive/Exponential.java | 2 +- .../java/org/iconic/ea/operator/primitive/Floor.java | 2 +- .../ea/operator/primitive/FunctionalPrimitive.java | 9 +++++++++ .../iconic/ea/operator/primitive/GaussianFunction.java | 2 +- .../org/iconic/ea/operator/primitive/GreaterThan.java | 2 +- .../ea/operator/primitive/GreaterThanOrEqual.java | 2 +- .../org/iconic/ea/operator/primitive/IfThenElse.java | 2 +- .../org/iconic/ea/operator/primitive/LessThan.java | 2 +- .../iconic/ea/operator/primitive/LessThanOrEqual.java | 2 +- .../iconic/ea/operator/primitive/LogisticFunction.java | 2 +- .../java/org/iconic/ea/operator/primitive/Maximum.java | 2 +- .../java/org/iconic/ea/operator/primitive/Minimum.java | 2 +- .../java/org/iconic/ea/operator/primitive/Modulo.java | 2 +- .../iconic/ea/operator/primitive/Multiplication.java | 2 +- .../org/iconic/ea/operator/primitive/NaturalLog.java | 2 +- .../org/iconic/ea/operator/primitive/Negation.java | 2 +- .../java/org/iconic/ea/operator/primitive/Not.java | 2 +- .../main/java/org/iconic/ea/operator/primitive/Or.java | 2 +- .../java/org/iconic/ea/operator/primitive/Power.java | 2 +- .../java/org/iconic/ea/operator/primitive/Root.java | 2 +- .../org/iconic/ea/operator/primitive/SignFunction.java | 2 +- .../java/org/iconic/ea/operator/primitive/Sin.java | 2 +- .../org/iconic/ea/operator/primitive/SquareRoot.java | 2 +- .../org/iconic/ea/operator/primitive/StepFunction.java | 2 +- .../org/iconic/ea/operator/primitive/Subtraction.java | 2 +- .../java/org/iconic/ea/operator/primitive/Tan.java | 2 +- .../java/org/iconic/ea/operator/primitive/Tanh.java | 2 +- .../org/iconic/ea/operator/primitive/TwoArcTan.java | 2 +- .../java/org/iconic/ea/operator/primitive/Xor.java | 2 +- 41 files changed, 56 insertions(+), 43 deletions(-) diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/AbsoluteValue.java b/api/src/main/java/org/iconic/ea/operator/primitive/AbsoluteValue.java index 64945fb..a04efbc 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/AbsoluteValue.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/AbsoluteValue.java @@ -19,7 +19,7 @@ public class AbsoluteValue extends ArithmeticPrimitive { public AbsoluteValue() { super( args -> Math.abs(args.get(0)), - 1, "ABS", "Returns the positive value of a.", 4 + 1, "ABS", "Returns the positive value of a." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/Addition.java b/api/src/main/java/org/iconic/ea/operator/primitive/Addition.java index 875de90..9ab844d 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/Addition.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/Addition.java @@ -19,7 +19,7 @@ public class Addition extends ArithmeticPrimitive { public Addition() { super( args -> args.stream().mapToDouble(Number::doubleValue).sum(), - 2, "ADD", "Returns a + b.", 1 + 2, "ADD", "Returns a + b." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/And.java b/api/src/main/java/org/iconic/ea/operator/primitive/And.java index af6a0f9..b0901b9 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/And.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/And.java @@ -19,7 +19,7 @@ public class And extends ArithmeticPrimitive { public And() { super( args -> (args.get(0) > 0 && args.get(1) > 0) ? 1.d : 0.d, - 2, "AND", "Returns 1 if both a and b are greater than 0, 0 otherwise.", 4 + 2, "AND", "Returns 1 if both a and b are greater than 0, 0 otherwise." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/ArcCos.java b/api/src/main/java/org/iconic/ea/operator/primitive/ArcCos.java index 52d1c7d..e07bb13 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/ArcCos.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/ArcCos.java @@ -19,7 +19,7 @@ public class ArcCos extends ArithmeticPrimitive { public ArcCos() { super( args -> Math.acos(args.get(0)), - 1, "ACOS", "Returns the inverse cosine function of a.", 4 + 1, "ACOS", "Returns the inverse cosine function of a." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/ArcSin.java b/api/src/main/java/org/iconic/ea/operator/primitive/ArcSin.java index 966619b..002c3cd 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/ArcSin.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/ArcSin.java @@ -19,7 +19,7 @@ public class ArcSin extends ArithmeticPrimitive { public ArcSin() { super( args -> Math.asin(args.get(0)), - 1, "ASIN", "Returns the inverse sine function of a.", 4 + 1, "ASIN", "Returns the inverse sine function of a." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/ArcTan.java b/api/src/main/java/org/iconic/ea/operator/primitive/ArcTan.java index f64fd3c..ada76c7 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/ArcTan.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/ArcTan.java @@ -19,7 +19,7 @@ public class ArcTan extends ArithmeticPrimitive { public ArcTan() { super( args -> Math.atan(args.get(0)), - 1, "ATAN", "Returns the inverse single argument tangent function of a.", 4 + 1, "ATAN", "Returns the inverse single argument tangent function of a." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/ArithmeticPrimitive.java b/api/src/main/java/org/iconic/ea/operator/primitive/ArithmeticPrimitive.java index 6f9d980..d558181 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/ArithmeticPrimitive.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/ArithmeticPrimitive.java @@ -22,4 +22,8 @@ public class ArithmeticPrimitive extends FunctionalPrimitive, Double> lambda, final int arity, final String symbol, final String description, final Integer defaultComplexity) { super(lambda, arity, symbol, description, defaultComplexity); } + + public ArithmeticPrimitive(final Function, Double> lambda, final int arity, final String symbol, final String description) { + super(lambda, arity, symbol, description); + } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/Ceiling.java b/api/src/main/java/org/iconic/ea/operator/primitive/Ceiling.java index b6a29b8..99f59d3 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/Ceiling.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/Ceiling.java @@ -19,7 +19,7 @@ public class Ceiling extends ArithmeticPrimitive { public Ceiling() { super( args -> Math.ceil(args.get(0)), - 1, "CEIL", "Returns the integer of a rounded up.", 4 + 1, "CEIL", "Returns the integer of a rounded up." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/Constant.java b/api/src/main/java/org/iconic/ea/operator/primitive/Constant.java index 06f0bfb..749da56 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/Constant.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/Constant.java @@ -1,12 +1,12 @@ /** * Copyright 2018 Iconic - * + *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,6 +17,6 @@ public class Constant extends FunctionalPrimitive { public Constant(final T value) { - super(args -> value, 0, value.toString(), "A constant value.", 1); + super(args -> value, 0, value.toString(), "A constant value."); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/Cos.java b/api/src/main/java/org/iconic/ea/operator/primitive/Cos.java index 9bbc04c..63646c4 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/Cos.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/Cos.java @@ -19,7 +19,7 @@ public class Cos extends ArithmeticPrimitive { public Cos() { super( args -> Math.cos(args.get(0)), - 1, "COS", "Returns the cosine of a.", 3 + 1, "COS", "Returns the cosine of a." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/Division.java b/api/src/main/java/org/iconic/ea/operator/primitive/Division.java index 167c4ea..d7de19f 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/Division.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/Division.java @@ -32,7 +32,7 @@ public Division() { return identity; }, - 2, "DIV", "Returns the division of a / b.", 2 + 2, "DIV", "Returns the division of a / b." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/EqualTo.java b/api/src/main/java/org/iconic/ea/operator/primitive/EqualTo.java index ce8bbba..e8af73c 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/EqualTo.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/EqualTo.java @@ -19,7 +19,7 @@ public class EqualTo extends ArithmeticPrimitive { public EqualTo() { super( args -> args.get(0).equals(args.get(1)) ? 1.d : 0.d, - 2, "EQUAL", "Returns 1 if a is equal to b, 0 otherwise.", 4 + 2, "EQUAL", "Returns 1 if a is equal to b, 0 otherwise." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/Exponential.java b/api/src/main/java/org/iconic/ea/operator/primitive/Exponential.java index 11fb89b..e600a81 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/Exponential.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/Exponential.java @@ -19,7 +19,7 @@ public class Exponential extends ArithmeticPrimitive { public Exponential() { super( args -> Math.exp(args.get(0)), - 1, "EXP", "Returns e^a.", 4 + 1, "EXP", "Returns e^a." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/Floor.java b/api/src/main/java/org/iconic/ea/operator/primitive/Floor.java index 1cfd96b..0e8cae7 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/Floor.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/Floor.java @@ -19,7 +19,7 @@ public class Floor extends ArithmeticPrimitive { public Floor() { super( args -> Math.floor(args.get(0)), - 1, "FLOOR", "Returns the integer of a rounded down.", 4 + 1, "FLOOR", "Returns the integer of a rounded down." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/FunctionalPrimitive.java b/api/src/main/java/org/iconic/ea/operator/primitive/FunctionalPrimitive.java index 6b6d9ed..0603fd0 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/FunctionalPrimitive.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/FunctionalPrimitive.java @@ -43,6 +43,15 @@ public FunctionalPrimitive(Function, R> lambda, int arity, String symbol this.complexity = new SimpleIntegerProperty(defaultComplexity); } + public FunctionalPrimitive(Function, R> lambda, int arity, String symbol, String description) { + this.lambda = lambda; + this.arity = arity; + this.symbol = symbol; + this.description = description; + this.defaultComplexity = 1; + this.complexity = new SimpleIntegerProperty(this.defaultComplexity); + } + @Override public R apply(List args) { assert (args.size() >= getArity()); diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/GaussianFunction.java b/api/src/main/java/org/iconic/ea/operator/primitive/GaussianFunction.java index 72a1e8b..98fe5a2 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/GaussianFunction.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/GaussianFunction.java @@ -21,7 +21,7 @@ public class GaussianFunction extends ArithmeticPrimitive { public GaussianFunction() { super( args -> Math.exp(-Math.pow(args.get(0),2)), - 1, "GAUSS", "Returns exp(-x^2), providing a normal distribution.", 4 + 1, "GAUSS", "Returns exp(-x^2), providing a normal distribution." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/GreaterThan.java b/api/src/main/java/org/iconic/ea/operator/primitive/GreaterThan.java index 001ec38..a128977 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/GreaterThan.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/GreaterThan.java @@ -19,7 +19,7 @@ public class GreaterThan extends ArithmeticPrimitive { public GreaterThan() { super( args -> args.get(0) > args.get(1) ? 1.d : 0.d, - 2, "GREATER", "Returns 1 if a > b, 0 otherwise.", 4 + 2, "GREATER", "Returns 1 if a > b, 0 otherwise." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/GreaterThanOrEqual.java b/api/src/main/java/org/iconic/ea/operator/primitive/GreaterThanOrEqual.java index 990cc55..6c55d93 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/GreaterThanOrEqual.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/GreaterThanOrEqual.java @@ -19,7 +19,7 @@ public class GreaterThanOrEqual extends ArithmeticPrimitive { public GreaterThanOrEqual() { super( args -> args.get(0) >= args.get(1) ? 1.d : 0.d, - 2, "GREATER_EQUAL", "Returns 1 if a >= b, 0 otherwise.", 4 + 2, "GREATER_EQUAL", "Returns 1 if a >= b, 0 otherwise." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/IfThenElse.java b/api/src/main/java/org/iconic/ea/operator/primitive/IfThenElse.java index 7b58cac..aaff365 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/IfThenElse.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/IfThenElse.java @@ -19,7 +19,7 @@ public class IfThenElse extends ArithmeticPrimitive { public IfThenElse() { super( args -> args.get(0) > 0 ? args.get(1) : args.get(2), - 3, "IF", "Returns returns b if a > 0, c otherwise.", 5 + 3, "IF", "Returns returns b if a > 0, c otherwise." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/LessThan.java b/api/src/main/java/org/iconic/ea/operator/primitive/LessThan.java index 4ccf148..051608d 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/LessThan.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/LessThan.java @@ -19,7 +19,7 @@ public class LessThan extends ArithmeticPrimitive { public LessThan() { super( args -> args.get(0) < args.get(1) ? 1.d : 0.d, - 2, "LESS", "Returns 1 if a < b, 0 otherwise.", 4 + 2, "LESS", "Returns 1 if a < b, 0 otherwise." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/LessThanOrEqual.java b/api/src/main/java/org/iconic/ea/operator/primitive/LessThanOrEqual.java index 320749f..67c2211 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/LessThanOrEqual.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/LessThanOrEqual.java @@ -19,7 +19,7 @@ public class LessThanOrEqual extends ArithmeticPrimitive { public LessThanOrEqual() { super( args -> args.get(0) <= args.get(1) ? 1.d : 0.d, - 2, "LESSEQUAL", "Returns 1 if a <= b, 0 otherwise.", 4 + 2, "LESSEQUAL", "Returns 1 if a <= b, 0 otherwise." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/LogisticFunction.java b/api/src/main/java/org/iconic/ea/operator/primitive/LogisticFunction.java index de81b1a..232fe8b 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/LogisticFunction.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/LogisticFunction.java @@ -21,7 +21,7 @@ public class LogisticFunction extends ArithmeticPrimitive { public LogisticFunction() { super( args -> 1/(1+Math.exp(args.get(0))), - 1, "LOGISTIC", "Returns (1 / 1 + exp(-a)).\nThis is a common sigmoid squashing function.", 4 + 1, "LOGISTIC", "Returns (1 / 1 + exp(-a)).\nThis is a common sigmoid squashing function." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/Maximum.java b/api/src/main/java/org/iconic/ea/operator/primitive/Maximum.java index 68d9642..8086641 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/Maximum.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/Maximum.java @@ -19,7 +19,7 @@ public class Maximum extends ArithmeticPrimitive { public Maximum() { super( args -> Math.max(args.get(0),args.get(1)), - 2, "MAX", "Returns the maximum value of a and b.", 4 + 2, "MAX", "Returns the maximum value of a and b." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/Minimum.java b/api/src/main/java/org/iconic/ea/operator/primitive/Minimum.java index f72a95f..f505a76 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/Minimum.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/Minimum.java @@ -19,7 +19,7 @@ public class Minimum extends ArithmeticPrimitive { public Minimum() { super( args -> Math.min(args.get(0),args.get(1)), - 2, "MIN", "Returns the minimum value of a and b.", 4 + 2, "MIN", "Returns the minimum value of a and b." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/Modulo.java b/api/src/main/java/org/iconic/ea/operator/primitive/Modulo.java index adcc9f9..3dd032e 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/Modulo.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/Modulo.java @@ -19,7 +19,7 @@ public class Modulo extends ArithmeticPrimitive { public Modulo() { super( args -> args.get(0) % args.get(1), - 2, "MOD", "Returns the remainder of a / b.", 4 + 2, "MOD", "Returns the remainder of a / b." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/Multiplication.java b/api/src/main/java/org/iconic/ea/operator/primitive/Multiplication.java index 13a9105..7e2e106 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/Multiplication.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/Multiplication.java @@ -19,7 +19,7 @@ public class Multiplication extends ArithmeticPrimitive { public Multiplication() { super( args -> args.stream().reduce(1.d, (a, b) -> a * b), - 2, "MUL", "Returns a * b.", 1 + 2, "MUL", "Returns a * b." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/NaturalLog.java b/api/src/main/java/org/iconic/ea/operator/primitive/NaturalLog.java index 0563618..8254ffa 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/NaturalLog.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/NaturalLog.java @@ -19,7 +19,7 @@ public class NaturalLog extends ArithmeticPrimitive { public NaturalLog() { super( args -> Math.log(args.get(0)), - 1, "LN", "Returns the natural logarithm (base e) of a.", 4 + 1, "LN", "Returns the natural logarithm (base e) of a." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/Negation.java b/api/src/main/java/org/iconic/ea/operator/primitive/Negation.java index ec79e00..ad88114 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/Negation.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/Negation.java @@ -19,7 +19,7 @@ public class Negation extends ArithmeticPrimitive { public Negation() { super( args -> -args.get(0), - 1, "NEG", "Returns - a.", 1 + 1, "NEG", "Returns - a." ); diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/Not.java b/api/src/main/java/org/iconic/ea/operator/primitive/Not.java index 8da2d00..cd53e3d 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/Not.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/Not.java @@ -19,7 +19,7 @@ public class Not extends ArithmeticPrimitive { public Not() { super( args -> (args.get(0) > 0) ? 0.d : 1.d, - 1, "NOT", "Returns 0 if a is greater than 0, 1 otherwise.", 4 + 1, "NOT", "Returns 0 if a is greater than 0, 1 otherwise." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/Or.java b/api/src/main/java/org/iconic/ea/operator/primitive/Or.java index f680c77..2a7d2c7 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/Or.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/Or.java @@ -19,7 +19,7 @@ public class Or extends ArithmeticPrimitive { public Or() { super( args -> (args.get(0) > 0 || args.get(1) > 0) ? 1.d : 0.d, - 2, "OR", "Returns 1 if either a or b are greater than 0, 0 otherwise.", 4 + 2, "OR", "Returns 1 if either a or b are greater than 0, 0 otherwise." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/Power.java b/api/src/main/java/org/iconic/ea/operator/primitive/Power.java index 0fb8217..8afb72d 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/Power.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/Power.java @@ -19,7 +19,7 @@ public class Power extends ArithmeticPrimitive { public Power() { super( args -> Math.pow(args.get(0), args.get(1)), - 2, "POW", "Returns a^b.", 5 + 2, "POW", "Returns a^b." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/Root.java b/api/src/main/java/org/iconic/ea/operator/primitive/Root.java index b8bc1b9..e9432f4 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/Root.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/Root.java @@ -31,7 +31,7 @@ public Root() { } return Double.NaN; }, - 2, "ROOT", "Returns the b-th root of a if a is greater than 0, NaN otherwise.", 5 + 2, "ROOT", "Returns the b-th root of a if a is greater than 0, NaN otherwise." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/SignFunction.java b/api/src/main/java/org/iconic/ea/operator/primitive/SignFunction.java index e80a0d9..111ce3f 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/SignFunction.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/SignFunction.java @@ -21,7 +21,7 @@ public class SignFunction extends ArithmeticPrimitive { public SignFunction() { super( args -> Math.signum(args.get(0)), - 1, "SGN", "Returns -1 if a is negative, 1 if a is positive, 0 otherwise.", 4 + 1, "SGN", "Returns -1 if a is negative, 1 if a is positive, 0 otherwise." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/Sin.java b/api/src/main/java/org/iconic/ea/operator/primitive/Sin.java index 20c9cfd..06f921a 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/Sin.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/Sin.java @@ -19,7 +19,7 @@ public class Sin extends ArithmeticPrimitive { public Sin() { super( args -> Math.sin(args.get(0)), - 1, "SIN","Returns the sine of a.", 3 + 1, "SIN","Returns the sine of a." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/SquareRoot.java b/api/src/main/java/org/iconic/ea/operator/primitive/SquareRoot.java index 0dded20..3219a9a 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/SquareRoot.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/SquareRoot.java @@ -19,7 +19,7 @@ public class SquareRoot extends ArithmeticPrimitive { public SquareRoot() { super( args -> Math.sqrt(args.get(0)), - 1, "SQRT","Returns the square root of a.", 4 + 1, "SQRT","Returns the square root of a." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/StepFunction.java b/api/src/main/java/org/iconic/ea/operator/primitive/StepFunction.java index d7e914b..653d19e 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/StepFunction.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/StepFunction.java @@ -20,7 +20,7 @@ public class StepFunction extends ArithmeticPrimitive { public StepFunction() { super( args -> args.get(0) > 0 ? 1.d : 0.d, - 1, "STEP","Returns 1 if x is positive, 0 otherwise.", 4 + 1, "STEP","Returns 1 if x is positive, 0 otherwise." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/Subtraction.java b/api/src/main/java/org/iconic/ea/operator/primitive/Subtraction.java index d131791..7a79523 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/Subtraction.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/Subtraction.java @@ -27,7 +27,7 @@ public Subtraction() { return identity; }, - 2, "SUB", "Returns a - b.", 1 + 2, "SUB", "Returns a - b." ); diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/Tan.java b/api/src/main/java/org/iconic/ea/operator/primitive/Tan.java index 2cab2e2..baf74ce 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/Tan.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/Tan.java @@ -19,7 +19,7 @@ public class Tan extends ArithmeticPrimitive { public Tan() { super( args -> Math.tan(args.get(0)), - 1, "TAN","Returns the tangent of a.", 4 + 1, "TAN","Returns the tangent of a." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/Tanh.java b/api/src/main/java/org/iconic/ea/operator/primitive/Tanh.java index e747b3c..36ad5ac 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/Tanh.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/Tanh.java @@ -21,7 +21,7 @@ public class Tanh extends ArithmeticPrimitive { public Tanh() { super( args -> Math.tanh(args.get(0)), - 1, "TANH","Returns the hyperbolic tangent of a.\nThis is a common squashing function returning a value between -1 and 1.", 4 + 1, "TANH","Returns the hyperbolic tangent of a.\nThis is a common squashing function returning a value between -1 and 1." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/TwoArcTan.java b/api/src/main/java/org/iconic/ea/operator/primitive/TwoArcTan.java index 2ce3e37..eff5598 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/TwoArcTan.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/TwoArcTan.java @@ -19,7 +19,7 @@ public class TwoArcTan extends ArithmeticPrimitive { public TwoArcTan() { super( args -> Math.atan2(args.get(0),args.get(1)), - 2, "ATAN2","Returns the two argument inverse tangent function.", 4 + 2, "ATAN2","Returns the two argument inverse tangent function." ); } } diff --git a/api/src/main/java/org/iconic/ea/operator/primitive/Xor.java b/api/src/main/java/org/iconic/ea/operator/primitive/Xor.java index 87550e7..d4e6601 100644 --- a/api/src/main/java/org/iconic/ea/operator/primitive/Xor.java +++ b/api/src/main/java/org/iconic/ea/operator/primitive/Xor.java @@ -19,7 +19,7 @@ public class Xor extends ArithmeticPrimitive { public Xor() { super( args -> (args.get(0) > 0 ^ args.get(1) > 0) ? 1.d : 0.d, - 2, "XOR","Returns 1 if (a <= 0 and b > 0) or (a > 0 and b <= 0), 0 otherwise.", 4 + 2, "XOR","Returns 1 if (a <= 0 and b > 0) or (a > 0 and b <= 0), 0 otherwise." ); } } From 7482b05fc286cc2129fc2b1b2f43dd70c5c4060d Mon Sep 17 00:00:00 2001 From: "ubjinn@gmail.com" Date: Wed, 31 Oct 2018 04:49:38 +1100 Subject: [PATCH 02/11] Enable/Disable all primitive button. Added check to start search for atleast 1 primitive, however there is still funky stuff going on. The program will crash after the alert (Previously it would just crash, we weren't checking at all) If you select which dataset you wish to use, while having no primitives enabled it will crash. --- .../definition/DefineSearchController.java | 24 +++++++++++++++---- .../project/search/StartSearchController.java | 9 +++++++ .../views/workspace/DefineSearchView.fxml | 5 +++- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/client/src/main/java/org/iconic/project/definition/DefineSearchController.java b/client/src/main/java/org/iconic/project/definition/DefineSearchController.java index 28859bf..7eb411b 100644 --- a/client/src/main/java/org/iconic/project/definition/DefineSearchController.java +++ b/client/src/main/java/org/iconic/project/definition/DefineSearchController.java @@ -1,12 +1,12 @@ /** * Copyright 2018 Iconic - * + *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,6 +24,8 @@ import javafx.beans.value.ObservableValue; import javafx.collections.FXCollections; import javafx.collections.ObservableList; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; import javafx.fxml.Initializable; import javafx.fxml.FXML; import javafx.scene.Node; @@ -76,6 +78,9 @@ public class DefineSearchController implements Initializable, DefineSearchServic @FXML public TableView, SimpleBooleanProperty>> blockDisplayTableView; + @FXML + public Button enableAll; + @FXML public TextArea selectedBlockDisplayDescription; @@ -129,6 +134,15 @@ public void initialize(URL location, ResourceBundle resources) { blockDisplayTableView.getColumns().addAll(enabledCol, nameCol, complexityCol); + enableAll.setOnAction(event -> { + boolean setBoolean = enableAll.getText().compareTo("Enable All") == 0; + for (Map.Entry, SimpleBooleanProperty> item : + blockDisplayTableView.getItems()) { + item.getValue().set(setBoolean); + } + enableAll.setText(setBoolean?"Disable All":"Enable All"); + }); + // Listener for the description pane blockDisplayTableView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> { if (newValue != null) { @@ -367,7 +381,7 @@ public void changed(ObservableValue observable, Boolean oldVa String functionDefinition = tfTargetExpression.getText(); - if(dataset.isPresent()) { + if (dataset.isPresent()) { setFunction(); dataset.get().defineFunction(functionDefinition); } diff --git a/client/src/main/java/org/iconic/project/search/StartSearchController.java b/client/src/main/java/org/iconic/project/search/StartSearchController.java index 6272150..828a775 100644 --- a/client/src/main/java/org/iconic/project/search/StartSearchController.java +++ b/client/src/main/java/org/iconic/project/search/StartSearchController.java @@ -294,6 +294,15 @@ private void validateConfiguration(SearchConfigurationModel search) { return; } + if(search.getEnabledPrimitives().size() < 1){ + Alert alert = new Alert(Alert.AlertType.INFORMATION); + alert.setTitle("Search Invalid"); + alert.setHeaderText("Missing Primitives"); + alert.setContentText("The Defined Search has no enabled primitives to use! Please visit the 'Define Search' tab and enable at least one primitive."); + alert.showAndWait(); + return; + } + // Get the dataset Model - Check that the dataset doesn't have any missing values if (search.getDatasetModel().isPresent()) { DatasetModel datasetModel = search.getDatasetModel().get(); diff --git a/client/src/main/resources/views/workspace/DefineSearchView.fxml b/client/src/main/resources/views/workspace/DefineSearchView.fxml index 000abe2..2c1e4cd 100644 --- a/client/src/main/resources/views/workspace/DefineSearchView.fxml +++ b/client/src/main/resources/views/workspace/DefineSearchView.fxml @@ -81,7 +81,10 @@ -