-
Notifications
You must be signed in to change notification settings - Fork 122
Closed
Description
Hello. I have just managed to install v0.13, and run the benchmarks mentioned in julia discourse ( https://discourse.julialang.org/t/convex-jl-scs-more-than-100-slower-than-r-counterpart-cvxr-scs/31717/14 )
-
There is a massive speedup : Now convex.jl performance is indistiguishable from R/CVXR. In particular, timings scale linearly, as opposed to quadratically under v0.12.
-
Realistic problem sizes are now 100 times bigger than early december …!
-
Julia/convex.jl timings (all in secs):
5×5 DataFrame
│ Row │ nCol │ nRow │ moment1 │ setupTm │ solveTm │
│ │ Int64 │ Int64 │ DateTime │ Float64 │ Float64 │
├─────┼───────┼─────────┼─────────────────────────┼─────────┼─────────┤
│ 1 │ 36 │ 10000 │ 2019-12-07T10:22:49.093 │ 0.003 │ 0.641 │
│ 2 │ 36 │ 31600 │ 2019-12-07T10:22:49.737 │ 0.01 │ 1.954 │
│ 3 │ 36 │ 100000 │ 2019-12-07T10:22:51.701 │ 0.037 │ 6.152 │
│ 4 │ 36 │ 316000 │ 2019-12-07T10:22:57.89 │ 0.125 │ 17.738 │
│ 5 │ 36 │ 1000000 │ 2019-12-07T10:23:15.754 │ 0.729 │ 52.752 │
- R/CVXR
> df3
# A tibble: 5 x 5
nCol nRow moment setupTm solveTm
<dbl> <dbl> <dttm> <dbl> <dbl>
1 36 10000 2019-12-07 10:28:11 0.140 0.792
2 36 31600 2019-12-07 10:28:12 0.131 2.28
3 36 100000 2019-12-07 10:28:14 0.410 5.94
4 36 316000 2019-12-07 10:28:21 0.968 17.7
5 36 1000000 2019-12-07 10:28:39 2.70 55.2
Congratulations!
🥇 💯
- code: R/CVXR
library("scs")
library("CVXR")
library("tibble")
library("dplyr")
df3=tibble(nCol=numeric(),nRow=numeric(),moment=as.POSIXct(character()),setupTm=numeric(),solveTm=numeric())
#for (bscale in c(0.1,0.3,1,2))
for (nRow in c(10000,31600,100000,316000,1000000)){
moment1=Sys.time()
nCol=36
AA = matrix(rnorm(nRow*nCol),ncol=nCol)
b = rnorm(nRow)
s <- Variable( nrow( AA)) # les coeffs d'investissement
x <- Variable( ncol( AA))
objective1 = Minimize( sum(s) )
constraints = list( x< 10, x > -10,
AA %*% x - b <= s,
AA %*% x - b >= -s,
sum( x) > 10)
prob1 = Problem( objective1, constraints)
moment2 = Sys.time()
solut2 = psolve( prob1,verbose=TRUE,solver="SCS",max_iters=10,warm_start=FALSE)
# sc_a = solut1$getValue(a)
moment3 = Sys.time()
df3=df3 %>% add_row(nCol=nCol,nRow=nRow,moment=moment1,setupTm=moment2-moment1,solveTm=moment3-moment2)
}
- code: julia/convex.jl.
- Only one change since v0.12: replace parameter
SCSSolverwithSCS.Optimizer
- Only one change since v0.12: replace parameter
using Convex
using SCS
using Random
using Dates
using LinearAlgebra
using DataFrames
df5= DataFrame(nCol = Int64[], nRow= Int64[], moment1=DateTime[], setupTm=Float64[], solveTm=Float64[])
for nRow in [10000,31600,100000,316000,1000000] #different problem sizes
m=nRow
n=36
moment1=Dates.now()
s = Variable(m)
x = Variable(n); # TODO: This is also more interesting with x = Variable(n)
# We can compare it to minimize norm(A*x-b, 1) in Matlab with variable x
A = randn(m,n)
b = randn(m)
p = Problem(:minimize,sum(s), [A*x - b <= s, A*x - b >= -s, x>-10, x< 10, sum(x) >10])
moment2= Dates.now()
# version 0.13
solve!(p,SCS.Optimizer( linear_solver= SCS.Direct, max_iters= 10))
# version 0.12
# solve!(p,SCSSolver( linear_solver= SCS.Direct, max_iters= 10))
#----------------------------------------- 3 solve problem
moment3= Dates.now()
#----------------------------------------- 4 collect timings.
cc=[n,m,moment1,Dates.value(moment2-moment1)/1000,Dates.value(moment3-moment2)/1000]
push!(df5,cc)
end
ericphanson, blegat, odow and ararslan
Metadata
Metadata
Assignees
Labels
No labels