Skip to content

Commit

Permalink
Add debug info
Browse files Browse the repository at this point in the history
  • Loading branch information
fspindle committed Mar 12, 2024
1 parent 83fba5e commit ed0c3ce
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
10 changes: 9 additions & 1 deletion example/math/quadprog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,19 @@ int main(int argc, char **argv)
r = randV(o) * 5;
C = randM(p, n) * 5;

// make sure Cx <= d has a solution within Ax = b
std::cout << "DEBUG 1 before solveBySVD()" << std::endl;
// make sure Cx <= d has a solution within Ax = b
vpColVector x = A.solveBySVD(b);
std::cout << "DEBUG 2 after solveBySVD()" << std::endl;
d = C * x;
for (int i = 0; i < p; ++i)
d[i] += (5. * rand()) / RAND_MAX;

// solver with warm start
vpQuadProg qp_WS;

std::cout << "DEBUG 3 after vpQuadProg()" << std::endl;

// timing
int total = 100;
double t_WS(0), t_noWS(0);
Expand Down Expand Up @@ -142,7 +146,9 @@ int main(int argc, char **argv)
vpQuadProg qp;
x = 0;
double t = vpTime::measureTimeMs();
std::cout << "DEBUG 4 before solveQP()" << std::endl;
qp.solveQP(Q, r, A, b, C, d, x);
std::cout << "DEBUG 4 after solveQP()" << std::endl;

t_noWS += vpTime::measureTimeMs() - t;
#ifdef VISP_HAVE_DISPLAY
Expand All @@ -153,7 +159,9 @@ int main(int argc, char **argv)
// with warm start
x = 0;
t = vpTime::measureTimeMs();
std::cout << "DEBUG 5 before solveQP()" << std::endl;
qp_WS.solveQP(Q, r, A, b, C, d, x);
std::cout << "DEBUG 5 after solveQP()" << std::endl;

t_WS += vpTime::measureTimeMs() - t;
#ifdef VISP_HAVE_DISPLAY
Expand Down
14 changes: 14 additions & 0 deletions example/math/quadprog_eq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,23 @@ int main(int argc, char **argv)
C = randM(p, n) * 5;

// make sure Cx <= d has a solution within Ax = b

std::cout << "DEBUG 1 before solveBySVD()" << std::endl;
vpColVector x = A.solveBySVD(b);
std::cout << "DEBUG 1 after solveBySVD()" << std::endl;
d = C * x;
for (int i = 0; i < p; ++i)
d[i] += (5. * rand()) / RAND_MAX;

// solver with stored equality and warm start
vpQuadProg qp_WS;
std::cout << "DEBUG 2 before setEqualityConstraint()" << std::endl;
qp_WS.setEqualityConstraint(A, b);
std::cout << "DEBUG 2 after setEqualityConstraint()" << std::endl;

vpQuadProg qp_ineq_WS;
qp_ineq_WS.setEqualityConstraint(A, b);
std::cout << "DEBUG 3 after setEqualityConstraint()" << std::endl;

// timing
int total = 100;
Expand All @@ -140,7 +146,9 @@ int main(int argc, char **argv)
// without warm start
x = 0;
double t = vpTime::measureTimeMs();
std::cout << "DEBUG 4 before solveQPe()" << std::endl;
vpQuadProg::solveQPe(Q, r, A, b, x);
std::cout << "DEBUG 4 after solveQPe()" << std::endl;

t_noWS += vpTime::measureTimeMs() - t;
#ifdef VISP_HAVE_DISPLAY
Expand All @@ -151,7 +159,9 @@ int main(int argc, char **argv)
// with pre-solved Ax = b
x = 0;
t = vpTime::measureTimeMs();
std::cout << "DEBUG 5 before solveQPe()" << std::endl;
qp_WS.solveQPe(Q, r, x);
std::cout << "DEBUG 5 after solveQPe()" << std::endl;

t_WS += vpTime::measureTimeMs() - t;
#ifdef VISP_HAVE_DISPLAY
Expand All @@ -164,7 +174,9 @@ int main(int argc, char **argv)
x = 0;
vpQuadProg qp;
t = vpTime::measureTimeMs();
std::cout << "DEBUG 6 before solveQP()" << std::endl;
qp.solveQP(Q, r, A, b, C, d, x);
std::cout << "DEBUG 6 after solveQP()" << std::endl;

t_ineq_noWS += vpTime::measureTimeMs() - t;
#ifdef VISP_HAVE_DISPLAY
Expand All @@ -175,7 +187,9 @@ int main(int argc, char **argv)
// with warm start + pre-solving
x = 0;
t = vpTime::measureTimeMs();
std::cout << "DEBUG 7 before solveQPi()" << std::endl;
qp_ineq_WS.solveQPi(Q, r, C, d, x, true);
std::cout << "DEBUG 7 after solveQPi()" << std::endl;

t_ineq_WS += vpTime::measureTimeMs() - t;
#ifdef VISP_HAVE_DISPLAY
Expand Down

0 comments on commit ed0c3ce

Please sign in to comment.