Observable for rule activity

17 views
Skip to first unread message

William Waites

unread,
Mar 6, 2021, 8:38:47 AM3/6/21
to kappa...@googlegroups.com
Hi all,

Is there a way to have cumulative rule activity as an observable? I have some models where there are several different ways of getting into a particular state. It seems like the natural way of finding this out is to write an observable like,

%obs: P1 activity(‘rule 1’)
%obs: P2 activity(‘rule 2’)

where this is just a counter on the rule itself that keeps track of how many times it has fired.

I have something like this for the Kappa on hypergraphs and it’s quite useful. In that case it answers the question of how much different settings where an agent can become “infected” contribute to the total. Is there a way to do something analogous with KaSim?

Cheers,
-w


Héctor F

unread,
Mar 6, 2021, 11:49:58 PM3/6/21
to kappa-users
Hi Will,
What I do is define a token, then increment the token each time the rule is fired (so indeed a "counter", though Kappa-counters are a different thing...). The token's value is the cumulative number of rule firings, and the time derivative gives you the rule's activity (numpy's diff is useful here). E.g:

%agent: Tik(a, b)    %init: 10 Tik()
%token: Tok          %init: 0 Tok        %obs: Tok |Tok|
Tik(a[./1]), Tik(b[./1]) | 1 Tok @ 1.0


I frequently split my reversible binding rules into the binary binding, unary binding, and unbinding, with tokens for each, and so I can check if rules I consider equivalent have actually comparable activities, and other stuff the static analyzer can't catch.

Cheers,
Héctor

Ricardo Honorato Z

unread,
Mar 7, 2021, 12:20:33 AM3/7/21
to William Waites, kappa-users
I meant to reply to all.

On Sun, 7 Mar 2021 at 01:16, Ricardo Honorato Z <rikard...@gmail.com> wrote:
Hi William,

I believe the activity of a rule could, in the past, be obtained by just using 'rule 1'. To plot the activity of rule 1 you'd do

    %plot: 'rule 1'

Not sure that's still the case.

Cheers,
Ricardo

--
You received this message because you are subscribed to the Google Groups "kappa-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kappa-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kappa-users/C3DBD43C-67F7-4553-9445-4A9CA1687DA0%40ieee.org.

William Waites

unread,
Mar 20, 2021, 4:35:35 AM3/20/21
to Ricardo Honorato Z, kappa-users
Sorry for the lag in responding…

> I believe the activity of a rule could, in the past, be obtained by just using 'rule 1'. To plot the activity of rule 1 you'd do
>
> %plot: 'rule 1'
>
> Not sure that's still the case.

That would be too easy!

Unfortunately,

%agent: A()

'r1' . -> A() @ 1

%plot: ‘r1’

results in,

Parsing test.ka…
done
+ simulation parameters
+ Sanity checks
File "test.ka", line 5, characters 7-11:
r1 is not a declared variable


William Waites

unread,
Mar 20, 2021, 4:46:19 AM3/20/21
to kappa-users
Sorry for the lag in responding…

> I believe the activity of a rule could, in the past, be obtained by just using 'rule 1'. To plot the activity of rule 1 you'd do
>
> %plot: 'rule 1'
>
> Not sure that's still the case.

William Waites

unread,
Mar 20, 2021, 4:46:48 AM3/20/21
to kappa-users
> What I do is define a token, then increment the token each time the rule is fired

That’s a reasonable workaround, though it does clutter the rules and the post-hoc analysis…

Ricardo Honorato Z

unread,
Mar 22, 2021, 5:11:36 PM3/22/21
to William Waites, kappa-users
Oh :(
Reply all
Reply to author
Forward
0 new messages