Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove osqp dependency #42

Merged
merged 5 commits into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Imports:
parallel,
splines2,
quadprog,
osqp,
bootnet,
qgraph,
ggplot2,
Expand All @@ -53,7 +52,6 @@ Collate:
'StepOne.R'
'Range.R'
'Method.R'
'OsqpSolver.R'
'QuadprogSolver.R'
'Solver.R'
'SolverFactory.R'
Expand Down
2 changes: 0 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ importFrom(ggplot2,stat_ecdf)
importFrom(ggplot2,theme)
importFrom(ggplot2,theme_bw)
importFrom(mvtnorm,rmvnorm)
importFrom(osqp,osqp)
importFrom(osqp,osqpSettings)
importFrom(parallel,clusterCall)
importFrom(parallel,clusterEvalQ)
importFrom(parallel,clusterExport)
Expand Down
109 changes: 0 additions & 109 deletions R/OsqpSolver.R

This file was deleted.

3 changes: 1 addition & 2 deletions R/SolverFactory.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#' @include OsqpSolver.R QuadprogSolver.R
#' @include QuadprogSolver.R

SolverFactory <- R6::R6Class("SolverFactory",
public = list(
get_solver = function(type) {
return(
switch(type,
osqp = OsqpSolver$new(),
quadprog = QuadprogSolver$new(),
stop(.__ERRORS__$not_developed)
)
Expand Down
1 change: 0 additions & 1 deletion R/powerly-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#' @importFrom patchwork plot_layout
#' @importFrom R6 R6Class
#' @importFrom bootnet genGGM ggmGenerator
#' @importFrom osqp osqpSettings osqp
#' @importFrom progress progress_bar
#' @importFrom qgraph EBICglasso
#' @importFrom quadprog solve.QP
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/function/powerly.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ powerly(
| `monotone` | A logical value indicating whether a monotonicity assumption should be placed on the values of the performance measure. The default is `TRUE` meaning that the performance measure changes as a function of sample size (i.e., either by increasing or decreasing as the sample size goes up). The alternative `FALSE` indicates that the performance measure it is not assumed to change as a function a sample size. |
| `increasing` | A logical value indicating whether the performance measure is assumed to follow a non-increasing or non-decreasing trend. `TRUE` (the default) indicates a non-decreasing trend (i.e., the performance measure increases as the sample size goes up). `FALSE` indicates a non-increasing trend (i.e., the performance measure decreases as the sample size goes up). |
| `spline_df` | A vector of positive integers representing the degrees of freedom considered for constructing the spline basis, or `NULL`. The best degree of freedom is selected based on Leave One Out Cross-Validation. If `NULL` (the default) is provided, a vector of degrees of freedom is automatically created with all integers between `3` and `20`. |
| `solver_type` | A character string representing the type of the quadratic solver used for estimating the spline coefficients. Possible values are `"quadprog"` (the default) and `"osqp"`. Currently, the "`osqp`" solver does not play nicely with `R`'s [`parallel`](https://stat.ethz.ch/R-manual/R-devel/library/parallel/doc/parallel.pdf) package and cannot be used when the `powerly` function is ran in parallel. |
| `solver_type` | A character string representing the type of the quadratic solver used for estimating the spline coefficients. Currently only `"quadprog"` (the default) is supported. |
| `boots` | A positive integer representing the number of bootstrap runs to perform on the matrix of performance measures in order to obtained bootstrapped values for the statistic of interest. The default is `10000`. |
| `lower_ci` | A single numerical value indicating the lower bound for the confidence interval to be computed on the bootstrapped statistics. The default is `0.025` (i.e., $2.5\%$). |
| `upper_ci` | A single numerical value indicating the upper bound for the confidence to be computed on the bootstrapped statistics. The default is `0.975` (i.e., $97.5\%$). |
Expand Down
6 changes: 2 additions & 4 deletions man-roxygen/powerly.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,8 @@
#' automatically created with all integers between `3` and `20`.
#'
#' @param solver_type A character string representing the type of the quadratic
#' solver used for estimating the spline coefficients. Possible values are
#' `"quadprog"` (the default) and `"osqp"`. Currently, the "`osqp`" solver does
#' not play nicely with `R`'s [`parallel::parallel`] package and cannot be used
#' when powerly is ran in parallel.
#' solver used for estimating the spline coefficients. Currently only
#' `"quadprog"` (the default) is supported.
#'
#' @param boots A positive integer representing the number of bootstrap runs to
#' perform on the matrix of performance measures in order to obtained
Expand Down
6 changes: 2 additions & 4 deletions man/powerly.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 0 additions & 32 deletions tests/testthat/helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,6 @@ solve_qp <- function(basis_matrix, y, a_mat, b_vec, meq = 0) {
return(quadprog::solve.QP(Dmat = d_mat, dvec = d_vec, Amat = t(a_mat), bvec = b_vec, meq = meq)$solution)
}

# Helper based on `osqp` for testing the `Solver` class.
solve_osqp <- function(basis_matrix, y, lower, upper) {
# Set settings.
settings <- osqp::osqpSettings(
verbose = FALSE,
eps_abs = 1e-10,
eps_rel = 1e-10,
linsys_solver = 0L,
warm_start = FALSE
)

# Create matrices for `osqp`.
p_mat <- crossprod(basis_matrix, basis_matrix)
q_vec <- -crossprod(basis_matrix, y)

# Create constraint matrix.
a_mat <- diag(1, ncol(basis_matrix))

# Create model.
model <- osqp::osqp(
P = p_mat,
q = q_vec,
A = a_mat,
l = lower,
u = upper,
pars = settings
)

# Optimize.
return(model$Solve()$x)
}

# Compute performance measures.
compute_measure <- function(true_parameters, estimated_parameters, measure) {
# Extract the true and estimated parameters from the weights matrices.
Expand Down
Loading