Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Agenda Groups #29

Closed
paullryan opened this issue Apr 6, 2013 · 2 comments
Closed

Agenda Groups #29

paullryan opened this issue Apr 6, 2013 · 2 comments
Assignees

Comments

@paullryan
Copy link
Contributor

A really useful feature would be have agenda groups support in the default rules language. This would allow groupings of rules that need to run together because of a logic reason that could be configured semantically. Currently the only way to achieve this is through a heavy use of priority/salience.

It would look like:

rule "A group a1 rule" {
  agenda-group: "a1",
  when { ...

rule "A group a2 rule" {
  agenda-group: "a2",
  when { ...

rule "Another group a1 rule" {
  agenda-group: "a1",
  when { ...

Then there would be a nools.groupArray which would be empty by default and you would add groups to this array in the order of desired execution such as nools.groupArray = ['a1', 'a2']. This ordering would result in a rules run of first attempting "A group a1 rule" and "Another group a1 rule" then attempting "A group a2 rule". Effectively running each agenda group as a separate rete tree that get's instantiated as the one prior is finished.

@ghost ghost assigned doug-martin Apr 19, 2013
doug-martin added a commit to doug-martin/nools that referenced this issue May 25, 2013
* Added new agenda-group (noolsjs#29)
* More documentation
  * Salience
  * Agenda Groups
  * Auto-focus
  * Scope
* Cleaned up agenda and made more modular
@doug-martin doug-martin mentioned this issue May 25, 2013
@doug-martin
Copy link
Contributor

Sorry this took so long. So the new version of nools (v0.1.4) now contains agenda groups. I implemented this slightly different that what was recommended from above instead I used a similar pattern to drools agenda-groups.

So In the above example you have two agenda groups defined. In order to set focus to one of them you would use the focus method on the session. AgendaGroups are all managed inside of the agenda used by the session so each agenda uses the same rete network but activations are partitioned into different activation trees based off of their respective agenda groups (default being main).

As you focus a particular agenda group that group is added to a stack maintained by the agenda and only activations from a particular agenda group are fired until:

A) The agenda group runs out of activations to fire and it is then popped from the stack and the next agenda group takes focus.

B) Focus is called explicitly in which case that agenda group is added to the stack and takes precedence.

C) An activation with auto-focus set to true is activated at which point that activations agenda group takes focus.

Any recommendations would be appreciated and I hope this fits your needs!

-Doug

@paullryan
Copy link
Contributor Author

No need to apologize, it's open source, if I'd really needed it sooner then it's my responsibility to implement and submit as a pull request :) So thanks for doing this. I'm actually quite familiar with drools and have submitted some work to the expert engine in the past so this is perfect. I had given a design that had a minimal solution but this should work much nicer.

Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants