Hello,
 
  I am trying to find an efficient way of making a Jess workflow that
work with facts that behave like singletons.  Any approach I can think
of seems against the rule engine paradigm.  Could you please advise me
on how to do this properly?
 
This is what I am considering:
 
 
* A set of "input" facts is asserted into the system by Java at the
start.  
* The Jess logic turns them into a weighted "feature" facts.   Each
feature fact is simply a tuple of (feature, weight).  
* If one rule wants to emit feature X with weight 0.3, and another one
wants to emit (the same) feature X with weight 0.5, a single feature X
with weight 0.8 needs to be created.  Some features can be emitted with
negative weights as well.  When queried, the system needs to behave as
if there is only one feature of type X, with its weight equal to the
combined weights of all the features X that have been asserted.
* Other rules use the weights of the tags in their LHS conditionals.
This, fundamentally, is the primary use of the weights.
 

The key idea of the system is that the only thing that matters about the
feature facts is their combined weight.  My question is what is the most
effective way of implementing this?  One idea is that every time I need
to assert a feature X, I instead query for an existing instance of
feature X, retract it, and reassert a new one with the combined weight.
This seems somewhat ugly, because all of the asserts turn into
complicated affairs.  Another solution I can think of is to allow
multiple instances of fact X to exist in the system simultaneously, and
have the rules that rest on their sums use the (accumulate) conditional
to calculate their weighted sums.  This too seems deficient because of
the computational expensiveness of repeatedly calculating the sum
weights; and also, it would require working around the fact that Jess
does not allow repeat facts.  A third approach is to allow multiple
instances of the same feature, but have a high-salience rule that sits
around and waits for the existence of two instances of the same feature,
and then retracts them and restates one feature with a combined weight;
my gut feeling is that this is the preferable approach, but necessitates
a bit more retraction than the first solution and allows repeat facts
which are against the rules of Jess.
 

Is there an accepted way of working with this sort of weighted-singleton
facts in Jess?  Else, does one of the approaches I listed seem
preferable?
 
 
Great thanks,
Andrei Boutyline

Reply via email to