You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi
I'm trying to solve a Quadratic optimization problem with linear constrains using the R package CVXR. Although the default solver is able to solve the optimization, Mosek solver is not. The reason I'm looking to use Mosek is because I need to solve a bigger problem with more than 250 constrains and the default solver gives an inaccurate solution, so I'm looking to solve the bigger problem with Mosek. Here's a simple example were Mosek is not working:
suppressMessages(suppressWarnings(library(CVXR)))
Problem data
set.seed(10)
n <- 10
SAMPLES <- 100
mu <- matrix(abs(rnorm(n)), nrow = n)
Sigma <- matrix(rnorm(n^2), nrow = n, ncol = n)
Sigma <- t(Sigma) %*% Sigma
Form problem
w <- Variable(n)
ret <- t(mu) %*% w
risk <- quad_form(w, Sigma)
constraints <- list(w >= 0, sum(w) == 1,ret==mean(mu))
Risk aversion parameters
prob <- Problem(Minimize(risk), constraints)
result <- solve(prob,solver='MOSEK')
Hi
I'm trying to solve a Quadratic optimization problem with linear constrains using the R package CVXR. Although the default solver is able to solve the optimization, Mosek solver is not. The reason I'm looking to use Mosek is because I need to solve a bigger problem with more than 250 constrains and the default solver gives an inaccurate solution, so I'm looking to solve the bigger problem with Mosek. Here's a simple example were Mosek is not working:
suppressMessages(suppressWarnings(library(CVXR)))
Problem data
set.seed(10)
n <- 10
SAMPLES <- 100
mu <- matrix(abs(rnorm(n)), nrow = n)
Sigma <- matrix(rnorm(n^2), nrow = n, ncol = n)
Sigma <- t(Sigma) %*% Sigma
Form problem
w <- Variable(n)
ret <- t(mu) %*% w
risk <- quad_form(w, Sigma)
constraints <- list(w >= 0, sum(w) == 1,ret==mean(mu))
Risk aversion parameters
prob <- Problem(Minimize(risk), constraints)
result <- solve(prob,solver='MOSEK')
It gives the following error.
Error in py_call_impl(callable, dots$args, dots$keywords) :
TypeError: 'int' object is not iterable
10.stop(structure(list(message = "TypeError: 'int' object is not iterable",
call = py_call_impl(callable, dots$args, dots$keywords),
cppstack = structure(list(file = "", line = -1L, stack = c("1 reticulate.so 0x000000010d278f9b _ZN4Rcpp9exceptionC2EPKcb + 219",
"2 reticulate.so 0x000000010d27fa35 _ZN4Rcpp4stopERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE + 53", ...
9.mosek_intf at mosekglue.py#51
8.get_mosekglue()$mosek_intf(reticulate::r_to_py(A), b, reticulate::r_to_py(G),
h, c, dims, offset, reticulate::dict(solver_opts), verbose)
7.Solver.solve(solver, objective, constraints, object@.cached_data,
warm_start, verbose, ...)
6.Solver.solve(solver, objective, constraints, object@.cached_data,
warm_start, verbose, ...)
5.CVXR::psolve(a, b, ...)
4.CVXR::psolve(a, b, ...)
3.solve.Problem(prob, solver = "MOSEK")
2.solve(prob, solver = "MOSEK")
1.solve(prob, solver = "MOSEK")
Somebody knows how to solve it, may be re expressing the problem?
My session info is the following:
R version 3.5.2 (2018-12-20)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.1
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/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] stats graphics grDevices utils datasets methods base
other attached packages:
[1] reticulate_1.10 Matrix_1.2-15 CVXR_0.99-2 e1071_1.7-0.1 rstudioapi_0.9.0
[6] openxlsx_4.1.0
loaded via a namespace (and not attached):
[1] Rcpp_1.0.0 lattice_0.20-38 class_7.3-14 gmp_0.5-13.2 R.methodsS3_1.7.1
[6] grid_3.5.2 R6_2.3.0 jsonlite_1.6 zip_1.0.0 Rmpfr_0.7-2
[11] R.oo_1.22.0 R.utils_2.7.0 tools_3.5.2 bit64_0.9-7 bit_1.1-14
[16] compiler_3.5.2 scs_1.1-1 ECOSolveR_0.4
The text was updated successfully, but these errors were encountered: