Verified Commit f4414ffb authored by Justin Carpentier's avatar Justin Carpentier
Browse files

core: rename macro variable

parent ccb3f9ed
Pipeline #17926 failed with stage
in 9 minutes and 11 seconds
......@@ -63,8 +63,8 @@ ADD_LIBRARY(${PROJECT_NAME} SHARED
)
IF(TRACE_SOLVER)
TARGET_COMPILE_DEFINITIONS(${PROJECT_NAME} PRIVATE TRACE_SOLVER)
ENDIF(TRACE_SOLVER)
TARGET_COMPILE_DEFINITIONS(${PROJECT_NAME} PRIVATE EIQGUADPROG_TRACE_SOLVER)
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} SYSTEM PUBLIC ${EIGEN3_INCLUDE_DIR})
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} INTERFACE $<INSTALL_INTERFACE:include>)
......
......@@ -41,7 +41,7 @@ bool RtEiquadprog<nVars, nEqCon, nIneqCon>::add_constraint(typename RtMatrixX<nV
typename RtMatrixX<nVars, nVars>::d& J,
typename RtVectorX<nVars>::d& d, int& iq, double& R_norm) {
// int n=J.rows();
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Add constraint " << iq << '/';
#endif
int j, k;
......@@ -102,7 +102,7 @@ bool RtEiquadprog<nVars, nEqCon, nIneqCon>::add_constraint(typename RtMatrixX<nV
into column iq - 1 of R
*/
R.col(iq - 1).head(iq) = d.head(iq);
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << iq << std::endl;
#endif
......@@ -120,7 +120,7 @@ void RtEiquadprog<nVars, nEqCon, nIneqCon>::delete_constraint(typename RtMatrixX
typename RtVectorX<nIneqCon + nEqCon>::d& u, int& iq,
int l) {
// int n = J.rows();
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Delete constraint " << l << ' ' << iq;
#endif
int i, j, k;
......@@ -148,7 +148,7 @@ void RtEiquadprog<nVars, nEqCon, nIneqCon>::delete_constraint(typename RtMatrixX
for (j = 0; j < iq; j++) R(j, iq - 1) = 0.0;
/* constraint has been fully removed */
iq--;
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << '/' << iq << std::endl;
#endif
......@@ -238,7 +238,7 @@ RtEiquadprog_status RtEiquadprog<nVars, nEqCon, nIneqCon>::solve_quadprog(
}
c2 = m_J.trace();
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
print_matrix("m_J", m_J, nVars);
#endif
......@@ -264,7 +264,7 @@ RtEiquadprog_status RtEiquadprog<nVars, nEqCon, nIneqCon>::solve_quadprog(
#endif
/* and compute the current solution value */
f_value = 0.5 * g0.dot(x);
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Unconstrained solution: " << f_value << std::endl;
print_vector("x", x, nVars);
#endif
......@@ -282,7 +282,7 @@ RtEiquadprog_status RtEiquadprog<nVars, nEqCon, nIneqCon>::solve_quadprog(
update_z(z, m_J, d, iq);
update_r(R, r, d, iq);
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
print_matrix("R", R, iq);
print_vector("z", z, nVars);
print_vector("r", r, iq);
......@@ -363,7 +363,7 @@ l1:
return RT_EIQUADPROG_MAX_ITER_REACHED;
}
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
print_vector("x", x, nVars);
#endif
/* step 1: choose a violated constraint */
......@@ -391,7 +391,7 @@ l1:
}
#endif
STOP_PROFILER_EIQUADPROG_RT(PROFILE_EIQUADPROG_STEP_1_2);
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
print_vector("s", s, nIneqCon);
#endif
......@@ -434,7 +434,7 @@ l2: /* Step 2: check for feasibility and determine a new S-pair */
// DEBUG_STREAM("Add constraint "<<ip<<" to active set\n")
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Trying with constraint " << ip << std::endl;
print_vector("np", np, nVars);
#endif
......@@ -453,7 +453,7 @@ l2a: /* Step 2a: determine step direction */
}
/* compute N* np (if q > 0): the negative of the step direction in the dual space */
update_r(R, r, d, iq);
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Step direction z" << std::endl;
print_vector("z", z, nVars);
print_vector("r", r, iq + 1);
......@@ -485,7 +485,7 @@ l2a: /* Step 2a: determine step direction */
/* the step is chosen as the minimum of t1 and t2 */
t = std::min(t1, t2);
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Step sizes: " << t << " (t1 = " << t1 << ", t2 = " << t2 << ") ";
#endif
STOP_PROFILER_EIQUADPROG_RT(PROFILE_EIQUADPROG_STEP_2B);
......@@ -506,7 +506,7 @@ l2a: /* Step 2a: determine step direction */
u(iq) += t;
iai(l) = l;
delete_constraint(R, m_J, A, u, iq, l);
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << " in dual space: " << f_value << std::endl;
print_vector("x", x, nVars);
print_vector("z", z, nVars);
......@@ -524,7 +524,7 @@ l2a: /* Step 2a: determine step direction */
u.head(iq) -= t * r.head(iq);
u(iq) += t;
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << " in both spaces: " << f_value << std::endl;
print_vector("x", x, nVars);
print_vector("u", u, iq + 1);
......@@ -533,7 +533,7 @@ l2a: /* Step 2a: determine step direction */
#endif
if (t == t2) {
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Full step has taken " << t << std::endl;
print_vector("x", x, nVars);
#endif
......@@ -542,7 +542,7 @@ l2a: /* Step 2a: determine step direction */
if (!add_constraint(R, m_J, d, iq, R_norm)) {
iaexcl(ip) = 0;
delete_constraint(R, m_J, A, u, iq, ip);
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
print_matrix("R", R, nVars);
print_vector("A", A, iq);
#endif
......@@ -557,7 +557,7 @@ l2a: /* Step 2a: determine step direction */
goto l2; /* go to step 2 */
} else
iai(ip) = -1;
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
print_matrix("R", R, nVars);
print_vector("A", A, iq);
#endif
......@@ -572,7 +572,7 @@ l2a: /* Step 2a: determine step direction */
s(ip) = ci0(ip);
for (int tmp = 0; tmp < nVars; tmp++) s(ip) += CI(ip, tmp) * x[tmp];
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Partial step has taken " << t << std::endl;
print_vector("x", x, nVars);
print_matrix("R", R, nVars);
......
......@@ -21,11 +21,11 @@ inline Scalar distance(Scalar a, Scalar b) {
template <class Derived>
void print_vector(const char* name, Eigen::MatrixBase<Derived>& x, int n) {
// std::cerr << name << x.transpose() << std::endl;
std::cerr << name << x.transpose() << std::endl;
}
template <class Derived>
void print_matrix(const char* name, Eigen::MatrixBase<Derived>& x, int n) {
// std::cerr << name << std::endl << x << std::endl;
std::cerr << name << std::endl << x << std::endl;
}
#endif
......@@ -44,7 +44,7 @@ void EiquadprogFast::reset(size_t nVars, size_t nEqCon, size_t nIneqCon) {
bool EiquadprogFast::add_constraint(MatrixXd& R, MatrixXd& J, VectorXd& d, size_t& iq, double& R_norm) {
size_t nVars = J.rows();
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Add constraint " << iq << '/';
#endif
size_t j, k;
......@@ -105,7 +105,7 @@ bool EiquadprogFast::add_constraint(MatrixXd& R, MatrixXd& J, VectorXd& d, size_
into column iq - 1 of R
*/
R.col(iq - 1).head(iq) = d.head(iq);
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << iq << std::endl;
#endif
......@@ -119,7 +119,7 @@ into column iq - 1 of R
void EiquadprogFast::delete_constraint(MatrixXd& R, MatrixXd& J, VectorXi& A, VectorXd& u, size_t nEqCon, size_t& iq,
size_t l) {
size_t nVars = R.rows();
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Delete constraint " << l << ' ' << iq;
#endif
size_t i, j, k;
......@@ -147,7 +147,7 @@ void EiquadprogFast::delete_constraint(MatrixXd& R, MatrixXd& J, VectorXi& A, Ve
for (j = 0; j < iq; j++) R(j, iq - 1) = 0.0;
/* constraint has been fully removed */
iq--;
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << '/' << iq << std::endl;
#endif
......@@ -248,7 +248,7 @@ EiquadprogFast_status EiquadprogFast::solve_quadprog(const MatrixXd& Hess, const
}
c2 = m_J.trace();
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
print_matrix("m_J", m_J, nVars);
#endif
......@@ -275,7 +275,7 @@ EiquadprogFast_status EiquadprogFast::solve_quadprog(const MatrixXd& Hess, const
#endif
/* and compute the current solution value */
f_value = 0.5 * g0.dot(x);
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Unconstrained solution: " << f_value << std::endl;
print_vector("x", x, nVars);
#endif
......@@ -292,7 +292,7 @@ EiquadprogFast_status EiquadprogFast::solve_quadprog(const MatrixXd& Hess, const
update_z(z, m_J, d, iq);
update_r(R, r, d, iq);
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
print_matrix("R", R, iq);
print_vector("z", z, nVars);
print_vector("r", r, iq);
......@@ -378,7 +378,7 @@ l1:
START_PROFILER_EIQUADPROG_FAST(EIQUADPROG_FAST_STEP_1);
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
print_vector("x", x, nVars);
#endif
/* step 1: choose a violated constraint */
......@@ -406,7 +406,7 @@ l1:
}
#endif
STOP_PROFILER_EIQUADPROG_FAST(EIQUADPROG_FAST_STEP_1_2);
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
print_vector("s", s, nIneqCon);
#endif
......@@ -450,7 +450,7 @@ l2: /* Step 2: check for feasibility and determine a new S-pair */
// DEBUG_STREAM("Add constraint "<<ip<<" to active set\n")
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Trying with constraint " << ip << std::endl;
print_vector("np", np, nVars);
#endif
......@@ -471,7 +471,7 @@ l2a: /* Step 2a: determine step direction */
/* compute N* np (if q > 0): the negative of the
step direction in the dual space */
update_r(R, r, d, iq);
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Step direction z" << std::endl;
print_vector("z", z, nVars);
print_vector("r", r, iq + 1);
......@@ -506,7 +506,7 @@ l2a: /* Step 2a: determine step direction */
/* the step is chosen as the minimum of t1 and t2 */
t = std::min(t1, t2);
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Step sizes: " << t << " (t1 = " << t1 << ", t2 = " << t2 << ") ";
#endif
STOP_PROFILER_EIQUADPROG_FAST(EIQUADPROG_FAST_STEP_2B);
......@@ -527,7 +527,7 @@ l2a: /* Step 2a: determine step direction */
u(iq) += t;
iai(l) = static_cast<VectorXi::Scalar>(l);
delete_constraint(R, m_J, A, u, nEqCon, iq, l);
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << " in dual space: " << f_value << std::endl;
print_vector("x", x, nVars);
print_vector("z", z, nVars);
......@@ -545,7 +545,7 @@ l2a: /* Step 2a: determine step direction */
u.head(iq) -= t * r.head(iq);
u(iq) += t;
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << " in both spaces: " << f_value << std::endl;
print_vector("x", x, nVars);
print_vector("u", u, iq + 1);
......@@ -554,7 +554,7 @@ l2a: /* Step 2a: determine step direction */
#endif
if (t == t2) {
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Full step has taken " << t << std::endl;
print_vector("x", x, nVars);
#endif
......@@ -563,7 +563,7 @@ l2a: /* Step 2a: determine step direction */
if (!add_constraint(R, m_J, d, iq, R_norm)) {
iaexcl(ip) = 0;
delete_constraint(R, m_J, A, u, nEqCon, iq, ip);
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
print_matrix("R", R, nVars);
print_vector("A", A, iq);
#endif
......@@ -578,7 +578,7 @@ l2a: /* Step 2a: determine step direction */
goto l2; /* go to step 2 */
} else
iai(ip) = -1;
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
print_matrix("R", R, nVars);
print_vector("A", A, iq);
#endif
......@@ -591,7 +591,7 @@ l2a: /* Step 2a: determine step direction */
delete_constraint(R, m_J, A, u, nEqCon, iq, l);
s(ip) = CI.row(ip).dot(x) + ci0(ip);
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Partial step has taken " << t << std::endl;
print_vector("x", x, nVars);
print_matrix("R", R, nVars);
......
......@@ -84,7 +84,7 @@ double solve_quadprog(LLT<MatrixXd, Lower>& chol, double c1, VectorXd& g0, const
J.setIdentity();
chol.matrixU().solveInPlace(J);
c2 = J.trace();
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
print_matrix("J", J, n);
#endif
......@@ -99,7 +99,7 @@ double solve_quadprog(LLT<MatrixXd, Lower>& chol, double c1, VectorXd& g0, const
chol.solveInPlace(x);
/* and compute the current solution value */
f_value = 0.5 * g0.dot(x);
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Unconstrained solution: " << f_value << std::endl;
print_vector("x", x, n);
#endif
......@@ -111,7 +111,7 @@ double solve_quadprog(LLT<MatrixXd, Lower>& chol, double c1, VectorXd& g0, const
compute_d(d, J, np);
update_z(z, J, d, iq);
update_r(R, r, d, iq);
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
print_matrix("R", R, iq);
print_vector("z", z, n);
print_vector("r", r, iq);
......@@ -147,7 +147,7 @@ double solve_quadprog(LLT<MatrixXd, Lower>& chol, double c1, VectorXd& g0, const
l1:
iter++;
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
print_vector("x", x, n);
#endif
/* step 1: choose a violated constraint */
......@@ -166,7 +166,7 @@ l1:
s(i) = sum;
psi += std::min(0.0, sum);
}
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
print_vector("s", s, mi);
#endif
......@@ -200,7 +200,7 @@ l2: /* Step 2: check for feasibility and determine a new S-pair */
/* add ip to the active set A */
A(iq) = static_cast<VectorXi::Scalar>(ip);
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Trying with constraint " << ip << std::endl;
print_vector("np", np, n);
#endif
......@@ -211,7 +211,7 @@ l2a: /* Step 2a: determine step direction */
update_z(z, J, d, iq);
/* compute N* np (if q > 0): the negative of the step direction in the dual space */
update_r(R, r, d, iq);
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Step direction z" << std::endl;
print_vector("z", z, n);
print_vector("r", r, iq + 1);
......@@ -240,7 +240,7 @@ l2a: /* Step 2a: determine step direction */
/* the step is chosen as the minimum of t1 and t2 */
t = std::min(t1, t2);
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Step sizes: " << t << " (t1 = " << t1 << ", t2 = " << t2 << ") ";
#endif
......@@ -260,7 +260,7 @@ l2a: /* Step 2a: determine step direction */
u(iq) += t;
iai(l) = static_cast<VectorXi::Scalar>(l);
delete_constraint(R, J, A, u, p, iq, l);
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << " in dual space: " << f_value << std::endl;
print_vector("x", x, n);
print_vector("z", z, n);
......@@ -277,7 +277,7 @@ l2a: /* Step 2a: determine step direction */
u.head(iq) -= t * r.head(iq);
u(iq) += t;
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << " in both spaces: " << f_value << std::endl;
print_vector("x", x, n);
print_vector("u", u, iq + 1);
......@@ -286,7 +286,7 @@ l2a: /* Step 2a: determine step direction */
#endif
if (t == t2) {
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Full step has taken " << t << std::endl;
print_vector("x", x, n);
#endif
......@@ -295,7 +295,7 @@ l2a: /* Step 2a: determine step direction */
if (!add_constraint(R, J, d, iq, R_norm)) {
iaexcl(ip) = 0;
delete_constraint(R, J, A, u, p, iq, ip);
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
print_matrix("R", R, n);
print_vector("A", A, iq);
#endif
......@@ -309,7 +309,7 @@ l2a: /* Step 2a: determine step direction */
goto l2; /* go to step 2 */
} else
iai(ip) = -1;
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
print_matrix("R", R, n);
print_vector("A", A, iq);
#endif
......@@ -317,21 +317,21 @@ l2a: /* Step 2a: determine step direction */
}
/* a patial step has taken */
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Partial step has taken " << t << std::endl;
print_vector("x", x, n);
#endif
/* drop constraint l */
iai(l) = static_cast<VectorXi::Scalar>(l);
delete_constraint(R, J, A, u, p, iq, l);
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
print_matrix("R", R, n);
print_vector("A", A, iq);
#endif
s(ip) = CI.col(ip).dot(x) + ci0(ip);
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
print_vector("s", s, mi);
#endif
goto l2a;
......@@ -339,7 +339,7 @@ l2a: /* Step 2a: determine step direction */
bool add_constraint(MatrixXd& R, MatrixXd& J, VectorXd& d, size_t& iq, double& R_norm) {
size_t n = J.rows();
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Add constraint " << iq << '/';
#endif
size_t j, k;
......@@ -385,7 +385,7 @@ bool add_constraint(MatrixXd& R, MatrixXd& J, VectorXd& d, size_t& iq, double& R
into column iq - 1 of R
*/
R.col(iq - 1).head(iq) = d.head(iq);
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << iq << std::endl;
#endif
......@@ -398,7 +398,7 @@ bool add_constraint(MatrixXd& R, MatrixXd& J, VectorXd& d, size_t& iq, double& R
void delete_constraint(MatrixXd& R, MatrixXd& J, VectorXi& A, VectorXd& u, size_t p, size_t& iq, size_t l) {
size_t n = R.rows();
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Delete constraint " << l << ' ' << iq;
#endif
size_t i, j, k, qq = 0;
......@@ -425,7 +425,7 @@ void delete_constraint(MatrixXd& R, MatrixXd& J, VectorXi& A, VectorXd& u, size_
for (j = 0; j < iq; j++) R(j, iq - 1) = 0.0;
/* constraint has been fully removed */
iq--;
#ifdef TRACE_SOLVER
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << '/' << iq << std::endl;
#endif
......
Supports Markdown
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