From 7c97f186dd54cc6643e664f8849f8add70b42881 Mon Sep 17 00:00:00 2001 From: Brian Thibault Date: Fri, 8 May 2015 15:21:24 -0500 Subject: [PATCH 1/2] Adding FIFO fact recency resolution --- lib/conflict.js | 10 +++++++++- readme.md | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/conflict.js b/lib/conflict.js index 8e7c36e..41077da 100644 --- a/lib/conflict.js +++ b/lib/conflict.js @@ -23,6 +23,13 @@ function factRecency(a, b) { return ret; } +function factRecencyInverse(a, b) { + // negate fact recency, + // but need 0 to produce 1 in ret value of strategy function + var fRI = -factRecency(a,b); + return (fRI === 0 ? 1 : fRI); +} + function activationRecency(a, b) { return a.recency - b.recency; } @@ -31,7 +38,8 @@ var strategies = { salience: salience, bucketCounter: bucketCounter, factRecency: factRecency, - activationRecency: activationRecency + activationRecency: activationRecency, + factRecencyInverse: factRecencyInverse }; exports.strategies = strategies; diff --git a/readme.md b/readme.md index e5bc0d9..1b76091 100644 --- a/readme.md +++ b/readme.md @@ -767,6 +767,7 @@ When declaring a flow it is defined with a default conflict resolution strategy. * `activationRecency` - sort activations on activation recency. This is a `LIFO` strategy the latest activation takes precedence. * `factRecency` - sort activations based on `fact` recency. Each time a fact is `asserted` or `modified` its recency is incremented. * `bucketCounter` - sort activations on the internal `bucket` counter. The bucket counter is incremented after an activation is fired and the internal `workingMemory` is altered. +* `factRecencyInverse` - sort activations by the oldest fact first. This is a `FIFO` strategy, the earliest fact takes precedence. The default conflict resolution strategy consists of `salience` and `activationRecency`. From b8840b5f75aab958559aa0e7a487ed3708b04a20 Mon Sep 17 00:00:00 2001 From: Brian Thibault Date: Fri, 8 May 2015 16:39:01 -0500 Subject: [PATCH 2/2] Bumping version number --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3155750..2aa2485 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nools", "description": "A rules engine for node", - "version": "0.4.1", + "version": "0.4.2", "bin": { "nools": "./bin/nools" },