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
A.weight > 0
Set fact calculated_weight = calculated_weight + A.weight
Set fact calculated_certaintity = calculated_certaintity + A.certaintity
Set fact final_answer = calculated_certaintity / calculated_weight.
Something like that. Hope it helps
[mailto:firstname.lastname@example.org] On Behalf Of thomas kukofka
Sent: Friday, August 29, 2008 10:08 AM
To: Rules Users List
Subject: [rules-users] rule algorithm
I search a rule implementation for the following calculation:
I have n Objects of differents types (A, B, C, ...) each with a
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
A (certaintyA: certainty)
B (certaintyB: certainty)
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?