Skip to content

Commit 3713416

Browse files
committed
[unittest] [eiquadprog-rt] test_unfeasible_constraints
1 parent c4cfba9 commit 3713416

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

unittest/eiquadprog-rt.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,51 @@ BOOST_AUTO_TEST_CASE(test_unfeasible_inequalities) {
318318
BOOST_CHECK(status != RT_EIQUADPROG_OPTIMAL);
319319
}
320320

321+
// min ||x-x_0||^2, x_0 = (1 1)^T
322+
// s.t.
323+
// x[1] = 1 - x[0]
324+
// x[0] <= 0
325+
// x[1] <= 0
326+
//
327+
// correctly fails, but returns wrong error code
328+
329+
BOOST_AUTO_TEST_CASE(test_unfeasible_constraints) {
330+
RtEiquadprog<2, 1, 2> qp;
331+
332+
RtMatrixX<2, 2>::d Q;
333+
Q.setZero();
334+
Q(0, 0) = 1.0;
335+
Q(1, 1) = 1.0;
336+
337+
RtVectorX<2>::d C;
338+
C(0) = -1.;
339+
C(1) = -1.;
340+
341+
RtMatrixX<1, 2>::d Aeq;
342+
Aeq(0, 0) = 1.;
343+
Aeq(0, 1) = 1.;
344+
345+
RtVectorX<1>::d Beq;
346+
Beq(0) = -1.;
347+
348+
RtMatrixX<2, 2>::d Aineq;
349+
Aineq.setZero();
350+
Aineq(0, 0) = -1.;
351+
Aineq(1, 1) = -1.;
352+
353+
RtVectorX<2>::d Bineq;
354+
Bineq.setZero();
355+
356+
RtVectorX<2>::d x;
357+
358+
RtEiquadprog_status expected = RT_EIQUADPROG_INFEASIBLE;
359+
360+
RtEiquadprog_status status = qp.solve_quadprog(Q, C, Aeq, Beq, Aineq, Bineq, x);
361+
362+
BOOST_WARN_EQUAL(status, expected);
363+
BOOST_CHECK(status != RT_EIQUADPROG_OPTIMAL);
364+
}
365+
321366
// min -||x||^2
322367
// DOES NOT WORK!
323368

0 commit comments

Comments
 (0)