commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles Sadowski <gil...@harfang.homelinux.org>
Subject Re: svn commit: r1090656 - in /commons/proper/math/trunk: ./ src/main/java/org/apache/commons/math/optimization/linear/ src/site/xdoc/ src/test/java/org/apache/commons/math/optimization/linear/
Date Sat, 09 Apr 2011 21:08:32 GMT
On Sat, Apr 09, 2011 at 07:20:48PM -0000, luc@apache.org wrote:
> Author: luc
> Date: Sat Apr  9 19:20:47 2011
> New Revision: 1090656
> 
> URL: http://svn.apache.org/viewvc?rev=1090656&view=rev
> Log:
> Fixed two errors in simplex solver when entries are close together or
> when variables are not restricted to non-negative.
> 
> Jira: MATH-434
> 
> Modified:
>     commons/proper/math/trunk/pom.xml
>     commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/linear/SimplexSolver.java
>     commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/linear/SimplexTableau.java
>     commons/proper/math/trunk/src/site/xdoc/changes.xml
>     commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/linear/SimplexSolverTest.java
> 
> Modified: commons/proper/math/trunk/pom.xml
> URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/pom.xml?rev=1090656&r1=1090655&r2=1090656&view=diff
> ==============================================================================
> --- commons/proper/math/trunk/pom.xml (original)
> +++ commons/proper/math/trunk/pom.xml Sat Apr  9 19:20:47 2011
> @@ -187,6 +187,9 @@
>        <name>J. Lewis Muir</name>
>      </contributor>
>      <contributor>
> +      <name>Thomas Neidhart</name>
> +    </contributor>
> +    <contributor>
>        <name>Fredrik Norin</name>
>      </contributor>
>      <contributor>
> 
> Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/linear/SimplexSolver.java
> URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/linear/SimplexSolver.java?rev=1090656&r1=1090655&r2=1090656&view=diff
> ==============================================================================
> --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/linear/SimplexSolver.java
(original)
> +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/linear/SimplexSolver.java
Sat Apr  9 19:20:47 2011
> @@ -22,6 +22,7 @@ import java.util.List;
>  
>  import org.apache.commons.math.optimization.OptimizationException;
>  import org.apache.commons.math.optimization.RealPointValuePair;
> +import org.apache.commons.math.util.FastMath;
>  import org.apache.commons.math.util.MathUtils;
>  
>  
> @@ -31,26 +32,34 @@ import org.apache.commons.math.util.Math
>   * @since 2.0
>   */
>  public class SimplexSolver extends AbstractLinearOptimizer {
> -
> -    /** Default amount of error to accept in floating point comparisons. */
> +    
> +    /** Default amount of error to accept for algorithm convergence. */
>      private static final double DEFAULT_EPSILON = 1.0e-6;
> -
> -    /** Amount of error to accept in floating point comparisons. */
> +     
> +    /** Amount of error to accept for algorithm convergence. */
>      protected final double epsilon;
>  
> +    /** Default amount of error to accept in floating point comparisons (as ulps). */
> +    private static final int DEFAULT_ULPS = 10;
> +
> +    /** Amount of error to accept in floating point comparisons (as ulps). */
> +    protected final int maxUlps;
> +
>      /**
>       * Build a simplex solver with default settings.
>       */
>      public SimplexSolver() {
> -        this(DEFAULT_EPSILON);
> +        this(DEFAULT_EPSILON, DEFAULT_ULPS);
>      }
>  
>      /**
>       * Build a simplex solver with a specified accepted amount of error
> -     * @param epsilon the amount of error to accept in floating point comparisons
> +     * @param epsilon the amount of error to accept for algorithm convergence
> +     * @param maxUlps amount of error to accept in floating point comparisons 
>       */
> -    public SimplexSolver(final double epsilon) {
> +    public SimplexSolver(final double epsilon, final int maxUlps) {
>          this.epsilon = epsilon;
> +        this.maxUlps = maxUlps;
>      }
>  
>      /**
> @@ -62,8 +71,9 @@ public class SimplexSolver extends Abstr
>          double minValue = 0;
>          Integer minPos = null;
>          for (int i = tableau.getNumObjectiveFunctions(); i < tableau.getWidth() -
1; i++) {
> -            if (MathUtils.compareTo(tableau.getEntry(0, i), minValue, epsilon) <
0) {
> -                minValue = tableau.getEntry(0, i);
> +            final double entry = tableau.getEntry(0, i);
> +            if (MathUtils.compareTo(entry, minValue, getEpsilon(entry)) < 0) {

                                                       ^^^^^^^^^^^^^^^^^^

I thought that Thomas agreed that "MathUtils.equals(double,double,int)"
should be used instead of "getEpsilon".


Gilles

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message