Author: tn Date: Sun Dec 15 21:15:21 2013 New Revision: 1551058 URL: http://svn.apache.org/r1551058 Log: Rename enum to uppercase, make test deterministic.
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/linear/PivotSelectionRule.java commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/linear/SimplexSolver.java commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optim/linear/SimplexSolverTest.java Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/linear/PivotSelectionRule.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/linear/PivotSelectionRule.java?rev=1551058&r1=1551057&r2=1551058&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/linear/PivotSelectionRule.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/linear/PivotSelectionRule.java Sun Dec 15 21:15:21 2013 @@ -29,11 +29,11 @@ public enum PivotSelectionRule implement * The classical rule, the variable with the most negative coefficient * in the objective function row will be chosen as entering variable. */ - Dantzig, + DANTZIG, /** * The first variable with a negative coefficient in the objective function * row will be chosen as entering variable. This rule guarantees to prevent * cycles, but may take longer to find an optimal solution. */ - Bland + BLAND } Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/linear/SimplexSolver.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/linear/SimplexSolver.java?rev=1551058&r1=1551057&r2=1551058&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/linear/SimplexSolver.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/linear/SimplexSolver.java Sun Dec 15 21:15:21 2013 @@ -129,7 +129,7 @@ public class SimplexSolver extends Linea this.epsilon = epsilon; this.maxUlps = maxUlps; this.cutOff = cutOff; - this.pivotSelection = PivotSelectionRule.Dantzig; + this.pivotSelection = PivotSelectionRule.DANTZIG; } /** @@ -203,7 +203,7 @@ public class SimplexSolver extends Linea minPos = i; // Bland's rule: chose the entering column with the lowest index - if (pivotSelection == PivotSelectionRule.Bland && isValidPivotColumn(tableau, i)) { + if (pivotSelection == PivotSelectionRule.BLAND && isValidPivotColumn(tableau, i)) { break; } } Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optim/linear/SimplexSolverTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optim/linear/SimplexSolverTest.java?rev=1551058&r1=1551057&r2=1551058&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optim/linear/SimplexSolverTest.java (original) +++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optim/linear/SimplexSolverTest.java Sun Dec 15 21:15:21 2013 @@ -55,7 +55,7 @@ public class SimplexSolverTest { PointValuePair solution = solver.optimize(f, new LinearConstraintSet(constraints), GoalType.MAXIMIZE, new NonNegativeConstraint(true), - PivotSelectionRule.Bland); + PivotSelectionRule.BLAND); Assert.assertEquals(1.0d, solution.getValue(), epsilon); Assert.assertTrue(validSolution(solution, constraints, epsilon)); } @@ -98,8 +98,10 @@ public class SimplexSolverTest { constraints.add(new LinearConstraint(new double[] {15.0, -46.0, -41.0, -83.0, -98.0, -99.0, -21.0, -35.0, -7.0, -14.0, -80.0, -63.0, -18.0, -42.0, -5.0, -34.0, -56.0, -70.0, -16.0, -18.0, -74.0, -61.0, -47.0, -41.0, -15.0, -79.0, -18.0, -47.0, -88.0, -68.0, -55.0,}, Relationship.GEQ, 0.0)); double epsilon = 1e-6; - PointValuePair solution = new SimplexSolver().optimize(DEFAULT_MAX_ITER, f, new LinearConstraintSet(constraints), - GoalType.MINIMIZE, new NonNegativeConstraint(true)); + PointValuePair solution = new SimplexSolver().optimize(DEFAULT_MAX_ITER, f, + new DeterministicLinearConstraintSet(constraints), + GoalType.MINIMIZE, new NonNegativeConstraint(true), + PivotSelectionRule.BLAND); Assert.assertEquals(1.0d, solution.getValue(), epsilon); Assert.assertTrue(validSolution(solution, constraints, epsilon)); } @@ -765,7 +767,7 @@ public class SimplexSolverTest { // we need to use a DeterministicLinearConstraintSet to always get the same behavior solver.optimize(new MaxIter(100), f, new DeterministicLinearConstraintSet(constraints), GoalType.MINIMIZE, new NonNegativeConstraint(true), callback, - PivotSelectionRule.Bland); + PivotSelectionRule.BLAND); Assert.fail("expected TooManyIterationsException"); } catch (TooManyIterationsException ex) { // expected @@ -779,7 +781,7 @@ public class SimplexSolverTest { // we need to use a DeterministicLinearConstraintSet to always get the same behavior solver.optimize(new MaxIter(111), f, new DeterministicLinearConstraintSet(constraints), GoalType.MINIMIZE, new NonNegativeConstraint(true), callback, - PivotSelectionRule.Bland); + PivotSelectionRule.BLAND); //Assert.fail("expected TooManyIterationsException"); } catch (TooManyIterationsException ex) { // expected