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

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@808312 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Luc Maisonobe 2009-08-27 08:05:01 +00:00
parent 24e9fc91c7
commit 62c09640bb
1 changed files with 13 additions and 2 deletions

View File

@ -75,13 +75,24 @@ public class SimplexSolverTest {
}
@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