From 85928738340617fb09b2e55376b5848da747d4f5 Mon Sep 17 00:00:00 2001 From: Adrien Escande Date: Thu, 13 Jun 2024 17:26:16 +0200 Subject: [PATCH] [clang-format] --- include/jrl-qp/GoldfarbIdnaniSolver.h | 1 - include/jrl-qp/SolverOptions.h | 8 +++++--- src/GoldfarbIdnaniSolver.cpp | 3 +-- tests/OptionsTest.cpp | 27 ++++++++++++++------------- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/include/jrl-qp/GoldfarbIdnaniSolver.h b/include/jrl-qp/GoldfarbIdnaniSolver.h index a287b83..b586b98 100644 --- a/include/jrl-qp/GoldfarbIdnaniSolver.h +++ b/include/jrl-qp/GoldfarbIdnaniSolver.h @@ -32,7 +32,6 @@ class JRLQP_DLLAPI GoldfarbIdnaniSolver : public DualSolver const VectorConstRef & xl, const VectorConstRef & xu); - /** This is used to set the precomputed R factor in the QR decomposition of the initially * active constraints. Should be used when options.gFactorization is GFactorization::L_TINV_Q. * Use only if you know what you are doing. diff --git a/include/jrl-qp/SolverOptions.h b/include/jrl-qp/SolverOptions.h index 8fb7975..2d2e02c 100644 --- a/include/jrl-qp/SolverOptions.h +++ b/include/jrl-qp/SolverOptions.h @@ -22,7 +22,7 @@ enum class GFactorization /** G is given as the lower triangular matrix invL such that G^-1 = invL invL^T */ L_TINV, /** G is given as a matrix J = L^-T Q, where G = L L^T and Q is the orthonormal - matrix appearing in the QR decomposition of the activated constraints (see other + matrix appearing in the QR decomposition of the activated constraints (see other options for details). */ L_TINV_Q }; @@ -33,8 +33,10 @@ struct JRLQP_DLLAPI SolverOptions int maxIter_ = 500; double bigBnd_ = 1e100; bool warmStart_ = false; - bool equalityFirst_ = false; //True if all equality constraints are given first in the constraint matrix - bool RIsGiven_ = false; // True when the R factor in the decomposition of some initially active constraints is given. If equalityFirst is true, these are the equality constraints. Ignored if gFactorization != L_TINV_Q or equalityFirst_ = false. + bool equalityFirst_ = false; // True if all equality constraints are given first in the constraint matrix + bool RIsGiven_ = false; // True when the R factor in the decomposition of some initially active constraints is given. + // If equalityFirst is true, these are the equality constraints. Ignored if gFactorization != + // L_TINV_Q or equalityFirst_ = false. GFactorization gFactorization_ = GFactorization::NONE; std::uint32_t logFlags_ = 0; std::ostream * logStream_ = &defaultStream_; diff --git a/src/GoldfarbIdnaniSolver.cpp b/src/GoldfarbIdnaniSolver.cpp index c34ae36..51a6d63 100644 --- a/src/GoldfarbIdnaniSolver.cpp +++ b/src/GoldfarbIdnaniSolver.cpp @@ -69,14 +69,13 @@ internal::InitTermination GoldfarbIdnaniSolver::init_() JRLQP_LOG_COMMENT(log_, LogFlags::INPUT, "Incompatible options: RIsGiven with gFactorization or equalityFirst"); } - auto ret = (options_.gFactorization_ == GFactorization::NONE) ? Eigen::internal::llt_inplace::blocked(pb_.G) : -1; if(ret >= 0) return TerminationStatus::NON_POS_HESSIAN; - if (options_.equalityFirst()) + if(options_.equalityFirst()) { processInitialActiveSetWithEqualityOnly(); initializeComputationData(); diff --git a/tests/OptionsTest.cpp b/tests/OptionsTest.cpp index 93b6753..b00bede 100644 --- a/tests/OptionsTest.cpp +++ b/tests/OptionsTest.cpp @@ -61,7 +61,7 @@ TEST_CASE("Test EqualityFirst") auto pb = QPProblem(randomProblem(ProblemCharacteristics(7, 7, neq, 8))); pb.C.transposeInPlace(); - for (int i = 0; i < neq; ++i) + for(int i = 0; i < neq; ++i) { REQUIRE_EQ(pb.l[i], pb.u[i]); } @@ -86,20 +86,20 @@ TEST_CASE("Test EqualityFirst") solver.solve(L, pb.a, pb.C, pb.l, pb.u, pb.xl, pb.xu); Eigen::VectorXd x2 = solver.solution(); - //options.gFactorization(jrl::qp::GFactorization::L_INV); - //solver.options(options); - //solver.solve(invL, pb.a, pb.C, pb.l, pb.u, pb.xl, pb.xu); - //Eigen::VectorXd x3 = solver.solution(); + // options.gFactorization(jrl::qp::GFactorization::L_INV); + // solver.options(options); + // solver.solve(invL, pb.a, pb.C, pb.l, pb.u, pb.xl, pb.xu); + // Eigen::VectorXd x3 = solver.solution(); - //options.gFactorization(jrl::qp::GFactorization::L_TINV); - //solver.options(options); - //solver.solve(invLT, pb.a, pb.C, pb.l, pb.u, pb.xl, pb.xu); - //Eigen::VectorXd x4 = solver.solution(); + // options.gFactorization(jrl::qp::GFactorization::L_TINV); + // solver.options(options); + // solver.solve(invLT, pb.a, pb.C, pb.l, pb.u, pb.xl, pb.xu); + // Eigen::VectorXd x4 = solver.solution(); FAST_CHECK_UNARY(x1.isApprox(x0)); FAST_CHECK_UNARY(x2.isApprox(x0)); - //FAST_CHECK_UNARY(x3.isApprox(x0)); - //FAST_CHECK_UNARY(x4.isApprox(x0)); + // FAST_CHECK_UNARY(x3.isApprox(x0)); + // FAST_CHECK_UNARY(x4.isApprox(x0)); } } @@ -108,7 +108,7 @@ TEST_CASE("Precomputed R") const int nbVar = 7; const int neq = 4; const int nIneq = 8; - jrl::qp::GoldfarbIdnaniSolver solver(nbVar, neq+nIneq, false); + jrl::qp::GoldfarbIdnaniSolver solver(nbVar, neq + nIneq, false); jrl::qp::SolverOptions options; for(int i = 0; i < 10; ++i) @@ -137,8 +137,9 @@ TEST_CASE("Precomputed R") options.gFactorization(jrl::qp::GFactorization::L_TINV_Q); options.RIsGiven(true); + options.equalityFirst(true); solver.options(options); - solver.setPrecomputedR(Eigen::MatrixXd(qr.matrixQR().triangularView())); + solver.setPrecomputedR(qr.matrixQR()); solver.solve(J, pb.a, pb.C, pb.l, pb.u, pb.xl, pb.xu); Eigen::VectorXd x1 = solver.solution();