Hi Mitch.

Make modifications to the code: using defglobals instead of simple binds.

(defglobal ?*coinCount* = 50)
(defglobal ?*totalAmount* = 100)

and make corresponding changes to all the references to ?coinCount and ?totalAmount to be ?*coinCount* and ?*totalAmount*, respectively.

Defglobals are visible everywhere in your program.

Win

Mitch Christensen wrote:

Thank you both for responding.

I can see that Ernest's solution leverages filtering, but I don't have a
clue what's going on with the CCP stuff.

I suspect I'd be better off focussing on the proper use of Jess first.

A bit off topic, but I get a "variable not bound" exception if I use a
variable in the pattern to replace the hard-coded '50' and '100' values.  Is
it illegal to reference a bound variable in a pattern?  (offending code
snippet below...)

-Mitch

(defrule find-solution
        (coin (denomination penny) (count ?cp) (amount ?ap))
        (coin (denomination nickel)
                (count ?cn&:(<= (+ ?cp ?cn) ?coinCounts))  <<-- Generates an error
                (amount ?an&:(<= (+ ?ap ?an) ?totalAmt)))

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Behalf Of [EMAIL PROTECTED]
Sent: Monday, August 11, 2003 1:20 PM
To: [EMAIL PROTECTED]
Subject: Re: JESS: Newbie question (Coin puzzle-SOLVED)


I think Win Carus wrote:


Ernest's approach reduces matching time substantially and does make it
possible in a realistic time to compute the $2.00 change combinations
using a version of your script modified as he suggest.

However ... the "generate-and-test" approach is still very
memory-intensive and a still-better alternative would be to use the CCP
approach implemented by Futtersack and Labat
(http://www.droit.univ-paris5.fr/futtersack/english/research/CCP/).
Although the approach discussed refers only to a CLIPS implementation,
Jess code is also available for download. The basic idea behind CCP is
to assert facts only as needed; and backtrack only to sensible
alternative search paths. This can reduce memory use substantially and
make some problems possible to solve (or possible to solve in reasonable
times).





Thanks, Win, for bringing this up again. Professor Futtersack used to
be a frequent correspondent in Jess's early days. Mr. Carus has
suggested to me recently that a form of CCP might gainfully be
integrated into Jess; this is on my teetering stack of worthwhile
things to investigate. I think this would be a Really Good Thing.


--------------------------------------------------------- Ernest Friedman-Hill Distributed Systems Research Phone: (925) 294-2154 Sandia National Labs FAX: (925) 294-2234 PO Box 969, MS 9012 [EMAIL PROTECTED] Livermore, CA 94550 http://herzberg.ca.sandia.gov

--------------------------------------------------------------------
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]
--------------------------------------------------------------------

--------------------------------------------------------------------
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]
--------------------------------------------------------------------





-------------------------------------------------------------------- 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] --------------------------------------------------------------------



Reply via email to