/
warmstart.jl
41 lines (36 loc) · 1.07 KB
/
warmstart.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using Convex, SCS
set_default_solver(SCSSolver(verbose = 0, max_iters = 1000000))
println(
"small test to compile and see if we throw warnings when warmstarting what can't be warmstarted.",
)
n = 10
y = rand(n)
x = Variable(n)
lambda = [100]
problem = minimize(sumsquares(y - x) + lambda[1] * sumsquares(x - 10))
@time solve!(problem, warmstart = true)
println("\nnow try first solving and then warmstarting")
n = 1000
y = rand(n)
x = Variable(n)
lambda = [100]
problem = minimize(sumsquares(y - x) + lambda[1] * sumsquares(x - 10))
@time solve!(problem)
@show problem.optval
lambda[1] = 105
println(
"this run should be faster than the last and have slightly higher optimal value",
)
@time solve!(problem, warmstart = true)
@show problem.optval
println("\nnow try with scalar variables")
lambda = 100
problem = minimize(sumsquares(y - x) + lambda * sumsquares(x - 10))
@time solve!(problem)
@show problem.optval
lambda = 105
println(
"this run should be faster than the last and have slightly higher optimal value",
)
@time solve!(problem, warmstart = true)
@show problem.optval