Unverified Commit 85ae02cf authored by Guilhem Saurel's avatar Guilhem Saurel Committed by GitHub
Browse files

Merge pull request #25 from nim65s/devel

fix warning about conversion of unused parameters 
parents 9bfeb65d f6d519a1
Pipeline #18190 passed with stage
in 8 minutes and 28 seconds
......@@ -2,6 +2,7 @@
[![Pipeline status](https://gitlab.laas.fr/stack-of-tasks/eiquadprog/badges/master/pipeline.svg)](https://gitlab.laas.fr/stack-of-tasks/eiquadprog/commits/master)
[![Coverage report](https://gitlab.laas.fr/stack-of-tasks/eiquadprog/badges/master/coverage.svg?job=doc-coverage)](http://projects.laas.fr/gepetto/doc/stack-of-tasks/eiquadprog/master/coverage/)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/stack-of-tasks/eiquadprog/master.svg)](https://results.pre-commit.ci/latest/github/stack-of-tasks/eiquadprog/master)
This repo contains different C++ implementations of the algorithm of Goldfarb and Idnani for the solution of a (convex) Quadratic Programming problem by means of a dual method.
......
......@@ -245,7 +245,7 @@ RtEiquadprog_status RtEiquadprog<nVars, nEqCon, nIneqCon>::solve_quadprog(
c2 = m_J.trace();
#ifdef EIQGUADPROG_TRACE_SOLVER
utils::print_matrix("m_J", m_J, nVars);
utils::print_matrix("m_J", m_J);
#endif
/* c1 * c2 is an estimate for cond(Hess) */
......@@ -271,7 +271,7 @@ RtEiquadprog_status RtEiquadprog<nVars, nEqCon, nIneqCon>::solve_quadprog(
f_value = 0.5 * g0.dot(x);
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Unconstrained solution: " << f_value << std::endl;
utils::print_vector("x", x, nVars);
utils::print_vector("x", x);
#endif
STOP_PROFILER_EIQUADPROG_RT(PROFILE_EIQUADPROG_STEP_1_UNCONSTR_MINIM);
......@@ -288,10 +288,10 @@ RtEiquadprog_status RtEiquadprog<nVars, nEqCon, nIneqCon>::solve_quadprog(
update_r(R, r, d, iq);
#ifdef EIQGUADPROG_TRACE_SOLVER
utils::print_matrix("R", R, iq);
utils::print_vector("z", z, nVars);
utils::print_vector("r", r, iq);
utils::print_vector("d", d, nVars);
utils::print_matrix("R", R);
utils::print_vector("z", z);
utils::print_vector("r", r);
utils::print_vector("d", d);
#endif
/* compute full step length t2: i.e., the minimum step in primal space s.t.
......@@ -372,7 +372,7 @@ l1:
}
#ifdef EIQGUADPROG_TRACE_SOLVER
utils::print_vector("x", x, nVars);
utils::print_vector("x", x);
#endif
/* step 1: choose a violated constraint */
for (i = nEqCon; i < iq; i++) {
......@@ -400,7 +400,7 @@ l1:
#endif
STOP_PROFILER_EIQUADPROG_RT(PROFILE_EIQUADPROG_STEP_1_2);
#ifdef EIQGUADPROG_TRACE_SOLVER
utils::print_vector("s", s, nIneqCon);
utils::print_vector("s", s);
#endif
STOP_PROFILER_EIQUADPROG_RT(PROFILE_EIQUADPROG_STEP_1);
......@@ -447,7 +447,7 @@ l2: /* Step 2: check for feasibility and determine a new S-pair */
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Trying with constraint " << ip << std::endl;
utils::print_vector("np", np, nVars);
utils::print_vector("np", np);
#endif
STOP_PROFILER_EIQUADPROG_RT(PROFILE_EIQUADPROG_STEP_2);
......@@ -468,11 +468,11 @@ l2a: /* Step 2a: determine step direction */
update_r(R, r, d, iq);
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Step direction z" << std::endl;
utils::print_vector("z", z, nVars);
utils::print_vector("r", r, iq + 1);
utils::print_vector("u", u, iq + 1);
utils::print_vector("d", d, nVars);
utils::print_vector("A", A, iq + 1);
utils::print_vector("z", z);
utils::print_vector("r", r);
utils::print_vector("u", u);
utils::print_vector("d", d);
utils::print_vector("A", A);
#endif
STOP_PROFILER_EIQUADPROG_RT(PROFILE_EIQUADPROG_STEP_2A);
......@@ -525,9 +525,9 @@ l2a: /* Step 2a: determine step direction */
delete_constraint(R, m_J, A, u, iq, l);
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << " in dual space: " << f_value << std::endl;
utils::print_vector("x", x, nVars);
utils::print_vector("z", z, nVars);
utils::print_vector("A", A, iq + 1);
utils::print_vector("x", x);
utils::print_vector("z", z);
utils::print_vector("A", A);
#endif
STOP_PROFILER_EIQUADPROG_RT(PROFILE_EIQUADPROG_STEP_2C);
goto l2a;
......@@ -543,16 +543,16 @@ l2a: /* Step 2a: determine step direction */
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << " in both spaces: " << f_value << std::endl;
utils::print_vector("x", x, nVars);
utils::print_vector("u", u, iq + 1);
utils::print_vector("r", r, iq + 1);
utils::print_vector("A", A, iq + 1);
utils::print_vector("x", x);
utils::print_vector("u", u);
utils::print_vector("r", r);
utils::print_vector("A", A);
#endif
if (t == t2) {
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Full step has taken " << t << std::endl;
utils::print_vector("x", x, nVars);
utils::print_vector("x", x);
#endif
/* full step has taken */
/* add constraint ip to the active set*/
......@@ -560,8 +560,8 @@ l2a: /* Step 2a: determine step direction */
iaexcl(ip) = 0;
delete_constraint(R, m_J, A, u, iq, ip);
#ifdef EIQGUADPROG_TRACE_SOLVER
utils::print_matrix("R", R, nVars);
utils::print_vector("A", A, iq);
utils::print_matrix("R", R);
utils::print_vector("A", A);
#endif
for (i = 0; i < nIneqCon; i++) iai(i) = i;
for (i = 0; i < iq; i++) {
......@@ -575,8 +575,8 @@ l2a: /* Step 2a: determine step direction */
} else
iai(ip) = -1;
#ifdef EIQGUADPROG_TRACE_SOLVER
utils::print_matrix("R", R, nVars);
utils::print_vector("A", A, iq);
utils::print_matrix("R", R);
utils::print_vector("A", A);
#endif
STOP_PROFILER_EIQUADPROG_RT(PROFILE_EIQUADPROG_STEP_2C);
goto l1;
......@@ -591,10 +591,10 @@ l2a: /* Step 2a: determine step direction */
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Partial step has taken " << t << std::endl;
utils::print_vector("x", x, nVars);
utils::print_matrix("R", R, nVars);
utils::print_vector("A", A, iq);
utils::print_vector("s", s, nIneqCon);
utils::print_vector("x", x);
utils::print_matrix("R", R);
utils::print_vector("A", A);
utils::print_vector("s", s);
#endif
STOP_PROFILER_EIQUADPROG_RT(PROFILE_EIQUADPROG_STEP_2C);
......
......@@ -24,14 +24,23 @@ inline Scalar distance(Scalar a, Scalar b) {
}
template <class Derived>
void print_vector(const char *name, Eigen::MatrixBase<Derived> &x, int /*n*/) {
void print_vector(const char *name, Eigen::MatrixBase<Derived> &x) {
std::cerr << name << x.transpose() << std::endl;
}
template <class Derived>
void print_matrix(const char *name, Eigen::MatrixBase<Derived> &x, int /*n*/) {
void print_matrix(const char *name, Eigen::MatrixBase<Derived> &x) {
std::cerr << name << std::endl << x << std::endl;
}
template <class Derived>
void print_vector(const char *name, Eigen::MatrixBase<Derived> &x, int /*n*/) {
print_vector(name, x);
}
template <class Derived>
void print_matrix(const char *name, Eigen::MatrixBase<Derived> &x, int /*n*/) {
print_matrix(name, x);
}
} // namespace utils
} // namespace eiquadprog
......
......@@ -255,7 +255,7 @@ EiquadprogFast_status EiquadprogFast::solve_quadprog(
c2 = m_J.trace();
#ifdef EIQGUADPROG_TRACE_SOLVER
utils::print_matrix("m_J", m_J, nVars);
utils::print_matrix("m_J", m_J);
#endif
/* c1 * c2 is an estimate for cond(Hess) */
......@@ -283,7 +283,7 @@ EiquadprogFast_status EiquadprogFast::solve_quadprog(
f_value = 0.5 * g0.dot(x);
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Unconstrained solution: " << f_value << std::endl;
utils::print_vector("x", x, nVars);
utils::print_vector("x", x);
#endif
STOP_PROFILER_EIQUADPROG_FAST(EIQUADPROG_FAST_STEP_1_UNCONSTR_MINIM);
......@@ -299,10 +299,10 @@ EiquadprogFast_status EiquadprogFast::solve_quadprog(
update_r(R, r, d, iq);
#ifdef EIQGUADPROG_TRACE_SOLVER
utils::print_matrix("R", R, iq);
utils::print_vector("z", z, nVars);
utils::print_vector("r", r, iq);
utils::print_vector("d", d, nVars);
utils::print_matrix("R", R);
utils::print_vector("z", z);
utils::print_vector("r", r);
utils::print_vector("d", d);
#endif
/* compute full step length t2: i.e.,
......@@ -386,7 +386,7 @@ l1:
START_PROFILER_EIQUADPROG_FAST(EIQUADPROG_FAST_STEP_1);
#ifdef EIQGUADPROG_TRACE_SOLVER
utils::print_vector("x", x, nVars);
utils::print_vector("x", x);
#endif
/* step 1: choose a violated constraint */
for (i = nEqCon; i < iq; i++) {
......@@ -414,7 +414,7 @@ l1:
#endif
STOP_PROFILER_EIQUADPROG_FAST(EIQUADPROG_FAST_STEP_1_2);
#ifdef EIQGUADPROG_TRACE_SOLVER
utils::print_vector("s", s, nIneqCon);
utils::print_vector("s", s);
#endif
STOP_PROFILER_EIQUADPROG_FAST(EIQUADPROG_FAST_STEP_1);
......@@ -461,7 +461,7 @@ l2: /* Step 2: check for feasibility and determine a new S-pair */
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Trying with constraint " << ip << std::endl;
utils::print_vector("np", np, nVars);
utils::print_vector("np", np);
#endif
STOP_PROFILER_EIQUADPROG_FAST(EIQUADPROG_FAST_STEP_2);
......@@ -482,11 +482,11 @@ l2a: /* Step 2a: determine step direction */
update_r(R, r, d, iq);
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Step direction z" << std::endl;
utils::print_vector("z", z, nVars);
utils::print_vector("r", r, iq + 1);
utils::print_vector("u", u, iq + 1);
utils::print_vector("d", d, nVars);
utils::print_vector("A", A, iq + 1);
utils::print_vector("z", z);
utils::print_vector("r", r);
utils::print_vector("u", u);
utils::print_vector("d", d);
utils::print_vector("A", A);
#endif
STOP_PROFILER_EIQUADPROG_FAST(EIQUADPROG_FAST_STEP_2A);
......@@ -539,9 +539,9 @@ l2a: /* Step 2a: determine step direction */
delete_constraint(R, m_J, A, u, nEqCon, iq, l);
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << " in dual space: " << f_value << std::endl;
utils::print_vector("x", x, nVars);
utils::print_vector("z", z, nVars);
utils::print_vector("A", A, iq + 1);
utils::print_vector("x", x);
utils::print_vector("z", z);
utils::print_vector("A", A);
#endif
STOP_PROFILER_EIQUADPROG_FAST(EIQUADPROG_FAST_STEP_2C);
goto l2a;
......@@ -557,16 +557,16 @@ l2a: /* Step 2a: determine step direction */
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << " in both spaces: " << f_value << std::endl;
utils::print_vector("x", x, nVars);
utils::print_vector("u", u, iq + 1);
utils::print_vector("r", r, iq + 1);
utils::print_vector("A", A, iq + 1);
utils::print_vector("x", x);
utils::print_vector("u", u);
utils::print_vector("r", r);
utils::print_vector("A", A);
#endif
if (t == t2) {
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Full step has taken " << t << std::endl;
utils::print_vector("x", x, nVars);
utils::print_vector("x", x);
#endif
/* full step has taken */
/* add constraint ip to the active set*/
......@@ -574,8 +574,8 @@ l2a: /* Step 2a: determine step direction */
iaexcl(ip) = 0;
delete_constraint(R, m_J, A, u, nEqCon, iq, ip);
#ifdef EIQGUADPROG_TRACE_SOLVER
utils::print_matrix("R", R, nVars);
utils::print_vector("A", A, iq);
utils::print_matrix("R", R);
utils::print_vector("A", A);
#endif
for (i = 0; i < nIneqCon; i++) iai(i) = static_cast<VectorXi::Scalar>(i);
for (i = 0; i < iq; i++) {
......@@ -589,8 +589,8 @@ l2a: /* Step 2a: determine step direction */
} else
iai(ip) = -1;
#ifdef EIQGUADPROG_TRACE_SOLVER
utils::print_matrix("R", R, nVars);
utils::print_vector("A", A, iq);
utils::print_matrix("R", R);
utils::print_vector("A", A);
#endif
STOP_PROFILER_EIQUADPROG_FAST(EIQUADPROG_FAST_STEP_2C);
goto l1;
......@@ -603,10 +603,10 @@ l2a: /* Step 2a: determine step direction */
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Partial step has taken " << t << std::endl;
utils::print_vector("x", x, nVars);
utils::print_matrix("R", R, nVars);
utils::print_vector("A", A, iq);
utils::print_vector("s", s, nIneqCon);
utils::print_vector("x", x);
utils::print_matrix("R", R);
utils::print_vector("A", A);
utils::print_vector("s", s);
#endif
STOP_PROFILER_EIQUADPROG_FAST(EIQUADPROG_FAST_STEP_2C);
......
......@@ -98,7 +98,7 @@ double solve_quadprog(LLT<MatrixXd, Lower> &chol, double c1, VectorXd &g0,
chol.matrixU().solveInPlace(J);
c2 = J.trace();
#ifdef EIQGUADPROG_TRACE_SOLVER
utils::print_matrix("J", J, n);
utils::print_matrix("J", J);
#endif
/* c1 * c2 is an estimate for cond(G) */
......@@ -114,7 +114,7 @@ double solve_quadprog(LLT<MatrixXd, Lower> &chol, double c1, VectorXd &g0,
f_value = 0.5 * g0.dot(x);
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Unconstrained solution: " << f_value << std::endl;
utils::print_vector("x", x, n);
utils::print_vector("x", x);
#endif
/* Add equality constraints to the working set A */
......@@ -125,10 +125,10 @@ double solve_quadprog(LLT<MatrixXd, Lower> &chol, double c1, VectorXd &g0,
update_z(z, J, d, iq);
update_r(R, r, d, iq);
#ifdef EIQGUADPROG_TRACE_SOLVER
utils::print_matrix("R", R, iq);
utils::print_vector("z", z, n);
utils::print_vector("r", r, iq);
utils::print_vector("d", d, n);
utils::print_matrix("R", R);
utils::print_vector("z", z);
utils::print_vector("r", r);
utils::print_vector("d", d);
#endif
/* compute full step length t2: i.e., the minimum step in primal space s.t.
......@@ -161,7 +161,7 @@ double solve_quadprog(LLT<MatrixXd, Lower> &chol, double c1, VectorXd &g0,
l1:
iter++;
#ifdef EIQGUADPROG_TRACE_SOLVER
utils::print_vector("x", x, n);
utils::print_vector("x", x);
#endif
/* step 1: choose a violated constraint */
for (i = me; i < iq; i++) {
......@@ -180,7 +180,7 @@ l1:
psi += std::min(0.0, sum);
}
#ifdef EIQGUADPROG_TRACE_SOLVER
utils::print_vector("s", s, mi);
utils::print_vector("s", s);
#endif
if (std::abs(psi) <= static_cast<double>(mi) *
......@@ -217,7 +217,7 @@ l2: /* Step 2: check for feasibility and determine a new S-pair */
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Trying with constraint " << ip << std::endl;
utils::print_vector("np", np, n);
utils::print_vector("np", np);
#endif
l2a: /* Step 2a: determine step direction */
......@@ -230,11 +230,11 @@ l2a: /* Step 2a: determine step direction */
update_r(R, r, d, iq);
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Step direction z" << std::endl;
utils::print_vector("z", z, n);
utils::print_vector("r", r, iq + 1);
utils::print_vector("u", u, iq + 1);
utils::print_vector("d", d, n);
utils::print_vector("A", A, iq + 1);
utils::print_vector("z", z);
utils::print_vector("r", r);
utils::print_vector("u", u);
utils::print_vector("d", d);
utils::print_vector("A", A);
#endif
/* Step 2b: compute step length */
......@@ -283,9 +283,9 @@ l2a: /* Step 2a: determine step direction */
delete_constraint(R, J, A, u, p, iq, l);
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << " in dual space: " << f_value << std::endl;
utils::print_vector("x", x, n);
utils::print_vector("z", z, n);
utils::print_vector("A", A, iq + 1);
utils::print_vector("x", x);
utils::print_vector("z", z);
utils::print_vector("A", A);
#endif
goto l2a;
}
......@@ -300,16 +300,16 @@ l2a: /* Step 2a: determine step direction */
u(iq) += t;
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << " in both spaces: " << f_value << std::endl;
utils::print_vector("x", x, n);
utils::print_vector("u", u, iq + 1);
utils::print_vector("r", r, iq + 1);
utils::print_vector("A", A, iq + 1);
utils::print_vector("x", x);
utils::print_vector("u", u);
utils::print_vector("r", r);
utils::print_vector("A", A);
#endif
if (t == t2) {
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Full step has taken " << t << std::endl;
utils::print_vector("x", x, n);
utils::print_vector("x", x);
#endif
/* full step has taken */
/* add constraint ip to the active set*/
......@@ -317,8 +317,8 @@ l2a: /* Step 2a: determine step direction */
iaexcl(ip) = 0;
delete_constraint(R, J, A, u, p, iq, ip);
#ifdef EIQGUADPROG_TRACE_SOLVER
utils::print_matrix("R", R, n);
utils::print_vector("A", A, iq);
utils::print_matrix("R", R);
utils::print_vector("A", A);
#endif
for (i = 0; i < m; i++) iai(i) = static_cast<VectorXi::Scalar>(i);
for (i = 0; i < iq; i++) {
......@@ -331,8 +331,8 @@ l2a: /* Step 2a: determine step direction */
} else
iai(ip) = -1;
#ifdef EIQGUADPROG_TRACE_SOLVER
utils::print_matrix("R", R, n);
utils::print_vector("A", A, iq);
utils::print_matrix("R", R);
utils::print_vector("A", A);
#endif
goto l1;
}
......@@ -340,20 +340,20 @@ l2a: /* Step 2a: determine step direction */
/* a patial step has taken */
#ifdef EIQGUADPROG_TRACE_SOLVER
std::cerr << "Partial step has taken " << t << std::endl;
utils::print_vector("x", x, n);
utils::print_vector("x", x);
#endif
/* drop constraint l */
iai(l) = static_cast<VectorXi::Scalar>(l);
delete_constraint(R, J, A, u, p, iq, l);
#ifdef EIQGUADPROG_TRACE_SOLVER
utils::print_matrix("R", R, n);
utils::print_vector("A", A, iq);
utils::print_matrix("R", R);
utils::print_vector("A", A);
#endif
s(ip) = CI.col(ip).dot(x) + ci0(ip);
#ifdef EIQGUADPROG_TRACE_SOLVER
utils::print_vector("s", s, mi);
utils::print_vector("s", s);
#endif
goto l2a;
}
......
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