51 #include <visp3/core/vpConfig.h> 53 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) && defined(VISP_HAVE_LAPACK) 55 #include <visp3/core/vpQuadProg.h> 56 #include <visp3/core/vpTime.h> 60 int main (
int argc,
char **argv)
66 #ifdef VISP_HAVE_DISPLAY 67 bool opt_display =
true;
68 bool opt_click_allowed =
true;
71 for (
int i = 0; i < argc; i++) {
72 #ifdef VISP_HAVE_DISPLAY 73 if (std::string(argv[i]) ==
"-d")
75 else if (std::string(argv[i]) ==
"-c")
76 opt_click_allowed =
false;
79 if (std::string(argv[i]) ==
"-h" || std::string(argv[i]) ==
"--help") {
80 std::cout <<
"\nUsage: " << argv[0] <<
" [-d] [-c] [-h] [--help]" << std::endl;
81 std::cout <<
"\nOptions: \n" 82 #ifdef VISP_HAVE_DISPLAY 84 " Disable the image display. This can be useful \n" 85 " for automatic tests using crontab under Unix or \n" 86 " using the task manager under Windows.\n" 89 " Disable the mouse click. Useful to automate the \n" 90 " execution of this program without humain intervention.\n" 94 " Print the help.\n"<< std::endl;
113 for(
int i = 0; i < p; ++i)
114 d[i] += (5.*rand())/RAND_MAX;
121 double t_WS(0), t_noWS(0);
122 const double eps = 1e-2;
124 #ifdef VISP_HAVE_DISPLAY 127 plot =
new QPlot(1, total, {
"time to solveQP",
"warm start"});
130 for(
int k = 0; k < total; ++k)
137 Q += eps * randM(o,n);
139 A += eps * randM(m,n);
141 C += eps * randM(p,n);
148 qp.
solveQP(Q, r, A, b, C, d, x);
151 #ifdef VISP_HAVE_DISPLAY 159 qp_WS.
solveQP(Q, r, A, b, C, d, x);
162 #ifdef VISP_HAVE_DISPLAY 164 plot->plot(0, 1, k, t);
168 std::cout.precision(3);
169 std::cout <<
"Warm start: t = " << t_WS <<
" ms (for 1 QP = " << t_WS/total <<
" ms)\n";
170 std::cout <<
"No warm start: t = " << t_noWS <<
" ms (for 1 QP = " << t_noWS/total <<
" ms)" << std::endl;
172 #ifdef VISP_HAVE_DISPLAY 174 if (opt_click_allowed) {
175 std::cout <<
"Click in the graph to exit..." << std::endl;
183 #elif !(VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) 186 std::cout <<
"You did not build ViSP with c++11 or higher compiler flag" << std::endl;
187 std::cout <<
"Tip:" << std::endl;
188 std::cout <<
"- Configure ViSP again using cmake -DUSE_CXX_STANDARD=11, and build again this example" << std::endl;
194 std::cout <<
"You did not build ViSP with Lapack support" << std::endl;
void solveBySVD(const vpColVector &B, vpColVector &x) const
Implementation of a matrix and operations on matrices.
VISP_EXPORT double measureTimeMs()
This class provides a solver for Quadratic Programs.
Implementation of column vector and the associated operations.
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)