Commit 6d790dcf authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

[CMake] add TRACE_SOLVER option

fix https://github.com/stack-of-tasks/tsid/issues/93
parent 4c4d0402
...@@ -25,6 +25,9 @@ SET(PROJECT_NAME eiquadprog) ...@@ -25,6 +25,9 @@ SET(PROJECT_NAME eiquadprog)
SET(PROJECT_DESCRIPTION "C++ reimplementation of eiquadprog") SET(PROJECT_DESCRIPTION "C++ reimplementation of eiquadprog")
SET(PROJECT_URL "https://github.com/${PROJECT_ORG}/${PROJECT_NAME}") SET(PROJECT_URL "https://github.com/${PROJECT_ORG}/${PROJECT_NAME}")
# Project options
OPTION(TRACE_SOLVER "trace solver on stderr" OFF)
# Project configuration # Project configuration
SET(PROJECT_USE_CMAKE_EXPORT TRUE) SET(PROJECT_USE_CMAKE_EXPORT TRUE)
SET(CXX_DISABLE_WERROR TRUE) SET(CXX_DISABLE_WERROR TRUE)
...@@ -50,7 +53,7 @@ SET(${PROJECT_NAME}_HEADERS ...@@ -50,7 +53,7 @@ SET(${PROJECT_NAME}_HEADERS
include/${PROJECT_NAME}/eiquadprog-fast.hpp include/${PROJECT_NAME}/eiquadprog-fast.hpp
include/${PROJECT_NAME}/eiquadprog-rt.hpp include/${PROJECT_NAME}/eiquadprog-rt.hpp
include/${PROJECT_NAME}/eiquadprog-rt.hxx include/${PROJECT_NAME}/eiquadprog-rt.hxx
include/${PROJECT_NAME}/eiquadprog-utils.hxx include/${PROJECT_NAME}/eiquadprog-utils.hxx
) )
ADD_LIBRARY(${PROJECT_NAME} SHARED ADD_LIBRARY(${PROJECT_NAME} SHARED
...@@ -58,6 +61,10 @@ ADD_LIBRARY(${PROJECT_NAME} SHARED ...@@ -58,6 +61,10 @@ ADD_LIBRARY(${PROJECT_NAME} SHARED
src/eiquadprog.cpp src/eiquadprog.cpp
) )
IF(TRACE_SOLVER)
TARGET_COMPILE_DEFINITIONS(${PROJECT_NAME} PRIVATE TRACE_SOLVER)
ENDIF(TRACE_SOLVER)
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} SYSTEM PRIVATE ${EIGEN3_INCLUDE_DIR}) TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} SYSTEM PRIVATE ${EIGEN3_INCLUDE_DIR})
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} SYSTEM INTERFACE ${EIGEN3_INCLUDE_DIR}) TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} SYSTEM INTERFACE ${EIGEN3_INCLUDE_DIR})
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} INTERFACE $<INSTALL_INTERFACE:include>) TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} INTERFACE $<INSTALL_INTERFACE:include>)
......
#include <iostream> #include <iostream>
#include "eiquadprog/eiquadprog-fast.hpp" #include "eiquadprog/eiquadprog-fast.hpp"
#define TRACE_SOLVER
namespace eiquadprog { namespace eiquadprog {
namespace solvers { namespace solvers {
......
...@@ -193,7 +193,7 @@ l2a: /* Step 2a: determine step direction */ ...@@ -193,7 +193,7 @@ l2a: /* Step 2a: determine step direction */
print_vector("r", r, iq + 1); print_vector("r", r, iq + 1);
print_vector("u", u, iq + 1); print_vector("u", u, iq + 1);
print_vector("d", d, n); print_vector("d", d, n);
print_ivector("A", A, iq + 1); print_vector("A", A, iq + 1);
#endif #endif
/* Step 2b: compute step length */ /* Step 2b: compute step length */
...@@ -240,7 +240,7 @@ l2a: /* Step 2a: determine step direction */ ...@@ -240,7 +240,7 @@ l2a: /* Step 2a: determine step direction */
std::cerr << " in dual space: " << f_value << std::endl; std::cerr << " in dual space: " << f_value << std::endl;
print_vector("x", x, n); print_vector("x", x, n);
print_vector("z", z, n); print_vector("z", z, n);
print_ivector("A", A, iq + 1); print_vector("A", A, iq + 1);
#endif #endif
goto l2a; goto l2a;
} }
...@@ -258,7 +258,7 @@ l2a: /* Step 2a: determine step direction */ ...@@ -258,7 +258,7 @@ l2a: /* Step 2a: determine step direction */
print_vector("x", x, n); print_vector("x", x, n);
print_vector("u", u, iq + 1); print_vector("u", u, iq + 1);
print_vector("r", r, iq + 1); print_vector("r", r, iq + 1);
print_ivector("A", A, iq + 1); print_vector("A", A, iq + 1);
#endif #endif
if (t == t2) { if (t == t2) {
...@@ -273,7 +273,7 @@ l2a: /* Step 2a: determine step direction */ ...@@ -273,7 +273,7 @@ l2a: /* Step 2a: determine step direction */
delete_constraint(R, J, A, u, p, iq, ip); delete_constraint(R, J, A, u, p, iq, ip);
#ifdef TRACE_SOLVER #ifdef TRACE_SOLVER
print_matrix("R", R, n); print_matrix("R", R, n);
print_ivector("A", A, iq); print_vector("A", A, iq);
#endif #endif
for (i = 0; i < m; i++) iai(i) = static_cast<VectorXi::Scalar>(i); for (i = 0; i < m; i++) iai(i) = static_cast<VectorXi::Scalar>(i);
for (i = 0; i < iq; i++) { for (i = 0; i < iq; i++) {
...@@ -287,7 +287,7 @@ l2a: /* Step 2a: determine step direction */ ...@@ -287,7 +287,7 @@ l2a: /* Step 2a: determine step direction */
iai(ip) = -1; iai(ip) = -1;
#ifdef TRACE_SOLVER #ifdef TRACE_SOLVER
print_matrix("R", R, n); print_matrix("R", R, n);
print_ivector("A", A, iq); print_vector("A", A, iq);
#endif #endif
goto l1; goto l1;
} }
...@@ -302,7 +302,7 @@ l2a: /* Step 2a: determine step direction */ ...@@ -302,7 +302,7 @@ l2a: /* Step 2a: determine step direction */
delete_constraint(R, J, A, u, p, iq, l); delete_constraint(R, J, A, u, p, iq, l);
#ifdef TRACE_SOLVER #ifdef TRACE_SOLVER
print_matrix("R", R, n); print_matrix("R", R, n);
print_ivector("A", A, iq); print_vector("A", A, iq);
#endif #endif
s(ip) = CI.col(ip).dot(x) + ci0(ip); s(ip) = CI.col(ip).dot(x) + ci0(ip);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment