| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * Copyright 2015, LAAS-CNRS | ||
| 3 | * Author: Andrea Del Prete | ||
| 4 | */ | ||
| 5 | |||
| 6 | #include <hpp/centroidal-dynamics/logger.hh> | ||
| 7 | #include <hpp/centroidal-dynamics/solver_LP_qpoases.hh> | ||
| 8 | |||
| 9 | USING_NAMESPACE_QPOASES | ||
| 10 | |||
| 11 | namespace centroidal_dynamics { | ||
| 12 | |||
| 13 |
3/6✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 15 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 15 times.
✗ Branch 9 not taken.
|
15 | Solver_LP_qpoases::Solver_LP_qpoases() : Solver_LP_abstract() { |
| 14 | // m_options.initialStatusBounds = ST_INACTIVE; | ||
| 15 | // m_options.setToReliable(); | ||
| 16 |
1/2✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
|
15 | m_options.setToDefault(); |
| 17 | 15 | m_options.printLevel = PL_NONE; // PL_LOW | |
| 18 | 15 | m_options.enableRegularisation = BT_TRUE; | |
| 19 | 15 | m_options.enableEqualities = BT_TRUE; | |
| 20 | 15 | } | |
| 21 | |||
| 22 | 9029 | LP_status Solver_LP_qpoases::solve(Cref_vectorX c, Cref_vectorX lb, | |
| 23 | Cref_vectorX ub, Cref_matrixXX A, | ||
| 24 | Cref_vectorX Alb, Cref_vectorX Aub, | ||
| 25 | Ref_vectorX sol) { | ||
| 26 | 9029 | int n = (int)c.size(); // number of variables | |
| 27 | 9029 | int m = (int)A.rows(); // number of constraints | |
| 28 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 9029 times.
|
9029 | assert(lb.size() == n); |
| 29 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 9029 times.
|
9029 | assert(ub.size() == n); |
| 30 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 9029 times.
|
9029 | assert(A.cols() == n); |
| 31 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 9029 times.
|
9029 | assert(Alb.size() == m); |
| 32 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 9029 times.
|
9029 | assert(Aub.size() == m); |
| 33 | |||
| 34 | 9029 | int iters = m_maxIter; | |
| 35 | 9029 | double solutionTime = m_maxTime; | |
| 36 |
6/6✓ Branch 1 taken 9017 times.
✓ Branch 2 taken 12 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 9014 times.
✓ Branch 6 taken 15 times.
✓ Branch 7 taken 9014 times.
|
9029 | if (n != m_solver.getNV() || m != m_solver.getNC()) { |
| 37 |
2/4✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
|
15 | m_solver = SQProblem(n, m, HST_ZERO); |
| 38 |
1/2✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
|
15 | m_solver.setOptions(m_options); |
| 39 | // m_solver.printOptions(); | ||
| 40 | 15 | m_init_succeeded = false; | |
| 41 |
2/4✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
|
15 | m_H = MatrixXX::Zero(n, n); |
| 42 | } | ||
| 43 | |||
| 44 |
4/4✓ Branch 0 taken 9027 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 9013 times.
|
9029 | if (!m_useWarmStart || !m_init_succeeded) { |
| 45 |
1/2✓ Branch 7 taken 16 times.
✗ Branch 8 not taken.
|
16 | m_status = m_solver.init(NULL, c.data(), A.data(), lb.data(), ub.data(), |
| 46 | Alb.data(), Aub.data(), iters, &solutionTime); | ||
| 47 |
1/2✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
|
16 | if (m_status == SUCCESSFUL_RETURN) m_init_succeeded = true; |
| 48 | } else { | ||
| 49 | // this doesn't work if I pass NULL instead of m_H.data() | ||
| 50 | 9013 | m_status = | |
| 51 |
2/4✓ Branch 7 taken 9013 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 9013 times.
✗ Branch 11 not taken.
|
9013 | m_solver.hotstart(m_H.data(), c.data(), A.data(), lb.data(), ub.data(), |
| 52 | Alb.data(), Aub.data(), iters, &solutionTime); | ||
| 53 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9013 times.
|
9013 | if (m_status != SUCCESSFUL_RETURN) m_init_succeeded = false; |
| 54 | } | ||
| 55 | |||
| 56 |
1/2✓ Branch 0 taken 9029 times.
✗ Branch 1 not taken.
|
9029 | if (m_status == SUCCESSFUL_RETURN) { |
| 57 |
1/2✓ Branch 2 taken 9029 times.
✗ Branch 3 not taken.
|
9029 | m_solver.getPrimalSolution(sol.data()); |
| 58 | } | ||
| 59 | |||
| 60 |
1/2✓ Branch 1 taken 9029 times.
✗ Branch 2 not taken.
|
18058 | return getStatus(); |
| 61 | } | ||
| 62 | |||
| 63 | 9029 | LP_status Solver_LP_qpoases::getStatus() { | |
| 64 | 9029 | int ss = getSimpleStatus(m_status); | |
| 65 |
1/2✓ Branch 0 taken 9029 times.
✗ Branch 1 not taken.
|
9029 | if (ss == 0) return LP_STATUS_OPTIMAL; |
| 66 | ✗ | if (ss == 1) return LP_STATUS_MAX_ITER_REACHED; | |
| 67 | ✗ | if (ss == -2) return LP_STATUS_INFEASIBLE; | |
| 68 | ✗ | if (ss == -3) return LP_STATUS_UNBOUNDED; | |
| 69 | ✗ | return LP_STATUS_ERROR; | |
| 70 | } | ||
| 71 | |||
| 72 | } // end namespace centroidal_dynamics | ||
| 73 |