cvxgrp / CVXR

An R modeling language for convex optimization problems.

Home Page:https://cvxr.rbind.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem does not follow DCP rules when using large number

EunyoungL opened this issue · comments

Describe the bug
I ran CVXR in R
I need two inputs as below.

  1. C.matrix.n <- 808 * 808 matrix
  2. X.scaled <- a list of 808 elements

When I used the smaller dataset, such as up to 100 * 100 matrix and the list of 100 elements,
it worked fine.
but when I used a higher dimension dataset, it gave us

Error in construct_intermediate_chain(object, candidate_solvers, gp = gp) :
Problem does not follow DCP rules.

why is it happening?? it did work perfectly fine! Please help me out!!
It did not work without regularization, either.
here was my R code.

Dmat <- 2 * C.matrix.n
dvec <- rep(0, length(X.scaled))

m <- dim(C.matrix.n)[1]
w <- Variable(m)
first <- quad_form(w, Dmat)
second <- t(dvec) %*% w
lambda <- Parameter(pos = TRUE)

value(lambda) <- 0.1
reg <- lambda*(p_norm(p_norm(w[1:25],1),2) + p_norm(p_norm(w[26:141],1),2) + p_norm(p_norm(w[142:808],1),2))
obj <- first - second + reg
constr <- list(w >= 0, sum(w) == 1)
prob <- Problem(Minimize(obj), constr)
result <- solve(prob)

Version

sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.2.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] parallel stats graphics grDevices utils datasets
[7] methods base

other attached packages:
[1] matrixcalc_1.0-5 Matrix_1.4-0 quadprog_1.5-8
[4] igraph_1.2.11 factoextra_1.0.7 data.table_1.14.2
[7] doParallel_1.0.17 iterators_1.0.14 foreach_1.5.2
[10] CVXR_1.0-10 kernlab_0.9-29 tictoc_1.0.1
[13] mixKernel_0.8 reticulate_1.24 mixOmics_6.18.1
[16] ggplot2_3.3.5 lattice_0.20-45 MASS_7.3-55
[19] dplyr_1.0.7

loaded via a namespace (and not attached):
[1] nlme_3.1-155 bitops_1.0-7
[3] matrixStats_0.61.0 phyloseq_1.38.0
[5] bit64_4.0.5 RColorBrewer_1.1-2
[7] GenomeInfoDb_1.30.1 tools_4.1.2
[9] utf8_1.2.2 R6_2.5.1
[11] vegan_2.5-7 DBI_1.1.2
[13] BiocGenerics_0.40.0 mgcv_1.8-38
[15] colorspace_2.0-2 permute_0.9-7
[17] rhdf5filters_1.6.0 ade4_1.7-18
[19] withr_2.4.3 tidyselect_1.1.1
[21] gridExtra_2.3 mnormt_2.0.2
[23] bit_4.0.4 compiler_4.1.2
[25] cli_3.1.1 Biobase_2.54.0
[27] pacman_0.5.1 scales_1.1.1
[29] psych_2.1.9 stringr_1.4.0
[31] XVector_0.34.0 pkgconfig_2.0.3
[33] rlang_1.0.1 rstudioapi_0.13
[35] generics_0.1.2 jsonlite_1.7.3
[37] BiocParallel_1.28.3 RCurl_1.98-1.5
[39] magrittr_2.0.2 osqp_0.6.0.5
[41] GenomeInfoDbData_1.2.7 biomformat_1.22.0
[43] Rcpp_1.0.8 munsell_0.5.0
[45] S4Vectors_0.32.3 Rhdf5lib_1.16.0
[47] fansi_1.0.2 ape_5.6-1
[49] lifecycle_1.0.1 stringi_1.7.6
[51] zlibbioc_1.40.0 rhdf5_2.38.0
[53] plyr_1.8.6 grid_4.1.2
[55] ggrepel_0.9.1 crayon_1.4.2
[57] Biostrings_2.62.0 splines_4.1.2
[59] multtest_2.50.0 tmvnsim_1.0-2
[61] pillar_1.7.0 corpcor_1.6.10
[63] reshape2_1.4.4 codetools_0.2-18
[65] stats4_4.1.2 glue_1.6.1
[67] LDRTools_0.2-1 png_0.1-7
[69] vctrs_0.3.8 gtable_0.3.0
[71] purrr_0.3.4 tidyr_1.2.0
[73] assertthat_0.2.1 Rmpfr_0.8-7
[75] RSpectra_0.16-0 survival_3.2-13
[77] rARPACK_0.11-0 tibble_3.1.6
[79] IRanges_2.28.0 ellipse_0.4.2
[81] cluster_2.1.2 corrplot_0.92
[83] gmp_0.6-2.1 ellipsis_0.3.2