|
1 | 1 | @testitem "Argmax2D" begin |
2 | 2 | using DecisionFocusedLearningBenchmarks |
3 | 3 |
|
4 | | - instance_dim = 10 |
5 | 4 | nb_features = 5 |
6 | | - |
7 | | - b = ArgmaxBenchmark(; instance_dim=instance_dim, nb_features=nb_features) |
| 5 | + b = Argmax2DBenchmark(; nb_features=nb_features) |
8 | 6 |
|
9 | 7 | io = IOBuffer() |
10 | 8 | show(io, b) |
11 | | - @test String(take!(io)) == "ArgmaxBenchmark(instance_dim=10, nb_features=5)" |
| 9 | + @test String(take!(io)) == "Argmax2DBenchmark(nb_features=5)" |
12 | 10 |
|
13 | 11 | dataset = generate_dataset(b, 50) |
14 | 12 | model = generate_statistical_model(b) |
15 | 13 | maximizer = generate_maximizer(b) |
16 | 14 |
|
17 | 15 | for (i, sample) in enumerate(dataset) |
18 | | - (; x, θ_true, y_true) = sample |
19 | | - @test size(x) == (nb_features, instance_dim) |
20 | | - @test length(θ_true) == instance_dim |
21 | | - @test length(y_true) == instance_dim |
22 | | - @test isnothing(sample.instance) |
23 | | - @test all(y_true .== maximizer(θ_true)) |
| 16 | + (; x, θ_true, y_true, instance) = sample |
| 17 | + @test length(x) == nb_features |
| 18 | + @test length(θ_true) == 2 # 2D vectors |
| 19 | + @test length(y_true) == 2 # 2D point |
| 20 | + @test !isnothing(sample.instance) # instance is a polytope |
| 21 | + @test instance isa Vector{Vector{Float64}} # polytope is vector of 2D points |
| 22 | + @test all(length(vertex) == 2 for vertex in instance) # all vertices are 2D |
| 23 | + @test y_true in instance # solution should be a vertex of the polytope |
| 24 | + @test y_true == maximizer(θ_true; instance=instance) |
24 | 25 |
|
25 | 26 | θ = model(x) |
26 | | - @test length(θ) == instance_dim |
| 27 | + @test length(θ) == 2 # 2D vector |
27 | 28 |
|
28 | | - y = maximizer(θ) |
29 | | - @test length(y) == instance_dim |
| 29 | + y = maximizer(θ; instance=instance) |
| 30 | + @test length(y) == 2 # 2D point |
| 31 | + @test y in instance # solution should be a vertex of the polytope |
30 | 32 | end |
31 | 33 | end |
0 commit comments