Skip to content

Commit aef9db4

Browse files
olivier-stasseOlivier Stasse
authored andcommitted
Reorganization to have a library for:
* eiquadprog-fast * eiquadprog Associated tests + integration tests.
1 parent 1b32975 commit aef9db4

16 files changed

+623
-528
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
build*/
2+
*~

CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,16 @@ SEARCH_FOR_BOOST()
4848
SET(${PROJECT_NAME}_HEADERS
4949
include/${PROJECT_NAME}/eiquadprog.hpp
5050
include/${PROJECT_NAME}/eiquadprog-fast.hpp
51-
include/${PROJECT_NAME}/eiquadprog-fast.hxx
5251
include/${PROJECT_NAME}/eiquadprog-rt.hpp
5352
include/${PROJECT_NAME}/eiquadprog-rt.hxx
5453
)
5554

56-
ADD_LIBRARY(${PROJECT_NAME} INTERFACE)
55+
ADD_LIBRARY(${PROJECT_NAME} SHARED
56+
src/eiquadprog-fast.cpp
57+
src/eiquadprog.cpp
58+
)
59+
60+
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} SYSTEM PRIVATE ${EIGEN3_INCLUDE_DIR})
5761
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} SYSTEM INTERFACE ${EIGEN3_INCLUDE_DIR})
5862
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} INTERFACE $<INSTALL_INTERFACE:include>)
5963
INSTALL(TARGETS ${PROJECT_NAME} EXPORT ${TARGETS_EXPORT_NAME} DESTINATION lib)

