/
run_VUplots.jl
62 lines (50 loc) · 2.24 KB
/
run_VUplots.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using NonSmoothSolvers
using NonSmoothProblems
using LinearAlgebra
using DataStructures
include("plot_utils.jl")
function run_VUplots()
problems = []
xopt=[-0.12625658060784,-0.03437830253436,-0.00685719866363, 0.02636065787685, 0.06729492268391,-0.27839950072585, 0.07421866459664, 0.13852404793680, 0.08403122337963, 0.03858030992197]
pb = MaxQuadAlt()
push!(problems, (; name="maxquadBGLS", pb, xinit=ones(10), iterations_limit=40, Fopt = prevfloat(F(pb, xopt))))
for ν in 0:3
pb, xopt, Fopt, Mopt = NSP.F3d_U(ν)
xinit = xopt .+ Float64[100, 33, -100]
push!(problems, (; name="F3d-U$(ν)", pb, xinit, iterations_limit=20, Fopt))
end
pb, xopt, Fopt, Mopt = NSP.F2d()
push!(problems, (; name="F2d", pb, xinit=[0.9, 1.9], iterations_limit=20, Fopt))
getpoint(o, os, osext) = deepcopy(os.p)
plot = TikzDocument()
for problem in problems
@info "++ Problem $(problem.name)"
x = problem.xinit
pb = problem.pb
iterations_limit = problem.iterations_limit
Fopt = problem.Fopt
# NOTE: Bundle without Newton accel
# o = VUbundle(Newton_accel = false)
# optparams = OptimizerParams(;iterations_limit, trace_length=35)
# try
# sol, tr = optimize!(pb, o, x; optparams, optimstate_extensions = OrderedDict{Symbol,Function}(:p => getpoint))
# push!(plot, plot_seriousnullsteps(pb, tr, Fopt; title = problem.name*"- without Newton"))
# write_nullsteps(pb, tr, joinpath("output", problem.name*"_without_Newton"*".txt"))
# catch e
# @error e
# end
# NOTE: Bundle with Newton accel
o = VUbundle(Newton_accel = true)
optparams = OptimizerParams(;iterations_limit, trace_length=35)
try
sol, tr = optimize!(pb, o, x; optparams, optimstate_extensions = OrderedDict{Symbol,Function}(:p => getpoint))
push!(plot, plot_seriousnullsteps(pb, tr, Fopt; title = problem.name*"- with qNewton"))
write_nullsteps(pb, tr, joinpath("output", problem.name*"_with_qNewton"*".txt"))
@show sol
catch e
@error e
end
end
savefig(plot, joinpath("output", "VU_seriousnullsteps"))
return nothing
end