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

can anyone make Mosek solver multithreading??

fck1984 opened this issue · comments

set.seed(10)
n <- 1000
SAMPLES <- 100
mu <- matrix(abs(rnorm(n)), nrow = n)
Sigma <- matrix(rnorm(n^2), nrow = n, ncol = n)
Sigma <- t(Sigma) %*% Sigma

w <- Variable(n)
ret <- t(mu) %*% w
risk <- quad_form(w, Sigma)
constraints <- list(w >= 0, sum(w) == 1)

gammas <- 10^seq(-2, 3, length.out = SAMPLES)
ret_data <- rep(0, SAMPLES)
risk_data <- rep(0, SAMPLES)
w_data <- matrix(0, nrow = SAMPLES, ncol = n)

for(i in seq_along(gammas)) {
gamma <- gammas[i]
objective <- ret - gamma * risk
prob <- Problem(Maximize(objective), constraints)
result <- psolve(prob,solver = "MOSEK",mosek_params=list("msk_ipar_num_threads"=20))
risk_data[i] <- result$getValue(sqrt(risk))
ret_data[i] <- result$getValue(ret)
w_data[i,] <- result$getValue(w)
}

I set psolve(prob,solver = "MOSEK",mosek_params=list("msk_ipar_num_threads"=20))
and the multithreading just didn't work

sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.1 LTS

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

locale:
[1] LC_CTYPE=en_US.utf8 LC_NUMERIC=C
[3] LC_TIME=en_US.utf8 LC_COLLATE=en_US.utf8
[5] LC_MONETARY=en_US.utf8 LC_MESSAGES=en_US.utf8
[7] LC_PAPER=en_US.utf8 LC_NAME=en_US.utf8
[9] LC_ADDRESS=en_US.utf8 LC_TELEPHONE=en_US.utf8
[11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=en_US.utf8

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

other attached packages:
[1] Tushare_0.1.3 forecast_8.5 forcats_0.4.0 dplyr_0.8.3
[5] purrr_0.3.3 readr_1.3.1 tidyr_0.8.3 tibble_2.0.1
[9] ggplot2_3.1.0 tidyverse_1.2.1 httr_1.4.0 CVXR_1.0-1
[13] xlsx_0.6.1 Rmosek_9.1.0 xts_0.11-2 zoo_1.8-4
[17] RMySQL_0.10.17 DBI_1.0.0 stringr_1.4.0 reshape2_1.4.3
[21] mltools_0.3.5 lightgbm_2.3.2 R6_2.4.1 data.table_1.12.8
[25] Matrix_1.2-15

loaded via a namespace (and not attached):
[1] tseries_0.10-46 bit64_0.9-7 jsonlite_1.6.1 ECOSolveR_0.5.3
[5] modelr_0.1.4 assertthat_0.2.0 TTR_0.23-6 xlsxjars_0.6.1
[9] cellranger_1.1.0 slam_0.1-47 pillar_1.3.1 backports_1.1.3
[13] lattice_0.20-38 glue_1.3.0 quadprog_1.5-8 rvest_0.3.3
[17] colorspace_1.4-0 plyr_1.8.4 timeDate_3043.102 pkgconfig_2.0.2
[21] broom_0.5.2 haven_2.1.0 scales_1.0.0 Rglpk_0.6-4
[25] gmp_0.6-0 generics_0.0.2 withr_2.1.2 urca_1.3-0
[29] nnet_7.3-12 lazyeval_0.2.1 Rmpfr_0.8-1 cli_2.0.0
[33] quantmod_0.4-13 magrittr_1.5 crayon_1.3.4 readxl_1.3.1
[37] fansi_0.4.0 nlme_3.1-137 xml2_1.2.0 tools_3.5.2
[41] hms_0.4.2 munsell_0.5.0 compiler_3.5.2 rlang_0.4.2
[45] grid_3.5.2 rstudioapi_0.9.0 gtable_0.2.0 fracdiff_1.4-2
[49] curl_3.3 lubridate_1.7.4 bit_1.1-15.2 rJava_0.9-11
[53] stringi_1.3.1 parallel_3.5.2 Rcpp_1.0.5 tidyselect_0.2.5
[57] lmtest_0.9-36