Hi. I need to implement some sort of 'adviser' or 'recommender' system,
and I'm considering JBoss Rules to do the task. It would be an adviser
for choosing which car to buy, for example. Imagine: 'I want a car which
is all-wheel-drive, and I would like it in green, but I don't mind if
it's in another color'. The user can choose how important is each
feature for him, or if it's mandatory (in the previous example, the
'all-wheel-drive' requirement is mandatory, while the color it's not).
So, I would have all the car catalog in the working memory permanently
(class Car), and I would assert a buyer (class Buyer), and I would like
to get the cars that best match the user requirements and wishes. I had
outlined something like this (pseudocode):
################
rule "CarRecommendation"
when
buyer : Buyer()
car : Car (feature1=mandatoryRequirement1,
feature2=mandatoryRequirement2, ...)
eval (carUserCompatibilityLevel(car, buyer) >
COMPATIBILITY_THRESHOLD)
then
buyer.getRecommendedCars().add(car);
end
function int carUserCompatibilityLevel(Car car, Buyer buyer) {
return [compatibility level based on car suitableness to user
preferences];
}
################
My main question is if I'm forced to use an 'eval' element in order to
get what I want. I'm afraid I need to use it, and I'm concerned about
the performance since the WorkingMemory will hold up to 10 million
'cars' (well, they aren't really cars, the car-buyer thing it's just an
example for the sake of simplicity), and the docs clearly state that
evals are not nearly as efficient as field constraints (memory usage is
not a concern in this moment).
Since the 'car' catalog is so large, I wish I could get the cars with
the highest compatibility levels first and stop when I reach, for
example, 50 recommended cars (I would add something like 'if
buyer.getRecommendedCars().size() > CAR_LIMIT retract(buyer)' to the
consequence), and so I would't have the need for a
COMPATIBILITY_THRESHOLD. I don't know if that's even possible.
I'm new to this kind of programming and any tip would be appreciated,
even if it involves to totally change the approach (i. e., not using a
rule engine for the task). Just any clue that points me in the right
direction.
Thanks in advance