CVXR icon indicating copy to clipboard operation
CVXR copied to clipboard

DCP check is too slow

Open flodel opened this issue 5 years ago • 0 comments

Hello, I am working on an optimization problem with a complex formulation and although the problem is easy to solve (<1 sec once Rglpk::Rglpk_solve_LP is called), the DCP check (CVXR::is_dcp) within CVXR::solve is very, very slow (minutes).

Here is a small reproducible example. Though unrelated to my optimization problem, it shows the kind of slow DCP check I am experiencing:

library(CVXR) n <- 5L; m <- 3L X <- Variable(n, m) y <- runif(n) cumX <- cumsum_axis(X, axis = 2) # %*% diag(m) cumE <- sum_entries(cumX, axis = 1) - y posE <- sum_entries(pos(cumE)) negE <- sum_entries(neg(cumE)) # * 1 objective <- Minimize(posE + negE) problem <- Problem(objective) system.time({ result <- is_dcp(problem) }) ## user system elapsed ## 3.234 0.021 3.447

If you then run the same code but uncomment the * 1 multiplication, it runs in

## user system elapsed ## 12.278 0.104 14.546

If you then run the same code but uncomment the %*% diag(m), it runs in

## user system elapsed ## 52.452 0.646 69.411

I hope you will be able to find the problem and speed up is_dcp. If not or if it looks like it will take some time to implement, would you please consider making the ignore_dcp option skip completely the DCP check? Or provide a separate option?

Thank you.

flodel avatar Aug 31 '19 20:08 flodel