Skip to content

Commit

Permalink
Test for <= in counters
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinepouille committed Jan 3, 2024
1 parent 788731c commit 686c6d3
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/integration/compiler/counters_smaller_than/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#Command-line:
"${KAPPABIN}"KaSim -l 1 counters_smaller_than.ka -seed 23014 -d output -syntax 4 || true
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
%agent: A(c{=0 / += 7})
%agent: B()

'rule_a' A(c{<=2}) -> A(c{+=1}) @ 1
'rule_b' A(c{>=5}) -> A(c{-=1}) @ 1
'rule_c' A(c{=3}) -> A(c{+=1}) @ 1
'rule_aa' A(c{<=1}),. -> ., B() @ 0.2

%init: 10 A(c{=0})
%init: 10 A(c{=7})

// %obs: 'A' |A()|
%obs: 'B' |B()|
%obs: 'A0' |A(c{=0})|
%obs: 'A1' |A(c{=1})|
%obs: 'A2' |A(c{=2})|
%obs: 'A3' |A(c{=3})|
%obs: 'A4' |A(c{=4})|
%obs: 'A5' |A(c{=5})|
%obs: 'A6' |A(c{=6})|
%obs: 'A7' |A(c{=7})|
19 changes: 19 additions & 0 deletions tests/integration/compiler/counters_smaller_than/output/LOG.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Parsing counters_smaller_than.ka...
done
+ simulation parameters
+ Sanity checks
+ Compiling...
+ Building initial simulation conditions...
-variable declarations
-rules
-interventions
-observables
-update_domain construction
28 (sub)observables 58 navigation steps
-initial conditions
+ Building initial state (200 agents)
Done
+ Command line to rerun is: 'KaSim' '-l' '1' 'counters_smaller_than.ka' '-seed' '23014' '-d' 'output' '-syntax' '4'
______________________________________________________________________
######################################################################
Simulation ended
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Output of 'KaSim' '-l' '1' 'counters_smaller_than.ka' '-seed' '23014' '-d' 'output' '-syntax' '4'
"[T]","B","A0","A1","A2","A3","A4","A5","A6","A7"
0.,0,10,0,0,0,0,0,0,10
1.,2,3,2,2,0,1,2,3,5
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
%def: "seed" "23014"
%def: "dumpIfDeadlocked" "true"
%def: "maxConsecutiveClash" "3"
%def: "progressBarSize" "70"
%def: "progressBarSymbol" "#"
%def: "plotPeriod" "1" "t.u."
%def: "outputFileName" "data.csv"


%agent: A(c{=0/+=7} c__inverted{=0/+=7})
%agent: B()

%var:/*0*/ 'B' |B()|
%var:/*1*/ 'A0' |A(c{=0})|
%var:/*2*/ 'A1' |A(c{=1})|
%var:/*3*/ 'A2' |A(c{=2})|
%var:/*4*/ 'A3' |A(c{=3})|
%var:/*5*/ 'A4' |A(c{=4})|
%var:/*6*/ 'A5' |A(c{=5})|
%var:/*7*/ 'A6' |A(c{=6})|
%var:/*8*/ 'A7' |A(c{=7})|
%plot: [T]
%plot: B
%plot: A0
%plot: A1
%plot: A2
%plot: A3
%plot: A4
%plot: A5
%plot: A6
%plot: A7

'rule_a' A(c{>=0/+=1} c__inverted{>=5/+=-1}) @ 1
'rule_b' A(c{>=5/+=-1} c__inverted{>=0/+=1}) @ 1
'rule_c' A(c{=3/+=1} c__inverted{>=1/+=-1}) @ 1
'rule_aa' A(c[#] c__inverted{>=6})-, B()+ @ 0.2

/*0*/%mod: (|A(c__inverted{=8})| = 1) do $PRINTF ""; $PRINTF "Counter c__inverted of agent A reached maximum"; $STOP "counter_perturbation.ka"; repeat [false]
/*1*/%mod: (|A(c{=8})| = 1) do $PRINTF ""; $PRINTF "Counter c of agent A reached maximum"; $STOP "counter_perturbation.ka"; repeat [false]

%init: 10 A(c{=0} c__inverted{=7})
%init: 10 A(c{=7} c__inverted{=0})

%mod: [E] = 19 do $STOP;

0 comments on commit 686c6d3

Please sign in to comment.