Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Stack Of Tasks
eiquadprog
Commits
fe6ff27b
Commit
fe6ff27b
authored
Sep 17, 2019
by
Gabriele Buondonno
Browse files
[unittest] [eiquadprog-rt] test_full
parent
0048447e
Changes
2
Hide whitespace changes
Inline
Side-by-side
unittest/CMakeLists.txt
View file @
fe6ff27b
...
...
@@ -4,6 +4,7 @@ ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN)
SET
(
TESTS
eiquadprog-basic
eiquadprog-fast
eiquadprog-rt
)
FOREACH
(
test
${
TESTS
}
)
...
...
unittest/eiquadprog-rt.cpp
0 → 100644
View file @
fe6ff27b
#include
<iostream>
#include
<Eigen/Core>
#include
<boost/test/unit_test.hpp>
#include
"eiquadprog/eiquadprog-rt.hpp"
using
namespace
eiquadprog
::
solvers
;
/**
* solves the problem
* min. 0.5 * x' Hess x + g0' x
* s.t. CE x + ce0 = 0
* CI x + ci0 >= 0
*/
BOOST_AUTO_TEST_SUITE
(
BOOST_TEST_MODULE
)
// min ||x-x_0||^2, x_0 = (1 1)^T
// s.t.
// x[1] = 5 - x[0]
// x[1] >= 3
BOOST_AUTO_TEST_CASE
(
test_full
)
{
RtEiquadprog
<
2
,
1
,
1
>
qp
;
RtMatrixX
<
2
,
2
>::
d
Q
;
Q
.
setZero
();
Q
(
0
,
0
)
=
1.0
;
Q
(
1
,
1
)
=
1.0
;
RtVectorX
<
2
>::
d
C
;
C
(
0
)
=
-
1.
;
C
(
1
)
=
-
1.
;
RtMatrixX
<
1
,
2
>::
d
Aeq
;
Aeq
(
0
,
0
)
=
1.
;
Aeq
(
0
,
1
)
=
1.
;
RtVectorX
<
1
>::
d
Beq
;
Beq
(
0
)
=
-
5.
;
RtMatrixX
<
1
,
2
>::
d
Aineq
;
Aineq
.
setZero
();
Aineq
(
0
,
1
)
=
1.
;
RtVectorX
<
1
>::
d
Bineq
;
Bineq
(
0
)
=
-
3.
;
RtVectorX
<
2
>::
d
x
;
RtVectorX
<
2
>::
d
solution
;
solution
(
0
)
=
2.
;
solution
(
1
)
=
3.
;
double
val
=
1.5
;
RtEiquadprog_status
expected
=
RT_EIQUADPROG_OPTIMAL
;
RtEiquadprog_status
status
=
qp
.
solve_quadprog
(
Q
,
C
,
Aeq
,
Beq
,
Aineq
,
Bineq
,
x
);
BOOST_CHECK_EQUAL
(
status
,
expected
);
BOOST_CHECK_CLOSE
(
qp
.
getObjValue
(),
val
,
1e-6
);
BOOST_CHECK
(
x
.
isApprox
(
solution
));
}
BOOST_AUTO_TEST_SUITE_END
()
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment