Author: erans
Date: Thu Nov 22 23:17:49 2012
New Revision: 1412713

URL: http://svn.apache.org/viewvc?rev=1412713&view=rev
Log:
MATH-902
Fixed Javadoc. Added unit tests.

Added:
    
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optimization/SimplePointCheckerTest.java
   (with props)
    
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optimization/SimpleValueCheckerTest.java
   (with props)
    
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optimization/SimpleVectorValueCheckerTest.java
   (with props)
Modified:
    
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/SimplePointChecker.java
    
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/SimpleValueChecker.java
    
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/SimpleVectorValueChecker.java

Modified: 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/SimplePointChecker.java
URL: 
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/SimplePointChecker.java?rev=1412713&r1=1412712&r2=1412713&view=diff
==============================================================================
--- 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/SimplePointChecker.java
 (original)
+++ 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/SimplePointChecker.java
 Thu Nov 22 23:17:49 2012
@@ -87,8 +87,7 @@ public class SimplePointChecker<PAIR ext
      *
      * @param relativeThreshold Relative tolerance threshold.
      * @param absoluteThreshold Absolute tolerance threshold.
-     * @param maxIter Maximum iteration count. Setting it to a negative
-     * value will disable this stopping criterion.
+     * @param maxIter Maximum iteration count.
      * @throws NotStrictlyPositiveException if {@code maxIter <= 0}.
      *
      * @since 3.1

Modified: 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/SimpleValueChecker.java
URL: 
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/SimpleValueChecker.java?rev=1412713&r1=1412712&r2=1412713&view=diff
==============================================================================
--- 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/SimpleValueChecker.java
 (original)
+++ 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/SimpleValueChecker.java
 Thu Nov 22 23:17:49 2012
@@ -85,8 +85,7 @@ public class SimpleValueChecker
      *
      * @param relativeThreshold relative tolerance threshold
      * @param absoluteThreshold absolute tolerance threshold
-     * @param maxIter Maximum iteration count. Setting it to a negative
-     * value will disable this stopping criterion.
+     * @param maxIter Maximum iteration count.
      * @throws NotStrictlyPositiveException if {@code maxIter <= 0}.
      *
      * @since 3.1

Modified: 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/SimpleVectorValueChecker.java
URL: 
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/SimpleVectorValueChecker.java?rev=1412713&r1=1412712&r2=1412713&view=diff
==============================================================================
--- 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/SimpleVectorValueChecker.java
 (original)
+++ 
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/SimpleVectorValueChecker.java
 Thu Nov 22 23:17:49 2012
@@ -87,8 +87,7 @@ public class SimpleVectorValueChecker
      *
      * @param relativeThreshold Relative tolerance threshold.
      * @param absoluteThreshold Absolute tolerance threshold.
-     * @param maxIter Maximum iteration count. Setting it to a negative
-     * value will disable this stopping criterion.
+     * @param maxIter Maximum iteration count.
      * @throws NotStrictlyPositiveException if {@code maxIter <= 0}.
      *
      * @since 3.1

Added: 
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optimization/SimplePointCheckerTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optimization/SimplePointCheckerTest.java?rev=1412713&view=auto
==============================================================================
--- 
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optimization/SimplePointCheckerTest.java
 (added)
+++ 
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optimization/SimplePointCheckerTest.java
 Thu Nov 22 23:17:49 2012
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math3.optimization;
+
+import org.apache.commons.math3.exception.NotStrictlyPositiveException;
+import org.junit.Test;
+import org.junit.Assert;
+
+public class SimplePointCheckerTest {
+    @Test(expected=NotStrictlyPositiveException.class)
+    public void testIterationCheckPrecondition() {
+        new SimplePointChecker<PointValuePair>(1e-1, 1e-2, 0);
+    }
+
+    @Test
+    public void testIterationCheck() {
+        final int max = 10;
+        final SimplePointChecker<PointValuePair> checker
+            = new SimplePointChecker<PointValuePair>(1e-1, 1e-2, max);
+        Assert.assertTrue(checker.converged(max, null, null)); 
+        Assert.assertTrue(checker.converged(max + 1, null, null));
+    }
+
+    @Test
+    public void testIterationCheckDisabled() {
+        final SimplePointChecker<PointValuePair> checker
+            = new SimplePointChecker<PointValuePair>(1e-8, 1e-8);
+
+        final PointValuePair a = new PointValuePair(new double[] { 1d }, 1d);
+        final PointValuePair b = new PointValuePair(new double[] { 10d }, 10d);
+
+        Assert.assertFalse(checker.converged(-1, a, b));
+        Assert.assertFalse(checker.converged(0, a, b));
+        Assert.assertFalse(checker.converged(1000000, a, b));
+
+        Assert.assertTrue(checker.converged(-1, a, a));
+        Assert.assertTrue(checker.converged(-1, b, b));
+    }
+
+}

