Skip to content

Small-than implementation in counters as translation into new "inverted counter"#679

Merged
jiquiame merged 4 commits intomasterfrom
onde/counter-impl
Jan 4, 2024
Merged

Small-than implementation in counters as translation into new "inverted counter"#679
jiquiame merged 4 commits intomasterfrom
onde/counter-impl

Conversation

@jiquiame
Copy link
Contributor

@jiquiame jiquiame commented Jan 3, 2024

Allows <= tests in a agent counter.

Using <= will enable in parallel a hidden inverted counter where the >= test will be made.
Counter logic is planned to be revamped to allow this naturally.

Example of use:

%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})|

Here, a counter c__inverted is added onto agent A, which manages the <= tests.

@hmedina
Copy link
Collaborator

hmedina commented Jan 3, 2024

Does this change anything besides adding the "lesser than" testing capacity?

I maintain a parser/analyzer at https://github.com/hmedina/KaSaAn which I'll need to update, so I'm just wondering if there's more to it or just this.

@jiquiame
Copy link
Contributor Author

jiquiame commented Jan 4, 2024

Does this change anything besides adding the "lesser than" testing capacity?

I maintain a parser/analyzer at https://github.com/hmedina/KaSaAn which I'll need to update, so I'm just wondering if there's more to it or just this.

Hey :-)

Not sure how you manage counters there. If there are no <= tests in the model, everything will behave the same.

It seems like KaSaAn is based on parsing snapshots ?
As for now <= is syntaxic sugar for adding a new counter, a new counter ending in __inverted will appear in the snapshots if <= is used.

It is likely we add a new logic that will remove this new counter for the rule condition to work.

Does that answer your question?

@jiquiame jiquiame merged commit f04a65d into master Jan 4, 2024
@hmedina
Copy link
Collaborator

hmedina commented Jan 4, 2024

Hey there!

Ok, if snapshots won't contain this new construct, only rules, then I don't need to update my parsing yet, as the "real" thing in the snapshot should parse fine. Will contact maps have the rule's definition (<=), or the generated new agent (__inverted)?

@jiquiame jiquiame deleted the onde/counter-impl branch January 4, 2024 16:46
@jiquiame
Copy link
Contributor Author

jiquiame commented Jan 4, 2024

In this PR, after the parsing of the .ka, the <= are gone and replaced by the use of the __inverted agent, which will then show up everywhere, including the contact maps.

Everything should work fine on your end.

jiquiame pushed a commit that referenced this pull request Jan 8, 2024
…ed counter" (#679)

* Code cleanup in counters_compiler

* Added translation from CLTE to CGTE

* Test for <= in counters

* fix ci
@jiquiame
Copy link
Contributor Author

Hello @hmedina , after discussion with @feret , we actually are hiding these counters now in snapshots since this recent commit

Sorry for the worry about this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants