Rename enum to uppercase, make test deterministic.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1551058 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
05aae985d9
commit
f7222ca6c3
|
@ -29,11 +29,11 @@ public enum PivotSelectionRule implements OptimizationData {
|
|||
* 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
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ public class SimplexSolver extends LinearOptimizer {
|
|||
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 LinearOptimizer {
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue