Skip to content

Commit

Permalink
Fix warnings in nmpc_cgmres.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmurooka committed Dec 22, 2022
1 parent 88a5b64 commit 6de5cd7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
15 changes: 8 additions & 7 deletions nmpc_cgmres/tests/src/CartPoleProblem.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,14 @@ class CartPoleProblem : public nmpc_cgmres::CgmresProblem

if(ref_func_ == nullptr)
{
ref_func_ = [&](double t, Eigen::Ref<Eigen::VectorXd> ref) { ref.setZero(); };
ref_func_ = [&](double, // t
Eigen::Ref<Eigen::VectorXd> ref) { ref.setZero(); };
}
ref_.resize(dim_x_);
}

/** \brief Calculate the state equation. */
virtual void stateEquation(double t,
virtual void stateEquation(double, // t
const Eigen::Ref<const Eigen::VectorXd> & xvec,
const Eigen::Ref<const Eigen::VectorXd> & uvec,
Eigen::Ref<Eigen::VectorXd> dotxvec) override
Expand All @@ -72,7 +73,7 @@ class CartPoleProblem : public nmpc_cgmres::CgmresProblem
const double & m2 = state_eq_param_(1);
const double & l = state_eq_param_(2);

const double & x = xvec(0);
// const double & x = xvec(0);
const double & theta = xvec(1);
const double & dx = xvec(2);
const double & dtheta = xvec(3);
Expand Down Expand Up @@ -103,9 +104,9 @@ class CartPoleProblem : public nmpc_cgmres::CgmresProblem
const double & m2 = state_eq_param_(1);
const double & l = state_eq_param_(2);

const double & x = xvec(0);
// const double & x = xvec(0);
const double & theta = xvec(1);
const double & dx = xvec(2);
// const double & dx = xvec(2);
const double & dtheta = xvec(3);
const double & f = uvec(0);

Expand Down Expand Up @@ -151,7 +152,7 @@ class CartPoleProblem : public nmpc_cgmres::CgmresProblem
}

/** \brief Calculate \f$ \frac{\partial h}{\partial u} \f$. */
virtual void calcDhDu(double t,
virtual void calcDhDu(double, // t
const Eigen::Ref<const Eigen::VectorXd> & xvec,
const Eigen::Ref<const Eigen::VectorXd> & uvec,
const Eigen::Ref<const Eigen::VectorXd> & lmd,
Expand All @@ -161,7 +162,7 @@ class CartPoleProblem : public nmpc_cgmres::CgmresProblem
const double & m2 = state_eq_param_(1);
const double & l = state_eq_param_(2);

const double & x = xvec(0);
// const double & x = xvec(0);
const double & theta = xvec(1);
const double & f = uvec(0);
const double & r1 = obj_weight_(4);
Expand Down
8 changes: 4 additions & 4 deletions nmpc_cgmres/tests/src/SemiactiveDamperProblem.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class SemiactiveDamperProblem : public nmpc_cgmres::CgmresProblem
}

/** \brief Calculate the state equation. */
virtual void stateEquation(double t,
virtual void stateEquation(double, // t
const Eigen::Ref<const Eigen::VectorXd> & x,
const Eigen::Ref<const Eigen::VectorXd> & u,
Eigen::Ref<Eigen::VectorXd> dotx) override
Expand All @@ -48,7 +48,7 @@ class SemiactiveDamperProblem : public nmpc_cgmres::CgmresProblem
}

/** \brief Calculate the costate equation. */
virtual void costateEquation(double t,
virtual void costateEquation(double, // t
const Eigen::Ref<const Eigen::VectorXd> & lmd,
const Eigen::Ref<const Eigen::VectorXd> & xu,
Eigen::Ref<Eigen::VectorXd> dotlmd) override
Expand All @@ -67,7 +67,7 @@ class SemiactiveDamperProblem : public nmpc_cgmres::CgmresProblem
}

/** \brief Calculate \f$ \frac{\partial \phi}{\partial x} \f$. */
virtual void calcDphiDx(double t,
virtual void calcDphiDx(double, // t
const Eigen::Ref<const Eigen::VectorXd> & x,
Eigen::Ref<Eigen::VectorXd> DphiDx) override
{
Expand All @@ -80,7 +80,7 @@ class SemiactiveDamperProblem : public nmpc_cgmres::CgmresProblem
}

/** \brief Calculate \f$ \frac{\partial h}{\partial u} \f$. */
virtual void calcDhDu(double t,
virtual void calcDhDu(double, // t
const Eigen::Ref<const Eigen::VectorXd> & x,
const Eigen::Ref<const Eigen::VectorXd> & u,
const Eigen::Ref<const Eigen::VectorXd> & lmd,
Expand Down
23 changes: 13 additions & 10 deletions nmpc_cgmres/tests/src/TestGmres.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ class GmresLinearSolver : public LinearSolver
virtual void solve(const Eigen::MatrixXd & A,
const Eigen::VectorXd & b,
Eigen::Ref<Eigen::VectorXd> x,
double & tm,
double & err)
double &, // tm
double & // err
)
{
gmres_ = std::make_shared<nmpc_cgmres::Gmres>();
gmres_->make_triangular_ = make_triangular_;
Expand All @@ -43,8 +44,9 @@ class FullPivLuLinearSolver : public LinearSolver
virtual void solve(const Eigen::MatrixXd & A,
const Eigen::VectorXd & b,
Eigen::Ref<Eigen::VectorXd> x,
double & tm,
double & err)
double &, // tm
double & // err
)
{
x = A.fullPivLu().solve(b);
}
Expand All @@ -56,8 +58,9 @@ class HouseholderQrLinearSolver : public LinearSolver
virtual void solve(const Eigen::MatrixXd & A,
const Eigen::VectorXd & b,
Eigen::Ref<Eigen::VectorXd> x,
double & tm,
double & err)
double &, // tm
double & // err
)
{
x = A.householderQr().solve(b);
}
Expand All @@ -67,11 +70,11 @@ double eval(std::shared_ptr<LinearSolver> solver,
const std::vector<Eigen::MatrixXd> & A_list,
const std::vector<Eigen::VectorXd> & b_list)
{
int trial_num = A_list.size();
size_t trial_num = A_list.size();
double tm = 0;
double err = 0;

for(int i = 0; i < trial_num; i++)
for(size_t i = 0; i < trial_num; i++)
{
const Eigen::MatrixXd & A = A_list[i];
const Eigen::VectorXd & b = b_list[i];
Expand All @@ -85,8 +88,8 @@ double eval(std::shared_ptr<LinearSolver> solver,
err += (A * x - b).norm();
}

tm /= trial_num;
err /= trial_num;
tm /= static_cast<double>(trial_num);
err /= static_cast<double>(trial_num);
std::cout << "ave time: " << 1e3 * tm << " [msec], ave err: " << err << std::endl;

return err;
Expand Down

0 comments on commit 6de5cd7

Please sign in to comment.