Skip to content

Commit

Permalink
feat: return total number of iterations from algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
jolars committed Dec 6, 2023
1 parent a0d7f45 commit e13ab6b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/slope/fit_slope.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ fitSlope(const T& x,

Clusters clusters(beta);

int it_total = 0;

// Regularization path loop
for (int path_step = 0; path_step < path_length; ++path_step) {
if (params.print_level > 0) {
Expand Down Expand Up @@ -238,6 +240,7 @@ fitSlope(const T& x,
params);
}
}
it_total++;
}

// Store everything for this step of the path
Expand All @@ -259,7 +262,9 @@ fitSlope(const T& x,
Eigen::SparseMatrix<double> betas(p, path_length);
betas.setFromTriplets(beta_triplets.begin(), beta_triplets.end());

return { beta0s, betas, alpha, lambda, primals_path, dual_gaps_path };
return {
beta0s, betas, alpha, lambda, primals_path, dual_gaps_path, it_total
};
}

} // namespace slope
1 change: 1 addition & 0 deletions src/slope/results.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ struct Results
const Eigen::ArrayXd lambda;
const std::vector<std::vector<double>> primals;
const std::vector<std::vector<double>> dual_gaps;
const int it_total;
};

} // namespace slope

0 comments on commit e13ab6b

Please sign in to comment.