Skip to content

Commit fdbc713

Browse files
committed
test fixed size shortest paths
1 parent 9721b22 commit fdbc713

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

test/fixed_size_shortest_path.jl

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,31 @@
1-
module FixedSizeShortestPathTest
1+
@testitem "FixedSizeShortestPath" begin
2+
using DecisionFocusedLearningBenchmarks.FixedSizeShortestPath
3+
using Graphs
24

3-
using DecisionFocusedLearningBenchmarks.FixedSizeShortestPath
5+
p = 5
6+
grid_size = (5, 5)
7+
A = (grid_size[1] - 1) * grid_size[2] + grid_size[1] * (grid_size[2] - 1)
8+
b = FixedSizeShortestPathBenchmark(; p=p, grid_size=grid_size)
49

5-
bench = FixedSizeShortestPathBenchmark()
10+
@test nv(b.graph) == grid_size[1] * grid_size[2]
11+
@test ne(b.graph) == A
612

7-
(; features, costs, solutions) = generate_dataset(bench)
8-
9-
model = generate_statistical_model(bench)
10-
maximizer = generate_maximizer(bench)
13+
dataset = generate_dataset(b, 50)
14+
model = generate_statistical_model(b)
15+
maximizer = generate_maximizer(b)
1116

17+
for sample in dataset
18+
x = sample.x
19+
θ_true = sample.θ
20+
y_true = sample.y
21+
@test size(x) == (p,)
22+
@test length(θ_true) == A
23+
@test length(y_true) == A
24+
@test isnothing(sample.instance)
25+
@test all(y_true .== maximizer(-θ_true))
26+
θ = model(x)
27+
@test length(θ) == length(θ_true)
28+
y = maximizer(θ)
29+
@test length(y) == length(y_true)
30+
end
1231
end

0 commit comments

Comments
 (0)