Kappa-Dev / KappaTools

Tool suite for kappa models. Documentation and binaries can be found in the release section. Try it online at
http://kappalanguage.org/
GNU Lesser General Public License v3.0
113 stars 41 forks source link

Alarm perturbations trigger abnormally with -mixture option #630

Closed hmedina closed 3 years ago

hmedina commented 3 years ago

When taking the mixture from a snapshot via -mixture, the internal clock should be fast-forwarded to the time declared in the mixture file. If perturbations in a different file use time, weird results happen. In the below, each code pod is in a different file. The perturbation calls for a snapshot at the end of the simulation.

Invocation:

KaSim -i foo_ruleset.ka -mixture foo_mixture.ka -i foo_perturbation.ka -d foo
Parsing foo_perturbation.ka...
done
Parsing foo_ruleset.ka...
done
+ simulation parameters
+ Sanity checks
Parsing foo_mixture.ka...
done
+ Compiling...
+ Building initial simulation conditions...
         -variable declarations
         -rules
         -interventions
         -observables
         -update_domain construction
         4 (sub)observables 0 navigation steps
         -initial conditions
+ Self seeding...
+ Building initial state (1000 agents)
Done
+ Command line to rerun is: 'KaSim' '-i' 'foo_ruleset.ka' '-mixture' 'foo_mixture.ka' '-i' 'foo_perturbation.ka' '-d' 'foo' -seed 935530661
1.00 time units in 0 events
Simulation ended

foo_ruleset.ka:

%agent: A(l, r)
A(l[./1]), A(r[./1]) @ 1.0e-2 {1.0}
A(l[1/.]), A(r[1/.]) @ 1.0
%init: 1000 A()

foo_mixture.ka:

%def: "T0" "1"
%init: 1000 A(l, r)

foo_perturbation.ka:

%mod: alarm 4.0 do $STOP "snap.ka" ;

snap.ka:

// Snapshot [Event: 0]
// "uuid" : "574725003"
%def: "T0" "1"

%init: 1000 /*1 agents*/ A(l[.] r[.])

Kappa Simulator: v4.1-6-g89cf84617

Observations: 1) Zero events; KaSim did nothing 2) 1.00 time units in 0 events but I requested a stop at alarm 4.0 3) Word options usually take double dash, whereas letter options take single dash, and so -mixture makes my muscle memory trigger a syntax error Every. Single. Time. 4) The alarm for the mixture snapshot and the end-of-sim snapshot is the same 5) If I run without that --mixture option, I get several thousand events by alarm 4.0

hmedina commented 3 years ago

Update: the perturbation need not be in a different file.

With a model containing the perturbation line: %mod: alarm 400.0 ([T] > 0) do $STOP "snap_T_400.ka" ;

The witness file correctly holds: /*1*/%mod: alarm 400. ([T] > 0) do $STOP "snap_T_400.ka"; repeat [false]

And yet the requested snapshot snap_T_400.ka has:

[...]
%def: "T0" "200"
[...]

If T0 remains at 200, why did the perturbation fire?