(Sorry this turned out to be kind of long)
I'm a new JESS user, trying to figure out how to model
the following constraints about shipping packages:
* there are three carriers: UPS, FedEx, DHL
* there are three shipping methods: overnight, 2-day, ground
* there are three pricing models: premium, regular, discount
* Discount pricing is not available for overnight and 2-day, otherwise all pricing is
available
* Discount pricing is not available for FedEx and UPS, otherwise all pricing is
available
* We have no ground service contract with DHL, otherwise all services are available
So I wrote these rules:
; validity
(defrule gotConflict (conflict) => (printout t "Sorry, you have a conflict" crlf))
(defrule okReport (not (conflict)) => (printout t "Your choices are OK" crlf))
; rules from problem statement
(defrule rPrice (price discount ?) (or (ship overnight ?) (ship twoday ?)) => (assert
(conflict)))
(defrule rCarrier (price discount) (or (carrier UPS) (carrier FedEx)) => (assert
(conflict)))
(defrule rService (carrier DHL) (ship ground) => (assert (conflict)))
This works if I assert choices for carrier, shipping, and pricing. For example, if I do
(assert (ship ground))
(assert (carrier UPS))
(assert (price regular))
and run it, I get the OK message.
If I do
(assert (ship ground))
(assert (carrier DHL))
(assert (price regular))
and run it, I get the conflict message
So far so good. What I really want to do is answer questions like
"Can I ship overnight?" or "Can I get a discounted price?"
And if I just do
(assert (ship overnight))
and run, I get the OK message, which is correct; however if I say
(assert (price discount))
and run, I get the OK message, which is incorrect (the first two rules
imply that the only way to get a discount is to ship ground with DHL,
and the third rule says that's not allowed)
So the single fact (price discount) doesn't cause any of the rules to fire,
but if you enumerate all the carrier/ship/price triples with price=discount
you find that they all trigger at least one rule. Is there a way to get JESS
to examine these possibilities without writing code to try all the combinations?
I thought maybe backward chaining would do it, but a way to use it in this
case didn't jump out at me. Suggestions?
Thanks,
Don
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------