Skip to content

Commit

Permalink
Optimal Design example clean up (#201)
Browse files Browse the repository at this point in the history
* Remove print out.

* Have one seed for all the tests and examples.

* Precompile call.

* x0 not required just the active set.

---------

Co-authored-by: Deborah Hendrych <[email protected]>
Co-authored-by: Hendrych <[email protected]>
  • Loading branch information
3 people authored Sep 24, 2024
1 parent f4d5a85 commit b3c4e61
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions examples/optimal_experiment_design.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ include("oed_utils.jl")
A continuous version of the problem can be found in the examples in FrankWolfe.jl:
https://github.com/ZIB-IOL/FrankWolfe.jl/blob/master/examples/optimal_experiment_design.jl
"""
seed = rand(UInt64)

@show seed
Random.seed!(seed)
m = 40
verbose = true

Expand All @@ -52,8 +49,6 @@ verbose = true

Ex_mat, n, N, ub = build_data(m)

@show Ex_mat

# sharpness constants
σ = minimum(Ex_mat' * Ex_mat)
λ_max = maximum(ub) * maximum([norm(Ex_mat[i,:])^2 for i=1:size(Ex_mat,1)])
Expand All @@ -69,6 +64,10 @@ verbose = true
line_search = FrankWolfe.MonotonicGenericStepsize(FrankWolfe.Adaptive(), domain_oracle)
heu = Boscia.Heuristic(Boscia.rounding_hyperplane_heuristic, 0.7, :hyperplane_aware_rounding)

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)

_, active_set = build_start_point(Ex_mat, N, ub)
z = greedy_incumbent(Ex_mat, N, ub)
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,

gradient = similar(x)
Expand All @@ -78,7 +77,7 @@ verbose = true
@show dual_gap

blmo = build_blmo(m, N, ub)
x0, active_set = build_start_point(Ex_mat, N, ub)
_, active_set = build_start_point(Ex_mat, N, ub)
z = greedy_incumbent(Ex_mat, N, ub)
domain_oracle = build_domain_oracle(Ex_mat, n)
heu = Boscia.Heuristic(Boscia.rounding_hyperplane_heuristic, 0.7, :hyperplane_aware_rounding)
Expand All @@ -87,7 +86,6 @@ verbose = true

@show x
@show x_s
#@show f(x), f(x_s)
@show g(x), g(x_s)
@test isapprox(g(x), g(x_s), atol=1e-3, rtol=5e-2)
end
Expand Down

0 comments on commit b3c4e61

Please sign in to comment.