51 #include <visp3/core/vpConfig.h> 53 #ifdef VISP_HAVE_CPP11_COMPATIBILITY 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;
70 for (
int i = 0; i < argc; i++) {
71 #ifdef VISP_HAVE_DISPLAY 72 if (std::string(argv[i]) ==
"-d")
76 if (std::string(argv[i]) ==
"-h") {
77 std::cout <<
"\nUsage: " << argv[0] <<
" [-d] [-h]" << std::endl;
78 std::cout <<
"\nOptions: \n" 79 #ifdef VISP_HAVE_DISPLAY 81 " Disable the image display. This can be useful \n" 82 " for automatic tests using crontab under Unix or \n" 83 " using the task manager under Windows.\n" 87 " Print the help.\n"<< std::endl;
106 for(
int i = 0; i < p; ++i)
107 d[i] += (5.*rand())/RAND_MAX;
114 double t_WS(0), t_noWS(0);
115 const double eps = 1e-2;
117 #ifdef VISP_HAVE_DISPLAY 120 plot =
new QPlot(1, total, {
"time to solveQP",
"warm start"});
123 for(
int k = 0; k < total; ++k)
130 Q += eps * randM(o,n);
132 A += eps * randM(m,n);
134 C += eps * randM(p,n);
141 qp.
solveQP(Q, r, A, b, C, d, x);
144 #ifdef VISP_HAVE_DISPLAY 152 qp_WS.
solveQP(Q, r, A, b, C, d, x);
155 #ifdef VISP_HAVE_DISPLAY 157 plot->
plot(0, 1, k, t);
161 std::cout.precision(3);
162 std::cout <<
"Warm start: t = " << t_WS <<
" ms (for 1 QP = " << t_WS/total <<
" ms)\n";
163 std::cout <<
"No warm start: t = " << t_noWS <<
" ms (for 1 QP = " << t_noWS/total <<
" ms)" << std::endl;
165 #ifdef VISP_HAVE_DISPLAY 176 std::cout <<
"You did not build ViSP with C++11 compiler flag" << std::endl;
177 std::cout <<
"Tip:" << std::endl;
178 std::cout <<
"- Configure ViSP again using cmake -DUSE_CPP11=ON, and build again this example" << std::endl;
Implementation of a matrix and operations on matrices.
VISP_EXPORT double measureTimeMs()
void solveBySVD(const vpColVector &B, vpColVector &x) const
This class provides a solver for Quadratic Programs.
void plot(int g, int c, int i, double t)
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)