Skip to content

Commit

Permalink
refactor: drop tol from solver since it's not used
Browse files Browse the repository at this point in the history
  • Loading branch information
jolars committed Feb 25, 2025
1 parent dcd0826 commit ba55cc1
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 23 deletions.
1 change: 0 additions & 1 deletion src/slope/slope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ Slope::path(T& x,
// TODO: Make this part of the slope class
auto solver = setupSolver(this->solver_type,
this->loss_type,
this->tol,
jit_normalization,
this->intercept,
this->update_clusters,
Expand Down
8 changes: 3 additions & 5 deletions src/slope/solvers/hybrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,16 @@ class Hybrid : public SolverBase
public:
/**
* @brief Constructs Hybrid solver for SLOPE optimization
* @param tol Convergence tolerance threshold
* @param jit_normalization Feature normalization strategy
* @param intercept If true, fits intercept term
* @param update_clusters If true, updates clusters during optimization
* @param cd_iterations Frequency of proximal gradient descent updates
*/
Hybrid(double tol,
JitNormalization jit_normalization,
Hybrid(JitNormalization jit_normalization,
bool intercept,
bool update_clusters,
int cd_iterations)
: SolverBase(tol, jit_normalization, intercept)
: SolverBase(jit_normalization, intercept)
, update_clusters(update_clusters)
, cd_iterations(cd_iterations)
{
Expand Down Expand Up @@ -121,7 +119,7 @@ class Hybrid : public SolverBase

const int n = x.rows();

solvers::PGD pgd_solver(tol, jit_normalization, intercept, "pgd");
solvers::PGD pgd_solver(jit_normalization, intercept, "pgd");

// Run proximal gradient descent
pgd_solver.run(beta0,
Expand Down
6 changes: 2 additions & 4 deletions src/slope/solvers/pgd.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,14 @@ class PGD : public SolverBase
public:
/**
* @brief Constructs Proximal Gradient Descent solver for SLOPE optimization
* @param tol Convergence tolerance threshold
* @param jit_normalization Feature normalization strategy
* @param intercept If true, fits intercept term
* @param update_type Type of update strategy to use
*/
PGD(double tol,
JitNormalization jit_normalization,
PGD(JitNormalization jit_normalization,
bool intercept,
const std::string& update_type)
: SolverBase(tol, jit_normalization, intercept)
: SolverBase(jit_normalization, intercept)
, learning_rate(1.0)
, learning_rate_decr(0.5)
, update_type{ update_type }
Expand Down
8 changes: 3 additions & 5 deletions src/slope/solvers/setup_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace slope {
std::unique_ptr<solvers::SolverBase>
setupSolver(const std::string& solver_type,
const std::string& loss,
double tol,
JitNormalization jit_normalization,
bool intercept,
bool update_clusters,
Expand All @@ -29,14 +28,13 @@ setupSolver(const std::string& solver_type,
}

if (solver_choice == "pgd") {
return std::make_unique<solvers::PGD>(
tol, jit_normalization, intercept, "pgd");
return std::make_unique<solvers::PGD>(jit_normalization, intercept, "pgd");
} else if (solver_choice == "fista") {
return std::make_unique<solvers::PGD>(
tol, jit_normalization, intercept, "fista");
jit_normalization, intercept, "fista");
} else if (solver_choice == "hybrid") {
return std::make_unique<solvers::Hybrid>(
tol, jit_normalization, intercept, update_clusters, cd_iterations);
jit_normalization, intercept, update_clusters, cd_iterations);
} else {
throw std::invalid_argument("solver type not recognized");
}
Expand Down
3 changes: 0 additions & 3 deletions src/slope/solvers/setup_solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ namespace slope {
* with various configurations possible.
*
* @param solver_type Type of solver to use (e.g., "pgd", "admm")
* @param loss Type of loss function ("quadratic", "logistic",
* "poisson", "multinomial")
* @param tol Convergence tolerance for the solver
* @param jit_normalization Type of JIT normalization
* @param intercept Whether to fit an intercept term
Expand All @@ -29,7 +27,6 @@ namespace slope {
std::unique_ptr<solvers::SolverBase>
setupSolver(const std::string& solver_type,
const std::string& loss,
double tol,
JitNormalization jit_normalization,
bool intercept,
bool update_clusters,
Expand Down
7 changes: 2 additions & 5 deletions src/slope/solvers/solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,12 @@ class SolverBase
/**
* @brief Constructs a base solver for SLOPE optimization
*
* @param tol Convergence tolerance for the optimization
* @param jit_normalization Type of just-in-time normalization to apply (None,
* Center, Scale, or Both)
* @param intercept Whether to fit an intercept term
*/
SolverBase(double tol, JitNormalization jit_normalization, bool intercept)
: tol(tol)
, jit_normalization(jit_normalization)
SolverBase(JitNormalization jit_normalization, bool intercept)
: jit_normalization(jit_normalization)
, intercept(intercept)
{
}
Expand Down Expand Up @@ -112,7 +110,6 @@ class SolverBase
const Eigen::MatrixXd& y) = 0;

protected:
double tol; ///< Convergence tolerance threshold
JitNormalization jit_normalization; ///< JIT feature normalization strategy
bool intercept; ///< If true, fits intercept term
};
Expand Down

0 comments on commit ba55cc1

Please sign in to comment.