Skip to content

Commit

Permalink
[CMake] add TRACE_SOLVER option
Browse files Browse the repository at this point in the history
  • Loading branch information
nim65s committed May 28, 2020
1 parent 4c4d040 commit 6d790dc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ SET(PROJECT_NAME eiquadprog)
SET(PROJECT_DESCRIPTION "C++ reimplementation of eiquadprog")
SET(PROJECT_URL "https://github.com/${PROJECT_ORG}/${PROJECT_NAME}")

# Project options
OPTION(TRACE_SOLVER "trace solver on stderr" OFF)

# Project configuration
SET(PROJECT_USE_CMAKE_EXPORT TRUE)
SET(CXX_DISABLE_WERROR TRUE)
Expand All @@ -50,14 +53,18 @@ SET(${PROJECT_NAME}_HEADERS
include/${PROJECT_NAME}/eiquadprog-fast.hpp
include/${PROJECT_NAME}/eiquadprog-rt.hpp
include/${PROJECT_NAME}/eiquadprog-rt.hxx
include/${PROJECT_NAME}/eiquadprog-utils.hxx
include/${PROJECT_NAME}/eiquadprog-utils.hxx
)

ADD_LIBRARY(${PROJECT_NAME} SHARED
src/eiquadprog-fast.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 INTERFACE ${EIGEN3_INCLUDE_DIR})
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} INTERFACE $<INSTALL_INTERFACE:include>)
Expand Down
1 change: 0 additions & 1 deletion src/eiquadprog-fast.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <iostream>

#include "eiquadprog/eiquadprog-fast.hpp"
#define TRACE_SOLVER

namespace eiquadprog {
namespace solvers {
Expand Down
12 changes: 6 additions & 6 deletions src/eiquadprog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ double solve_quadprog2(LLT<MatrixXd, Lower>& chol, double c1, VectorXd& g0, cons
print_vector("r", r, iq + 1);
print_vector("u", u, iq + 1);
print_vector("d", d, n);
print_ivector("A", A, iq + 1);
print_vector("A", A, iq + 1);
#endif

/* Step 2b: compute step length */
Expand Down Expand Up @@ -240,7 +240,7 @@ double solve_quadprog2(LLT<MatrixXd, Lower>& chol, double c1, VectorXd& g0, cons
std::cerr << " in dual space: " << f_value << std::endl;
print_vector("x", x, n);
print_vector("z", z, n);
print_ivector("A", A, iq + 1);
print_vector("A", A, iq + 1);
#endif
goto l2a;
}
Expand All @@ -258,7 +258,7 @@ double solve_quadprog2(LLT<MatrixXd, Lower>& chol, double c1, VectorXd& g0, cons
print_vector("x", x, n);
print_vector("u", u, iq + 1);
print_vector("r", r, iq + 1);
print_ivector("A", A, iq + 1);
print_vector("A", A, iq + 1);
#endif

if (t == t2) {
Expand All @@ -273,7 +273,7 @@ double solve_quadprog2(LLT<MatrixXd, Lower>& chol, double c1, VectorXd& g0, cons
delete_constraint(R, J, A, u, p, iq, ip);
#ifdef TRACE_SOLVER
print_matrix("R", R, n);
print_ivector("A", A, iq);
print_vector("A", A, iq);
#endif
for (i = 0; i < m; i++) iai(i) = static_cast<VectorXi::Scalar>(i);
for (i = 0; i < iq; i++) {
Expand All @@ -287,7 +287,7 @@ double solve_quadprog2(LLT<MatrixXd, Lower>& chol, double c1, VectorXd& g0, cons
iai(ip) = -1;
#ifdef TRACE_SOLVER
print_matrix("R", R, n);
print_ivector("A", A, iq);
print_vector("A", A, iq);
#endif
goto l1;
}
Expand All @@ -302,7 +302,7 @@ double solve_quadprog2(LLT<MatrixXd, Lower>& chol, double c1, VectorXd& g0, cons
delete_constraint(R, J, A, u, p, iq, l);
#ifdef TRACE_SOLVER
print_matrix("R", R, n);
print_ivector("A", A, iq);
print_vector("A", A, iq);
#endif

s(ip) = CI.col(ip).dot(x) + ci0(ip);
Expand Down

0 comments on commit 6d790dc

Please sign in to comment.