@@ -8,13 +8,13 @@ using Random
88"""
99$TYPEDEF
1010
11- Benchmark problem with an argmax as the CO algorithm.
11+ Basic benchmark problem with an argmax as the CO algorithm.
1212
1313# Fields
1414$TYPEDFIELDS
1515"""
1616struct ArgmaxBenchmark <: AbstractBenchmark
17- " iinstances dimension, total number of classes"
17+ " instances dimension, total number of classes"
1818 instance_dim:: Int
1919 " number of features"
2020 nb_features:: Int
4545"""
4646$TYPEDSIGNATURES
4747
48- Return a top k maximizer.
48+ Return an argmax maximizer.
4949"""
5050function Utils. generate_maximizer (bench:: ArgmaxBenchmark )
5151 return one_hot_argmax
5454"""
5555$TYPEDSIGNATURES
5656
57- Generate a dataset of labeled instances for the subset selection problem.
58- The mapping between features and cost is identity.
57+ Generate a dataset of labeled instances for the argmax problem.
5958"""
60- function Utils. generate_dataset (bench:: ArgmaxBenchmark , dataset_size:: Int = 10 ; seed:: Int = 0 )
59+ function Utils. generate_dataset (
60+ bench:: ArgmaxBenchmark , dataset_size:: Int = 10 ; seed:: Int = 0 , noise_std= 0.0
61+ )
6162 (; instance_dim, nb_features) = bench
6263 rng = MersenneTwister (seed)
6364 features = [randn (rng, Float32, nb_features, instance_dim) for _ in 1 : dataset_size]
6465 mapping = Chain (Dense (nb_features => 1 ; bias= false ), vec)
6566 costs = mapping .(features)
66- solutions = one_hot_argmax .(costs)
67+ # solutions = one_hot_argmax.(costs)
68+ noisy_solutions = [
69+ one_hot_argmax (θ + noise_std * randn (rng, Float32, instance_dim)) for θ in costs
70+ ]
6771 return [
6872 DataSample (; x, θ_true, y_true) for
69- (x, θ_true, y_true) in zip (features, costs, solutions )
73+ (x, θ_true, y_true) in zip (features, costs, noisy_solutions )
7074 ]
7175end
7276
0 commit comments