commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r754765 - in /commons/proper/math/trunk: ./ src/java/org/apache/commons/math/optimization/ src/java/org/apache/commons/math/optimization/direct/ src/java/org/apache/commons/math/optimization/general/ src/java/org/apache/commons/math/random/...
Date Sun, 15 Mar 2009 21:35:39 GMT
Author: luc
Date: Sun Mar 15 21:35:38 2009
New Revision: 754765

URL: http://svn.apache.org/viewvc?rev=754765&view=rev
Log:
fixed checkstyle and findbugs errors

Modified:
    commons/proper/math/trunk/findbugs-exclude-filter.xml
    commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/ScalarDifferentiableOptimizer.java
    commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/ScalarOptimizer.java
    commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/ScalarPointValuePair.java
    commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/VectorialDifferentiableOptimizer.java
    commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/direct/DirectSearchOptimizer.java
    commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/AbstractLeastSquaresOptimizer.java
    commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizer.java
    commons/proper/math/trunk/src/java/org/apache/commons/math/random/CorrelatedRandomVectorGenerator.java
    commons/proper/math/trunk/src/java/org/apache/commons/math/random/GaussianRandomGenerator.java
    commons/proper/math/trunk/src/java/org/apache/commons/math/random/NormalizedRandomGenerator.java
    commons/proper/math/trunk/src/java/org/apache/commons/math/random/RandomVectorGenerator.java
    commons/proper/math/trunk/src/java/org/apache/commons/math/random/UncorrelatedRandomVectorGenerator.java
    commons/proper/math/trunk/src/java/org/apache/commons/math/random/UniformRandomGenerator.java
    commons/proper/math/trunk/src/java/org/apache/commons/math/util/MathUtils.java
    commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/general/GaussNewtonOptimizerTest.java
    commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java

Modified: commons/proper/math/trunk/findbugs-exclude-filter.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/findbugs-exclude-filter.xml?rev=754765&r1=754764&r2=754765&view=diff
==============================================================================
--- commons/proper/math/trunk/findbugs-exclude-filter.xml (original)
+++ commons/proper/math/trunk/findbugs-exclude-filter.xml Sun Mar 15 21:35:38 2009
@@ -55,12 +55,12 @@
 
   <!-- the following expositions of internal representation are intentional and documented
-->
   <Match>
-    <Class name="org.apache.commons.math.optimization.PointValuePair"/>
+    <Class name="org.apache.commons.math.optimization.ScalarPointValuePair"/>
     <Method name="getPointRef" params="" returns="double[]" />
     <Bug pattern="EI_EXPOSE_REP" />
   </Match>
   <Match>
