@@ -3,43 +3,45 @@ using Graphs, Test
3
3
4
4
@testset " independence problem" begin
5
5
g = Graphs. smallgraph (" petersen" )
6
- gp = Independence (g; optimizer= GreedyMethod ())
7
- res1 = solve (gp, " size max" )[]
8
- res2 = solve (gp, " counting sum" )[]
9
- res3 = solve (gp, " counting max" )[]
10
- res4 = solve (gp, " counting max2" )[]
11
- res5 = solve (gp, " counting all" )[]
12
- res6 = solve (gp, " config max" )[]
13
- res7 = solve (gp, " configs max" )[]
14
- res8 = solve (gp, " configs max2" )[]
15
- res9 = solve (gp, " configs all" )[]
16
- res10 = solve (gp, " counting all (fft)" )[]
17
- res11 = solve (gp, " counting all (finitefield)" )[]
18
- res12 = solve (gp, " config max (bounded)" )[]
19
- res13 = solve (gp, " configs max (bounded)" )[]
20
- res14 = solve (gp, " counting max3" )[]
21
- res15 = solve (gp, " configs max3" )[]
22
- res16 = solve (gp, " configs max2 (bounded)" )[]
23
- res17 = solve (gp, " configs max3 (bounded)" )[]
24
- @test res1. n == 4
25
- @test res2 == 76
26
- @test res3. n == 4 && res3. c == 5
27
- @test res4. maxorder == 4 && res4. coeffs[1 ] == 30 && res4. coeffs[2 ]== 5
28
- @test res5 == Polynomial ([1.0 , 10.0 , 30 , 30 , 5 ])
29
- @test res6. c. data ∈ res7. c. data
30
- @test all (x-> sum (x) == 4 , res7. c. data)
31
- @test all (x-> sum (x) == 3 , res8. coeffs[1 ]. data) && all (x-> sum (x) == 4 , res8. coeffs[2 ]. data) && length (res8. coeffs[1 ]. data) == 30 && length (res8. coeffs[2 ]. data) == 5
32
- @test all (x-> all (c-> sum (c) == x[1 ]- 1 , x[2 ]. data), enumerate (res9. coeffs))
33
- @test res10 ≈ res5
34
- @test res11 == res5
35
- @test res12. c. data ∈ res13. c. data
36
- @test res13. c. data == res7. c. data
37
- @test res14. maxorder == 4 && res14. coeffs[1 ]== 30 && res14. coeffs[2 ] == 30 && res14. coeffs[3 ]== 5
38
- @test all (x-> sum (x) == 2 , res15. coeffs[1 ]. data) && all (x-> sum (x) == 3 , res15. coeffs[2 ]. data) && all (x-> sum (x) == 4 , res15. coeffs[3 ]. data) &&
39
- length (res15. coeffs[1 ]. data) == 30 && length (res15. coeffs[2 ]. data) == 30 && length (res15. coeffs[3 ]. data) == 5
40
- @test all (x-> sum (x) == 3 , res16. coeffs[1 ]. data) && all (x-> sum (x) == 4 , res16. coeffs[2 ]. data) && length (res16. coeffs[1 ]. data) == 30 && length (res16. coeffs[2 ]. data) == 5
41
- @test all (x-> sum (x) == 2 , res17. coeffs[1 ]. data) && all (x-> sum (x) == 3 , res17. coeffs[2 ]. data) && all (x-> sum (x) == 4 , res17. coeffs[3 ]. data) &&
42
- length (res17. coeffs[1 ]. data) == 30 && length (res17. coeffs[2 ]. data) == 30 && length (res17. coeffs[3 ]. data) == 5
6
+ for optimizer in (GreedyMethod (), TreeSA (ntrials= 1 ))
7
+ gp = Independence (g; optimizer= optimizer)
8
+ res1 = solve (gp, " size max" )[]
9
+ res2 = solve (gp, " counting sum" )[]
10
+ res3 = solve (gp, " counting max" )[]
11
+ res4 = solve (gp, " counting max2" )[]
12
+ res5 = solve (gp, " counting all" )[]
13
+ res6 = solve (gp, " config max" )[]
14
+ res7 = solve (gp, " configs max" )[]
15
+ res8 = solve (gp, " configs max2" )[]
16
+ res9 = solve (gp, " configs all" )[]
17
+ res10 = solve (gp, " counting all (fft)" )[]
18
+ res11 = solve (gp, " counting all (finitefield)" )[]
19
+ res12 = solve (gp, " config max (bounded)" )[]
20
+ res13 = solve (gp, " configs max (bounded)" )[]
21
+ res14 = solve (gp, " counting max3" )[]
22
+ res15 = solve (gp, " configs max3" )[]
23
+ res16 = solve (gp, " configs max2 (bounded)" )[]
24
+ res17 = solve (gp, " configs max3 (bounded)" )[]
25
+ @test res1. n == 4
26
+ @test res2 == 76
27
+ @test res3. n == 4 && res3. c == 5
28
+ @test res4. maxorder == 4 && res4. coeffs[1 ] == 30 && res4. coeffs[2 ]== 5
29
+ @test res5 == Polynomial ([1.0 , 10.0 , 30 , 30 , 5 ])
30
+ @test res6. c. data ∈ res7. c. data
31
+ @test all (x-> sum (x) == 4 , res7. c. data)
32
+ @test all (x-> sum (x) == 3 , res8. coeffs[1 ]. data) && all (x-> sum (x) == 4 , res8. coeffs[2 ]. data) && length (res8. coeffs[1 ]. data) == 30 && length (res8. coeffs[2 ]. data) == 5
33
+ @test all (x-> all (c-> sum (c) == x[1 ]- 1 , x[2 ]. data), enumerate (res9. coeffs))
34
+ @test res10 ≈ res5
35
+ @test res11 == res5
36
+ @test res12. c. data ∈ res13. c. data
37
+ @test res13. c == res7. c
38
+ @test res14. maxorder == 4 && res14. coeffs[1 ]== 30 && res14. coeffs[2 ] == 30 && res14. coeffs[3 ]== 5
39
+ @test all (x-> sum (x) == 2 , res15. coeffs[1 ]. data) && all (x-> sum (x) == 3 , res15. coeffs[2 ]. data) && all (x-> sum (x) == 4 , res15. coeffs[3 ]. data) &&
40
+ length (res15. coeffs[1 ]. data) == 30 && length (res15. coeffs[2 ]. data) == 30 && length (res15. coeffs[3 ]. data) == 5
41
+ @test all (x-> sum (x) == 3 , res16. coeffs[1 ]. data) && all (x-> sum (x) == 4 , res16. coeffs[2 ]. data) && length (res16. coeffs[1 ]. data) == 30 && length (res16. coeffs[2 ]. data) == 5
42
+ @test all (x-> sum (x) == 2 , res17. coeffs[1 ]. data) && all (x-> sum (x) == 3 , res17. coeffs[2 ]. data) && all (x-> sum (x) == 4 , res17. coeffs[3 ]. data) &&
43
+ length (res17. coeffs[1 ]. data) == 30 && length (res17. coeffs[2 ]. data) == 30 && length (res17. coeffs[3 ]. data) == 5
44
+ end
43
45
end
44
46
45
47
@testset " save load" begin
79
81
save_configs (" _test.txt" , m; format= :text )
80
82
mb = load_configs (" _test.txt" ; format= :text , nflavors= 3 )
81
83
@test mb == m
82
- end
84
+ end
85
+
86
+ @testset " slicing" begin
87
+ g = Graphs. smallgraph (" petersen" )
88
+ gp = Independence (g; optimizer= TreeSA (nslices= 5 , ntrials= 1 ))
89
+ res1 = solve (gp, " size max" )[]
90
+ res2 = solve (gp, " counting sum" )[]
91
+ res3 = solve (gp, " counting max" )[]
92
+ res4 = solve (gp, " counting max2" )[]
93
+ res5 = solve (gp, " counting all" )[]
94
+ res6 = solve (gp, " config max" )[]
95
+ res7 = solve (gp, " configs max" )[]
96
+ res8 = solve (gp, " configs max2" )[]
97
+ res9 = solve (gp, " configs all" )[]
98
+ res10 = solve (gp, " counting all (fft)" )[]
99
+ res11 = solve (gp, " counting all (finitefield)" )[]
100
+ res12 = solve (gp, " config max (bounded)" )[]
101
+ res13 = solve (gp, " configs max (bounded)" )[]
102
+ res14 = solve (gp, " counting max3" )[]
103
+ res15 = solve (gp, " configs max3" )[]
104
+ res16 = solve (gp, " configs max2 (bounded)" )[]
105
+ res17 = solve (gp, " configs max3 (bounded)" )[]
106
+ @test res1. n == 4
107
+ @test res2 == 76
108
+ @test res3. n == 4 && res3. c == 5
109
+ @test res4. maxorder == 4 && res4. coeffs[1 ] == 30 && res4. coeffs[2 ]== 5
110
+ @test res5 == Polynomial ([1.0 , 10.0 , 30 , 30 , 5 ])
111
+ @test res6. c. data ∈ res7. c. data
112
+ @test all (x-> sum (x) == 4 , res7. c. data)
113
+ @test all (x-> sum (x) == 3 , res8. coeffs[1 ]. data) && all (x-> sum (x) == 4 , res8. coeffs[2 ]. data) && length (res8. coeffs[1 ]. data) == 30 && length (res8. coeffs[2 ]. data) == 5
114
+ @test all (x-> all (c-> sum (c) == x[1 ]- 1 , x[2 ]. data), enumerate (res9. coeffs))
115
+ @test res10 ≈ res5
116
+ @test res11 == res5
117
+ @test res12. c. data ∈ res13. c. data
118
+ @test res13. c == res7. c
119
+ @test res14. maxorder == 4 && res14. coeffs[1 ]== 30 && res14. coeffs[2 ] == 30 && res14. coeffs[3 ]== 5
120
+ @test all (x-> sum (x) == 2 , res15. coeffs[1 ]. data) && all (x-> sum (x) == 3 , res15. coeffs[2 ]. data) && all (x-> sum (x) == 4 , res15. coeffs[3 ]. data) &&
121
+ length (res15. coeffs[1 ]. data) == 30 && length (res15. coeffs[2 ]. data) == 30 && length (res15. coeffs[3 ]. data) == 5
122
+ @test all (x-> sum (x) == 3 , res16. coeffs[1 ]. data) && all (x-> sum (x) == 4 , res16. coeffs[2 ]. data) && length (res16. coeffs[1 ]. data) == 30 && length (res16. coeffs[2 ]. data) == 5
123
+ @test all (x-> sum (x) == 2 , res17. coeffs[1 ]. data) && all (x-> sum (x) == 3 , res17. coeffs[2 ]. data) && all (x-> sum (x) == 4 , res17. coeffs[3 ]. data) &&
124
+ length (res17. coeffs[1 ]. data) == 30 && length (res17. coeffs[2 ]. data) == 30 && length (res17. coeffs[3 ]. data) == 5
125
+ end
126
+
0 commit comments