-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfixed_size_shortest_path.jl
More file actions
35 lines (30 loc) · 1.01 KB
/
fixed_size_shortest_path.jl
File metadata and controls
35 lines (30 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
@testset "FixedSizeShortestPath" begin
using DecisionFocusedLearningBenchmarks.FixedSizeShortestPath
using Graphs
p = 5
grid_size = (5, 5)
A = (grid_size[1] - 1) * grid_size[2] + grid_size[1] * (grid_size[2] - 1)
b = FixedSizeShortestPathBenchmark(; p=p, grid_size=grid_size)
@test nv(b.graph) == grid_size[1] * grid_size[2]
@test ne(b.graph) == A
dataset = generate_dataset(b, 50)
model = generate_statistical_model(b)
maximizer = generate_maximizer(b)
gap = compute_gap(b, dataset, model, maximizer)
@test gap >= 0
for sample in dataset
x = sample.x
θ_true = sample.θ
y_true = sample.y
@test all(θ_true .< 0)
@test size(x) == (p,)
@test length(θ_true) == A
@test length(y_true) == A
@test isempty(sample.context)
@test all(y_true .== maximizer(θ_true))
θ = model(x)
@test length(θ) == length(θ_true)
y = maximizer(θ)
@test length(y) == length(y_true)
end
end