Skip to content

Commit b3505c2

Browse files
committed
bugfix
1 parent e17355a commit b3505c2

2 files changed

Lines changed: 17 additions & 10 deletions

File tree

src/StochasticVehicleScheduling/StochasticVehicleScheduling.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ $TYPEDFIELDS
6363
nb_scenarios::Int = 10
6464
end
6565

66+
function Utils.objective_value(
67+
::StochasticVehicleSchedulingBenchmark, sample::DataSample, y::BitVector
68+
)
69+
return evaluate_solution(y, sample.instance)
70+
end
71+
6672
"""
6773
$TYPEDSIGNATURES
6874
@@ -92,7 +98,7 @@ function Utils.generate_dataset(
9298
]
9399
features = get_features.(instances)
94100
if compute_solutions
95-
solutions = [algorithm(instance; kwargs...) for instance in instances]
101+
solutions = [algorithm(instance; kwargs...).value for instance in instances]
96102
return [
97103
DataSample(; x=feature, instance, y_true=solution) for
98104
(instance, feature, solution) in zip(instances, features, solutions)
@@ -208,6 +214,7 @@ end
208214

209215
export StochasticVehicleSchedulingBenchmark
210216
export generate_dataset, generate_maximizer, generate_statistical_model
217+
export objective_value
211218
export plot_instance, plot_solution
212219
export compact_linearized_mip,
213220
compact_mip, column_generation_algorithm, evaluate_solution, is_feasible

src/Utils/interface.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ $TYPEDSIGNATURES
6262
For simple benchmarks where there is no instance object, maximizer does not need any keyword arguments.
6363
"""
6464
function maximizer_kwargs(
65-
::AbstractBenchmark, sample::DataSample{F,S,C,Nothing}
65+
::AbstractBenchmark, sample::DataSample{Nothing,F,S,C}
6666
) where {F,S,C}
6767
return NamedTuple()
6868
end
@@ -88,23 +88,23 @@ end
8888
"""
8989
$TYPEDSIGNATURES
9090
91-
Compute the objective value of the target in the sample (needs to exist).
91+
Compute the objective value of given solution `y`.
9292
"""
9393
function objective_value(
94-
bench::AbstractBenchmark, sample::DataSample{F,S,C,I}
95-
) where {F,S<:AbstractArray,C<:AbstractArray,I}
96-
return objective_value(bench, sample.θ_true, sample.y_true)
94+
bench::AbstractBenchmark, sample::DataSample{I,F,S,C}, y::AbstractArray
95+
) where {I,F,S,C<:AbstractArray}
96+
return objective_value(bench, sample.θ_true, y)
9797
end
9898

9999
"""
100100
$TYPEDSIGNATURES
101101
102-
Compute the objective value of given solution `y`.
102+
Compute the objective value of the target in the sample (needs to exist).
103103
"""
104104
function objective_value(
105-
bench::AbstractBenchmark, sample::DataSample{F,S,C,I}, y::AbstractArray
106-
) where {F,S,C<:AbstractArray,I}
107-
return objective_value(bench, sample.θ_true, y)
105+
bench::AbstractBenchmark, sample::DataSample{I,F,S,C}
106+
) where {I,F,S<:AbstractArray,C}
107+
return objective_value(bench, sample, sample.y_true)
108108
end
109109

110110
"""

0 commit comments

Comments
 (0)