-    <Class name="org.apache.commons.math.optimization.PointValuePair"/>
+    <Class name="org.apache.commons.math.optimization.ScalarPointValuePair"/>
     <Method name="&lt;init>" params="double[],double,boolean" returns="void" />
     <Bug pattern="EI_EXPOSE_REP2" />
   </Match>

Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/ScalarDifferentiableOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/ScalarDifferentiableOptimizer.java?rev=754765&r1=754764&r2=754765&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/ScalarDifferentiableOptimizer.java
(original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/ScalarDifferentiableOptimizer.java
Sun Mar 15 21:35:38 2009
@@ -68,7 +68,7 @@
     void setConvergenceChecker(ScalarConvergenceChecker checker);
 
     /** Get the convergence checker.
-     * @param checker object to use to check for convergence
+     * @return object used to check for convergence
      */
     ScalarConvergenceChecker getConvergenceChecker();
 

Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/ScalarOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/ScalarOptimizer.java?rev=754765&r1=754764&r2=754765&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/ScalarOptimizer.java
(original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/ScalarOptimizer.java
Sun Mar 15 21:35:38 2009
@@ -68,7 +68,7 @@
     void setConvergenceChecker(ScalarConvergenceChecker checker);
 
     /** Get the convergence checker.
-     * @param checker object to use to check for convergence
+     * @return object used to check for convergence
      */
     ScalarConvergenceChecker getConvergenceChecker();
 

Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/ScalarPointValuePair.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/ScalarPointValuePair.java?rev=754765&r1=754764&r2=754765&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/ScalarPointValuePair.java
(original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/ScalarPointValuePair.java
Sun Mar 15 21:35:38 2009
@@ -56,7 +56,7 @@
      * it will be referenced
      */
     public ScalarPointValuePair(final double[] point, final double value,
-                          final boolean copyArray) {
+                                final boolean copyArray) {
         this.point = copyArray ? point.clone() : point;
         this.value  = value;
     }

Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/VectorialDifferentiableOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/VectorialDifferentiableOptimizer.java?rev=754765&r1=754764&r2=754765&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/VectorialDifferentiableOptimizer.java
(original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/VectorialDifferentiableOptimizer.java
Sun Mar 15 21:35:38 2009
@@ -78,7 +78,7 @@
     void setConvergenceChecker(VectorialConvergenceChecker checker);
 
     /** Get the convergence checker.
-     * @param checker object to use to check for convergence
+     * @return object used to check for convergence
      */
     VectorialConvergenceChecker getConvergenceChecker();
 

Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/direct/DirectSearchOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/direct/DirectSearchOptimizer.java?rev=754765&r1=754764&r2=754765&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/direct/DirectSearchOptimizer.java
(original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/direct/DirectSearchOptimizer.java
Sun Mar 15 21:35:38 2009
@@ -313,7 +313,8 @@
 
     /** Build an initial simplex.
      * @param startPoint the start point for optimization
-     * @exception IllegalArgumentException
+     * @exception IllegalArgumentException if the start point does not match
+     * simplex dimension
      */
     private void buildSimplex(final double[] startPoint)
         throws IllegalArgumentException {

Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/AbstractLeastSquaresOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/AbstractLeastSquaresOptimizer.java?rev=754765&r1=754764&r2=754765&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/AbstractLeastSquaresOptimizer.java
(original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/AbstractLeastSquaresOptimizer.java
Sun Mar 15 21:35:38 2009
@@ -303,8 +303,8 @@
 
         // store least squares problem characteristics
         this.f         = f;
-        this.target    = target;
-        this.weights   = weights;
+        this.target    = target.clone();
+        this.weights   = weights.clone();
         this.variables = startPoint.clone();
         this.residuals = new double[target.length];
 
@@ -320,6 +320,11 @@
     }
 
     /** Perform the bulk of optimization algorithm.
+     * @return the point/value pair giving the optimal value for objective function
+     * @exception ObjectiveException if the objective function throws one during
+     * the search
+     * @exception OptimizationException if the algorithm failed to converge
+     * @exception IllegalArgumentException if the start point dimension is wrong
      */
     abstract protected VectorialPointValuePair doOptimize()
     throws ObjectiveException, OptimizationException, IllegalArgumentException;

Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizer.java?rev=754765&r1=754764&r2=754765&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizer.java
(original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizer.java
Sun Mar 15 21:35:38 2009
@@ -55,7 +55,7 @@
      * and the maximal number of evaluation is set to
      * {@link AbstractLeastSquaresOptimizer#DEFAULT_MAX_EVALUATIONS}.
      * @param useLU if true, the normal equations will be solved using LU
-     * decomposition, otherwise it will be solved using QR decomposition
+     * decomposition, otherwise they will be solved using QR decomposition
      */
     public GaussNewtonOptimizer(final boolean useLU) {
         this.useLU = useLU;

Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/random/CorrelatedRandomVectorGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/random/CorrelatedRandomVectorGenerator.java?rev=754765&r1=754764&r2=754765&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/random/CorrelatedRandomVectorGenerator.java
(original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/random/CorrelatedRandomVectorGenerator.java
Sun Mar 15 21:35:38 2009
@@ -60,7 +60,10 @@
  */
 
 public class CorrelatedRandomVectorGenerator
-implements RandomVectorGenerator {
+    implements RandomVectorGenerator {
+
+    /** Serializable version identifier. */
+    private static final long serialVersionUID = -7162933284241468177L;
 
     /** Simple constructor.
      * <p>Build a correlated random vector generator from its mean

Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/random/GaussianRandomGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/random/GaussianRandomGenerator.java?rev=754765&r1=754764&r2=754765&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/random/GaussianRandomGenerator.java
(original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/random/GaussianRandomGenerator.java
Sun Mar 15 21:35:38 2009
@@ -27,6 +27,9 @@
 
 public class GaussianRandomGenerator implements NormalizedRandomGenerator {
 
+    /** Serializable version identifier. */
+    private static final long serialVersionUID = -4698731518385853565L;
+
     /** Create a new generator.
      * @param generator underlying random generator to use
      */

Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/random/NormalizedRandomGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/random/NormalizedRandomGenerator.java?rev=754765&r1=754764&r2=754765&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/random/NormalizedRandomGenerator.java
(original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/random/NormalizedRandomGenerator.java
Sun Mar 15 21:35:38 2009
@@ -17,6 +17,8 @@
 
 package org.apache.commons.math.random;
 
+import java.io.Serializable;
+
 /** 
  * This interface represent a normalized random generator for
  * scalars.
@@ -24,7 +26,7 @@
  * @version $Revision$ $Date$
  * @since 1.2
  */
-public interface NormalizedRandomGenerator {
+public interface NormalizedRandomGenerator extends Serializable {
 
   /** Generate a random scalar with null mean and unit standard deviation.
    * <p>This method does <strong>not</strong> specify the shape of the

Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/random/RandomVectorGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/random/RandomVectorGenerator.java?rev=754765&r1=754764&r2=754765&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/random/RandomVectorGenerator.java
(original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/random/RandomVectorGenerator.java
Sun Mar 15 21:35:38 2009
@@ -17,6 +17,8 @@
 
 package org.apache.commons.math.random;
 
+import java.io.Serializable;
+
 /** This interface represents a random generator for whole vectors.
  * 
  * @since 1.2
@@ -24,7 +26,7 @@
  *
  */
 
-public interface RandomVectorGenerator {
+public interface RandomVectorGenerator extends Serializable {
 
   /** Generate a random vector.
    * @return a random vector as an array of double.

Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/random/UncorrelatedRandomVectorGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/random/UncorrelatedRandomVectorGenerator.java?rev=754765&r1=754764&r2=754765&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/random/UncorrelatedRandomVectorGenerator.java
(original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/random/UncorrelatedRandomVectorGenerator.java
Sun Mar 15 21:35:38 2009
@@ -31,6 +31,9 @@
 public class UncorrelatedRandomVectorGenerator
   implements RandomVectorGenerator {
 
+  /** Serializable version identifier. */
+  private static final long serialVersionUID = -3268228248001718811L;
+
   /** Simple constructor.
    * <p>Build an uncorrelated random vector generator from
    * its mean and standard deviation vectors.</p>

Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/random/UniformRandomGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/random/UniformRandomGenerator.java?rev=754765&r1=754764&r2=754765&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/random/UniformRandomGenerator.java
(original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/random/UniformRandomGenerator.java
Sun Mar 15 21:35:38 2009
@@ -31,6 +31,9 @@
 
 public class UniformRandomGenerator implements NormalizedRandomGenerator {
 
+    /** Serializable version identifier. */
+    private static final long serialVersionUID = 1569292426375546027L;
+
     /** Create a new generator.
      * @param generator underlying random generator to use
      */

Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/util/MathUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/util/MathUtils.java?rev=754765&r1=754764&r2=754765&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/util/MathUtils.java (original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/util/MathUtils.java Sun Mar
15 21:35:38 2009
@@ -549,8 +549,8 @@
      * <code>0</code>.</li>
      * </ul>
      * 
-     * @param u any number
-     * @param v any number
+     * @param p any number
+     * @param q any number
      * @return the greatest common divisor, never negative
      * @throws ArithmeticException
      *             if the result cannot be represented as a nonnegative int

Modified: commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/general/GaussNewtonOptimizerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/general/GaussNewtonOptimizerTest.java?rev=754765&r1=754764&r2=754765&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/general/GaussNewtonOptimizerTest.java
(original)
+++ commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/general/GaussNewtonOptimizerTest.java
Sun Mar 15 21:35:38 2009
@@ -112,6 +112,7 @@
             optimizer.optimize(problem, problem.target, new double[] { 1 }, new double[]
{ 0 });
         assertEquals(0, optimizer.getRMS(), 1.0e-10);
         assertEquals(1.5, optimum.getPoint()[0], 1.0e-10);
+        assertEquals(3.0, optimum.getValue()[0], 1.0e-10);
     }
 
     public void testColumnsPermutation() throws ObjectiveException, OptimizationException
{
@@ -128,6 +129,9 @@
         assertEquals(0, optimizer.getRMS(), 1.0e-10);
         assertEquals(7.0, optimum.getPoint()[0], 1.0e-10);
         assertEquals(3.0, optimum.getPoint()[1], 1.0e-10);
+        assertEquals(4.0, optimum.getValue()[0], 1.0e-10);
+        assertEquals(6.0, optimum.getValue()[1], 1.0e-10);
+        assertEquals(1.0, optimum.getValue()[2], 1.0e-10);
 
     }
 

Modified: commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java?rev=754765&r1=754764&r2=754765&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java
(original)
+++ commons/proper/math/trunk/src/test/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java
Sun Mar 15 21:35:38 2009
@@ -119,13 +119,14 @@
             fail("wrong exception caught");
         }
         assertEquals(1.5, optimum.getPoint()[0], 1.0e-10);
+        assertEquals(3.0, optimum.getValue()[0], 1.0e-10);
     }
 
     public void testQRColumnsPermutation() throws ObjectiveException, OptimizationException
{
 
         LinearProblem problem =
             new LinearProblem(new double[][] { { 1.0, -1.0 }, { 0.0, 2.0 }, { 1.0, -2.0 }
},
-                    new double[] { 4.0, 6.0, 1.0 });
+                              new double[] { 4.0, 6.0, 1.0 });
 
         LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer();
         VectorialPointValuePair optimum =
@@ -133,6 +134,9 @@
         assertEquals(0, optimizer.getRMS(), 1.0e-10);
         assertEquals(7.0, optimum.getPoint()[0], 1.0e-10);
         assertEquals(3.0, optimum.getPoint()[1], 1.0e-10);
+        assertEquals(4.0, optimum.getValue()[0], 1.0e-10);
+        assertEquals(6.0, optimum.getValue()[1], 1.0e-10);
+        assertEquals(1.0, optimum.getValue()[2], 1.0e-10);
 
     }
 



Mime
View raw message