Propchange: 
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optimization/SimplePointCheckerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optimization/SimpleValueCheckerTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optimization/SimpleValueCheckerTest.java?rev=1412713&view=auto
==============================================================================
--- 
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optimization/SimpleValueCheckerTest.java
 (added)
+++ 
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optimization/SimpleValueCheckerTest.java
 Thu Nov 22 23:17:49 2012
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math3.optimization;
+
+import org.apache.commons.math3.exception.NotStrictlyPositiveException;
+import org.junit.Test;
+import org.junit.Assert;
+
+public class SimpleValueCheckerTest {
+    @Test(expected=NotStrictlyPositiveException.class)
+    public void testIterationCheckPrecondition() {
+        new SimpleValueChecker(1e-1, 1e-2, 0);
+    }
+
+    @Test
+    public void testIterationCheck() {
+        final int max = 10;
+        final SimpleValueChecker checker = new SimpleValueChecker(1e-1, 1e-2, 
max);
+        Assert.assertTrue(checker.converged(max, null, null)); 
+        Assert.assertTrue(checker.converged(max + 1, null, null));
+    }
+
+    @Test
+    public void testIterationCheckDisabled() {
+        final SimpleValueChecker checker = new SimpleValueChecker(1e-8, 1e-8);
+
+        final PointValuePair a = new PointValuePair(new double[] { 1d }, 1d);
+        final PointValuePair b = new PointValuePair(new double[] { 10d }, 10d);
+
+        Assert.assertFalse(checker.converged(-1, a, b));
+        Assert.assertFalse(checker.converged(0, a, b));
+        Assert.assertFalse(checker.converged(1000000, a, b));
+
+        Assert.assertTrue(checker.converged(-1, a, a));
+        Assert.assertTrue(checker.converged(-1, b, b));
+    }
+
+}

Propchange: 
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optimization/SimpleValueCheckerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optimization/SimpleVectorValueCheckerTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optimization/SimpleVectorValueCheckerTest.java?rev=1412713&view=auto
==============================================================================
--- 
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optimization/SimpleVectorValueCheckerTest.java
 (added)
+++ 
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optimization/SimpleVectorValueCheckerTest.java
 Thu Nov 22 23:17:49 2012
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math3.optimization;
+
+import org.apache.commons.math3.exception.NotStrictlyPositiveException;
+import org.junit.Test;
+import org.junit.Assert;
+
+public class SimpleVectorValueCheckerTest {
+    @Test(expected=NotStrictlyPositiveException.class)
+    public void testIterationCheckPrecondition() {
+        new SimpleVectorValueChecker(1e-1, 1e-2, 0);
+    }
+
+    @Test
+    public void testIterationCheck() {
+        final int max = 10;
+        final SimpleVectorValueChecker checker = new 
SimpleVectorValueChecker(1e-1, 1e-2, max);
+        Assert.assertTrue(checker.converged(max, null, null));
+        Assert.assertTrue(checker.converged(max + 1, null, null));
+    }
+
+    @Test
+    public void testIterationCheckDisabled() {
+        final SimpleVectorValueChecker checker = new 
SimpleVectorValueChecker(1e-8, 1e-8);
+
+        final PointVectorValuePair a = new PointVectorValuePair(new double[] { 
1d },
+                                                                new double[] { 
1d });
+        final PointVectorValuePair b = new PointVectorValuePair(new double[] { 
10d },
+                                                                new double[] { 
10d });
+
+        Assert.assertFalse(checker.converged(-1, a, b));
+        Assert.assertFalse(checker.converged(0, a, b));
+        Assert.assertFalse(checker.converged(1000000, a, b));
+
+        Assert.assertTrue(checker.converged(-1, a, a));
+        Assert.assertTrue(checker.converged(-1, b, b));
+    }
+
+}

Propchange: 
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optimization/SimpleVectorValueCheckerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to