File tree Expand file tree Collapse file tree 2 files changed +14
-14
lines changed Expand file tree Collapse file tree 2 files changed +14
-14
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ using LinearAlgebra: dot
88using SCIP: SCIP
99using SimpleWeightedGraphs: SimpleWeightedDiGraph
1010using StatsBase: StatsBase
11+ using Statistics: mean
1112
1213include (" data_sample.jl" )
1314include (" interface.jl" )
Original file line number Diff line number Diff line change @@ -137,21 +137,20 @@ function compute_gap(
137137 bench:: AbstractBenchmark ,
138138 dataset:: AbstractVector{<:DataSample} ,
139139 statistical_model,
140- maximizer;
141- percentage :: Bool = false ,
140+ maximizer,
141+ op = mean ,
142142)
143- res = 0.0
144143 check = is_minimization_problem (bench)
145144
146- for sample in dataset
147- target_obj = objective_value (bench, sample)
148- x = sample. x
149- θ = statistical_model (x)
150- y = maximizer (θ; maximizer_kwargs (bench, sample) ... )
151- obj = objective_value ( bench, sample, y )
152- Δ = check ? obj - target_obj : target_obj - obj
153- res += Δ / abs ( target_obj)
154- end
155- gap = res / length (dataset)
156- return percentage ? gap * 100 : gap
145+ return op (
146+ map (dataset) do sample
147+ target_obj = objective_value (bench, sample)
148+ x = sample . x
149+ θ = statistical_model (x )
150+ y = maximizer (θ; maximizer_kwargs ( bench, sample) ... )
151+ obj = objective_value (bench, sample, y)
152+ Δ = check ? obj - target_obj : target_obj - obj
153+ return Δ / abs (target_obj)
154+ end ,
155+ )
157156end
You can’t perform that action at this time.
0 commit comments