46#include <visp3/core/vpConfig.h>
48#if defined(VISP_HAVE_LAPACK) && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
50#include <visp3/core/vpQuadProg.h>
51#include <visp3/core/vpTime.h>
55int main(
int argc,
char **argv)
57#ifdef ENABLE_VISP_NAMESPACE
65#ifdef VISP_HAVE_DISPLAY
66 bool opt_display =
true;
67 bool opt_click_allowed =
true;
70 for (
int i = 1;
i < argc;
i++) {
71#ifdef VISP_HAVE_DISPLAY
72 if (std::string(argv[i]) ==
"-d") {
75 else if (std::string(argv[i]) ==
"-c") {
76 opt_click_allowed =
false;
80 if (std::string(argv[i]) ==
"-h" || std::string(argv[i]) ==
"--help") {
81 std::cout <<
"\nUsage: " << argv[0] <<
" [-d] [-c] [-h] [--help]" << std::endl;
82 std::cout <<
"\nOptions: \n"
83#ifdef VISP_HAVE_DISPLAY
85 " Disable the image display. This can be useful \n"
86 " for automatic tests using crontab under Unix or \n"
87 " using the task manager under Windows.\n"
90 " Disable the mouse click. Useful to automate the \n"
91 " execution of this program without human intervention.\n"
115 for (
int i = 0;
i <
p; ++
i)
116 d[i] += (5. * rand()) / RAND_MAX;
123 double t_WS(0), t_noWS(0);
124 const double eps = 1
e-2;
126#ifdef VISP_HAVE_DISPLAY
127 QPlot *
plot =
nullptr;
129 plot =
new QPlot(1, total, {
"time to solveQP",
"warm start" });
132 for (
int k = 0; k < total; ++k) {
138 Q += eps * randM(o, n);
140 A += eps * randM(m, n);
142 C += eps * randM(p, n);
149 qp.
solveQP(Q, r, A, b, C, d, x);
152#ifdef VISP_HAVE_DISPLAY
154 plot->plot(0, 0, k, t);
160 qp_WS.
solveQP(Q, r, A, b, C, d, x);
163#ifdef VISP_HAVE_DISPLAY
165 plot->plot(0, 1, k, t);
169 std::cout.precision(3);
170 std::cout <<
"Warm start: t = " << t_WS <<
" ms (for 1 QP = " << t_WS / total <<
" ms)\n";
171 std::cout <<
"No warm start: t = " << t_noWS <<
" ms (for 1 QP = " << t_noWS / total <<
" ms)" << std::endl;
173#ifdef VISP_HAVE_DISPLAY
175 if (opt_click_allowed) {
176 std::cout <<
"Click in the graph to exit..." << std::endl;
184#elif !(VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
187 std::cout <<
"You did not build ViSP with c++11 or higher compiler flag" << std::endl;
188 std::cout <<
"Tip:" << std::endl;
189 std::cout <<
"- Configure ViSP again using cmake -DUSE_CXX_STANDARD=11, and build again this example" << std::endl;
195 std::cout <<
"You did not build ViSP with Lapack support" << std::endl;
Implementation of column vector and the associated operations.
Implementation of a matrix and operations on matrices.
void solveBySVD(const vpColVector &B, vpColVector &x) const
This class provides a solver for Quadratic Programs.
bool solveQP(const vpMatrix &Q, const vpColVector &r, vpMatrix A, vpColVector b, const vpMatrix &C, const vpColVector &d, vpColVector &x, const double &tol=1e-6)
VISP_EXPORT double measureTimeMs()