Author: luc
Date: Thu Aug 27 08:05:01 2009
New Revision: 808312
URL: http://svn.apache.org/viewvc?rev=808312&view=rev
Log:
added tests for both the <= and the >= versions of the constraints
one leads to 0 as a solution, the other one leads to no feasible solution
JIRA: MATH-290
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/linear/SimplexSolverTest.java
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=808312&r1=808311&r2=808312&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
Thu Aug 27 08:05:01 2009
@@ -75,13 +75,24 @@
}
@Test
- public void testMath290() throws OptimizationException {
+ public void testMath290GEQ() throws OptimizationException {
LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] {
1, 5 }, 0 );
Collection<LinearConstraint> constraints = new
ArrayList<LinearConstraint>();
constraints.add(new LinearConstraint(new double[] { 2, 0 },
Relationship.GEQ, -1.0));
SimplexSolver solver = new SimplexSolver();
RealPointValuePair solution = solver.optimize(f, constraints,
GoalType.MINIMIZE, true);
- assertNotNull(solution);
+ assertEquals(0, solution.getValue(), .0000001);
+ assertEquals(0, solution.getPoint()[0], .0000001);
+ assertEquals(0, solution.getPoint()[1], .0000001);
+ }
+
+ @Test(expected=NoFeasibleSolutionException.class)
+ public void testMath290LEQ() throws OptimizationException {
+ LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] {
1, 5 }, 0 );
+ Collection<LinearConstraint> constraints = new
ArrayList<LinearConstraint>();
+ constraints.add(new LinearConstraint(new double[] { 2, 0 },
Relationship.LEQ, -1.0));
+ SimplexSolver solver = new SimplexSolver();
+ solver.optimize(f, constraints, GoalType.MINIMIZE, true);
}
@Test