Skip to content

Commit

Permalink
[clang-format]
Browse files Browse the repository at this point in the history
  • Loading branch information
aescande committed Jun 13, 2024
1 parent 97b598c commit 8592873
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
1 change: 0 additions & 1 deletion include/jrl-qp/GoldfarbIdnaniSolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 5 additions & 3 deletions include/jrl-qp/SolverOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand All @@ -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_;
Expand Down
3 changes: 1 addition & 2 deletions src/GoldfarbIdnaniSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double, Eigen::Lower>::blocked(pb_.G)
: -1;

if(ret >= 0) return TerminationStatus::NON_POS_HESSIAN;

if (options_.equalityFirst())
if(options_.equalityFirst())
{
processInitialActiveSetWithEqualityOnly();
initializeComputationData();
Expand Down
27 changes: 14 additions & 13 deletions tests/OptionsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand All @@ -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));
}
}

Expand All @@ -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)
Expand Down Expand Up @@ -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<Eigen::Upper>()));
solver.setPrecomputedR(qr.matrixQR());
solver.solve(J, pb.a, pb.C, pb.l, pb.u, pb.xl, pb.xu);
Eigen::VectorXd x1 = solver.solution();

Expand Down

0 comments on commit 8592873

Please sign in to comment.