@@ -40,88 +40,114 @@ include("oed_utils.jl")
40
40
https://github.com/ZIB-IOL/FrankWolfe.jl/blob/master/examples/optimal_experiment_design.jl
41
41
"""
42
42
43
- m = 40
43
+
44
+ m = 50
44
45
verbose = true
45
46
46
47
# # A-Optimal Design Problem
47
-
48
48
@testset " A-Optimal Design" begin
49
49
50
50
Ex_mat, n, N, ub = build_data (m)
51
51
52
- # sharpness constants
53
- σ = minimum (Ex_mat' * Ex_mat)
54
- λ_max = maximum (ub) * maximum ([norm (Ex_mat[i,:])^ 2 for i= 1 : size (Ex_mat,1 )])
55
- θ = 1 / 2
56
- M = sqrt (λ_max^ 3 / n * σ^ 4 )
57
-
58
-
59
- g, grad! = build_a_criterion (Ex_mat, build_safe= true )
52
+ g, grad! = build_a_criterion (Ex_mat, build_safe= false )
60
53
blmo = build_blmo (m, N, ub)
61
- x0, active_set = build_start_point (Ex_mat, N, ub)
62
- z = greedy_incumbent (Ex_mat, N, ub)
63
- domain_oracle = build_domain_oracle (Ex_mat, n)
64
- line_search = FrankWolfe. MonotonicGenericStepsize (FrankWolfe. Adaptive (), domain_oracle)
65
54
heu = Boscia. Heuristic (Boscia. rounding_hyperplane_heuristic, 0.7 , :hyperplane_aware_rounding )
55
+ domain_oracle = build_domain_oracle (Ex_mat, n)
66
56
67
- x, _, result = Boscia . solve (g, grad!, blmo, active_set = active_set, start_solution = z, time_limit = 10 , verbose = false , domain_oracle = domain_oracle, custom_heuristics = [heu], sharpness_exponent = θ, sharpness_constant = M, line_search = line_search)
68
-
69
- _ , active_set = build_start_point (Ex_mat, N, ub)
57
+ # precompile
58
+ line_search = FrankWolfe . MonotonicGenericStepsize (FrankWolfe . Adaptive (), domain_oracle)
59
+ x0 , active_set = build_start_point (Ex_mat, N, ub)
70
60
z = greedy_incumbent (Ex_mat, N, ub)
71
- x, _, result = Boscia. solve (g, grad!, blmo, active_set= active_set, start_solution= z, verbose= verbose, domain_oracle= domain_oracle, custom_heuristics= [heu], sharpness_exponent= θ, sharpness_constant= M, line_search= line_search) # sharpness_exponent=θ, sharpness_constant=M,
72
-
73
- gradient = similar (x)
74
- grad! (gradient, x)
75
- v = Boscia. compute_extreme_point (blmo, gradient)
76
- dual_gap = FrankWolfe. dot (gradient, x) - FrankWolfe. dot (gradient, v)
77
- @show dual_gap
61
+ x, _, _ = Boscia. solve (g, grad!, blmo, active_set= active_set, start_solution= z, time_limit= 10 , verbose= false , domain_oracle= domain_oracle, custom_heuristics= [heu], line_search= line_search)
78
62
79
- blmo = build_blmo (m, N, ub)
80
- _, active_set = build_start_point (Ex_mat, N, ub)
63
+ # proper run with MGLS and Adaptive
64
+ line_search = FrankWolfe. MonotonicGenericStepsize (FrankWolfe. Adaptive (), domain_oracle)
65
+ x0, active_set = build_start_point (Ex_mat, N, ub)
81
66
z = greedy_incumbent (Ex_mat, N, ub)
82
- domain_oracle = build_domain_oracle (Ex_mat, n)
83
- heu = Boscia. Heuristic (Boscia. rounding_hyperplane_heuristic, 0.7 , :hyperplane_aware_rounding )
84
-
85
- x_s, _, result = Boscia. solve (g, grad!, blmo, active_set= active_set, start_solution= z, verbose= verbose, line_search= FrankWolfe. Secant (domain_oracle= domain_oracle), domain_oracle= domain_oracle, sharpness_exponent= θ, sharpness_constant= M, custom_heuristics= [heu]) # sharpness_exponent=θ, sharpness_constant=M,
86
-
87
- @show x
88
- @show x_s
89
- @show g (x), g (x_s)
90
- @test isapprox (g (x), g (x_s), atol= 1e-3 , rtol= 5e-2 )
67
+ x, _, result = Boscia. solve (
68
+ g,
69
+ grad!,
70
+ blmo,
71
+ active_set= active_set,
72
+ start_solution= z,
73
+ verbose= verbose,
74
+ domain_oracle= domain_oracle,
75
+ custom_heuristics= [heu],
76
+ line_search= line_search,
77
+ )
78
+
79
+ # Run with Secant
80
+ x0, active_set = build_start_point (Ex_mat, N, ub)
81
+ z = greedy_incumbent (Ex_mat, N, ub)
82
+ line_search = FrankWolfe. Secant (domain_oracle= domain_oracle)
83
+
84
+ x_s, _, result_s = Boscia. solve (
85
+ g,
86
+ grad!,
87
+ blmo,
88
+ active_set= active_set,
89
+ start_solution= z,
90
+ verbose= verbose,
91
+ domain_oracle= domain_oracle,
92
+ custom_heuristics= [heu],
93
+ line_search= line_search,
94
+ )
95
+
96
+ @test result_s[:dual_bound ] <= g (x) + 1e-4
97
+ @test result[:dual_bound ] <= g (x_s) + 1e-4
98
+ @test isapprox (g (x), g (x_s), atol= 1e-3 )
91
99
end
92
100
93
101
# # D-Optimal Design Problem
94
-
95
102
@testset " D-optimal Design" begin
96
103
Ex_mat, n, N, ub = build_data (m)
97
104
98
- # sharpness constants
99
- σ = minimum (Ex_mat' * Ex_mat)
100
- λ_max = maximum (ub) * maximum ([norm (Ex_mat[i,:])^ 2 for i= 1 : size (Ex_mat,1 )])
101
- θ = 1 / 2
102
- M = sqrt (2 * λ_max^ 2 / n * σ^ 4 )
103
-
104
-
105
- g, grad! = build_d_criterion (Ex_mat, build_safe= true )
105
+ g, grad! = build_d_criterion (Ex_mat, build_safe= false )
106
106
blmo = build_blmo (m, N, ub)
107
- x0, active_set = build_start_point (Ex_mat, N, ub)
108
- z = greedy_incumbent (Ex_mat, N, ub)
109
- domain_oracle = build_domain_oracle (Ex_mat, n)
110
107
heu = Boscia. Heuristic (Boscia. rounding_hyperplane_heuristic, 0.7 , :hyperplane_aware_rounding )
108
+ domain_oracle = build_domain_oracle (Ex_mat, n)
111
109
112
- x, _, result = Boscia. solve (g, grad!, blmo, active_set= active_set, start_solution= z, verbose= verbose, domain_oracle= domain_oracle, sharpness_exponent= θ, sharpness_constant= M, custom_heuristics= [heu])
113
-
114
- blmo = build_blmo (m, N, ub)
110
+ # precompile
111
+ line_search = FrankWolfe. MonotonicGenericStepsize (FrankWolfe. Adaptive (), domain_oracle)
115
112
x0, active_set = build_start_point (Ex_mat, N, ub)
116
113
z = greedy_incumbent (Ex_mat, N, ub)
117
- domain_oracle = build_domain_oracle (Ex_mat, n)
118
- heu = Boscia. Heuristic (Boscia. rounding_hyperplane_heuristic, 0.7 , :hyperplane_aware_rounding )
114
+ x, _, _ = Boscia. solve (g, grad!, blmo, active_set= active_set, start_solution= z, time_limit= 10 , verbose= false , domain_oracle= domain_oracle, custom_heuristics= [heu], line_search= line_search)
119
115
120
- x_s, _, result = Boscia. solve (g, grad!, blmo, active_set= active_set, start_solution= z, verbose= verbose, line_search= FrankWolfe. Secant (domain_oracle= domain_oracle), domain_oracle= domain_oracle, sharpness_exponent= θ, sharpness_constant= M, custom_heuristics= [heu])
121
-
122
- @show x
123
- @show x_s
124
- @show g (x), g (x_s)
125
- @test isapprox (g (x), g (x_s), atol= 1e-4 , rtol= 1e-2 )
116
+ # proper run with MGLS and Adaptive
117
+ line_search = FrankWolfe. MonotonicGenericStepsize (FrankWolfe. Adaptive (), domain_oracle)
118
+ x0, active_set = build_start_point (Ex_mat, N, ub)
119
+ z = greedy_incumbent (Ex_mat, N, ub)
120
+ x, _, result = Boscia. solve (
121
+ g,
122
+ grad!,
123
+ blmo,
124
+ active_set= active_set,
125
+ start_solution= z,
126
+ verbose= verbose,
127
+ domain_oracle= domain_oracle,
128
+ custom_heuristics= [heu],
129
+ line_search= line_search,
130
+ )
131
+
132
+ # Run with Secant
133
+ x0, active_set = build_start_point (Ex_mat, N, ub)
134
+ z = greedy_incumbent (Ex_mat, N, ub)
135
+ line_search = FrankWolfe. Secant (domain_oracle= domain_oracle)
136
+
137
+ x_s, _, result_s = Boscia. solve (
138
+ g,
139
+ grad!,
140
+ blmo,
141
+ active_set= active_set,
142
+ start_solution= z,
143
+ verbose= verbose,
144
+ domain_oracle= domain_oracle,
145
+ custom_heuristics= [heu],
146
+ line_search= line_search,
147
+ )
148
+
149
+ @test result_s[:dual_bound ] <= g (x)
150
+ @test result[:dual_bound ] <= g (x_s)
151
+ @test isapprox (g (x), g (x_s), rtol= 1e-2 )
126
152
end
127
153
0 commit comments