You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2011/04/11 19:43:41 UTC
svn commit: r1091143 - in /commons/proper/math/trunk/src:
main/java/org/apache/commons/math/optimization/linear/SimplexTableau.java
test/java/org/apache/commons/math/optimization/linear/SimplexSolverTest.java
Author: luc
Date: Mon Apr 11 17:43:40 2011
New Revision: 1091143
URL: http://svn.apache.org/viewvc?rev=1091143&view=rev
Log:
replaced remaining getEpsilon by using ulps in double comparisons
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/linear/SimplexTableau.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/linear/SimplexSolverTest.java
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/linear/SimplexTableau.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/linear/SimplexTableau.java?rev=1091143&r1=1091142&r2=1091143&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/linear/SimplexTableau.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/linear/SimplexTableau.java Mon Apr 11 17:43:40 2011
@@ -33,7 +33,6 @@ import org.apache.commons.math.linear.Re
import org.apache.commons.math.linear.RealVector;
import org.apache.commons.math.optimization.GoalType;
import org.apache.commons.math.optimization.RealPointValuePair;
-import org.apache.commons.math.util.FastMath;
import org.apache.commons.math.util.MathUtils;
/**
@@ -312,9 +311,9 @@ class SimplexTableau implements Serializ
Integer row = null;
for (int i = 0; i < getHeight(); i++) {
final double entry = getEntry(i, col);
- if (MathUtils.equals(entry, 1d, getEpsilon(entry)) && (row == null)) {
+ if (MathUtils.equals(entry, 1d, maxUlps) && (row == null)) {
row = i;
- } else if (!MathUtils.equals(entry, 0d, getEpsilon(entry))) {
+ } else if (!MathUtils.equals(entry, 0d, maxUlps)) {
return null;
}
}
@@ -336,7 +335,7 @@ class SimplexTableau implements Serializ
// positive cost non-artificial variables
for (int i = getNumObjectiveFunctions(); i < getArtificialVariableOffset(); i++) {
final double entry = tableau.getEntry(0, i);
- if (MathUtils.compareTo(entry, 0d, getEpsilon(entry)) > 0) {
+ if (MathUtils.compareTo(entry, 0d, maxUlps) > 0) {
columnsToDrop.add(i);
}
}
@@ -615,14 +614,5 @@ class SimplexTableau implements Serializ
throws ClassNotFoundException, IOException {
ois.defaultReadObject();
MatrixUtils.deserializeRealMatrix(this, "tableau", ois);
- }
-
- /**
- * Get an epsilon that is adjusted to the magnitude of the given value.
- * @param value the value for which to get the epsilon
- * @return magnitude-adjusted epsilon using {@link FastMath.ulp}
- */
- private double getEpsilon(double value) {
- return FastMath.ulp(value) * (double) maxUlps;
}
}
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/linear/SimplexSolverTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/linear/SimplexSolverTest.java?rev=1091143&r1=1091142&r2=1091143&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/linear/SimplexSolverTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/linear/SimplexSolverTest.java Mon Apr 11 17:43:40 2011
@@ -31,7 +31,7 @@ import org.junit.Test;
public class SimplexSolverTest {
@Test
- public void test434NegativeVariable() throws OptimizationException
+ public void testMath434NegativeVariable() throws OptimizationException
{
LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] {0.0, 0.0, 1.0}, 0.0d);
ArrayList<LinearConstraint> constraints = new ArrayList<LinearConstraint>();
@@ -49,7 +49,7 @@ public class SimplexSolverTest {
}
@Test(expected = NoFeasibleSolutionException.class)
- public void test434UnfeasibleSolution() throws OptimizationException
+ public void testMath434UnfeasibleSolution() throws OptimizationException
{
double epsilon = 1e-6;
@@ -64,7 +64,7 @@ public class SimplexSolverTest {
}
@Test
- public void test434PivotRowSelection() throws OptimizationException
+ public void testMath434PivotRowSelection() throws OptimizationException
{
LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] {1.0}, 0.0);
@@ -81,7 +81,7 @@ public class SimplexSolverTest {
}
@Test
- public void test434PivotRowSelection2() throws OptimizationException
+ public void testMath434PivotRowSelection2() throws OptimizationException
{
LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] {0.0d, 1.0d, 1.0d, 0.0d, 0.0d, 0.0d, 0.0d}, 0.0d);