Skip to content

Commit 462ea81

Browse files
authored
Fix bug regarding exceeding max QN value (#13)
1 parent 1a0c725 commit 462ea81

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/qualitative_networks.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ end
255255
"""
256256
function limit_change(prev_value, next_value, N::Int)
257257
if next_value > prev_value
258-
limited_value = min(prev_value + 1, N + 1)
258+
limited_value = min(prev_value + 1, N)
259259
elseif next_value < prev_value
260260
limited_value = max(prev_value - 1, 0)
261261
else

test/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
55
HerbCore = "2b23ba43-8213-43cb-b5ea-38c12b45bd45"
66
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
77
MetaGraphsNext = "fa8bd995-216d-47f1-8a91-f3b68fbeb377"
8+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
89
SoleLogics = "b002da8f-3cb3-4d91-bbe3-2953433912b5"
910
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

test/test-qn.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using DynamicalSystemsBase: step!, get_state, set_state!
22
using Graphs: ne, nv
3+
using Random: seed!
34

45
@testset "QN Grammar Creation" begin
56
entities = [:a, :b, :c]
@@ -64,7 +65,11 @@ end
6465
end
6566

6667
@testset "Async QN" begin
67-
async_qn = aqn(network, N)
68-
step!(async_qn, 10)
69-
@test all(get_state(async_qn.model) .<= N)
68+
seed!(42)
69+
70+
for i = 1:100
71+
async_qn = aqn(network, N + i)
72+
step!(async_qn, 10)
73+
@test all(get_state(async_qn.model) .<= N + i)
74+
end
7075
end

0 commit comments

Comments
 (0)