Skip to content

Commit

Permalink
Const-qualify variables in InteriorPoint() (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
calcmogul authored Dec 24, 2023
1 parent b55a38c commit b88674d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/optimization/solver/InteriorPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Eigen::VectorXd InteriorPoint(
const SolverConfig& config,
const Eigen::Ref<const Eigen::VectorXd>& initialGuess,
SolverStatus* status) {
auto solveStartTime = std::chrono::system_clock::now();
const auto solveStartTime = std::chrono::system_clock::now();

// Map decision variables and constraints to VariableMatrices for Lagrangian
VariableMatrix xAD{decisionVariables};
Expand Down Expand Up @@ -172,7 +172,7 @@ Eigen::VectorXd InteriorPoint(
}};

// Barrier parameter minimum
double μ_min = config.tolerance / 10.0;
const double μ_min = config.tolerance / 10.0;

// Barrier parameter μ
double μ = 0.1;
Expand Down Expand Up @@ -316,7 +316,7 @@ Eigen::VectorXd InteriorPoint(
// [ Aₑ 0 ]
//
// Don't assign upper triangle because solver only uses lower triangle.
Eigen::SparseMatrix<double> topLeft =
const Eigen::SparseMatrix<double> topLeft =
H.triangularView<Eigen::Lower>() +
(A_i.transpose() * Σ * A_i).triangularView<Eigen::Lower>();
triplets.clear();
Expand Down Expand Up @@ -350,7 +350,7 @@ Eigen::VectorXd InteriorPoint(

// Solve the Newton-KKT system
solver.Compute(lhs, equalityConstraints.size(), μ);
Eigen::VectorXd step{x.rows() + y.rows(), 1};
Eigen::VectorXd step{x.rows() + y.rows()};
if (solver.Info() == Eigen::Success) {
step = solver.Solve(rhs);
} else {
Expand All @@ -375,7 +375,7 @@ Eigen::VectorXd InteriorPoint(
bool stepAcceptable = false;

// αᵐᵃˣ = max(α ∈ (0, 1] : sₖ + αpₖˢ ≥ (1−τⱼ)sₖ)
double α_max = FractionToTheBoundaryRule(s, p_s, τ);
const double α_max = FractionToTheBoundaryRule(s, p_s, τ);
double α = α_max;

// αₖᶻ = max(α ∈ (0, 1] : zₖ + αpₖᶻ ≥ (1−τⱼ)zₖ)
Expand Down Expand Up @@ -658,7 +658,7 @@ Eigen::VectorXd InteriorPoint(
}
}

auto innerIterEndTime = std::chrono::system_clock::now();
const auto innerIterEndTime = std::chrono::system_clock::now();

// Diagnostics for current iteration
if (config.diagnostics) {
Expand Down

0 comments on commit b88674d

Please sign in to comment.