include/eiquadprog/eiquadprog-fast.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@ namespace eiquadprog {
6161

6262
namespace solvers {
6363

64+
#include "eiquadprog/eiquadprog-utils.hxx"
65+
6466
/**
6567
* Possible states of the solver.
6668
*/
67-
enum EiquadprogFast_status {
69+
enum EiquadprogFast_status {
6870
EIQUADPROG_FAST_OPTIMAL = 0,
6971
EIQUADPROG_FAST_INFEASIBLE = 1,
7072
EIQUADPROG_FAST_UNBOUNDED = 2,
@@ -228,7 +230,5 @@ class EiquadprogFast {
228230
} /* namespace solvers */
229231
} /* namespace eiquadprog */
230232

231-
/* --- Details -------------------------------------------------------------------- */
232-
#include "eiquadprog/eiquadprog-fast.hxx"
233233

234234
#endif /* EIQUADPROGFAST_HPP_ */

include/eiquadprog/eiquadprog-rt.hpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ namespace eiquadprog {
7171

7272
namespace solvers {
7373

74+
#include "eiquadprog/eiquadprog-utils.hxx"
7475
/**
7576
* Possible states of the solver.
7677
*/
@@ -135,14 +136,14 @@ class RtEiquadprog {
135136
* s.t. CE x + ce0 = 0
136137
* CI x + ci0 >= 0
137138
*/
138-
inline RtEiquadprog_status solve_quadprog(const typename RtMatrixX<nVars, nVars>::d& Hess,
139-
const typename RtVectorX<nVars>::d& g0,
140-
const typename RtMatrixX<nEqCon, nVars>::d& CE,
141-
const typename RtVectorX<nEqCon>::d& ce0,
142-
const typename RtMatrixX<nIneqCon, nVars>::d& CI,
143-
const typename RtVectorX<nIneqCon>::d& ci0,
144-
typename RtVectorX<nVars>::d& x);
145-
139+
RtEiquadprog_status solve_quadprog(const typename RtMatrixX<nVars, nVars>::d& Hess,
140+
const typename RtVectorX<nVars>::d& g0,
141+
const typename RtMatrixX<nEqCon, nVars>::d& CE,
142+
const typename RtVectorX<nEqCon>::d& ce0,
143+
const typename RtMatrixX<nIneqCon, nVars>::d& CI,
144+
const typename RtVectorX<nIneqCon>::d& ci0,
145+
typename RtVectorX<nVars>::d& x);
146+
146147
typename RtMatrixX<nVars, nVars>::d m_J; // J * J' = Hessian
147148
bool is_inverse_provided_;
148149

@@ -244,18 +245,19 @@ class RtEiquadprog {
244245
R.topLeftCorner(iq, iq).template triangularView<Eigen::Upper>().solveInPlace(r.head(iq));
245246
}
246247

247-
inline bool add_constraint(typename RtMatrixX<nVars, nVars>::d& R, typename RtMatrixX<nVars, nVars>::d& J,
248+
bool add_constraint(typename RtMatrixX<nVars, nVars>::d& R, typename RtMatrixX<nVars, nVars>::d& J,
248249
typename RtVectorX<nVars>::d& d, int& iq, double& R_norm);
249250

250-
inline void delete_constraint(typename RtMatrixX<nVars, nVars>::d& R, typename RtMatrixX<nVars, nVars>::d& J,
251-
typename RtVectorX<nIneqCon + nEqCon>::i& A,
252-
typename RtVectorX<nIneqCon + nEqCon>::d& u, int& iq, int l);
251+
void delete_constraint(typename RtMatrixX<nVars, nVars>::d& R, typename RtMatrixX<nVars, nVars>::d& J,
252+
typename RtVectorX<nIneqCon + nEqCon>::i& A,
253+
typename RtVectorX<nIneqCon + nEqCon>::d& u, int& iq, int l);
253254
};
254255

255256
} /* namespace solvers */
256257
} /* namespace eiquadprog */
257258

258-
/* --- Details -------------------------------------------------------------------- */
259259
#include "eiquadprog/eiquadprog-rt.hxx"
260+
/* --- Details -------------------------------------------------------------------- */
261+
260262

261263
#endif /* __eiquadprog_rt_hpp__ */

include/eiquadprog/eiquadprog-rt.hxx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,22 @@ namespace eiquadprog {
2626
namespace solvers {
2727

2828
template <int nVars, int nEqCon, int nIneqCon>
29-
RtEiquadprog<nVars, nEqCon, nIneqCon>::RtEiquadprog() : solver_return_(std::numeric_limits<double>::infinity()) {
29+
RtEiquadprog<nVars, nEqCon, nIneqCon>::RtEiquadprog() :
30+
solver_return_(std::numeric_limits<double>::infinity()) {
3031
m_maxIter = DEFAULT_MAX_ITER;
31-
q = 0; // size of the active set A (containing the indices of the active constraints)
32+
q = 0; // size of the active set A
33+
// (containing the indices of the active constraints)
3234
is_inverse_provided_ = false;
3335
}
3436

3537
template <int nVars, int nEqCon, int nIneqCon>
3638
RtEiquadprog<nVars, nEqCon, nIneqCon>::~RtEiquadprog() {}
3739

3840
template <int nVars, int nEqCon, int nIneqCon>
39-
bool RtEiquadprog<nVars, nEqCon, nIneqCon>::add_constraint(typename RtMatrixX<nVars, nVars>::d& R,
40-
typename RtMatrixX<nVars, nVars>::d& J,
41-
typename RtVectorX<nVars>::d& d, int& iq, double& R_norm) {
41+
bool RtEiquadprog<nVars, nEqCon, nIneqCon>::
42+
add_constraint(typename RtMatrixX<nVars, nVars>::d& R,
43+
typename RtMatrixX<nVars, nVars>::d& J,
44+
typename RtVectorX<nVars>::d& d, int& iq, double& R_norm) {
4245
// int n=J.rows();
4346
#ifdef TRACE_SOLVER
4447
std::cerr << "Add constraint " << iq << '/';

include/eiquadprog/eiquadprog-utils.hxx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef EIQUADPROG_UTILS_HPP_
22
#define EIQUADPROG_UTILS_HPP_
33

4+
#include <Eigen/Core>
5+
46
/// Compute sqrt(a^2 + b^2)
57
template <typename Scalar>
68
inline Scalar distance(Scalar a, Scalar b) {

0 commit comments

Comments
 (0)