Re: JESS: [EXTERNAL] Question on QueryResult close() function

2013-06-28 Thread Peter Lin
Hi Daniel,

How are you measuring the leak?

It is important to look at the heap used and not the total heap allocated
to the JVM process. What I've done in the past with JESS is write a
function that uses java's runtime class to get actual memory used stats.

Runtime rt = Runtime.getRuntime();
long free = rt.freeMemory();
long total = rt.totalMemory();

If you have concerns about JVM heap getting to big, then set -Xmx to the
value you desire. If runtime stats don't help, your only viable option is
to use a profiling tool like YourKit, JProbe or some other profiler to
track down the leak.

peter


On Fri, Jun 28, 2013 at 9:21 AM, Friedman-Hill, Ernest
ejfr...@sandia.govwrote:

  Hi Daniel,

 ** **

 Closing a QueryResult doesn’t really do anything important; normal garbage
 collection will free all of its resources.

 ** **

 I used Google to see if there was a standard Jess/Matlab integration that
 I didn’t know about, but I didn’t find one; I’m afraid I don’t know
 anything about how Jess and Matlab are typically used together. Jess does
 “warm up” for a few iterations if run repeatedly with the same rules –
 i.e., “(reset)” won’t necessarily get you back to the same memory usage as
 before the first run – but this levels off quickly. It would be a good idea
 to run a heap analyzer tool to see what kind of objects are being leaked;
 that might give us a clue as to what’s happening.

 ** **

 *From:* owner-jess-us...@sandia.gov [mailto:owner-jess-us...@sandia.gov] *On
 Behalf Of *Daniel Selva
 *Sent:* Thursday, June 27, 2013 12:53 PM
 *To:* jess-users
 *Subject:* JESS: [EXTERNAL] Question on QueryResult close() function

 ** **

 Hi,

 ** **

 I am experiencing a memory leak problem in a Matlab-Jess application and I
 am trying to locate the leak. I came across the definition of the close()
 method of the QueryResult class. I have never called this method after
 using queries. 

 ** **

 1) Should I call close() after using a query?

 2) Could not calling close() be the cause of the leak? 

 ** **

 If not, I would appreciate any tips on typical causes of leaks in
 Matlab-Jess applications. 

 ** **

 Thanks in advance,


 Daniel



Re: JESS: [EXTERNAL] Jess rule validation algorithm

2013-06-06 Thread Peter Lin
the literature on rule validation and ruleset validation is pretty deep.
Check on ACMQueue for old papers on the subject dating back to 80's and
90's.

There's too much prior art to attempt any sort of explanation on a mailing
list. I've been studying the topic since 2000 and the bottom line is it's
very tough. The simplest approach is to generate facts for each rule,
assert those facts and check the rule fired. Beyond that, you'd have to
analyze the RETE network to calculate the rule dependency graph and compare
the rules fired against the dependency graph.

peter lin


On Thu, Jun 6, 2013 at 10:52 AM, Wessel, Alexander a.wes...@itcampus.dewrote:

  Hi Jess-users,

 I’ m a german computer senice student working on my master thesis.  The
 topic is rule verification in rule based systems. We are using Jess as
 rule engine. Currently I’m looking for an implementation of a rule checker
 for Jess.  Alternative I’m looking for an algorithm to recognize rule
 errors like subsumed rules, circular rules, conflicting rules and so one.
 

 ** **

 I would appreciate if you can me give me an advice where I can find an
 implementation or an algorithm for further research?

 ** **

 Thanks for your help.

 ** **

 best regards

 ** **

 Alexander Wessel

 ** **

 Email: a.wes...@itcampus.de
 Phone: +49 341 49287-0 | Fax: +49 341 49287-790

 itCampus Software- und Systemhaus GmbH | a Software AG Company
 Nonnenstrasse 37 | 04229 Leipzig | Germany | http://www.itcampus.de
 Amtsgericht Leipzig HRB 15872 | Managing Director: Guido Laures
 USt-IdNr DE202041156

 ** **

 ** **



Re: JESS: [EXTERNAL] Jess Licensing Question

2012-03-06 Thread Peter Lin
Back in 2002-2003 I used JESS to build a pre-trade compliance engine
for a trading platform.

JESS is a fantastic expert system shell. Like any other tool, the key
is taking time to learn how to use it. Logic programming is different
than imperative or OOP. The benefit is the result of how JESS is used.
I recommend to most people that ask which rule engine would you use?

On Mon, Mar 5, 2012 at 7:10 PM, Yuan Rao raoday...@hotmail.com wrote:
 Does anyone have experience licensing Jess for commercial use?

 My employer is interested in licensing the software. But getting formal
 references from Sandia turns out would take longer than we'd expected. While
 waiting for Sandia's formal references to come through, I wonder if anyone
 here have had some experience they wouldn't mind sharing.

 If you have licensed the software and have anything to say about your
 experience using the software in commercial environment, the process of
 licensing it, and any lessons learned, I'd really appreciate it.

 Thanks!

 Yuan


To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.




Re: JESS: On the Performance of Logical Retractions

2011-06-13 Thread Peter Lin
I'll second that advice. There's other resources on TMS. I've used
this page in the past, which provides a high level explanation of
different types of TMS
http://www.cis.temple.edu/~ingargio/cis587/readings/tms.html. Read as
much as you can on TMS if that's critical to your research. ACMQueue
also has lots of papers on TMS.

choosing the right TMS to solve your problem isn't easy and will
likely take lots of effort, trial and error. There's no short cut and
using TMS correctly in a real application is quite challenging. Most
of the business rules applications I've worked on and projects friends
have worked on generally don't use logical TMS. Usually I see people
use it in a simple proof of concept, but as the project grows in
complexity, they remove it. Trying to wrap one's head around a
rulebase with hundreds or thousands rules with logical TMS quickly
becomes daunting even for an experience rule developer.

Without some kind of visual tool or analysis tool to examine the
logical dependencies, following the relationship in a 2K rule ruleset
gets rather confusing.

