48 #include <visp3/core/vpConfig.h>
50 #if defined(VISP_HAVE_LAPACK) && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
52 #include <visp3/core/vpQuadProg.h>
53 #include <visp3/core/vpTime.h>
57 int main(
int argc,
char **argv)
63 #ifdef VISP_HAVE_DISPLAY
64 bool opt_display =
true;
65 bool opt_click_allowed =
true;
68 for (
int i = 0; i < argc; i++) {
69 #ifdef VISP_HAVE_DISPLAY
70 if (std::string(argv[i]) ==
"-d")
72 else if (std::string(argv[i]) ==
"-c")
73 opt_click_allowed =
false;
76 if (std::string(argv[i]) ==
"-h" || std::string(argv[i]) ==
"--help") {
77 std::cout <<
"\nUsage: " << argv[0] <<
" [-d] [-c] [-h] [--help]" << 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"
86 " Disable the mouse click. Useful to automate the \n"
87 " execution of this program without human intervention.\n"
111 for (
int i = 0; i < p; ++i)
112 d[i] += (5. * rand()) / RAND_MAX;
119 double t_WS(0), t_noWS(0);
120 const double eps = 1e-2;
122 #ifdef VISP_HAVE_DISPLAY
123 QPlot *plot =
nullptr;
125 plot =
new QPlot(1, total, {
"time to solveQP",
"warm start" });
128 for (
int k = 0; k < total; ++k) {
134 Q += eps * randM(o, n);
136 A += eps * randM(m, n);
138 C += eps * randM(p, n);
145 qp.
solveQP(Q, r, A, b, C, d, x);
148 #ifdef VISP_HAVE_DISPLAY
150 plot->plot(0, 0, k, t);
156 qp_WS.
solveQP(Q, r, A, b, C, d, x);
159 #ifdef VISP_HAVE_DISPLAY
161 plot->plot(0, 1, k, t);
165 std::cout.precision(3);
166 std::cout <<
"Warm start: t = " << t_WS <<
" ms (for 1 QP = " << t_WS / total <<
" ms)\n";
167 std::cout <<
"No warm start: t = " << t_noWS <<
" ms (for 1 QP = " << t_noWS / total <<
" ms)" << std::endl;
169 #ifdef VISP_HAVE_DISPLAY
171 if (opt_click_allowed) {
172 std::cout <<
"Click in the graph to exit..." << std::endl;
180 #elif !(VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
183 std::cout <<
"You did not build ViSP with c++11 or higher compiler flag" << std::endl;
184 std::cout <<
"Tip:" << std::endl;
185 std::cout <<
"- Configure ViSP again using cmake -DUSE_CXX_STANDARD=11, and build again this example" << std::endl;
191 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()