I would have all of the object be of the same type or implement
the same interface (A), then set some calculated facts in a rule that I would
use in a subsequent rule to get the final calculation.
This first rule fires for every instance of the type or
interface
If
A.weight > 0
Then
Set fact calculated_weight = calculated_weight + A.weight
Set fact calculated_certaintity = calculated_certaintity +
A.certaintity * A.weight
If
True
Then
Set fact final_answer = calculated_certaintity /
calculated_weight.
Something like that. Hope it helps
Barry
From:
rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of thomas kukofka
Sent: Friday, August 29, 2008 10:08 AM
To: Rules Users List
Subject: [rules-users] rule algorithm
Hello,
I search a rule implementation for the following calculation:
I have n Objects of differents types (A, B, C, ...) each with a parameter
certainty.
the overall certainty is calculated as follows: certaintyOverall = (certaintyA
* weightA + certaintyB * weightB + ... ) / (weightA + weightB + ...)
If it can be assumed that all Objects in the formula always exist it's quite
easy:
when
A (certaintyA: certainty)
B (certaintyB: certainty)
...
then
certaintyOverall = (certaintyA * weightA + certaintyB * weightB + ... )
/ (weightA + weightB + ...)
But if one ore more objects are missing the formula should be reduced to the
certainty and weights of the existing objects. But there are too many
combinations of existing/nonexisting objects. How can this be implemented in
Drools?
Regards
Thomas