On Sat, Jun 11, 2011 at 2:23 PM, John Everett jever...@bbn.com wrote:
 If truth maintenance is a central part of your architecture, I recommend
 Building Problem Solvers, by Kenneth Forbus and Johan de Kleer.  It's on
 Amazon:

 http://www.amazon.com/Building-Problem-Solvers-Artificial-Intelligence/dp/02
 62061570/ref=sr_1_1?ie=UTF8qid=1307815663sr=8-1

 and you can find the source code for the truth maintenance systems described
 in the book here:

 http://www.qrg.northwestern.edu/BPS/readme.html

 As part of my PhD work, I developed a reasoning system based on the LTRE, a
 forward-chaining rule engine on top of a logic-based TMS that is described
 in Building Problem Solvers. Coming from this background, I continually find
 Jess to be a Swiss Army knife of capabilities. However, if the logical
 conditional in Jess is not sufficient for your architecture, you'll probably
 need to implement a separate TMS layer. The logic-based TMS, which does fast
 (but incomplete) Boolean constraint propagation, provides a good balance
 between expressivity and efficiency.

 The problem solver architectures presented in Building Problem Solvers use
 the rule engine's rules to construct a problem-specific dependency network,
 through which the TMS propagates truth values.  For example, the CyclePad
 system

 http://www.qrg.northwestern.edu/projects/NSF/Cyclepad/aboutcp.html

 enables the user to assemble and analyze thermodynamic cycles from a palette
 of devices (turbines, pumps, heaters, throttles, coolers, etc). Once the
 user has completed the cycle design, CyclePad runs its knowledge base of
 rules to generate a dependency network that captures the relationships among
 the thermodynamic properties at the inlet and outlet of each device. The
 user can choose the working fluid for the system, and this imposes further
 logical dependencies. For example, water will condense at certain
 combinations of pressure and temperature. The user analyzes the system by
 making assumptions about thermodynamic properties that the system then
 propagates through the dependency network.



 -John



 -Original Message-
 From: Ernest Friedman-Hill [mailto:ejfr...@sandia.gov]
 Sent: Saturday, June 11, 2011 8:20 AM
 To: jess-users@sandia.gov
 Subject: Re: JESS: On the Performance of Logical Retractions


 On Jun 11, 2011, at 6:11 AM, Oliya wrote:


 But still I have a question: what type of truth maintenance is
 supported in Jess? Can you provide links to more information please.


 The logical conditional element is the only form of truth
 maintenance in Jess. I thought you said you were already using it?


 

 Ernest Friedman-Hill
 Informatics  Decision Sciences, Sandia National Laboratories
 PO Box 969, MS 9012, Livermore, CA 94550
 http://www.jessrules.com







 
 To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
 in the BODY of a message to majord...@sandia.gov, NOT to the list
 (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
 




 
 To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
 in the BODY of a message to majord...@sandia.gov, NOT to the list
 (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
 







To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.

Re: JESS: On the Performance of Logical Retractions

2011-06-10 Thread Peter Lin
I've looked at OpenRuleBench in the past and I just looked at it again
real quick.

The way the test was done is the wrong way to use a production rule
engine. That's my bias opinion. I understand the intent was to measure
the performance with the same data, and similar rules. The point I'm
trying to make is that encoding knowledge as triples is pointless and
useless for practical applications. Many researchers have extended
triples to quads and others convert complex object models to triples
back-and-forth. If knowledge naturally fits in a complex object, why
decompose it to triples or quads?

To draw an absurd anology. Would you dismantle your car every night to
store it away and then re-assemble it every morning?

Think of it this way, say we want to use Lego bricks to capture
knowledge. If the subject happens to work well with a 1x3 brick, then
all you need is 1x3 bricks. If the subject is complex, just 1x3 brick
probably isn't going to work. In the real world, there's a lot more
than 1x3 brick and the things we want to capture usually requires a
wide variety of bricks.

If you need to assert a bunch of facts and then retract 50% of those
facts, the first question should be why am I doing that? and is that
a pointless exercise? The first question I would ask is, can I use
backward chaining or query approach instead?


On Fri, Jun 10, 2011 at 12:58 AM, Md Oliya md.ol...@gmail.com wrote:
 @Peter: I werent interested to plug into Rete at first place, neither
 had should I use RETE or how does RETE perform in mind. Rather, I was
 trying to find a solution for my problem at hand, and the more and more i
 developed my own solution, i found it to be more and more similar to the
 Rete. So I intended not to reinvent the wheel, and tap into the existing
 implementations. By performance of RETE i mean the cost of building and
 maintaining the network and not the data storage and retrieval costs.
 @Ernest: I understand your point and i think the main problem would be the
 cascading effect incurred by liberal use of the logical keyword, as you
 mentioned.
 As said before, I am using the Open Rule Bench, which is a set of test cases
 for a number of rule engines such as XSB, Jess, and Jena (etc.). It is
 perfectly self contained and you can set it up and test the Jess within 15
 minutes.
 But still I have a question:what type of truth maintenance method is
 implemented in jess? Do you solely rely on the Rete memory nodes and tokens
 for this purpose?

 On Fri, Jun 10, 2011 at 1:21 AM, Peter Lin wool...@gmail.com wrote:

 By performance of RETE what are you referring to?

 There are many aspects of RETE, which one must study carefully. It's
 good that you're translating RDF to OWL, but the larger question is
 why use OWL/RDF in the first place? Unless the knowledge easily fits
 into axioms like sky is blue or typical RDF examples, there's no
 benefit to storing or using RDF. My own bias perspective on RDF/OWL.

 The real question isn't should I use RETE or how does RETE perform.
 The real question is how do I solve the problem efficiently?

 I've built compliance engines for trading systems using JESS. I can
 say from first hand experience, it's how you use the engine that has
 the biggest factor. I've done things like load 500K records to check
 compliance across a portfolio set with minimal latency for nightly
 batch processes. the key though is taking time to study existing
 literature and understanding things before jumping to a solution.

 providing concrete examples of what your doing will likely get better
 advice than making general statements.


 On Thu, Jun 9, 2011 at 12:17 PM, Md Oliya md.ol...@gmail.com wrote:
  Thank you very much Peter for the useful information. I will definitely
  look
  into that.
  but in the context of this message, i am not loading a huge (subjective
  interpretation?) knowledge base. It's 100k assertions, with the
  operations
  taking around 400 MB.
  Secondly, in my experiments, I subtracted the loading time of the
  assertions/retractions in jess, as I'm focusing on the performance of
  the
  Rete.
  Lastly, I am not doing an RDF based mapping; rather, I follow the method
  of
  Description Logic Programs for translating each Class/Property of OWL
  into
  its corresponding template.
 
 
  --Oli.
 
 
  On Fri, Jun 10, 2011 at 12:03 AM, Peter Lin wool...@gmail.com wrote:
 
  Although it may be obvious to some people, I thought I'd mention
  this well known lesson.
 
  Do not load huge knowledge base into memory. This lesson is well
  documented in existing literature on knowledge base systems. it's also
  been discussed on JESS mailing list numerous times over the years, so
  I would suggest searching JESS mailing list to learn from other
  people's experience.
 
  It's better to intelligently load knowledge base into memory as
  needed, rather than blindly load everything. Even in the case where
  someone has 256Gb of memory, one should ask why load all that into
  memory

Re: JESS: On the Performance of Logical Retractions

2011-06-09 Thread Peter Lin
Although it may be obvious to some people, I thought I'd mention
this well known lesson.

Do not load huge knowledge base into memory. This lesson is well
documented in existing literature on knowledge base systems. it's also
been discussed on JESS mailing list numerous times over the years, so
I would suggest searching JESS mailing list to learn from other
people's experience.

It's better to intelligently load knowledge base into memory as
needed, rather than blindly load everything. Even in the case where
someone has 256Gb of memory, one should ask why load all that into
memory up front.

If the test is using RDF triples, it's well known that RDF triples
produces excessive partial matches and often results in
OutOfMemoryException. The real issue isn't JESS, it's how one tries to
solve a problem. I would recommend reading Gary Riley's book on expert
systems to avoid repeating a lot of mistakes that others have already
documented.


On Thu, Jun 9, 2011 at 11:41 AM, Md Oliya md.ol...@gmail.com wrote:
 Thank you Ernest.
 I am experimenting with the Lehigh university benchmark, where i transfer
 OWL TBox into their equivalent rules in Jess, with the logical construct.
 Specifically, I am using the dataset and transformations, as used in the
 OpenRuleBench.
 As for the runtimes, I missed a point about the retractions. The fact is,
 even if the session does not contain any rules (no defrules, just
 assertions), loading the same set of retractions takes a considerable time.
 This indicates that the high runtime is mostly incurred by jess internal
 operations.
 but still, when the number of changes grows high (say more than 10%) the
 runtime is not acceptable, and rerunning with the retracted kb would be
 faster.
 I have another question as well: what type of truth maintenance method is
 implemented in jess? Do you solely rely on the Rete memory nodes and tokens
 for this purpose?

 --Oli.


 On Mon, Jun 6, 2011 at 7:37 PM, Ernest Friedman-Hill ejfr...@sandia.gov
 wrote:

 I don't think there's a particular reason in general. Retracting a fact
 takes only a little longer than asserting one, on average. But if we assume
 liberal use of logical, retracting a single fact could result in a sort of
 cascade effect whereby retracting a single fact would result in many other
 facts, and many activations, being removed also due to dependencies.  All of
 that would take time.  Still, your case seems extreme. Maybe there's
 something pathological about this particular case.


 On Jun 5, 2011, at 3:18 PM, Md Oliya wrote:

 Hi,

 I am doing some experiments with a set of rules which contain the
 logical CE.
 I intend to see the performance of Jess on a set of assertions as well as
 retractions.

 After some experiments, I found that the runtime for assertions is much
 less than that of retractions.
 In fact, the performance on retractions is so bad that I would rather re
 (run) jess on a retracted kb.


 A sample test case:
 The KB size,  number of assertions, number of retractions, and number of
 rules are 100K, 50K, 1k, and 100, respectively.
 runtimes are  initial run: 860ms,  assertions:320ms --  retractions:
 4s.


 Would you please give some hints on the reason?


 Thanks in advance.
 --Oli.

 -
 Ernest Friedman-Hill
 Informatics  Decision Sciences, Sandia National Laboratories
 PO Box 969, MS 9012, Livermore, CA 94550
 http://www.jessrules.com







 
 To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
 in the BODY of a message to majord...@sandia.gov, NOT to the list
 (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
 








To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.




Re: JESS: On the Performance of Logical Retractions

2011-06-09 Thread Peter Lin
By performance of RETE what are you referring to?

There are many aspects of RETE, which one must study carefully. It's
good that you're translating RDF to OWL, but the larger question is
why use OWL/RDF in the first place? Unless the knowledge easily fits
into axioms like sky is blue or typical RDF examples, there's no
benefit to storing or using RDF. My own bias perspective on RDF/OWL.

The real question isn't should I use RETE or how does RETE perform.
The real question is how do I solve the problem efficiently?

I've built compliance engines for trading systems using JESS. I can
say from first hand experience, it's how you use the engine that has
the biggest factor. I've done things like load 500K records to check
compliance across a portfolio set with minimal latency for nightly
batch processes. the key though is taking time to study existing
literature and understanding things before jumping to a solution.

providing concrete examples of what your doing will likely get better
advice than making general statements.


On Thu, Jun 9, 2011 at 12:17 PM, Md Oliya md.ol...@gmail.com wrote:
 Thank you very much Peter for the useful information. I will definitely look
 into that.
 but in the context of this message, i am not loading a huge (subjective
 interpretation?) knowledge base. It's 100k assertions, with the operations
 taking around 400 MB.
 Secondly, in my experiments, I subtracted the loading time of the
 assertions/retractions in jess, as I'm focusing on the performance of the
 Rete.
 Lastly, I am not doing an RDF based mapping; rather, I follow the method of
 Description Logic Programs for translating each Class/Property of OWL into
 its corresponding template.


 --Oli.


 On Fri, Jun 10, 2011 at 12:03 AM, Peter Lin wool...@gmail.com wrote:

 Although it may be obvious to some people, I thought I'd mention
 this well known lesson.

 Do not load huge knowledge base into memory. This lesson is well
 documented in existing literature on knowledge base systems. it's also
 been discussed on JESS mailing list numerous times over the years, so
 I would suggest searching JESS mailing list to learn from other
 people's experience.

 It's better to intelligently load knowledge base into memory as
 needed, rather than blindly load everything. Even in the case where
 someone has 256Gb of memory, one should ask why load all that into
 memory up front.

 If the test is using RDF triples, it's well known that RDF triples
 produces excessive partial matches and often results in
 OutOfMemoryException. The real issue isn't JESS, it's how one tries to
 solve a problem. I would recommend reading Gary Riley's book on expert
 systems to avoid repeating a lot of mistakes that others have already
 documented.


 On Thu, Jun 9, 2011 at 11:41 AM, Md Oliya md.ol...@gmail.com wrote:
  Thank you Ernest.
  I am experimenting with the Lehigh university benchmark, where i
  transfer
  OWL TBox into their equivalent rules in Jess, with the logical
  construct.
  Specifically, I am using the dataset and transformations, as used in the
  OpenRuleBench.
  As for the runtimes, I missed a point about the retractions. The fact
  is,
  even if the session does not contain any rules (no defrules, just
  assertions), loading the same set of retractions takes a considerable
  time.
  This indicates that the high runtime is mostly incurred by jess internal
  operations.
  but still, when the number of changes grows high (say more than 10%) the
  runtime is not acceptable, and rerunning with the retracted kb would be
  faster.
  I have another question as well: what type of truth maintenance method
  is
  implemented in jess? Do you solely rely on the Rete memory nodes and
  tokens
  for this purpose?
 
  --Oli.
 
 
  On Mon, Jun 6, 2011 at 7:37 PM, Ernest Friedman-Hill
  ejfr...@sandia.gov
  wrote:
 
  I don't think there's a particular reason in general. Retracting a fact
  takes only a little longer than asserting one, on average. But if we
  assume
  liberal use of logical, retracting a single fact could result in a
  sort of
  cascade effect whereby retracting a single fact would result in many
  other
  facts, and many activations, being removed also due to dependencies.
   All of
  that would take time.  Still, your case seems extreme. Maybe there's
  something pathological about this particular case.
 
 
  On Jun 5, 2011, at 3:18 PM, Md Oliya wrote:
 
  Hi,
 
  I am doing some experiments with a set of rules which contain the
  logical CE.
  I intend to see the performance of Jess on a set of assertions as well
  as
  retractions.
 
  After some experiments, I found that the runtime for assertions is
  much
  less than that of retractions.
  In fact, the performance on retractions is so bad that I would rather
  re
  (run) jess on a retracted kb.
 
 
  A sample test case:
  The KB size,  number of assertions, number of retractions, and number
  of
  rules are 100K, 50K, 1k, and 100, respectively.
  runtimes are  initial run

Re: JESS: Jess and Clojure

2011-06-03 Thread Peter Lin
I've also pondered the idea of clojure + jess with others.

The benefits of doing full LISP is powerful, even if a significant
percent of the users will never use features beyond the existing CLIPS
functionality. The other benefit I see with clojure is the
transactional memory. The STM model is quite powerful.


On Fri, Jun 3, 2011 at 10:02 AM, Ernest Friedman-Hill
ejfr...@sandia.gov wrote:
 It's been mentioned that It Would Be Cool (R) to integrate Jess and Clojure;
 I think that would ultimately have to mean that all of Jess's Lisp(esque)
 interpreter would be thrown out and replaced by Clojure's REP loop, Jess
 constructs would be defined as special forms in Clojure, etc. It would
 indeed be cool, as Clojure is a much better Lisp than JessLisp. The
 downside would be that you'd lose all semblance of CLIPS language
 compatibility, as the various quoting rules and other language minutae are
 different. That would make it minimally a candidate for Jess 8, or more
 likely a new product (CloJess, or something?)

 But honestly, I hadn't thought too much about the kind of integration you're
 experimenting with here. I'd be afraid someone would suffer a brain injury
 trying to keep all the levels of meta straight! Not to mention the
 cognitive dissonance of working with two similar-looking but uncomfortably
 different languages at once. If you like that sort of thing, though (and I
 historically do -- I've written systems that generate code that generates
 code) then it could be a lot of fun.


 On Jun 1, 2011, at 5:26 AM, Jason Morris wrote:

 Hi All,

 I was wondering if anyone else has experimented with (or is actually
 using) Jess with Clojure?  I've been hacking around with it, and I've
 actually gotten Jess 7.2 to run on the latest Clojure build with a standard
 Sun 1.6 JVM.  I'm attaching a little toy app for illustration purposes. 
  For
 those who long to have the full power of a JVM LISP behind Jess, running it
 on Clojure seems promising.

 Ernest:  Do you know of any potential snags?

 Cheers,
 Jason
 --
 Morris Technical Solutions LLC
 consult...@morris-technical-solutions.com
 (517) 304-5883
 clojure.zip

 -
 Ernest Friedman-Hill
 Informatics  Decision Sciences, Sandia National Laboratories
 PO Box 969, MS 9012, Livermore, CA 94550
 http://www.jessrules.com







 
 To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
 in the BODY of a message to majord...@sandia.gov, NOT to the list
 (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
 







To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.




Re: JESS: Complex Event Processing

2011-03-14 Thread Peter Lin
By temporal operators, what are you referring to?

it's pretty easy to add a function in JESS that does date comparison
and then use them in a rule.

for example, in the past I've implemented functions like between-time
that takes 3 input values. another example is eq-hour that just checks
if a date is in the same hour. it should only take about 3-4 hours to
implement a half dozen functions for time comparison.



On Mon, Mar 14, 2011 at 10:29 AM, Tromm, Martijn
martijn.tr...@ordina.nl wrote:
 Hi,

 Does anybody have any experience with complex event processing in Jess?
 One of the shortcomings of Rete is that there is no native support for 
 temporal operators besides matching on timestamps and checking time 
 differences



To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.




Re: JESS: Complex Event Processing

2011-03-14 Thread Peter Lin
I read the paper when it first came out. The arguments proposed in the
paper are only applicable to rule engines that are object-oriented in
design and not applicable to expert system shells like JESS, Clips or
ART.

The limitations are the result of the design of the rule engine and
not a limitation of the algorithm. Engines that use functional
LISP/Prolog like design do not have these limittions. Claiming RETE is
not good for CEP is a misunderstanding of RETE algorithm. Let's not
confuse the limitations of a specific product(s) with the algorithm.

There are many ways to solve the problem that do not require having
3600 facts. Trying to brute force a solution is neither elegant or
efficient.

On Mon, Mar 14, 2011 at 11:08 AM, Tromm, Martijn
martijn.tr...@ordina.nl wrote:
 In CEP you may need sliding time windows. If you want to check for
 combinations of events or omissions of events in every time window that a
 particular triggering event belongs to, let’s say we have a time-window of
 one hour and need to update every second, then you have 3600 facts that
 match just one event. With many events and many event-patterns that need to
 be checked (subscriptions) you end up with a lot of nodes. This is
 especially problematic in a real-time setting.

 Also you may need to consider (and thus store) a history of states of the
 rete network. This is not natively supported.

 The following article
 http://www.rn.inf.tu-dresden.de/uploads/pikm32-walzer.pdf describes the
 problem pretty well and suggests an extension on the rete algorithm to deal
 with a sliding time window operator.

 I am curious if there are other implementations or workarounds in Jess that
 work well.

 Martijn



 But this is not a Rete issue. Rete is about managing facts for rules
 containing patterns that result in boolean values. You can invent any number
 of relational operators; they are just frontent syntactic sugar where
 otherwise you have to use a call to a boolean function.

 -W

 On 14 March 2011 15:29, Tromm, Martijn martijn.tr...@ordina.nl wrote:

 Hi,

 Does anybody have any experience with complex event processing in Jess?
 One of the shortcomings of Rete is that there is no native support for
 temporal operators besides matching on timestamps and checking time
 differences



 Disclaimer
 Dit bericht met eventuele bijlagen is vertrouwelijk en uitsluitend bestemd
 voor de geadresseerde. Indien u niet de bedoelde ontvanger bent, wordt u
 verzocht de afzender te waarschuwen en dit bericht met eventuele bijlagen
 direct te verwijderen en/of te vernietigen. Het is niet toegestaan dit
 bericht en eventuele bijlagen te vermenigvuldigen, door te sturen, openbaar
 te maken, op te slaan of op andere wijze te gebruiken. Ordina N.V. en/of
 haar groepsmaatschappijen accepteren geen verantwoordelijkheid of
 aansprakelijkheid voor schade die voortvloeit uit de inhoud en/of de
 verzending van dit bericht.

 This e-mail and any attachments are confidential and are solely intended for
 the addressee. If you are not the intended recipient, please notify the
 sender and delete and/or destroy this message and any attachments
 immediately. It is prohibited to copy, to distribute, to disclose or to use
 this e-mail and any attachments in any other way. Ordina N.V. and/or its
 group companies do not accept any responsibility nor liability for any
 damage resulting from the content of and/or the transmission of this
 message.





To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.




Re: JESS: Re: calculating benefit costs

2011-01-09 Thread Peter Lin
In the interest of exploration and education, here's a few random thoughts.

The approach wolfgang mentions is an old knowledge base technique. I
like to use it for data that is constant-like. Things like code
reference tables. One example of this is auto insurance rating. Many
companies rate based on zip code and assign a numeric value for each
zip code.

If a developer hard codes the constant in the rule, it means every
time the value changes, the rule would need to be updated. The problem
is actually worse than that. Say a company sells insurance in 5 states
and there's a total of 500 zip codes. Using the hard coded approach,
the developer would need to write 500 rules. If on the other hand, the
developer uses facts to match the insurance policy to a zip code
rating fact, we can easily change the rating value for a zipcode and
not affect the rules.

The downside is we need to have good management tools for editing the
reference data. All of the reference data should be versioned and
basic validation should be performed on the data before it is deployed
to production. Unfortunately, all of the products on the market today
do not provide robust tools for managing knowledge base data. In the
past, I've written custom applications for managing knowledge data in
financial applications.

For applications that have lots of code reference data that changes
regularly, I strongly recommend using fact data instead of hard coding
constants. The other benefit is tends to reduce lots of procedural
code in the RHS of the rule. Instead of using lots of if/then/else,
the rule tends to match the facts in the LHS and use the reference
data in the RHS. To put it another way, some of the calculations have
become pre-calculated codes. This can make the rules easier to read
and maintain. Also, by precalculating some of the data, we reduce the
amount of work the rule engine has to perform each time.

Using these types of knowledge base techniques also makes it easier to
write proof and validation routines to make sure the pre-calculated
tables are accurate. I would recommend reading books on knowledge base
and expert systems to get a broader understanding of rule programming.
Most of the business rule books out there are really just user manuals
and don't go into details on the design patterns used in expert
systems. Gary Riley's book is a great place to start.


As wolfgang stated,

On Sat, Jan 8, 2011 at 10:39 AM, Wolfgang Laun wolfgang.l...@gmail.com wrote:
 All the pundits advocate to put the decision logic into the LHS. Opinions
 vary a little wrt. to the use of static facts to
 reduce the number of rules. Some say, The more rules the merrier. I feel
 that using static facts for lookup of data is justified, considering this:

 Fact data is easier to change than rule code.
 Putting the data into facts is one way of avoiding hard coded constants.
 Less code means less room for bugs.

 Now to the one rule that does it all, posted by Derek, with the cascading if
 on the RHS. Looking at the code, I've seen a few things which might be worth
 noting.

 calcAgeAsOf is called many times. Why not call once and save the result?
 Age limits and costs should be kept in a list to avoi code repetition by
 using a loop. globals are one way of making such data available.
 Setting a variable depending on ?rel and a single logic avoids code
 duplication.
 The cost result is stored in the object using a call of some Java method.
 But bypassing Jess when modifying facts is not a good idea, most of the
 time.

 Below is the much reduced code. Of course, it still has the major defeciency
 of too much logic on the RHS,


 (defglobal ?*limAge* = (list 30    40    50    60 70   )
    ?*cstEmp* = (list 11.55 18.95 38.35 65.95 104.35)
    ?*cstRel* = (list  4.20  6.05 10.90 17.80  27.40)
 )

 (defrule setCalculatedCostGCI20k5k
   ?hbj - (HrBenefitJoin (hrBenefitConfigId 1-76)
  (benefitJoinId ?bjid)
 ;;   (calculatedCost ?cost)
  (calculatedCost 0)
 ;;   (OBJECT ?obj)
  (coveredPersonId ?cPer)
  (payingPersonId ?pPer)
  (relationshipId ?rel))
     (Person (personId ?cPer)
     (dob ?dob)
 ;;  (OBJECT ?objP)
     )
 =
 ; call once, bind result
   (bind ?years (call ?objP calcAgeAsOf(call com.arahant.utils.DateUtils now
 )))

 ; avoids cut-and-paste repettion of code
   (bind ?costs  (if (eq ?rel nil) then ?*cstEmp* else ?*cstRel* fi))

   (bind ?cost nil)
   (for (bind ?i 1) (= ?i (length$  ?*limAge*)) (++ ?i)
     (if ( ?years (nth$ ?i ?*limAge*)) then
   (bind ?cost (nth$ ?i ?costs))
   (break)
     )
   )

   (if (eq ?cost nil) then
     (printout t age greater than 69...  ?years  for  ?bjid   crlf)
    else
 ;  Bypassing Jess when modifying is not a good idea, most of the time.
 ;   (call ?obj overrideAgeCost ?cost)
     (modify ?hbj (calculatedCost ?cost))
   )
 )

 -W


 On 7 January 2011 19:44, Jason Morris 

Re: JESS: Hello To Jess User Group and How Is Jess Doing?

2011-01-02 Thread Peter Lin
edson is a member of drools team for those who don't know.



On Sat, Jan 1, 2011 at 6:01 PM, dc tech dctech1...@gmail.com wrote:
 Thank's Edson. Will check it out.
 Drools seems to have come a long compared to when I last looked at it -
 given that you have a foot in both camps, any wisdom and guidance would much
 appreciated. My bias is towards Jess, perhaps since I got introduced to
 rules engines with the excellent Jess book but is it worth looking at
 Drools?  I like the interactive 'protype'ability with Jess using the shell
 (still on 6.1). Does Drools have similar intractivity? We are developing
 using j
 jRuby (RoR) or Java.
 Thanks!
 On Fri, Dec 31, 2010 at 3:58 PM, Edson Tirelli ed.tire...@gmail.com wrote:

   May I suggest you take a look at Tohu?

 http://community.jboss.org/wiki/Tohu

   It is a small framework to do, it seems, exactly what you
 described. It is built on top of Drools, but even if you prefer to
 write your own framework on top of Jess, it can probably give you
 ideas for your own design. Need to say, though, that I never used it
 myself, so not sure how good/bad it is, but the video demo is nice.

  Lets not forget, even the Drools reference area (and JBoss Rules /
  Drools Developer Book) recommends you read: Jess in Action: Java 
  Rule-based
  Systems

   It is an excellent book for people that want to learn about
 Rule-based Systems, so why not recommend it? :) Being a Drools
 developer, I can tell you that we always had a good relationship with
 the Jess community, and we have much more to gain by cooperating than
 competing. That is not to detract from one engine or the other, it is
 just the open source way of promoting innovation and education and
 building upwards from the shoulders of the giants that came first...
 :)

   Cheers and Happy New Year!

   Edson


 2010/12/31 dc tech dctech1...@gmail.com:
  Perhaps a little, but not greatly. 
  Am happy to hear. Jess was my first introduction to rules engines 4-5
  years
  back but did not use it for a production system. Now we are looking to
  build
  a 'guided navigation' type of app using Jess where the rules determine
  what
  steps does a user need to do. I am really excited to be able to use a
  rules
  engine for that type of application; I am sure many of you have built
  similar things. Will keep you posted on questions/findings/lessons.
  Not having done real development for many years, I really enjoyed using
  the
  Jess shell (still v6, from the book) and actually build small prototypes
  with rules.
  Agree on the Drools making rules more accessible.
 
  On Thu, Dec 30, 2010 at 3:17 PM, Socrates Frangis
  soc.fran...@gmail.com
  wrote:
 
  Agree with Donald, were on holiday.
 
  Any impact from things like jBoss rules or other engines?
  -Perhaps a little, but not greatly. I will applaud Red Hat for
  exposing more and more people to rule engines through open source
  however.
 
  With that said, I think the many users of Jess stick with it due to
  it's maturity and 'rule engine features' as apposed to the convenient
  bundling of open source middle-ware. I have the feeling that many will
  get introduced to rule engines through Drools now, but when searching
  for something that gets the job done they will sway elsewhere.
 
  Lets not forget, even the Drools reference area (and JBoss Rules /
  Drools Developer Book) recommends you read:
  Jess in Action: Java Rule-based Systems
 
 
  On Thu, Dec 30, 2010 at 8:26 AM, dc tech dctech1...@gmail.com wrote:
   Rejoining the Jess community after a multi-year hiatus and notice
   that
   the
   mailing list has been very quiet.  I am curious to see how Jess is
   doing
   now
   a days? Any impact from things like jBoss rules or other engines? Is
   the
   community still pretty active?
   Happy Holidays to everyone !
 
 
 
  --
  V/R
  -Socrates Frangis
  -Mathematician  Software Engineer
 
 
 
 
  
  To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
  in the BODY of a message to majord...@sandia.gov, NOT to the list
  (use your own address!) List problems? Notify
  owner-jess-us...@sandia.gov.
  
 
 
 




 
 To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
 in the BODY of a message to majord...@sandia.gov, NOT to the list
 (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
 








To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.

Re: JESS: inference / rule engine

2010-05-01 Thread Peter Lin
A production rule engine like JESS is an inference engine.

Business process engine is not an inference engine
A validation rule engine is not an inference engine
A workflow engine is not an inference engine

There's many definitions for rule engine and many vendors claim their
bpm, workflow, or event process engine is a rule engine.

I would suggest getting Gary Riley's book on expert systems to get a
better understanding.

http://www.amazon.com/Expert-Systems-Principles-Programming-Fourth/dp/0534384471/ref=sr_1_1?ie=UTF8s=booksqid=1272760320sr=1-1

peter

On Sat, May 1, 2010 at 10:52 AM, Sashi Kumar sashi.kumar.4...@gmail.com wrote:
 i have doubt, are rule engine and inference engine same thing???
 or rule engine is a inference engine??



 -Sashi


 
 To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
 in the BODY of a message to majord...@sandia.gov, NOT to the list
 (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
 





To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.




Re: JESS: shadow facts which contains collections

2010-03-19 Thread Peter Lin
The only way to get around java collection limitations would be to
use AspectJ and weave in java beans property change support. You'd
have to assert each list to jess.rete. Not sure if that will work, but
it's a thought.

peter

On Fri, Mar 19, 2010 at 8:31 AM, Ernest Friedman-Hill ejfr...@gmail.com wrote:
 Jess doesn't have any special support for collections as JavaBeans
 properties, and in fact, I'd go so far as to say it doesn't work very well.
 There's no way for Jess to be notified when your List is modified by code
 outside of Jess, for example, or, as you note, if the objects it contains
 are modified.

 If (and only if) the objects in the list support proper equals() methods,
 then you could call Rete.updateObject() to tell Jess that something in the
 object has changed, and that should work out properly.

 On Mar 18, 2010, at 4:07 PM, Skeptic . wrote:



 Hi,
 Let's say I have this class wich instances will be added to a Rete engine
 :

 public class A {
    public int getI() {        return i;    }
    public ListB getBs() {        return
 Collections.unmodifiableList(bs);    }
    private int i;    private ListB bs;
    A(int i) {        this.i = i;        this.bs = new ArrayListB(bs);
      bs.add(1);        bs.add(2);        bs.add(3);    }
    public void change(int p) {        bs.add(new B(p));    }
 }
 And the following .clp file :
 (defclass A xxx.yyy.zzz.A)
 (defrule rule1  (A (i ?i) (bs ?bs))=  (printout t i: ?i crlf)  )
 (reset)
 and the following test code :

  Rete r = new Rete(); try {       r.batch(.../TestJess.clp);       A a =
 new A(5);
       r.add(a);       r.run();
       a.change();
       r.updateObject(a);       r.run();     } catch (JessException e) {
        e.printStackTrace();     }
 The rule will fire twice, once with i=5 and once with i=6. However, if I
 comment the line where i is modified in the changemethod, the rule will only
 fire once, because even if the list is modified, the value of bs is
 unchanged.

 If the desired behavior is to have the rule firing twice, is there a way
 to have it ?
 In fact, I know that I can add the list itself in the engine and match it
 in the LHS, but I would prefer to avoid that.

 Thanks.




 _
 Accès direct à Messenger depuis votre téléphone
 http://go.microsoft.com/?linkid=9712962

 
 To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
 in the BODY of a message to majord...@sandia.gov, NOT to the list
 (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
 

 -
 Ernest Friedman-Hill
 Informatics  Decision Sciences, Sandia National Laboratories
 PO Box 969, MS 9012, Livermore, CA 94550
 http://www.jessrules.com







 
 To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
 in the BODY of a message to majord...@sandia.gov, NOT to the list
 (use your own address!) List problems? Notify owner-jess-us...@sandia.gov

To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.




Re: JESS: trying to write a jess telnet wrapper..

2009-10-05 Thread Peter Lin
Said and I did something similar to this several years back. What I
did was I wrote a JMS client and passed messages between engine
instances via JMS.

I've been thinking about making that code available to others on my
jess contrib project site. I'm happy to clean it up and post if others
find it useful.

peter

On Mon, Oct 5, 2009 at 8:58 AM, Ernest Friedman-Hill ejfr...@gmail.com wrote:
 This isn't really Jess-specific, but rather just the general problem
 of sharing a command prompt across multiple networked clients. One
 easy solution is to use a chat server and wrap Jess as a bot.The
 chat server would take care of the I/O multiplexing. There are plenty
 of open-source Java chat servers to choose from.

 Now, that said, I have no idea why you'd want this.

 On 10/4/09, hari ks hari_...@yahoo.com wrote:
 hi,
   I need a jess telnet wrapper around Rete to modify working memory remotely
 at runtime. Here is code that I try to write:
 http://harisujathan2.blogspot.com/2009/10/jess-telnet-wrapper.html
 This has multiuser problems..
 Or is there a applet client to connect multiple clients to server for
 runtime modification of working memory?

 Thanks,
 Hari






 
 To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
 in the BODY of a message to majord...@sandia.gov, NOT to the list
 (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
 




 
 To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
 in the BODY of a message to majord...@sandia.gov, NOT to the list
 (use your own address!) List problems? Notify owner-jess-us...@sandia.gov

To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.




Re: JESS: JESS for Complex Event Processing

2009-10-01 Thread Peter Lin
If I understand the rules correctly. the example is using a fact to
define intervals. Doing it that way incurs a huge cost, since the
engine has to retract the fact at the end of the time window.

It would be more efficient to write a time function(s) and use them in
the LHS. That avoids hammering the engine, but doesn't completely
solve the issue. Rule_ce2, it retracts the stockEvent. Rule_ce1
doesn't retract the stockEvent, so over time the engine is going to
run out of memory.

Taking a step back, the bigger issue is temporal logic as it relates
to complex rulesets. In the example, there's only 2 rules that perform
a simple pattern match. One can't assume it's safe to retract the
stockEvent fact from the engine if some other rules use it.

without looking at the bigger picture and having a clear understanding
of temporal logic, any attempt to use a rule engine for event
processing is going to filled with potholes. I would suggest taking
time to study temporal logic and pattern matching theory more
thoroughly first.

peter

On Wed, Sep 30, 2009 at 3:22 PM, PF paul.i.fo...@gmail.com wrote:
 We are trying to apply Jess for complex event processing, but we have some
 problems with its speed. I want to check with this mailing list our sample
 program before we abandon the approach altogether. We also wonder if there
 is any way to speed it up. In our experiments, we detected complex events in
 streams of stock tickers or transactions of the form
 stock(Company,Price,Volume) (see below the rules in Jess while the events
 are represented as the facts pumped into the system with time stamps).

 I can provide all of our code for anyone that needs it (beside what I
 already pasted below).
 We get some very bad times and we also run of of memory for large datasets
 (10k stock ticks), while we can go up to millions of ticks and ~1% of the
 execution time with CEP systems (Drools Fusion, Esper, Etalis, etc.). I know
 that Jess might not be fit for this task, but we just wanted to try it since
 we saw some works applying it (or other production rule systems) for complex
 event processing.
 Please tell me if you see or know any optimizations.

 Thank you, regards,
 Paul Fodor

 test.clp:
 ; Complex events:
 ; stock(GOOG,Pr1,_)*stock(GOOG,Pr2,_)* (Pr1*0.8  Pr2)) - ce1.
 ; stock(MSFT,Pr1,_)*stock(MSFT,Pr2,_)* (Pr1*0.8  Pr2)) - ce2.
 ; ce1 \/ ce2 - ce3.
 ; ce1 /\ ce2 - ce4 {[T1,T2],T2-T1 20}.
 ; ce1 # ce2 - ce5.
 ; ce1*not(ce2)*ce1 - ce6.

 (deftemplate stockEvent define stock event template (slot symbol) (slot
 price) (slot time1) (slot time2))
 (deftemplate ce1 Define complex event temp (slot time1) (slot time2))
 (deftemplate ce2 Define complex event temp (slot time1) (slot time2))
 (deftemplate ce3 Define complex event temp (slot time1) (slot time2))
 (deftemplate tmp1ce3 Define complex event temp (slot time1) (slot time2))
 (deftemplate tmp2ce3 Define complex event temp (slot time1) (slot time2))
 (deftemplate ce4 Define complex event temp (slot time1) (slot time2))
 (deftemplate tmp1ce4 Define complex event temp (slot time1) (slot time2))
 (deftemplate tmp2ce4 Define complex event temp (slot time1) (slot time2))
 (deftemplate ce5 Define complex event temp (slot time1) (slot time2))
 (deftemplate tmp1ce5 Define complex event temp (slot time1) (slot time2))
 (deftemplate tmp2ce5 Define complex event temp (slot time1) (slot time2))
 (deftemplate ce6 Define complex event temp (slot time1) (slot time2))
 (deftemplate tmp1ce6 Define complex event temp (slot time1) (slot time2))
 (deftemplate tmp2ce6 Define complex event temp (slot time1) (slot time2))

 (defrule rule_ce1 Complex Event 1
  ?stockEvent1 - (stockEvent {symbol == GOOG}(price ?p1))
  ?stockEvent2 - (stockEvent {symbol == GOOG  time1  stockEvent1.time2 }
  (price ?p2:( ?p1 (* ?p2 1.2
   = (assert (ce1 (time1 ?stockEvent1.time1) (time2 ?stockEvent2.time2))) )

 (defrule rule_ce2 Complex Event 2
  ?stockEvent1 - (stockEvent {symbol == MSFT } (price ?p1))
  ?stockEvent2 - (stockEvent {symbol == MSFT  time1  stockEvent1.time2 }
  (price ?p2:( ?p1 (* ?p2 1.2
   = (retract ?stockEvent1 ?stockEvent2)
   (assert (ce2 (time1 ?stockEvent1.time1) (time2 ?stockEvent2.time2))) )

 (defrule rule_ce1_multiply Multiply Complex Event 1
  ?temp - (ce1 (time1 ?t1) (time2 ?t2))
   =
   (assert (tmp1ce3 (time1 ?t1) (time2 ?t2)))
   (assert (tmp1ce4 (time1 ?t1) (time2 ?t2)))
   (assert (tmp1ce5 (time1 ?t1) (time2 ?t2)))
   (assert (tmp1ce6 (time1 ?t1) (time2 ?t2)))
   (retract ?temp) )

 (defrule rule_ce2_multiply Multiply Complex Event 2
  ?temp - (ce2 (time1 ?t1) (time2 ?t2))
   =
   (assert (tmp2ce3 (time1 ?t1) (time2 ?t2)))
   (assert (tmp2ce4 (time1 ?t1) (time2 ?t2)))
   (assert (tmp2ce5 (time1 ?t1) (time2 ?t2)))
   (assert (tmp2ce6 (time1 ?t1) (time2 ?t2)))
   (retract ?temp) )

 (defrule rule_ce3 Complex Event ce3
  ?temp - (tmp1ce3)
   =
   (assert (ce3 (time1 ?temp.time1) (time2 ?temp.time2)))
   (retract ?temp) )

 (defrule rule_ce3 Complex Event ce3
  ?temp - 

Re: JESS: assertion - exception out of memory

2009-09-30 Thread Peter Lin
you can use the match function to see the matches

the other option is to calculate the average cost of the RETE network
to get an estimated cost.

peter

On Wed, Sep 30, 2009 at 11:21 AM, jo etaoi...@yahoo.com wrote:


 Is there a way to coax some statistics out of jess to see the impact of 
 asserted facts/rules ? or a kind of dump of the built network...

 Tx
 J



 - Original Message 
 From: Ernest Friedman-Hill ejfr...@sandia.gov
 To: jess-users jess-users@sandia.gov
 Sent: Wednesday, September 30, 2009 4:42:46 PM
 Subject: Re: JESS: assertion - exception out of memory

 Pattern-matching happens while facts are being asserted, not while rules are 
 firing, in the same way that the index of a database is built when the data 
 is inserted, not while a query is running. That's the essence of the Rete 
 algorithm used by Jess. Read the chapter on How Jess Works in the manual to 
 learn more.



 On Sep 30, 2009, at 7:54 AM, Lucia Masola wrote:

 thank you very much for your answer! I´m gonna make the changes that you
 mention. I do not have the program right here, and i came up with another
 issue regarding this problem. I encountered the out of memory exception when
 I asserted the facts, not when i want to run the rules. Do you think that
 this will solve the problem too?, or do i have to make another changes?. I
 was surprise that I couldn´t assert the facts, i thought that the rules
 didn´t matter at all until you tried to run them.

 On Wed, Sep 30, 2009 at 1:18 AM, Friedman-Hill, Ernest
 ejfr...@sandia.govwrote:

 Hi,

 I don't know why your code isn't in the message that went out to the
 mailing list, but I saw it when I approved the message for the list.
 Basically you're seeing exactly the issue discussed in the FAQ here:

 http://www.jessrules.com/jess/FAQ.shtml#Q12

 You've got a couple of rules with patterns like

 (Method ?m1)
 (Method ?m2)
 (Call (something ?m1) (something-else ?m2))
 (some-other-test ?m1 ?m2)

 These patterns first construct partial matches for all pairs of Method
 facts -- i.e., n^2 pairs, so this uses memory proportional to the square of
 the number of facts. If you just rearrange it like

 (Call (something ?m1) (something-else ?m2))
 (Method ?m1)
 (Method ?m2)
 (some-other-test ?m1 ?m2)

 then only the relevant pairs will be formed -- presumably a much smaller
 number. And if you can do something like

 (Call (something ?m1) (something-else ?m2))
 (some-other-test ?m1 ?m2)
 (Method ?m1)
 (Method ?m2)

 then the memory usage will be smaller still.


 -Original Message-
 From: owner-jess-us...@sandia.gov
 [mailto:owner-jess-us...@sandia.gov] On Behalf Of Lucia Masola
 Sent: Tuesday, September 29, 2009 10:59 PM
 To: jess-users
 Subject: JESS: assertion - exception out of memory

 Hi, I'm working in a java applications that has Jess
 embedded. I had some
 trouble in the assertions of facts. I'm asserting the facts
 from java and i
 received the exception out of memory. I realized that the
 problem is in
 the archive clp because when i tried to do the same assertion
 with another
 clp i didn't encounter the problem. I also tried to take out
 some rules from
 the clp in order to check which rule were having the problem
 and i found
 them, but i don't know how to solve it (the trouble rules are
 callerMethods,
 calleeMethods ). if anyone can help me with this issue i will
 appreciate it

 
 To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
 in the BODY of a message to majord...@sandia.gov, NOT to the list
 (use your own address!) List problems? Notify owner-jess-us...@sandia.gov

 -
 Ernest Friedman-Hill
 Informatics  Decision Sciences, Sandia National Laboratories
 PO Box 969, MS 9012, Livermore, CA 94550
 http://www.jessrules.com







 
 To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
 in the BODY of a message to majord...@sandia.gov, NOT to the list
 (use your own address!) List problems? Notify owner-jess-us...@sandia.gov

To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.




Re: JESS: Exception in thread main java.lang.OutOfMemoryError: Java heap space

2009-09-14 Thread Peter Lin
the simplest solution is to start JESS with the appropriate heap settings

-Xms256m -Xmx1024m

the default heap in java is 64mb

peter

On Mon, Sep 14, 2009 at 9:42 AM, jo etaoi...@yahoo.com wrote:
 Hi

 I got following error, which surprises me as I try to keep the amount of 
 facts to a minimum.

 Can I detect this condition *before* it is about to happen ? Any ideas on how 
 to prevent this ?

 30m is really not that long :(

 Exception in thread main java.lang.OutOfMemoryError: Java heap space
        at jess.factory.FactoryImpl.newToken(FactoryImpl.java:27)
        at jess.Node2.tokenMatchesLeft(Node2.java:326)
        at jess.Node2.doRunTestsVaryRight(Node2.java:314)
        at jess.Node2.doRunTestsVaryRight(Node2.java:299)
        at jess.Node2.runTestsVaryRight(Node2.java:292)
        at jess.Node2.callNodeLeft(Node2.java:156)
        at jess.NodeJoin.passAlong(NodeJoin.java:99)
        at jess.Node2.tokenMatchesLeft(Node2.java:328)
        at jess.Node2.doRunTestsVaryRight(Node2.java:314)
        at jess.Node2.doRunTestsVaryRight(Node2.java:299)
        at jess.Node2.runTestsVaryRight(Node2.java:292)
        at jess.Node2.callNodeLeft(Node2.java:156)
        at jess.NodeJoin.passAlong(NodeJoin.java:99)
        at jess.Node2.tokenMatchesLeft(Node2.java:328)
        at jess.Node2.doRunTestsVaryRight(Node2.java:314)
        at jess.Node2.doRunTestsVaryRight(Node2.java:299)
        at jess.Node2.runTestsVaryRight(Node2.java:292)
        at jess.Node2.callNodeLeft(Node2.java:156)
        at jess.Node1RTL.passAlong(Node1RTL.java:46)
        at jess.Node1RTL.callNodeRight(Node1RTL.java:28)
        at jess.Node1.passAlong(Node1.java:49)
        at jess.Node1MTELN.callNodeRight(Node1MTELN.java:35)
        at jess.Node1.passAlong(Node1.java:49)
        at jess.Node1TECT.callNodeRight(Node1TECT.java:40)
        at jess.NodeRoot.passAlong(NodeRoot.java:39)
        at jess.NodeRoot.callNodeRight(NodeRoot.java:14)
        at jess.FactList.processToken(FactList.java:31)
        at jess.FactList._assert(FactList.java:210)
        at jess.FactList.assertFact(FactList.java:181)
        at jess.Rete.assertFact(Rete.java:548)
        at jess.FactFunctions$Assert.call(FactFunctions.java:50)
        at jess.FunctionHolder.call(FunctionHolder.java:35)

 real    30m12.867s
 user    27m48.316s




 tx
 J





 
 To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
 in the BODY of a message to majord...@sandia.gov, NOT to the list
 (use your own address!) List problems? Notify owner-jess-us...@sandia.gov

To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.




JESS: RETE Topology Function for JESS

2009-09-04 Thread Peter Lin
I got approval from Ernest to make an announcement. For those who have
wondered which rule is more efficient? I've implemented a topology
cost function for JESS. What it does is look at the number of nodes a
fact would visit to trigger a single rule. From that, we can calculate
an average cost for the ruleset. I hope people find it useful. I'm
releasing the code as public domain, so anyone can use it, distribute
it, modify it, or do what ever you want with it.

The source code is available on google code and there is a single jar
release. In the SVN repository, there's a Duck Type RETE paper I
wrote, which provides an explanation of the topology cost function.

http://code.google.com/p/jesscontrib/downloads/list - jar release
http://code.google.com/p/jesscontrib/source/browse/#svn/trunk/JessContrib/docs
- paper on duck type RETE

if anyone has questions about the cost function, feel free to email me
directly.

peter lin



To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.




Re: JESS: jess and IM

2009-06-19 Thread Peter Lin
that's pretty cool.

I did something similar a few years back for a W3C demo using JMS to
remotely execute rules in JESS

peter

On Fri, Jun 19, 2009 at 1:56 PM, Lorenzo Miguel Elguea
Fernandezlelg...@up.edu.mx wrote:
 Hi,

 excuse my english...

 i have a proyect, to use services over instant messenger. For exmaple, use
 JESS engine in messenger client.

 if you have time to test, and a gmail acount, add j...@up.edu.mx to your
 gtalk users... and type  (batch resources/sticks.clp) to run demo

 I need to protect this apllication, for exmaple, make a code to format de
 HD, or stop the engine

 can you help me?

 thanks if you have any comments

 --
 Lorenzo Miguel Elguea Fernández
 Tecnologías de Información
 Universidad Panamericana
 México D.F.




To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.




Re: JESS: No-loop issue

2009-05-28 Thread Peter Lin
This is just my bias opinion, but the bigger issue is this. Rule
programming is logic programming. Therefore you need to think in those
terms.  What you need to do is check if the item is already in the box
before firing the rule. That can be done with either TESTCE.

The rule you have tells the rule engine to fire when ever there's an
item and box. The function is always modifying the box after it adds
the item to the multislot. the engine is doing exactly what you told
it to do. Instead, what you should do is add the item to the box if
it isn't already in it

hope that helps

peter

On Thu, May 21, 2009 at 9:14 PM, Aaron Novstrup
anovst...@stottlerhenke.com wrote:
 Hi Dr. Friedman-Hill,

 I ran into a bug in my rulebase today that I traced back to the use of the
 no-loop declaration (test case below).  This has bit other users in the past
 (see urls below), and I think it should be regarded as a bug.
 In my example, two separate facts (f-2 and f-3) activate a no-loop rule.
  When the rule fires for f-3, it modifies (retracts and reasserts) another
 fact, causing the activation associated with f-2 to be removed.  However,
 when the fact is reasserted, 'no-loop' prevents the engine from restoring
 the activation for f-2.

 This behavior seems inconsistent with the definition of the no-loop
 declaration.  The RHS of a 'no-loop' rule must not *cause* the immediate
 reactivation of the same rule, but it should not inhibit an activation that
 was already present when the rule fired.

 Thanks,
 ~~Aaron Novstrup

 http://www.mail-archive.com/jess-users@sandia.gov/msg08025.html
 http://www.mail-archive.com/jess-users@sandia.gov/msg09870.html

 ; JESS test case
 (deftemplate box
  (multislot items))

 (deffunction put-in-box (?box ?item)
  (bind ?items (fact-slot-value ?box items))
  (modify ?box (items (union$ ?items (create$ ?item
  )

 (defrule box-packer-rule
  (declare (no-loop TRUE))
  (moving ?item)
  ?b - (box)
  =
  (put-in-box ?b ?item)
  )

 (watch all)
 (reset)

 (assert (box))
 (assert (moving elvis-bobble-head-collection))
 (assert (moving jimi-hendrix-autographed-guitar))
 (run)

 ; execution trace
 Jess, the Rule Engine for the Java Platform
 Copyright (C) 2008 Sandia Corporation
 Jess Version 7.1p2 11/5/2008

 == Focus MAIN
 == f-0 (MAIN::initial-fact)
 == f-1 (MAIN::box (items ))
 == f-2 (MAIN::moving elvis-bobble-head-collection)
 == Activation: MAIN::box-packer-rule :  f-2, f-1
 == f-3 (MAIN::moving jimi-hendrix-autographed-guitar)
 == Activation: MAIN::box-packer-rule :  f-3, f-1
 FIRE 1 MAIN::box-packer-rule f-3, f-1
 == Activation: MAIN::box-packer-rule :  f-2, f-1
 = f-1 (MAIN::box (items jimi-hendrix-autographed-guitar))
 == Focus MAIN





To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.




Re: JESS: JSR-94 and JessListener

2009-05-08 Thread Peter Lin
unfortunately, JSR94 is very limited and isn't worth the hassle. it's
really there so that vendors can check off JSR94 from their list.

JSR94 really has no value, so just use JESS API directly.

peter


2009/5/8 Henschel, Jörg j.hensc...@itcampus.de:
 I'm trying to use Jess in a JSR-94 environment, as described in the Jess 
 documentation. Am I right to assume that currently there is no way to attach 
 JessListeners to the underlying Rete object?

 The JSR-94 API doesn't specify anything in that regard and short of fiddling 
 with jess.jsr94.RuleServiceProviderImpl itself, I don't see a way to add 
 event listeners.

 So - if I want event handling, I can't use the javax.rules API?

 Thank you for any insights here,
 Jörg Henschel



 
 To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
 in the BODY of a message to majord...@sandia.gov, NOT to the list
 (use your own address!) List problems? Notify owner-jess-us...@sandia.gov

To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.




Re: JESS: JSR-94 and JessListener

2009-05-08 Thread Peter Lin
writing your own rule engine wrapper is simple, so that is definitely
a better solution than using JSR94.

I've done that several times since 2000.

On Fri, May 8, 2009 at 9:59 AM, Wolfgang Laun wolfgang.l...@gmail.com wrote:
 Harsh words have been said about JSR-94, which I won't repeat here.

 One advice to give here is that you might design your own interface to
 maintain potential portability to some other rule based system.

 -W


 2009/5/8 Henschel, Jörg j.hensc...@itcampus.de

 I'm trying to use Jess in a JSR-94 environment, as described in the Jess
 documentation. Am I right to assume that currently there is no way to attach
 JessListeners to the underlying Rete object?

 The JSR-94 API doesn't specify anything in that regard and short of
 fiddling with jess.jsr94.RuleServiceProviderImpl itself, I don't see a way
 to add event listeners.

 So - if I want event handling, I can't use the javax.rules API?

 Thank you for any insights here,
 Jörg Henschel



 
 To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
 in the BODY of a message to majord...@sandia.gov, NOT to the list
 (use your own address!) List problems? Notify owner-jess-us...@sandia.gov



To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.




Re: JESS: changing facts in a fact file

2009-03-11 Thread Peter Lin
JESS simply loads the file and forgets about it.

If you want to monitor a file, you'll have to do that yourself and
then call clear and batch. If you don't want to reload the entire
file, you'll have to maintain state and keep track of the last line
and then only assert the new facts.

why not just send the new facts to JESS directly?

peter

On Wed, Mar 11, 2009 at 10:30 AM, Tanja Vicovac
tanja.vico...@tuwien.ac.at wrote:
 Hi,

 I have to create a KBS with a fact-file, which is extended every 10 minutes.
 I think it's possible to check in a certain intervall if the facts-file is
 changing or not (like polling), but is there another possibility?

 How does JESS recognize when facts in a fact-file are changing (example)?


 Thanks for advance,
 Tanja



 --
 Dipl.-Ing. Vicovac Tanja
 Forschungsgruppe Ingenieurgeodäsie
 Institut für Geodäsie und Geophysik
 Technische Universität Wien
 Gußhausstraße 27-29 / E128-3
 A-1040 Wien

 E-mail:   tanja.vico...@tuwien.ac.at
 Web:      http://info.tuwien.ac.at/ingeo
 Tel.:     (+43)-(0)1-58801-12844
 Fax:      (+43)-(0)1-58801-12894






 
 To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
 in the BODY of a message to majord...@sandia.gov, NOT to the list
 (use your own address!) List problems? Notify owner-jess-us...@sandia.gov

To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.




Re: JESS: changing facts in a fact file

2009-03-11 Thread Peter Lin
Instead of modifying the existing file, why not create a new file?
that way you can just load each new file at the set interval?

the other approach I've used in the past is to sent facts to JESS
using JMS messaging

peter

On Wed, Mar 11, 2009 at 1:00 PM, Jason Morris jason.c.mor...@gmail.com wrote:
 Hi Tanja,

 There is also an API called JNotify that allows one to receive file system
 events on Windows and LINUX.
 See:
 http://nixbit.com/cat/programming/libraries/jnotify/
 http://sourceforge.net/projects/jnotify/

 See if this is what you need.  You can also have a thread periodically
 monitor your file system.

 Cheers,
 Jason

 On Wed, Mar 11, 2009 at 10:30 AM, Tanja Vicovac
 tanja.vico...@tuwien.ac.atwrote:

 Hi,

 I have to create a KBS with a fact-file, which is extended every 10
 minutes. I think it's possible to check in a certain intervall if the
 facts-file is changing or not (like polling), but is there another
 possibility?

 How does JESS recognize when facts in a fact-file are changing (example)?


 Thanks for advance,
 Tanja



 --
 Dipl.-Ing. Vicovac Tanja
 Forschungsgruppe Ingenieurgeodäsie
 Institut für Geodäsie und Geophysik
 Technische Universität Wien
 Gußhausstraße 27-29 / E128-3
 A-1040 Wien

 E-mail:   tanja.vico...@tuwien.ac.at
 Web:      http://info.tuwien.ac.at/ingeo
 Tel.:     (+43)-(0)1-58801-12844
 Fax:      (+43)-(0)1-58801-12894






 
 To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
 in the BODY of a message to majord...@sandia.gov, NOT to the list
 (use your own address!) List problems? Notify owner-jess-us...@sandia.gov



To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.




Re: JESS: Jess speed issue! Help please?

2009-02-19 Thread Peter Lin
If you're talking about dynamically loading rules at runtime and doing
fuzzy reasoning. You'll find that using drools in compiled mode won't
scale very well due to PermGen issues with SUN and IBM JDK.

In a dynamic environment, the system could add tens of thousands of
rules over a long period of time, which means you would need to use
64bit JVM with permGen heap greater than 2GB or Oracle's 64bit
JRockit. Increasing the heap isn't a real solution though, because the
rules shouldn't be compiled to java classes to begin with for a
dynamic environment. I consider it a design flaw in drools and engines
that compile rules to classes.

The other issue is that it's harder to dynamically unload/reload a
rule with engines that compile rules to java classes. With interpreted
engines like JESS, removing or modifying a rule is straight forward
and avoids these kinds of issues.

The only way to allow a engine to modify an existing rule with engines
that compile to java classes is to have 1 classloader per rule.
Clearly, that is not scalable for thousands of rules in a ruleset.

There are ways around that, like never modifying rules and always
generating a new rule name. Having said that. Use cases that never
need to modify the rules at runtime or load new rules/rulesets work
fine in engines that compile to Java code. There are several simple
rule engines out there that compile to java classes, so it's a common
design flaw of engines that take that approach.

In general, an interpreted rule engine is much more powerful and
flexible for dynamic environments.

peter

On Thu, Feb 19, 2009 at 11:02 AM, David Ray cognitionmiss...@gmail.com wrote:
 Hi Ernest,

   Thank you very much for addressing my concerns. The time consumed
 for the compilation of rules (as you pointed out) is not a primary
 concern for our applications. I did realize that that phase would only
 occupy startup time, and for a long running system, is not the most
 relevant metric to be concerned with. There is however, an exception
 to this case where data is influencing the creation of new rules which
 may subsequently be inserted into the Rete engine at runtime. I doubt
 however that 10,000 rules would be inserted into the engine
 dynamically - and even so, at 5 or so secs. per 10K the engine's
 performance would not be a hinderance at all.

  Since I have your attention :) - I would like to share with you my
 primary use case - and the situation for which I am considering Jess.
 I am highly motivated to show Jess's applicability to my company due
 to the availability of Fuzzy Rules for Jess, for use in a highly
 transactional financial application with conceivably large data
 throughput. Fuzzy Rules being almost exclusively available in Jess,
 makes it a high priority. Any input or guidance you could share with
 me on this point would be highly appreciated - if you find that there
 are hints or insights that may become important in our usage or
 determination of Jess as an option?

 Once again, thanks

 David


 
 To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
 in the BODY of a message to majord...@sandia.gov, NOT to the list
 (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
 





To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.




Re: JESS: Jess speed issue! Help please?

2009-02-18 Thread Peter Lin
A couple of important things to consider.

By default drools uses compiled mode, which means it compiles code to
pure java when the ruleset is loaded.

To be fair, you'd have to run Drools in interpreted mode and force
drools to use mvel to evaluate the mod test.

the other option is to write a java function that implements JESS
function interface and don't use TESTCE. Instead do something like

(Random
  (x ?x:(isPrime ?x))
)

the isPrime would be a function that returns true/false

Another important thing to consider is that JESS is an expert system
shell, whereas drools is a business rule engine. The two are similar,
but not comparable on many levels. For example, JESS does type
coercion and provide a declarative + functional approach. JESS also
has solid support for multi-threaded environments, whereas drools does
not in version 4.x.

the other important thing to consider is you have to increase the
PermGen heap setting to get drools to load more than 15K rules in
compiled mode with Sun or IBM JDK. If you need to load 30K rules,
drools is going to hit the Perm limit very quickly, whereas JESS will
not.

peter

On Wed, Feb 18, 2009 at 4:28 PM, David Ray cognitionmiss...@gmail.com wrote:
 Hi,
  I am conducting a test of Jess where I am inserting 10,000 rules -
 each matching a particular modulus of a prime number and then calling
 code to aggregate prime roots of those numbers being matched. The test
 submits 100 random numbers one by one - each matching against one of
 the 10,000 rules - and the result is timed. It is a test I grabbed
 from one of the tests in the drools package which basically stress
 tests the rule engine and outputs timing results. I am doing this to
 compare the total computation time between Drools and Jess - and Jess
 is about 6 times slower, but I think the problem may not be Jess
 itself but either how my rules are constructed or some problem where
 Jess isn't flushing the I/O stream properly.

 Of particular note are the prepareConstructs() method where the rules
 are being built, and the execute() method where the rule engine is
 iteratively being invoked.

 I am attaching an executable Jar file which can be run via the
 command: java -jar primeNumTest.jar  -or- java -cp primeNumTest.jar
 PrimeFactorsTest

 Also, I am attaching the two java source files to this message.
 Program flow is pretty easy to follow looking at the main method in
 PrimeFactorsTest.java.

 I am very interested in using Jess and am evaluating its usage for my
 company, but this initial test presents some problems...

 Can anyone take a look at this and maybe tell me or point to what the
 problem may be?

 I'm a first-time majordomo user, and I seem to have a problem with
 posting (I guess
 you can't use attachments?) So I'm posting the 2 java source files inline 
 below,
 which can be compiled and run against jess.jar

 Thanks ahead of time,
 David

 



 import java.io.BufferedReader;
 import java.io.InputStreamReader;
 import java.util.Random;

 import jess.JessException;
 import jess.Rete;
 import jess.Value;


 /**
  * By default, creates 10,000 rules each matching a single prime number -
  * then inserts 100 random integers into the engine and collects those
  * rules which have fired, and all their roots outputting the timing
  * for each stage and each calculation.
  *
  * See the main() method (at the bottom) for program flow.
  *
  * @author David Ray
  */
 public class PrimeFactorsTest
 {
   private long seed;
   private long start;
   private long total;
   private int numRules;
   private int[] primes;
   private int[] randomNumbers;
   private Rete rete;
   private static long[] timepoint = new long[2];

   PrimeFactorsTest(int seed)
   {
   this.seed = seed;
   this.rete = new Rete();
   }

   /**
* Generates numFacts number of random numbers.
*
* @param numFacts
*/
   public void createRandomNums(int numFacts)
   {
   System.out.println(Generating random number knowledge...);
   Random rand = new Random(seed);
   randomNumbers = new int[numFacts];
   start = System.currentTimeMillis();
   for(int i = 0;i  numFacts;i++) {
 int nextRand = rand.nextInt(primes[numRules - 1])  + 1;
 if(nextRand  1) {--i; continue;}
 randomNumbers[i] = nextRand;
   }
   total = (System.currentTimeMillis() - start);
   System.out.println(Generated +numFacts+ random numbers in
 [+total+ msecs.]);
   }

   /**
* Inserts a Jess formatted command into the Jess Rete engine.
*
* @param statement
* @return  Value   A jess.Value object representing the
 result obtained
*  from executing the
 specified statement.
*/
   public Value insertStatement(String statement)
   {
   Value retVal = null;
  

Re: JESS: JESS Performace while emulating Event Stream Processing

2009-02-18 Thread Peter Lin
without a sample of the rules, it's difficult to know what is happening.

peter

On Wed, Feb 18, 2009 at 6:21 PM, Lars Ermert lar...@web.de wrote:
 Hello,
 i am currently writing a paper about the applicability of JESS as a
 Event Stream Processing Engine to evaluate its usefulness as a solution
 in such an environment.

 I emulate event streams by generating a certain number of different fact
 types via deftemplate and insert facts of these types directly from JAVA
 as a JavaBean into the engine. Before the engine is started via
 RunUntilHalt(), rules are defined for every fact type which wait for the
 occurrence of such a fact, and if one is found, create a new fact named
 stream-facttypename (also deffed in advance), adds a time stamp and
 inserts the data from the original fact which consists just of the name,
 an id and a float value while retracting the original fact.
 Every stream has a size restriction, half the streams are restricted by
 a maximum stream length, the others by a time window. To enforce these
 restrictions another rule per stream is added to remove deprecated facts
 from the stream.

 Now i need to evaluate the performance of the whole system. While
 everything works fine and the events are moved to the respective
 streams and purged according to the streams restriction, i have some
 problems with the performance.

 The pdf document provided by this link :

http://www.betonesel.net/JESS-testreihe-800EPS-p17-19.pdf

 shows the results of the tests.

 For the first charts a fact per second number of 800 was assumed and
 inserted in different ways.
 The line after Chart X means: I number of event types  number of
 insertions per second  runtime of test in seconds
 Half of the event/fact types  will be collected  in  time  restricted
 streams, half in length  restricted.
 number of  insertions per second means how often per second will an
 event be generated for every event type, so for 5 events and a 5
 insertions  per second 25 events will be generated per second. Unassigned
 events means how many events are in the knowledge base which
 have not been moved to their streams. Low numbers are due to the
 interruption of the processing, large number show the congestion of the
 system ( CPU, memory?!?! )
 The red graph shows the CPU usage of the engine thread alone.

 The JAVA Heap was set to sufficient 768MB, which is never used
 completely as the blue line shows (belongs to left Y-Axis)

 CHART 4 shows that with 800 fact types/streams and one insertion per
 second everything works fine while a bit rough

 CHART 1 if we try it the other way around with 100 types and 8
 insertions per second the whole system breaks down

 CHART 2+3 show different versions of the same problem with 800 events
 per second

 CHART 5+6 try to use the same insert per second value but lower the
 number of streams/facts. while it happens a bit later with less events
 per second, sooner or later the engine will suddenly need more CPU time
 and finally max out

 Can you give me any suggestions why this might happen?

 I know it is difficult to say without the source code and more knowledge
 about the exact proceedings, but before i delve into it with more detail
 i was wondering if you could give me any hints on how to optimize the
 engine for this kind of task.

 It does not seem to be a problem with the removal rules which have been
 optimized several times while improving the overal processing speed.

 Is it possible that the constant addition of new facts is a problem for
 JESS? No new rules are added during runtime yet.

 Sincerely
 Lars Ermert





 
 To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
 in the BODY of a message to majord...@sandia.gov, NOT to the list
 (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
 





To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.




Re: JESS: Performance

2008-11-17 Thread Peter Lin
without seeing an example of the rules, it's hard to know what is going on.

if you provide an example, it will be easier for others to provide tips

peter

On Mon, Nov 17, 2008 at 3:53 AM, Jessica Kampmann
[EMAIL PROTECTED] wrote:
 Dear all,

 i have performance problems asserting 11000 Facts in a for loop.
 I am using engine.assert(fact) and it takes much longer than very thing
 else.

 Regards Jessica


 --
 Freundliche Grüße / Kind regards

 Jessica Kampmann

 Software-Entwicklung

 Tel.: +49 40 398053 51
 Fax: +49 40 398053 53
 Mobil: +49 163 8288 730

 mailto:[EMAIL PROTECTED]

 http://www.ikor.de

 IKOR Products GmbH
 Ottenser Hauptstraße 56 ° 22765 Hamburg

 Geschäftsführer: Dieter Weiss

 Handelsregister Hamburg HRB 78406



 
 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]




Re: JESS: Preferred rules formulation using NOT CE

2008-11-17 Thread Peter Lin
I haven't tried running the rules, but the second format doesn't mean
the same thing as the first format.

normally, if I start a rule with a NOT CE, I have it match against a
literal value. Having a NOT CE that declares a binding isn't really
valid, if I'm not mistaken.

peter


On Mon, Nov 17, 2008 at 12:23 PM, Hal Hildebrand
[EMAIL PROTECTED] wrote:
 Which is more efficient:

 (DOMAIN::planned-process (host-id ?host) (id ?pid) (plan ?plan))
 (not (DOMAIN::host-association (host ?host)))
 (not (DOMAIN::decommission-process (process ?pid)))
 or

 (not (DOMAIN::host-association (host ?host)))
 (not (DOMAIN::decommission-process (process ?pid)))
 (DOMAIN::planned-process (host-id ?host) (id ?pid) (plan ?plan))
 Assuming that there are a large number of DOMAIN::planned-process facts in
 the system.  Are they essentially equivalent?
 Also, in general, is it more efficient to put the NOTs before or after in
 rule forms such as the above?



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]




Re: JESS: multilevel backward chaining

2008-08-26 Thread Peter Lin
what about implementing the approach Paul Haley used in ART for
backward chaining?


http://haleyai.com/wordpress/2008/03/11/goals-and-backward-chaining-using-the-rete-algorithm/

paul recently posted his old paper on his blog.

peter

On Tue, Aug 26, 2008 at 12:40 PM, Ernest Friedman-Hill
[EMAIL PROTECTED] wrote:
 On Aug 26, 2008, at 11:55 AM, Marcin Krol wrote:

 I have to say that daisy-chained backward-chaining rules are  decidedly
 non-trivial (and therefore harder to write and debug), while
 forward-chaining rules are very easy to understand (at least for me).

 I'm writing about Jess in my thesis on AI techniques, and so I wanted to
 ask you a few questions - is backward-chaining is really valuable in
 practice, outside of subjects like calling queries to databases (like in
 the example you give in Jess in Action)?

 If so, where do you think it is most useful? Are there any problems that
 are awkward to code using forward-chaining while they are more natural
 to code using backward-chaining rules?


 I think the most important applications have been the query-like ones. There
 are certainly
 plenty of techniques that work well with classical backward-chaining rules,
 but really can't be
 implemented using Jess's restricted form of backward chaining
 .

 How do you think backward-chaining adds to the expressive power of Jess
 understood as language? Is it worth the effort, both for rule engine
 developer and for the rule engine user?

 I think it *could* add tremendously to the expressiveness of the language if
 it were carried
 further. There are a lot of problems that can be expressed elegantly with
 backtracking, for example.
 There have been some user-modified versions of Jess that implement
 backtracking concepts, but none of them
 in an elegant way, AFAIK. Right now I think the truth is that beyond the
 query-like applications (which are
 equivalent in many ways to finders in JRules), Jess's backward chaining
 hasn't seen widespread use.



 I have sort of stumbled on one limitation of backward-chaining in Jess:
 constraints on slots, I found I couldn't call a function on slot:

 Jess Jess reported an error in routine ReteCompiler.addRule.
  Message: Can't use funcalls in backchained patterns __data.

 Is there a way around that? Or am I misunderstanding the problem,
 because one perhaps doesn't want to constrain slots in backward-chained
 rules as finding their values is the goal of this part of rule engine
 operation (as constraints would simply prevent firing one of b-c rules
 in the chain of reasoning in some cases, like it happened in my
 uncorrected example)?


 There's no way around it in the current version of Jess. As you know, goals
 are represented
 as regular facts, and stored in regular working memory. For anything other
 than literal constraints to
 be usable in goals, there would need to be a way of representing the
 constraint in the fact itself, and
 storing that representation in working memory. While not impossible to
 implement, this would impact many parts
 of the Jess codebase.

 Another approach would be to store goals not in working memory, but in a
 different
 structure altogether, one designed from the beginning to accommodate their
 requirements.
 In retrospect this is probably how Jess's backward chaining should have been
 implemented
 in the first place.


 -
 Ernest Friedman-Hill
 Informatics  Decision Sciences, Sandia National Laboratories
 PO Box 969, MS 9012, Livermore, CA 94550
 http://www.jessrules.com







 
 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]




Re: JESS: functions as values and calling them

2008-08-24 Thread Peter Lin
if I understand what you're trying to do, you will need to use method
cal in the test pattern like

the catch is function-fact.func needs to return boolean true/false if
you want to use it in the LHS.

peter

On Thu, Aug 14, 2008 at 11:23 AM, Hal Hildebrand
[EMAIL PROTECTED] wrote:
 I would like to have functions contained in the slot value of a fact and
 then apply them.  I can create and assign the function values by using
 (lambda ...), which seems to be what I'm looking for on that side of the
 equation:
 (deftemplate functional-fact
 (slot func)
 )
 (assert (functional-fact (func (lambda (?x) ( 1 ?x)
 However, the question becomes how do I actually call this function?  What I
 would like to do is use these in test CE:
 (deftemplate functional-fact
 (slot func)
 )
 (assert (functional-fact (func (lambda (?x) ( 1 ?x)
 (defrule test-me
 (functional-fact (func ?function))
 (test (?function 0))
 =
 (printout t 1  0 crlf))
 However, this does not work as I would expect instead failing with:
 Jess reported an error in routine call
 while executing (call ?function 0)
 while executing 'test' CE
 while executing rule LHS (TECT).
   Message: No method named '0' found in class jess.Deffunction.
   Program text: ( defrule test-me ( functional-fact ( func ?function ) ) (
 test ( ?function 0 ) ) =  ( printout t 1  0 crlf ) )  at line 11.
 Clearly, I'm not understanding this and would appreciate any help from those
 on the list.
 Thanks.




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]




Re: JESS: Modal logic in Jess

2008-08-07 Thread Peter Lin
I'm not aware of any that came close. I don't know if anyone tried to
extend JESS for modal logic. If you want to discuss this further, feel
free to email me directly.

peter

On Thu, Aug 7, 2008 at 5:07 AM, Martijn Tromm [EMAIL PROTECTED] wrote:
 Thanks for you answer and sorry for my late response.
 Indeed I did mean modal logic, epistemic, alethic and deontic logic in 
 particular. I know it's complex, especially multi-dimensional modal logics.

 I was curious if any had attempted to extend jess with modal operators.

 You said you didn't know any successful general purpose modal logic engines, 
 but do you know any that come close or have support for a decidable fragment 
 of modal logic?

 regards,
 Martijn





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]




Re: JESS: Modal logic in Jess

2008-07-29 Thread Peter Lin
by modal operators, what do you mean? Do you mean modal logic?

http://en.wikipedia.org/wiki/Modal_logic

Are you looking for temporal logic support, or modal logic support.
I'm not an expert on modal logic, but many people have tried to
implement a general purpose modal logic engine. to my knowledge there
aren't any commercial or successful modal logic rule engines. Proper
support for modal logic is very complex, so it's not a trivial task.

peter

On Tue, Jul 29, 2008 at 10:14 AM, Martijn Tromm [EMAIL PROTECTED] wrote:
 Hello,

 Has anybody ever attempted to add modal operators to the Jess language? Is 
 the Rete-algorithm appropriate for this anyway?

 best wishes,

 Martijn











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]




Re: JESS: using annotations

2008-07-17 Thread Peter Lin
The idea of adding annotations for JESS goes back several years, so I
don't think anyone questions the value of using it.  The question is
really about backward compatability for those stuck with jdk1.4.2.

a few years back I ported JESS to .NET and added support for
attributes, which is the .NET version of annotation. Actually
attributes came before java annotation. The attributes I created made
it easier to scan a library and declare all classes with the proper
attribute. Here is a short list of the attributes I used.

declare class - true/false
slot - name, true/false
static fact - true/false

For example, I made it so that I could load all classes in a library
except for classes marked declare false. by default, it would only
declare classes with declare true.  The same with slots, users could
explicitly include or exclude object fields from the deftemplate.

the static fact attribute made it easy to figure out if a classes
should be asserted as static.

You can go even further and give the rule compiler hints on how the
slots are used. For example, you could annotate a numeric field as
mutually exclusive or as value ranges. Another example is you can
annotate string fields to indicate the rules use regular expression
for the slot.

you could even add annotations to make it easier to test a rule.

peter




On Thu, Jul 17, 2008 at 3:48 AM, Wolfgang Laun
[EMAIL PROTECTED] wrote:
 I've tried to think up a few annotations as an alternative to the Bean
 introspection for deriving Jess templates from Java classes.

 Given that you can use BeanInfo and/or write your own extension of
 ReflectionClassResearcher I'd say that the extra effort isn't really
 worth it - unless you could add some additional features. These,
 however, would require supporting extensions to classes in jess (and,
 therefore, could not be implemented by a mere userfunction).

 Here is what I've come up with. Perhaps interesting, but no killer
 application as far as I can see. (I guess that the JessProperty is just
 syntactic sugar,
 because you could call such methods with a test CE.)

 JessTemplate( name=template-name,
 module=module-name,
 isSlotSpecific=boolean,
 isBackchainReactive=boolean,
 factoryClass=class,
 factoryMethod=method-name )

 factoryClass and factoryMethod can be used to create the Java object behind
 the shadow fact from Jess' assert.


 JessSlot( name=slot-name,
 defaultMethod=method-name,
 defaultClass=class )

 May be on a field or a method. defaultClass/defaultMethod may be used to
 produce the default value.


 JessPreModify()

 Method in the template class, to be called before an update from Jess.

 JessPostModify()

 Method in the template class, called after an update from Jess.
 It is possible for this method to send a PropertyChangeEvent,
 so this may be omitted from the set methods for individual slots.

 JessProperty()

 A boolean method with this annotation acts as a property
 that can be used in a conditional element as a fact-level
 predicate constraint (Jess extension).

 Example: Define a fact predicate constraint.

//Example: Code fragment
@JessTemplate
public class Car {
@JessSlot
protected int seat;
@JessSlot
protected int price;
//...
@JessProperty
public boolean eligible(){
return seat = 5  price = 1;
}
}

 A rule about a Car could now contain

  (defrule buyCar
 ?car - (Car :eligible)
  =
 (printout t buy:  ?car.id crlf)
  )

 Cheers
 Wolfgang


 Skeptic 2000 wrote:


 Yeah, I knew about BeanInfo classes, but after using them for a while,
 I'm not too satisfied (usability).

 Of course I could write some code that produce a Deftemplate, but what
 I'm interested in is a solution that include JessDE working accordingly.

 That's why I was thinking about replacing the default Bean
 introspection mechanism, but I'm not even sure it would work for JessDE.

 Thanks again.


 

  From: [EMAIL PROTECTED]
  To: jess-users@sandia.gov
  Subject: Re: JESS: using annotations
  Date: Wed, 16 Jul 2008 10:04:27 -0400
 
  Jess 7.1 still supports JDK 1.4, so annotations aren't available.
  Future Jess versions will support Java 5+ .
 
  I like the fact that Jess supports the JavaBeans spec; it's nice to be
  able to refer people to that for details. It's one less invention
  that needs to be maintained by us.
 
  It's not true, of course, that you're restricted to following naming
  conventions, as JavaBeans includes the BeanInfo concept for describing
  variances from the conventions.
 
  In any case, the jess.Deftemplate class has a complete  public API;
  you should be able write a Userfunction in Java which turned classes
  into Deftemplates following annotations using whatever scheme you
  like. If you do this, and describe it in our Wiki, then other people
 

Re: JESS: using annotations

2008-07-16 Thread Peter Lin
using annotation isn't hard. The only issue is backward compatability
for those stuck using IBM jdk 1.4. even with things like backport, it
may still leave some people out.

I know several people still stuck on IBM jdk1.4.


peter

On Tue, Jul 15, 2008 at 11:54 PM, Skeptic 2000 [EMAIL PROTECTED] wrote:

 Hi,

 Have you considered using annotations instead of naming scheme to create
 deftemplates associated to shadow facts ?

 Do you think it would be difficult thing to hack ?

 Thanks.


 



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]




Re: JESS: Slot name restrictions

2008-07-14 Thread Peter Lin
I could be wrong, but the restriction is needed because of the java
dot notation functionality.

http://www.jessrules.com/jess/docs/71/rules.html#patterns_simple

Jess (defrule two-same-age-different-name
?person1 - (person)
?person2 - (person {age == person1.age lastName != person1.lastName})
=(printout t Found two different  ?person1.age -year-old people. crlf))

JESS tries to get the age from person object in the example from
6.2.1. If slot names didn't have the restriction, it would be harder
to automatically resolve the slot.

In the past, I've replaced . with _ underline for things like URL's.

peter


On Mon, Jul 14, 2008 at 12:14 PM, Greenblatt, Alan
[EMAIL PROTECTED] wrote:
 I see there is a  new restriction with 7.1 that slot names may not contain a
 period ('.').  We will not be able to upgrade our platform to 7.1 as long as
 this restriction is in place.  We use URI's as slot names, where periods are
 accepted and common (e.g. http://en.wikipedia.org/wiki/URI;) .  What was
 the reason around putting in this restriction? Is there a possibility of
 removing this restriction or at least providing a runtime option removing
 the restriction?

 Thanks very much,

 Alan


 Alan Greenblatt
 VP, Semantic Technologies
 Metatomix, Inc.
 3 Allied Drive, Ste 210
 Dedham, MA 02026
 (781.907.6766 work
 (617.519.5583 cell
 [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]




Re: JESS: Slot name restrictions

2008-07-14 Thread Peter Lin
I could be wrong, but the new . dot notation is a new feature of JESS 7.

JESS 6 didn't support dot notation for accessing slots in the LHS or
RHS. In JESS 7.0, it didn't restrict the use of . in the slot name,
but JESS 7.1 does have the restriction.

I prefer lisp syntax myself, so I tend to stay away from using the new
Java . notation. Assuming I understand the problem correctly, it is
an issue for Alan because they are usnig . in the slot name, which
is now restricted in JESS 7.1

peter


On Mon, Jul 14, 2008 at 3:46 PM, Harrison, Gregory A
[EMAIL PROTECTED] wrote:
 The dot '.'  maybe I misread your posts but that seems similar to using
 a slash or backslash '/  \'

 Maybe there should be an acceptable set of characters listed (unless
 this was one of the acceptable characters and they just took it off the
 list, in which case that would be troublesome)

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 On Behalf Of Greenblatt, Alan
 Sent: Monday, July 14, 2008 3:38 PM
 To: jess-users@sandia.gov
 Subject: RE: JESS: Slot name restrictions

 I think I'm missing something.  Where did any OS-type terms enter
 this?

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 On Behalf Of Harrison, Gregory A
 Sent: Monday, July 14, 2008 3:16 PM
 To: jess-users@sandia.gov
 Subject: RE: JESS: Slot name restrictions

 It is interesting that such an OS-type term was chosen in the first
 place.  It seems like it would have been a risk, and here the risk has
 come to fore.  Perhaps in the new implementation you will choose a
 less risky means to encapsulate the information in a data structure
 that may be more similar to those currently in use as slot names.

 Greg

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 On Behalf Of Greenblatt, Alan
 Sent: Monday, July 14, 2008 1:54 PM
 To: jess-users@sandia.gov
 Subject: RE: JESS: Slot name restrictions

 There are a couple of significant problems with that option:

 1. We need to roundtrip the data.  I.e. We have a middleware platform
 with an embedded Jess engine.  We need to be able to not only be able
 to asserts facts based on data entering our platform, but also be able
 to regenerate data based on existing facts.  If I change periods to
 underscores then I have no way of knowing what is a valid underscore
 and what is a stand-in for a period.
 2. For a minor release of Jess (minor in the notation/release
 standpoint, not in its importance!), we need to change fundamentally
 how our platform operates, tooling surrounding our platform and
 potentially every existing application built on our platform that
 makes use of the embedded rules engine.  This seems a little onerous.


 Ideally, minor releases of any software package should be backwards
 compatible with existing releases within the same major release.
 (e.g. 7.1 should be backwards compatible with 7.0, but no guarantees
 on 6.x).

 - Alan

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 On Behalf Of Peter Lin
 Sent: Monday, July 14, 2008 12:43 PM
 To: jess-users@sandia.gov
 Subject: Re: JESS: Slot name restrictions

 I could be wrong, but the restriction is needed because of the java
 dot notation functionality.

 http://www.jessrules.com/jess/docs/71/rules.html#patterns_simple

 Jess (defrule two-same-age-different-name
?person1 - (person)
?person2 - (person {age == person1.age lastName !=
 person1.lastName})
=(printout t Found two different  ?person1.age -year-old
 people. crlf))

 JESS tries to get the age from person object in the example from
 6.2.1. If slot names didn't have the restriction, it would be harder
 to automatically resolve the slot.

 In the past, I've replaced . with _ underline for things like
 URL's.

 peter


 On Mon, Jul 14, 2008 at 12:14 PM, Greenblatt, Alan
 [EMAIL PROTECTED] wrote:
 I see there is a  new restriction with 7.1 that slot names may not
 contain a period ('.').  We will not be able to upgrade our platform

 to 7.1 as long as this restriction is in place.  We use URI's as
 slot
 names, where periods are accepted and common (e.g.
 http://en.wikipedia.org/wiki/URI;) .  What was the reason around
 putting in this restriction? Is there a possibility of removing this

 restriction or at least providing a runtime option removing the
 restriction?

 Thanks very much,

 Alan


 Alan Greenblatt
 VP, Semantic Technologies
 Metatomix, Inc.
 3 Allied Drive, Ste 210
 Dedham, MA 02026
 (781.907.6766 work
 (617.519.5583 cell
 [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

Re: JESS: Modifying a fact from the current activation

2008-07-08 Thread Peter Lin
In the past, what I've done is have a generic function, which logs
which rule + facts fired.  In my case, the business user writes/edits
rules through a custom rule editor. I wrote a rule compiler to compile
the business rules to executable JESS rules. When I generate the rule,
every action calls the function and passes in all the facts.

you might be able to do it with jess events
http://www.jessrules.com/jess/docs/71/api/jess/JessEvent.html

peter

On Tue, Jul 8, 2008 at 11:32 AM, Greenblatt, Alan
[EMAIL PROTECTED] wrote:
 You're absolutely right.  In my case though, I wanted a general purpose user
 function that could act on all of the facts which contributed to the firing
 of the rule.  I want to be able to create an audit trail of why various
 rules fired.  I didn't want the rule writer to have to worry about passing
 the appropriate parameters.

 - Alan



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]




Re: JESS: A question of optimisation

2008-07-02 Thread Peter Lin
the example confuses me a bit. If I had to do the same thing the rule
might look like this.

(defrule assignBed
?patient - (patient
(id ?p)
(unit ?u)
(bed ?b:(eq ?b 0) ) ;; if the patient hasn't been assinged.
assuming unassigned is zero
)
(care-unit
(id ?u) ;; join on the patient's assigned care-unit
(availableBeds ?beds:( ?beds 0) ) ;; checks to see if unit
has available bed
)
(bed
(id ?bedid) ;; bind bed id to variable ?bedid
(unit ?u) ;; join on the care-unit
)
=
(modify ?patient (bed ?bedid) )
)

The example in the email wouldn't work, since it would only match
patients that are already assigned to a bed in a care unit. I'm
guessing, you only want to assign beds to patients without an assigned
bed. The first pattern checks to make sure it doesn't try to find a
bed for patient that already has one.

doing it this way, the search space should be considerably smaller.

peter

On Wed, Jul 2, 2008 at 8:44 AM, Florian Fischer
[EMAIL PROTECTED] wrote:
 Hello,

 I have a question about optimizing a query in Jess.

 I have (let's take round numbers) 100 care units.  Each care unit has 20
 beds and on average 10 patients.
 I want to match patients to their beds.  A patient has an attribute
 giving its current bed.

 I could write something like
 (defrule ...
   (bed (id ?b))
   (patient (id ?p) (bed ?b))
   (not (the patient is attached to the bed))
   =
   (attach the patient to the bed)
 )

 but then, each patient is compared to each bed, which takes 2 millions
 comparisons.  I'd like to optimize that by first matching a patient to
 its care unit and then comparing the patient with the beds of that care
 unit.  That would take 1000*100 tests to match patients to care units
 and then 1000*20 tests to find the right bed.  That is 120'000 instead
 of 2'000'000 comparisons.

 So I would write something like this:

 (defrule ...
   (care-unit (id ?u))
   (bed (id ?b) (unit ?u))
   (patient (id ?p) (unit ?u) (bed ?b))
   (not (the patient is attached to the bed))
   =
   (attach the patient to the bed)
 )

 but will it work?  Will the matching of patients to care units be
 factored out and then compared only to the beds matching the care unit,
 or will each patient be checked against each of the 2 intermediates
 results of the first 2 lines?

 Best regards,
 Florian Fischer





 
 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]




Re: JESS: NRL for Jess

2008-06-25 Thread Peter Lin
the cost versus benefit definitely is an important consideration. In
the past, I built custom languages for privacy rules and regulatory
compliance rules, which are sufficiently narrow.

I definitely wouldn't attempt a DSL for general business rules. That
will most likely result in a nightmare.

peter

On Wed, Jun 25, 2008 at 1:50 AM, Michael Smith
[EMAIL PROTECTED] wrote:

 On Jun 24, 2008, at 8:53 AM, Peter Lin wrote:

 I'm going to disagree that NRL is an anti-pattern.

 OK.


 It all depends on how you use it.

 Agreed... though since I having a tendency to be querolous, I'd
 change how to when.


 I've successfully designed and built custom business
 rule languages in the past. The key is keeping the domain well defined
 and narrow.

 I am tempted to envy you a bit here (in that the scope has been
 defined and narrow enough to capture in a DSL, but interesting
 enough to warrant an expert system shell).


 Don't try to make a DSL that is a general purpose
 language.

 Agreed.  Unfortunately, it's been my experience that there is a
 significant risk that a customer will drive DSLs inexorably towards a
 general rule language.


 For example, say I want to create a rule language for defining privacy
 rules for mobile phones.

 ...crisp example elided (nothing to quibble about) ...


 Once you have enough rules to get a good idea of the scope, you can
 start designing the language.

 Generally at the point the scope is clearly resolved in the projects
 I'm thinking of, the bulk of the rules work has mostly been done.
 The rules development coincided with exploring the subject domain
 with one (or a handful) of experts.  The maintenance of the rules
 that followed been associated with a few experts at most, along with
 a knowledge engineer, and at fairly low change rates.

 Changing the rules in a mobile phone privacy system or a message
 routing system would seem to have a lot more rule-editing users, and
 a more constrained capability than sendmail + scripting would still
 be useful without a high risk of scope creep.


 Writing the parser is heavily dependent
 on how solid the DSL is. Once you have the parser, converting to JESS
 is straight forward.

 That seems reasonable.  No argument that the parser - Jess
 conversion should be mechanical, if a good DSL can be designed.  But
 the effort requires enough users/usage to justify.

 Some rule patterns can even be simplified into fact assertions, meta-
 rule to interpret them.  OTOH, the problem has to be constrained very
 well, or this approach can fail in a manner analogous to a overly
 specific DSL.


 Perhaps the key is that one must the problem well enough defined
 before attempting to define a DSL.   Analysis first, /then/ DSL
 design decisions.

 - Mike



 
 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]




Re: JESS: NRL for Jess

2008-06-24 Thread Peter Lin
I'm going to disagree that NRL is an anti-pattern. It all depends on
how you use it. I've successfully designed and built custom business
rule languages in the past. The key is keeping the domain well defined
and narrow. Don't try to make a DSL that is a general purpose
language.

For example, say I want to create a rule language for defining privacy
rules for mobile phones. The first thing I do is define a set of
entities the rules would need to reason over. A ficticious example
might be this.

addressbook
name
number
relation
time
allow
deny
take a message

The next step is to define some privacy rules a person might write. It
might looks like this.

deny any call not in my addressbook
allow any call from family
take a message for non-family before 8 am and after 6 pm

Once you have enough rules to get a good idea of the scope, you can
start designing the language. Writing the parser is heavily dependent
on how solid the DSL is. Once you have the parser, converting to JESS
is straight forward.

peter

On Tue, Jun 24, 2008 at 12:33 AM, Michael Smith
[EMAIL PROTECTED] wrote:

 On Jun 23, 2008, at 6:40 PM, Barry Flower wrote:

 I am interested in using Natural Rules Language for business rules
 definition and was wondering if anyone is aware of an implementation
 (commercial or otherwise) that can be used with Jess. I understand that it
 would need to be constrained for a specific business domain and would assume
 that the NRL would have the facility to be customised (using a constraint
 taxonomy or ontology).

 Cheers
 Barry

 I wouldn't recommend DROOLS in general [1], but they do have some support
 for creating a custom domain-specific language (DSL).  If having a DSL is of
 paramount importance, it is worth a gander.  But...
 IMO, such DSLs are usually an anti-pattern.  The DSL might get you started
 great guns at first and for demos -- but it will not do everything you and
 the customer will want, and then you'll have two problems: the problem at
 hand, and maintaining a rapidly expanding feature list for the DSL.  With
 the pressure to keep moving forward, the likely ad hoc development of the
 DSL will become increasingly unwieldy, frustrating, and expensive to
 maintain.
 As a developer -- unless all of your testing and development works within an
 automated testing environment, I suspect you'll find debugging and
 maintaining a DROOLS-based rules engine significantly more difficult, due to
 how it compiles and loads rules.  Even with the automation, the Jess command
 line is a powerful development environment (like any REPL).   So maybe
 you'll have three problems.   Depends on whether you find it useful to drop
 bits of code into an interpreted environment full of state or you re-run
 after editing (or re-run after compiling and editing).
 If you had a really large, and non-technical, set of rule writers relative
 to the software development team, and a budget to pay for DSL maintenance,
 then a DSL might make sense.  But good language design is tough for
 non-trivial cases.  Pretty soon one can find that the rules need to be more
 expressive than first thought, and more and more arcane syntax is needed,
 and one begins to wonder why the rule developers weren't just trained on the
 original rule engine's language.
 It's much the same yin/yang as the issues surrounding visual/wizardly rule
 editors.  If you go this way, try to study the best commercial software
 first, and only then decide if you want to roll your own.
 $0.02 and change,
 - Mike
 [1] Unfortunately, the open sourceness of DROOLS seems to trump any and all
 advantages Jess has to offer in many developers minds.   Jess's current
 license is an Achilles heel in many environments. The lack of an
 interpreted, shell-oriented, paradigm (no REPL) is a huge loss.



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]




Re: JESS: NRL for Jess

2008-06-23 Thread Peter Lin
I've done this before using a custom domain specific language. What I
did was define a syntax and grammar for a business rule language,
which was then compiled and stored as RuleML. At execution time, I
translated the RuleML to JESS clips.

in terms of storage, the rules were stored in the dsl format and ruleml format.

it can be done, if you're not afraid of defining your language and start small.

peter

On Mon, Jun 23, 2008 at 6:40 PM, Barry Flower [EMAIL PROTECTED] wrote:

 I am interested in using Natural Rules Language for business rules
 definition and was wondering if anyone is aware of an implementation
 (commercial or otherwise) that can be used with Jess. I understand that it
 would need to be constrained for a specific business domain and would assume
 that the NRL would have the facility to be customised (using a constraint
 taxonomy or ontology).

 Cheers
 Barry
 Barry Flower | Global Head eFM Strategy  Solutions | WIB Technology
 Westpac Institutional Bank | Level 2, Westpac Place, 275 Kent Street,
 Sydney, NSW 2000
 T +61 2 8254 6308 | M +61 439 467 971 | E [EMAIL PROTECTED]

 Please consider our environment before printing this email.

 WARNING - This email and any attachments may be confidential. If received in
 error, please delete and inform us by return email. Because emails and
 attachments may be interfered with, may contain computer viruses or other
 defects and may not be successfully replicated on other systems, you must be
 cautious. Westpac cannot guarantee that what you receive is what we sent. If
 you have any doubts about the authenticity of an email by Westpac, please
 contact us immediately.

 It is also important to check for viruses and defects before opening or
 using attachments. Westpac's liability is limited to resupplying any
 affected attachments.

 This email and its attachments are not intended to constitute any form of
 financial advice or recommendation of, or an offer to buy or offer to sell,
 any security or other financial product. We recommend that you seek your own
 independent legal or financial advice before proceeding with any investment
 decision.

 Westpac Institutional Bank is a division of Westpac Banking Corporation, a
 company registered in New South Wales in Australia under the Corporations
 Act 2001 (Cth). Westpac is authorised and regulated in the United Kingdom by
 the Financial Services Authority and is registered at Cardiff in the United
 Kingdom as Branch No. BR 106. Westpac operates in the United States of
 America as a federally chartered branch, regulated by the Office of the
 Comptroller of the Currency.

 Westpac Banking Corporation ABN 33 007 457 141.




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]




Re: JESS: Optimization Problem Solving with Jess

2008-06-20 Thread Peter Lin
the solution looks pretty pretty straight forward. it could probably
be generalized to allow for n number of lathes.

peter

On Fri, Jun 20, 2008 at 3:02 AM, Jason Morris [EMAIL PROTECTED] wrote:
 Hi All,

 Peter Lin sent me a manual for Xpress-MP (a Fair Isaac product), since we'd
 been discussing some work in the operations research / optimization domain.


 In that manual, the first problem that the authors give is the following:

 The Chess Set Problem
 =
 A small joinery makes two different sizes of boxwood chess sets. The small
 set requires 3 hours of machining on a lathe, and the large set requires 2
 hours. There are four lathes with skilled operators who each work a 40 hour
 week, so we have 160 lathe-hours per week. The small chess set requires 1 kg
 of boxwood, and the large set requires 3 kg. Unfortunately, boxwood is
 scarce and only 200 kg per week can be obtained.  When sold, each of the
 large chess sets yields a profit of $20, and one of the small chess set has
 a profit of $5.

 Q. How many sets of each kind should be made each week so as to maximize
 profit.

 Now, I happen to play chess and I do own an ebony and boxwood chess set, so
 I couldn't resist trying to solve this problem using rules and Jess.

 I am posting my solution, but don't peek if you want to try it yourself!
  :-)

 I think that it shows how elegant and powerful the Jess language is.

 Cheers,
 Jason

 ---
 Morris Technical Solutions LLC
 [EMAIL PROTECTED]
 (517) 304-5883




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]




Re: JESS: Optimization Problem Solving with Jess

2008-06-20 Thread Peter Lin
that's why there's robots. Who needs human lathe workers anymore :)

j/k

On Fri, Jun 20, 2008 at 12:36 PM, Jason Morris [EMAIL PROTECTED] wrote:
 Problems of this type usually have the added wrinkle that the production
 capacities of the lathes are different or the skill of the workers is
 different, and you have to choose which machines to operate and for how long
 and / or which workers to assign to which machines.

 All in all, I was pretty happy with my solution :-)

 On Fri, Jun 20, 2008 at 8:55 AM, Peter Lin [EMAIL PROTECTED] wrote:

 the solution looks pretty pretty straight forward. it could probably
 be generalized to allow for n number of lathes.

 peter

 On Fri, Jun 20, 2008 at 3:02 AM, Jason Morris [EMAIL PROTECTED]
 wrote:
  Hi All,
 
  Peter Lin sent me a manual for Xpress-MP (a Fair Isaac product), since
  we'd
  been discussing some work in the operations research / optimization
  domain.
 
 
  In that manual, the first problem that the authors give is the
  following:
 
  The Chess Set Problem
  =
  A small joinery makes two different sizes of boxwood chess sets. The
  small
  set requires 3 hours of machining on a lathe, and the large set requires
  2
  hours. There are four lathes with skilled operators who each work a 40
  hour
  week, so we have 160 lathe-hours per week. The small chess set requires
  1 kg
  of boxwood, and the large set requires 3 kg. Unfortunately, boxwood is
  scarce and only 200 kg per week can be obtained.  When sold, each of the
  large chess sets yields a profit of $20, and one of the small chess set
  has
  a profit of $5.
 
  Q. How many sets of each kind should be made each week so as to maximize
  profit.
 
  Now, I happen to play chess and I do own an ebony and boxwood chess set,
  so
  I couldn't resist trying to solve this problem using rules and Jess.
 
  I am posting my solution, but don't peek if you want to try it yourself!
   :-)
 
  I think that it shows how elegant and powerful the Jess language is.
 
  Cheers,
  Jason
 
  ---
  Morris Technical Solutions LLC
  [EMAIL PROTECTED]
  (517) 304-5883
 


 
 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]
 




 --
 ---
 Jason Morris
 Morris Technical Solutions LLC
 [EMAIL PROTECTED]
 (517) 304-5883



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]




Re: JESS: [Jess] Visual programming.

2008-05-28 Thread Peter Lin
Here's my 2 cents on visual rule programming.

Building a visual programming tool for rules is feasible, but it
depends on the scope. Take lego mindstorm for example. It uses icons
to denote an action or sensor, when the program is load on the
mindstorm control, it's converted to executable code.

the trick to building one for home automation/security would be to
define the common actions and map them to an icon with the required
parameters. For example, you might have one for turning on the outside
lights and another for turning them off. If the scope is sufficiently
narrow and well defined, it should be straight forward.

What isn't desirable in my mind is creating a general purpose visual
programming tool for writing arbitrary rules. My bias opinion is it's
much better to write it in clips syntax directly. Another option is to
have natural language rule authoring, instead of visual rule
authoring. Again, the key is keeping the scope narrow and well
defined.

peter

On Wed, May 28, 2008 at 9:07 AM, Wolfgang Laun
[EMAIL PROTECTED] wrote:
 Looking at the Jess Manual's Reference section, you can see the
 distinctions between (a) Jess Constructs and (b) Jess functions.

 (a) I can imagine that designing templates and left hand sides (for
 rules and queries) graphically could be nice to have. Graphics for
 templates would be very similar to what you have in UML for classes.
 But, as for the rules, ask yourself: Is there a way that a complex
 logical condition plus the bindings and the references to the bindings
 can be created, displayed and modified graphically more easily than
 textually? We're at the expression level of programming, and most visual
 systems just let you fill in a text box for those.

 (b) Programming in Jess is very much like programming in Lisp. If there
 are visual programming tools for Lisp, and if they are considered
 valuable, then you have the answer for Jess. I'd say that the control
 structures can be represented by something like Nassi-Shneiderman
 diagrams, but the rest, again, is expression level.

 But I expect that others might violently disagree with me, especially as
 I'm known to be  rather reluctant to follow the Design-by-Diagram
 acolytes ;-)

 Regards
 Wolfgang

 ivo jonker wrote:

 Hello everyone,

 For my trainee-graduation-project i implemented Jess as a reasoner in
 a home-security/automation system. Now, part of the final phase of my
 assignment is to define a few new graduation-assignments for a
 follow-up trainee project.

 Now, i was wondering. Is there anything such as a visual programming
 tool to programm Jess-code? If not, would it be valuable to the Jess
 community to have such a tool/plugin?

 Kind regards,
 Ivo Jonker






 
 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]




Re: JESS: DJESS

2008-02-20 Thread Peter Lin
that's one of the performance limitations with full fact replication
approach for distributed pattern matching. In a situation where a
significant percent of the facts always change, the most optimal method is
to replicate just the indexes. Most modern RETE implementation like JESS
already index the facts, so index replication allows the system to perform
index joins without the fact. It's similar to how databases do index joins
for partitioned tables.

I should state that I filed a patent for distributed RETE using index
replication back in 2004. As far as I know, that should be the most
efficient method of implementing distributed RETE and distributed reasoning.

peter

On Feb 20, 2008 9:12 AM, Mohd. Noor [EMAIL PROTECTED] wrote:


 Hi all,
 In the DJESS - how often the working memory/fact/repository has to be
 replicated?
 How about if my the information that I am going to fire is always change-
 so this is means that my distributed information are also need to change.

 Rgds
 mnoor





Re: JESS: DJESS

2008-02-20 Thread Peter Lin
I should state, the work was the result of several years of research by Said
Tabet and myself. To answer your question, both said and I are listed as the
inventors.

peter

On Feb 20, 2008 10:25 AM, Mohd. Noor [EMAIL PROTECTED] wrote:

 Thanks
 Peter, do you still holding the patent?  :)

 Cheers
 mnoor

 On Wed, Feb 20, 2008 at 2:43 PM, Peter Lin [EMAIL PROTECTED] wrote:

 
  that's one of the performance limitations with full fact replication
  approach for distributed pattern matching. In a situation where a
  significant percent of the facts always change, the most optimal method is
  to replicate just the indexes. Most modern RETE implementation like JESS
  already index the facts, so index replication allows the system to perform
  index joins without the fact. It's similar to how databases do index joins
  for partitioned tables.
 
  I should state that I filed a patent for distributed RETE using index
  replication back in 2004. As far as I know, that should be the most
  efficient method of implementing distributed RETE and distributed reasoning.
 
  peter
 
 
  On Feb 20, 2008 9:12 AM, Mohd. Noor [EMAIL PROTECTED] wrote:
 
  
   Hi all,
   In the DJESS - how often the working memory/fact/repository has to be
   replicated?
   How about if my the information that I am going to fire is always
   change- so this is means that my distributed information are also need to
   change.
  
   Rgds
   mnoor
  
  
  
 
 



Re: JESS: Matching on multi-slot length

2008-02-20 Thread Peter Lin
sounds like the rule is handling join/fork from a BPM graph?


On Feb 20, 2008 10:24 AM, Hal Hildebrand [EMAIL PROTECTED] wrote:

 I only posted an abstraction to figure out my problem, leaving out the
 other details.  What I'm doing is essentially modeling workflow which
 manages to some target number of instances, so the fact in question is
 further qualified by other attributes as you have indicated.

 On Feb 20, 2008, at 6:29 AM, Jason Morris wrote:

 Hi Hal, Peter  Wolfgang,

  The proposed solution does not compare a length with foo.desired, and
 binding of a multislot vaue should use a variable starting with $?.

 Hal, since you said you were satisfied with Peter's solution, I never
 posted my reply which anticipated Wolfgang's almost verbatim.
 However, if you really want what Peter was advocating then there is a bit
 more to it I think.  You have to recall that Jess doesn't allow multiple
 facts to have identical slot values -- that means that no two foo facts
 could have the exact same multislot list and desired value.  You may need
 this in your application, so you'd need some other slot like (slot id) to
 differentiate your facts.  Also, Peter's version would fire twice for each
 pair of foo facts that had the same slot length, which is not what you want
 I'd think.

 The implementation below addresses these issues.

 Cheers,
 Jason

 ;;
 ;; list-len.clp ;;
 ;;
 (clear)
 (watch all)

 (deftemplate foo (slot id) (multislot my-list) (slot desired))

 (deffacts init
 (foo (id 1) (my-list 1 2 3 4))
 (foo (id 2) (my-list a b c d))
 (foo (id 3) (my-list 5 6 7 8))
 (foo (id 4) (my-list e f g h)))

 (defrule myrule
 ; Find a foo fact...
 (foo (id ?id1) (my-list $?list1))
 ; ...and another fact of different id where the list lengths are the
 same...
 (foo (id ?id2~?id1) (my-list $?list2:(= (length$ ?list2) (length$
 ?list1
 ; ...such that we have not examined this pair of foo facts before.
 (not (has-fired ?id1 ?id2))
 =
 ; Assert that this pair has been processed with a little logic trick.
 (assert (has-fired ?id2 ?id1))
 (printout t Lists lengths in foo facts  ?id1  and  ?id2  are
 equal! crlf))

 :: Program
 (reset)
 (run)

 ;MAIN::myrule: +1+1+1+2+1+1+2+t
 ; == Focus MAIN
 ; == f-0 (MAIN::initial-fact)
 ; == f-1 (MAIN::foo (id 1) (my-list 1 2 3 4) (desired nil))
 ; == f-2 (MAIN::foo (id 2) (my-list a b c d) (desired nil))
 ;== Activation: MAIN::myrule :  f-2, f-1,
 ;== Activation: MAIN::myrule :  f-1, f-2,
 ; == f-3 (MAIN::foo (id 3) (my-list 5 6 7 8) (desired nil))
 ;== Activation: MAIN::myrule :  f-3, f-1,
 ;== Activation: MAIN::myrule :  f-3, f-2,
 ;== Activation: MAIN::myrule :  f-1, f-3,
 ;== Activation: MAIN::myrule :  f-2, f-3,
 ; == f-4 (MAIN::foo (id 4) (my-list e f g h) (desired nil))
 ;== Activation: MAIN::myrule :  f-4, f-1,
 ;== Activation: MAIN::myrule :  f-4, f-2,
 ;== Activation: MAIN::myrule :  f-4, f-3,
 ;== Activation: MAIN::myrule :  f-1, f-4,
 ;== Activation: MAIN::myrule :  f-2, f-4,
 ;== Activation: MAIN::myrule :  f-3, f-4,
 ;FIRE 1 MAIN::myrule f-3, f-4,
 ; == f-5 (MAIN::has-fired 4 3)
 ;== Activation: MAIN::myrule :  f-4, f-3,
 ;Lists lengths in foo facts 3 and 4 are equal!
 ;FIRE 2 MAIN::myrule f-4, f-2,
 ; == f-6 (MAIN::has-fired 2 4)
 ;== Activation: MAIN::myrule :  f-2, f-4,
 ;Lists lengths in foo facts 4 and 2 are equal!
 ;FIRE 3 MAIN::myrule f-1, f-4,
 ; == f-7 (MAIN::has-fired 4 1)
 ;== Activation: MAIN::myrule :  f-4, f-1,
 ;Lists lengths in foo facts 1 and 4 are equal!
 ;FIRE 4 MAIN::myrule f-3, f-2,
 ; == f-8 (MAIN::has-fired 2 3)
 ;== Activation: MAIN::myrule :  f-2, f-3,
 ;Lists lengths in foo facts 3 and 2 are equal!
 ;FIRE 5 MAIN::myrule f-3, f-1,
 ; == f-9 (MAIN::has-fired 1 3)
 ;== Activation: MAIN::myrule :  f-1, f-3,
 ;Lists lengths in foo facts 3 and 1 are equal!
 ;FIRE 6 MAIN::myrule f-1, f-2,
 ; == f-10 (MAIN::has-fired 2 1)
 ;== Activation: MAIN::myrule :  f-2, f-1,
 ;Lists lengths in foo facts 1 and 2 are equal!
 ; == Focus MAIN

 --
 ---
 Jason Morris
 Morris Technical Solutions LLC
 http://www.morris-technical-solutions.com





Re: JESS: Matching on multi-slot length

2008-02-19 Thread Peter Lin
I believe you need to use

(length$ multifield-expression)

and then do a test to compare the two lengths. so the rule might look like
this

(defrule myrule
(foo
(my-list ?list1)
)
(foo
(my-list ?list2)
)
   (test (eq (length$ ?list1) (length$ ?list2) ) )
=
  (printout t the lists have the same length)
)

that's how I've done it in the past. there might be an easier way.

On Feb 19, 2008 4:04 PM, Hal Hildebrand [EMAIL PROTECTED] wrote:

 I've been struggling with trying to formulate a LHS which tries to
 match the length of one of the fact's multislots with another slot.
 For example:

 (deftemplate foo (multislot my-list) (slot desired))

 I've tried the following:

 (foo (my-list ?my-list) (desired = (length$ ?my-list))

 (foo { desired == (length$ my-list) } )

 (foo  (my-list ?my-list { desired == (length$ ?my-list) } )


 And even though desired is 0 and the length of the list is 0, the rule
 simply won't fire.  Obviously, I'm missing something

 
 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]
 




Re: JESS: Distributed Jess Engine?

2008-02-06 Thread Peter Lin
In theory it is possible to build a distributed RETE rule engine. The catch
is no rule engine today supports that capability. I filed a patent for it
back in 2003/2004. anyone interested in details can email me directly.

peter lin

On Feb 6, 2008 11:57 AM, Mohd. Noor [EMAIL PROTECTED] wrote:

 Hi all,
 Is that any answer to Michael's question- I've the same inquires.

 Cheers
 mnoor

 On Jan 30, 2008 4:39 PM, Michael Frey [EMAIL PROTECTED] wrote:

  Hi,
 
  is it possible to distribute parts of Jess on multiple machines, e.g.
  one peer engine runs on node 1 while the original engine and it's rule
  base run on another one or are there other distribution mechanisms?
 
  Best Regards,
   Michael
 
  --
  Michael Frey
  Telecommunications Software  Systems Group
  ArcLabs Research  Innovation Centre
  West Campus
  Waterford Institute of Technology
  Carriagnore, Co.Waterford, Ireland
  mail: [EMAIL PROTECTED]
  web: http://www.tssg.org
 
 
 
  
  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]
  
 
 



Re: JESS: Accelerator Doc

2005-06-22 Thread Peter Lin
What I tend to do is to write a specific function to handle cases
where a rule uses numerous nested functions. This way, it's reusable
and avoid using the accelerator.



On 6/22/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 
 I think Negoita, Cristian wrote:
  Hi *,
 
  I'm considering implementing the Accelerator interface, to try to make
  my rules to run faster.
  Unfortunantely I didn't found out documentation about it, how to do, a
  sample, and so on...
  Maybe someone can point out some resources about this subject.
 
 It's an undocumented feature, and will remain so for the time being --
 because to use it, you have to work with other undocumented features,
 details of the Rete network that change often. In any event, it's only
 useful if your rule left-hand-sides contain complex nested Jess function
 calls. For example, the wordgame example problem can be sped up a
 lot by an Accelerator that compiles integer math. Otherwise, it really
 doesn't do much.
 
 
 -
 Ernest Friedman-Hill
 Advanced Software Research  Phone: (925) 294-2154
 Sandia National LabsFAX:   (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]




Re: JESS: jess and JDBC

2005-03-02 Thread Peter Lin
you really should write a function to do this and make it more
generic. doing a line for line translation from java to JESS isn't
desirable.

write a custom function that implements the UserFunction interface and
put your jdbc code in there.

peter


On Wed, 2 Mar 2005 05:45:25 -0800 (PST), sivan k
[EMAIL PROTECTED] wrote:
 Hello. 
   
 I am trying to write and application in Jess using JDBC to connect to a
 MySQL database. 
 I am not sure how to define a java object like Connection and Statement in
 Jess as in the java statements: 
  Connection con = null; 
  Statement stmt = null; 
   
 Would it work to write  
   
  
 (defglobal ?*con* = (new Connection); 
 (bind ?*con* nil) 
  
  
 (defglobal ?*stmt* = (new Statement); 
 (bind ?*stmt* nil) 
   
 I haven't tested these yet as I am not very sure if I am in the right
 direction in the way I am trying to use JDBC in Jess. I am basically trying
 to translate a java program into Jess word for word. 
   
 Thanks in advance for any suggestion. 
 Jenny
 
  
 Celebrate Yahoo!'s 10th Birthday! 
  Yahoo! Netrospective: 100 Moments of the Web 
 



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]




Re: JESS: medical ES

2005-01-12 Thread Peter Lin
You may want to contact the computer science department at UMass
Amherst. I know the CKC group work on a similar tool for emergency
rooms using rule engines. If I remember correctly, they used rule
engines to recommend potential treatments and help diagnose patients.
The project was a collaboration between UMass Medical and CKC.

peter


On Tue, 11 Jan 2005 21:59:02 -0800 (PST), sivan k
[EMAIL PROTECTED] wrote:
 I would like to build a sort of Medical ES for a school assignment using
 Jess whereby a patients lab test results are stored in a database and then
 used as facts which the expert system uses to recommend treatment. 
 I am not sure what type of architecture would be suitable. Can I do it by
 using purely Jess code but accessing Java APIs. 
   
 Suggestions are welcome! 
   
 Jenny
 
 __
 Do You Yahoo!?
 Tired of spam? Yahoo! Mail has the best spam protection around 
 http://mail.yahoo.com


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]




Re: JESS: Jess on the server side - how many engines/data sharing/threading? * Newbie Alert*

2004-12-14 Thread Peter Lin
from my experience with a simple Servlet container like Tomcat, having
a pool of 20 instances is no big deal. the way that I determine how
many instances I need is to look at my performance requirements.

it's always easier to get some real rules that are representative of
the real application, load up 20 engines and measure how much RAM it
takes. Then stress test it under varying loads. Once I get a base line
of how my rules + JESS perform, I then do a real application test and
see what is realistic.

peter lin


On Tue, 14 Dec 2004 14:13:31 -0800 (PST), [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
 I think [EMAIL PROTECTED] wrote:
 
  Given that, should we have RETE multiple engines that are
  instantiated? Perhaps a pool of 10 that we can use on demand?
 
 This really depends on how long processing a request takes. It's
 entirely possible that just one shared Rete object would be enough --
 or, of course, it may not be. In any case, yes, people use various
 object pooling solutions with Jess.
 
  How about data sharing? When the base facts are updated, the updates
  need to be applied to all the RETE engines.
 
 There are a number of ways you can do this. Database triggers are one
 way; periodic refreshes (or simply finite lifetimes) of the pooled
 objects are another way. Or, depending on the granularity of your
 data, you can avoid having all the catalog data in working memory, and
 simply pull in what you need for each request, then discard it
 afterwards.
 
 -
 Ernest Friedman-Hill
 Advanced Software Research  Phone: (925) 294-2154
 Sandia National LabsFAX:   (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]




RE: JESS: RE: Jess and C#

2002-12-31 Thread Peter Lin

I've played with C# a little and there are many similarities. Most of the
event mechanism work the same, though reflection and type casting is a
little different. David's idea of wrapping the engine to provide visual
basic like access is intriguing.

performance wise it might not be that big since it will compile everything
into the intermediate language. You would lose the OO and reflection
capabilities, but if some one didn't need OO capabilities it might be
sufficient.

There's also java to C# translator, which might get most of it. The
differences in collections API, const vs static final and a couple others
are minor.

peter

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 31, 2002 10:24 AM
To: [EMAIL PROTECTED]
Subject: Re: JESS: RE: Jess and C#


I think Peter Lin wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
 
 since Jess is inspired by clips and clips is written in C, you should be
 able to use clips in .NET. Assuming you label the calls to clips as unsafe
 and handle it appropriately.
 
 in theory you could download clips and use Visual Studio.NET C to compile
it
 for .NET framework.

Absolutely.  Of course, you'd be missing all the features that make
Jess useful -- i.e., the reflective access to real objects, the
object-oriented API, and the vastly better performance.


 
 peter
 



-
Ernest Friedman-Hill  
Distributed Systems ResearchPhone: (925) 294-2154
Sandia National LabsFAX:   (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]