/** @return */ public String validate() { logger.debug( "Max value validation found on field (" + logPrefix + ",annotation=" + annotation + ")."); if (value instanceof Number && new NumberComparator().compare(value, annotation.value()) > 0) { logger.debug("Max value exceeded for field (object=" + logPrefix + ",value=" + value + ")"); return annotation.message(); } return null; }
private static void getMaxVal(Node root, Max max, int curr) { if (root == null) return; curr += root.val; if (root.left == null && root.right == null) { if (curr > max.max_sum) { max.max_sum = curr; max.max_node = root; } } getMaxVal(root.left, max, curr); getMaxVal(root.right, max, curr); }
@Override public void meet(Max node) throws RuntimeException { builder.append("MAX("); optypes.push(ValueType.DOUBLE); node.getArg().visit(this); optypes.pop(); builder.append(")"); }
/** Main method */ public static void main(String[] args) { // Create two comparable circles ComparableCircle circle1 = new ComparableCircle(5); ComparableCircle circle2 = new ComparableCircle(4); // Display the max circle Object circle = Max.max(circle1, circle2); System.out.println("The max circle's radius is " + ((Circle) circle).getRadius()); System.out.println(circle); }
@Test public void testGetOutputNegative() { double[] inputs = new double[] {-0.1d, -0.21d, -0.8d, -0.9d}; for (int i = 0; i < inputNeurons.size(); i++) { inputNeurons.get(i).setInput(inputs[i]); inputNeurons.get(i).calculate(); } double actualOutput = instance.getOutput(inputConnections); assertEquals(-0.1d, actualOutput, 0.000001d); }
@Test public void testNoInputs() { double actualOutput = instance.getOutput(new ArrayList<Connection>()); assertEquals(0d, actualOutput, 0.000001d); }