Re: JESS: Eclipse

2004-03-31 Thread ejfried

I think [EMAIL PROTECTED] wrote:
> Hello,
> 
> I have a question concerning jess and eclipse. I`m using eclipse for java. Now i 
> downloaded the jess plug-in for eclipse, but I don`t know how to use it at all. 
> 

And what Jess Plug-in for Eclipse would this be, exactly? The ones
being developed for Charlemagne haven't been released yet; perhaps
this is something from a third party?


-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: literal constraints format

2004-03-31 Thread ejfried
I think Michael Knapik wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]

> Jess> (clear)
> TRUE
> Jess> (assert (letters b c))
> 
> Jess> (defrule literal-values
> (letters (__data b c))
> =>)
> Jess reported an error in routine Jesp.parsePattern.
>   Message: Bad slot value .
>   Program text: ( defrule literal-values ( letters (  at line 107.

This is a factual error in the book.  I had described how internally,
an ordered fact is represented as if it were an unordered fact with a
single multislot named "__data" (two underscores.) If you use the Java
API to inspect an ordered fact, you'll find that this is so. Likewise,
if you use the Java API to inspect the Patterns in a Defrule that
matches ordered facts, or the Rete network itself, you'll see that,
again, the two representations are equivalent.

But I went too far in the explanation: to help underscore that point,
I showed that you could write a rule using this alternate
representation. This isn't something anyone would ever want to do, but
it's interesting from a pedagological perspective. Unfortunately, it's
also wrong. An ordered deftemplate has a flag that says it's ordered,
and it turns out that the Jess parser looks at that flag. At some
point in the past this code would have compiled, but recent versions
of Jess reject it.

So this is an error in the book. As long as you understand the point
that's being made, the fact that the actual code doesn't compile isn't
especially important.

-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: NoClassDefFoundError: jess/JessException

2004-04-01 Thread ejfried
I think Vanmoerkerke Frederik wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Hello,
> 
> I want to try running an applet. The compiling has no problem but when i try to run 
> it in Internet Explorer as an applet, it gives me the following error.
> 
> java.lang.NoClassDefFoundError: jess/JessException
>  at java.lang.Class.getDeclaredConstructors0(Native Method)
>  at java.lang.Class.privateGetDeclaredConstructors(Class.java:1576)
>  at java.lang.Class.getConstructor0(Class.java:1748)
>  at java.lang.Class.newInstance0(Class.java:266)
>  at java.lang.Class.newInstance(Class.java:249)
>  at sun.applet.AppletPanel.createApplet(AppletPanel.java:548)


> 
> I've already set the classpath good because everything else for jess works.


Note that the CLASSPATH has nothing to do with running applets in IE
(or any other browser) -- all the applet's code is expected to be
available from the location indicated in the HTML file in which it's
embedded.

Deploying an applet isn't rocket science, but it can be tricky for the
uninitiated. The important details aren't in this code, but in the
HTML file you're using, and in the layout of the files you've placed
on the Web server. Without those details, I can't tell you what you're
doing wrong.



-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: WG: Re: JESS: Eclipse

2004-04-02 Thread ejfried
I think [EMAIL PROTECTED] wrote:
> Hi there,
> 
> it is the Sphere Solata Plug in for Eclipse, but I have not get it work till now
> 

Well, you'll want to ask *them* for support.



-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Fact ordering in rule. Need help.

2004-04-03 Thread ejfried
I think Govoni, Darren wrote:

> 
> ; This query does not work as you see it here.
> ; If I move the third clause to the top position, it will work,
> ; but it takes 15 minutes to run on the real wordnet facts.
> ; Why doesn't this work?
> (defquery q_wn_sense (declare (variables ?word))
>   (wn_sense (syn_id ?hypid) (word ?o&: (= (str-compare ?o ?word) 0)))
>   (wn_hyp (hypo_id ?hypid) (hyper_id ?hyperid))
>   (wn_sense (syn_id ?hyperid) (word ?w)) 
> )


I thought this had been explained before, but perhaps not. Each result
of this query will consist of a Token containing four jess.Fact
objects: a query-trigger fact, and a wn_sense fact, a wn_hyp fact, and
another wn_sense fact; these latter three match the three patterns in
the query. The query-trigger fact is available from the token by
calling fact(0). The first wn_sense is fact(1), the wn_hyp is fact(2),
and the second wn_sense is fact(3).

> 
> (deffunction f_wn_hyp (?word)
> (bind ?hyps (run-query q_wn_sense ?word))
>   (while (?hyps hasNext)
>  (bind ?token3 (call ?hyps next))
>  (bind ?fact3 (call ?token3 fact 1))

Here, you grab the first of the two wn_sense facts by calling fact(1)
on the token, but you actually want the second wn_sense fact -- i.e.,
the fourth fact in the Token, or fact(3). The "word" slot of the first
wn_sense fact contains the input paramter for the query (?word),
whereas the word slot of the other wn_sense will contain the unknown
"?w". 

Ao in any event: changing the "1" in the above to a "3" will give you
the result you're after.


>  (bind ?w (fact-slot-value ?fact3 word))
>  (printout t ?w crlf)
>   )
> )

-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Passing facts to UserFunctions in Java

2004-04-05 Thread ejfried
I think Ben Allen wrote:

> However when i load and then proceed to call this function, with this string,
> 

> String sendMesTest = "(sendMessage (message (data \"Ben, check out
> the Seafood restaurant\") (sender \"graham\") ) " + "(locationEvent
> (xCoord 123456) (yCoord 123456) (userID \"[EMAIL PROTECTED]") (date
> 1234567789011) ) )";

> 
> I get an exception. The reason i get an exception is that Jess interprets 
> the arguments passed to sendMessage as being of type Funcall and not of 
> type fact.


They *are* funcalls, and there's nothing you can do about it short of
modifying the parser. Normally, Jess parses a parenthesized list as a
function call. Any exceptions to this rule (for example, the patterns
in a defrule, the arguments of assert and modify) are handled by
special exceptions in the parser. These exceptions form the grammar of
the Jess language.

Workarounds: you could assert the fact, and you'd get a reference to
the Fact object as a return value from assert and pass it to
sendMessage. Or you could write a Userfunction named "string-to-fact"
which parsed a String and returned a Fact object; in current versions
of Jess you'd need the package-protected Jesp.parseFact() method to do
that, but you could make it public, or cheat and put your function
into the jess package. Or you could construct the Fact objects from
Java directly by some other means.







-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: JESS 7 MBean integration

2004-04-06 Thread ejfried
I think Gianna wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Hi guys,
> 
> 
> 
> I know this argument has been discussed some times ago (see msg05686 posted
> by Keith Donald), but I'd like to know if some kind of native JMX
> integration has been planned into Jess 7.
> 

Not planned for 7.0, no.


> As Keith stated, it would be very useful to provide a JMX support similar to
> JavaBeans API in order to manage MBean instances (i.e. components deployed
> into an Application Server) through JESS rules.

Can you give us a 20,000 foot view of what this would look like, for
someone who is not familiar with JMX or MBeans?


-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: JESS 7 MBean integration

2004-04-06 Thread ejfried
I think rul3zrul3z wrote:
>  
> I've been considering this for a while and here are my own thoughts.
>  
>  
> If someone is using it in Tomcat 5, JMX support is built in. All one
>  has to do is write a MBean and register it. In this case, having a
>  MBean to manage deploy/redeploy/undeploy a rule application would
>  be nice.

OK, I'm hearing two different things: one, emphasized in this message,
is that Jess itself is something that could be managed by JMX (which
stands for Java Management Extensions, right?).

The other is that MBeans (Message beans? Management beans? Still
waiting for somebody to give us an executive summary of this API) are
things that Jess might reason about.

Are these two things related at all? Somebody explain, please.


-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Jess hanging on 'modify'

2004-04-06 Thread ejfried
I think David Ash wrote:

> I'm having trouble in that Jess seems to sometimes (frequently
> enough to make it hard to use) hang when I do a 'modify' of a fact.
> There is no error message or anything-it just hangs.  Any ideas what
> might be causing this?

If you're doing this from a multithreaded Java program, it may be a
deadlock issue. If so, make sure you're running the latest version of
Jess, as there have been patches to prevent deadlocks in the past. A
"Control-Break" on Windows or "Control-\" on UNIX will give you a
stack dump that would be helpful in diagnosing the problem.



-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Help with calling Java from Jess

2004-04-06 Thread ejfried
I think Greg Biegel wrote:

> 
> One of my rules calls back to A which then performs an operation (event
> unsubscription). The callback occurs, and the method in A is called, but
> then when this method goes on to perform the event unscription, the method
> never returns. No error, no stacktrace at all.

If there are multiple threads involved, it may be a deadlock problem,
but basedon your description, I don't think that's it. Could it be an
issue with local vs. global JNI references? When you get a reference
to a Java object and you want to save it from one JNI call to the
next, you need to convert it to a global reference first. If you don't
-- well, then anything can happen, including a hang or a crash.

-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Jess hanging on 'modify'

2004-04-06 Thread ejfried
I think David Ash wrote:
> Yes I am indeed running it from a multithreaded Java program.  What is
> the latest version of Jess? 

6.1p6.


> What kind of issues may arise if I assert a fact from a different
> thread from the main thread in which the Jess engine is running?  Is
> that where the problem arises?

That's where the problem arises, yes. It's not *supposed* to be a
problem, but there have been deadlock bugs fixed in past versions of
Jess.

In any event, make sure you've upgraded to the latest patchlevel. If
you're seeing this problem in 6.1p6, generate a stack trace as
previously described and send it to me.



-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: problem in Jess

2004-04-13 Thread ejfried
I think Syed Shomaail wrote:
> 
> How do we make connection to a database such as Access in Jess


Just as in any other Java program, you can use JDBC, of course. For
the specific problem of reasoning about records in a database, you can
use Thomas Barnekow's Fact Storage Provider Framework (see the User
Contributions page at the Jess web site.)



-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Shadow facts question

2004-04-13 Thread ejfried
I think Greg Biegel wrote:

> (deffunction averageweight
>  return (+ SmartCouch_LoadCellSensor1_MassEvent_Bean (mass))
> SmartCouch_LoadCellSensor2_MassEvent_Bean (mass)))
> )


First, "return", like everything else in Jess, is a function, so
there's a missing set of parentheses here.

(deffunction averageweight
  (return (+ SmartCouch_LoadCellSensor1_MassEvent_Bean (mass))
 SmartCouch_LoadCellSensor2_MassEvent_Bean (mass)))

> On the other hand, accessing the bean in a rule with the following lhs works
> fine:
> (and
> (SmartCouch_LoadCellSensor1_MassEvent_Bean (sensorID 1))
> (SmartCouch_LoadCellSensor1_MassEvent_Bean (mass ?m&:(> ?m 5)))
> )


But more importantly, only the left-hand-side of a rule can
pattern-match working memory. You can't write patterns in a
deffunction like this. As I've corrected it, the deffunction will
think that SmartCouch_LoadCellSensor1_MassEvent_Bean is a function
you're trying to call, and you'll get another error.

Your three choices are to use a defquery so that averageweight can
query working memory, or to simply keep references to these two beans
in some well-known place so that the function can access them, or to
pass the masses in as arguments from a rule where you've already found
the beans bymatching.


-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Using eval to "hot-reload" predicates and auto-update the rete

2004-04-13 Thread ejfried
I think Eric Wang wrote:

> 
> Solution: "eval-ppdefrule".
> Call batch to read the new file.
> Then call (eval (ppdefrule )) to re-evaluate each rule.
> 


Very clever!

> Can the granularity of refreshing be made finer, e.g. to
> specify "refresh pattern 5 of rule R", to force only that pattern's
> set of partial matches to re-evaluate?

Not currently, no.

> 
> 2.  Given a file containing 1 or more functions, how can
> I find all rules that call these functions (and thus which
> must be refreshed)?

No convenient way now. There will be a cross-reference tool that lets
you do this interactively in Jess 7; I hadn't thought about making the
capability available as a meta-programming tool but I suppose that's
possible. 

One time we had a guy on the list who wanted to have defrules,
deftemplates, etc themselves all be described as facts, so that you
could reason about them. A (perhaps limited) version of this could
certainly be implemented and would be interesting to play with. An
introspecitve system like this could be more "intelligent" in many
ways. 


-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Calling a Java method

2004-04-15 Thread ejfried
I think Greg Biegel wrote:

> I want to call a constructor method on a Java
> object  from within Jess, this method takes a string argument. I need to
> call the constructor from Jess, passing it a global variable which contains
> a double. My question is how do I convert this double to a string so that I
> can pass it safely to the constructor?

You can either use Jess's "str-cat" function, which converts any
argument to a String, or you could use the String.valueOf() method.

(new Widget (str-cat ?*d*))

or

(new Widget (call String valueOf ?*d*))



-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Question about defquery

2004-04-15 Thread ejfried
I think Lakshmi Vempati wrote:
> 
> I am using a simple defquery to find a fact and then modify it.

For reasons that are too difficult to go into (although we've actually
discussed it before on this list) when you get a jess.Fact out of a
jess.Token (as you do when you're working with a query result) you
should call getIcon() to get the fact's canonical representation (I
know, that's a terrible method name) and use the return value instead
of the original Fact object. That should solve your problem.

-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Updated 7.0 trial?

2004-04-21 Thread ejfried
I think Alan Moore wrote:
> I finally had time to test out some new features in 7.0 but discovered that
> the download I saved has expired. Also, 7.0 no longer appears to be
> available for download.
> 
> Is there going to be another preview release in the near future?

The normal alpha test cycle will start... soon. Working hard on the
IDE part right now.

-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: query about numeric variables

2004-04-21 Thread ejfried
I think Moore, David [IES] wrote:
> 
>   (defrule age
>   (benefit-seeking)  
>   =>
>   (printout t "Please enter your age (in years) " crlf)
>   (assert (age(read
> 
> The disappointment is that the value for "age" does not appear to be one
> that can subsequently be processed mathematically. 

This should work fine; you would end up with a fact (age 37), where 37
is an INTEGER. (read) tokenizes its input exactly as if it were
parsing Jess source code.


> I would like a subsequent
> rule to have in its left hand side the condition that age is less than 70,
> but can't get this to happen.

Would look like

(defrule less-than-70
  (age ?a&:(< ?a 70))
  =>
  ; .. whatever
  )



-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Getting detailed match information

2004-04-21 Thread ejfried

I think Douglas Pearson wrote:
>  
> For example if I had:
>  
> (defrule simple-rule
>(child (id ?x) (name ?name))
>(parent (id ?y) (child ?x))
>=>
>(printout t "Child " ?x " name " ?name crlf)
> )
> 
> and I know fact-3 and fact-7 were matched...how can I tell
> (programmatically) which fact matched which condition?


Well, the facts in a token are in the same order as the patterns they
matched. There's no way to explicitly ask for the jess.Pattern that a
given fact in a jess.Token matched, although you could probably back
it out by getting the jess.Defrule of interest and calling
getConditionalElements() to get the root of the (potentially
tree-structured) LHS patterns. This is not well-documented, and for
good reason: you'll find that the structure changes quite a bit as
Jess evolves from version to version.

>  
> I'd also really like to get partial match information as well...not just
> when the rule fired and I'm less clear on how to even get started with that
> since the rule won't be in the agenda.

There's no public API for this, but if you've got a Jess license, you
can poke around in the source. See the implementation of the (matches)
command (which displays partial matches.) The key thing it does is
call getNodes() on the given Defrule object, which returns a List of
jess.Node objects. These are the Rete network nodes. You can root
through this list and find the Node2 objects (the join nodes) and then
look at their alpha memories.


-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: jess.Console question

2004-04-22 Thread ejfried
I think Maxim Tretyak wrote:
> Hi
> 
> Can I get advantages of jess.Console by such a way:
> 
> Jess> (new jess.Console "Hi" (engine))
> 
> 
> Console is appearing, but connand line input is transmitted directly to
> output text area, without interaction with Rete.


Very clever!

Just creating a Console doesn't do it though, there has to be a thread
running the Console.execute() method (the read-eval-print loop). You
could say 

Jess> (bind ?c (new jess.Console "Hi" (engine)))
Jess> (?c execute (create$))

The console would then work, but the original command line wouldn't
anymore; and there's no way (no easy way, anyway) to get it back. The
Console class has to reroute all of the Rete objects standard I/O
routers to connect it to the GUI; in the process, it gets disconnected
from standard I/O.


-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Shadow facts..

2004-04-22 Thread ejfried
I think Greg Biegel wrote:
> 
> (defrule avgweight
>  (SmartCouch_LoadCellSensor1_MassEvent_Bean (mass ?mass1))
>  (SmartCouch_LoadCellSensor2_MassEvent_Bean (mass ?mass2))
>  (SmartCouch_LoadCellSensor3_MassEvent_Bean (mass ?mass3))
>  (SmartCouch_LoadCellSensor4_MassEvent_Bean (mass ?mass4))
> =>
>  (bind ?*totalweight* (+ ?mass1 ?mass2 ?mass3 ?mass4))
>  (bind ?*averageweight* (/ ?*totalweight* 4))
>  (bind ?*averageweight* (- ?*averageweight* 0.5))
> )
> 
> However, each bean is not necessarily updated between each firing of the
> engine (as each bean is updated individually, it calls Rete.run()). What I
> am worried about is that this rule will only fire if ALL beans have had
> their mass field updated since the last firing, so I am unable to get a
> current average weight reading to use in the LHS of other rules in the same
> firing. 

No, it will actually fire any time any one of them changes, so maybe
that's good enough.

Defqueries are tough in Jess 6. They get a lot easier in Jess 7. But
there are examples in section 2.9 of the manual. You'd want your query
to look like

(defquery all-sensors
  (SmartCouch_LoadCellSensor1_MassEvent_Bean)
  (SmartCouch_LoadCellSensor2_MassEvent_Bean)
  (SmartCouch_LoadCellSensor3_MassEvent_Bean)
  (SmartCouch_LoadCellSensor4_MassEvent_Bean))

and the function that used it would look something like

(deffunction average-weight ()
  (bind ?result (run-query all-sensors))
  (bind ?token (?result next))
  (bind ?sum 0)
  (foreach i (create$ 1 2 3 4)
(bind ?sum (+ ?sum (fact-slot-value (?token fact ?i) mass
  (return (- (/ ?sum 4) 0.5)))



-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Jess DefQuery Help for a newbie

2004-04-22 Thread ejfried
I think Balakrishnan Prasath wrote:
> Hello,
>  
> I am trying to use defquery with 2 parameters as mentioned in the Page 129: Jess in 
> Action. I suppose we can any amount of input parameters. The code has been tweaked 
> as is required from Page 129 for my purpose.
>  
> ;;Template for the problem type. 
> ;;slot problemtype-category can refer to configuration or information or 
> troubleshooting. 
> (deftemplate problemtype 
> (slot problemtype-ident)
> (slot problemtype-category) 
> (slot problemtype-desc)
> (slot problemtype-techident)
> (slot problemtype-prodident))


OK. First of all, why use such long slot names? The template is
already called "problemtype" so why add "problemtype-" to every slot
name? Just makes the code much longer and harder to read.

> ;Write the defQuery.
> (defquery q_problemtype
> (declare (variables ?word ?param))
> (problemtype (problemtype-ident ?test) (problemtype-desc ?o&: (= (str-compare ?o 
> ?word) 0)) (problemtype-techident ?o&: (= (str-compare ?o ?param) 0)))
> )


The str-compare calls are not needed; just write

 (defquery q_problemtype
 (declare (variables ?word ?param))
 (problemtype (ident ?test) (problemtype-desc ?word)
  (problemtype-techident ?param)))
 )
> ;;bind the problem type.
> (bind ?w testing2)
> (bind ?y 2)
> (printout t crlf "Querying for word: " ?w crlf)
> (printout t crlf "Querying for word: " ?y crlf)
> (printout t "Running query..." crlf)
>  
> (bind ?it (run-query q_problemtype  ?w ?y))
> (printout t "Iterating results..." crlf)
>  
> (while (?it hasNext)
> (printout t crlf "Matched a fact group:" crlf)
> (bind ?token (call ?it next))
> (bind ?fact (call ?token fact 1)) ;; get the problemtype-ident fact of the match
> (printout t "prod: ")
> (printout t "problemtype-ident: " (fact-slot-value ?fact "problemtype-ident")))
> 
> (printout t crlf "Done" crlf)


This looks basically OK; did you at some point run "reset" so that the
facts in the deffacts were asserted?




-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Passing an instance of Rete to java

2004-04-23 Thread ejfried
I think Greg Biegel wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Hi,
> 
> Is there a way to pass a reference to the current instance of the rule
> engine from Jess, to a Java object. I tried using the 'this' keyword, but
> doesn't seem to work. So basically, I would like to construct a Java object
> from within Jess, but be able to call back to Jess from the object.
> 

The (engine) function returns the Rete object that the invoking Jess
code is running in; so

(bind ?o (new MyObject))
(?o mySetJessEngineMethod (engine))

would create an instance of MyObject, and call the imaginary
mySetJessEngineMethod method, passing a reference to the Rete object
as an argument.




-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: JESS 7 MBean integration

2004-04-23 Thread ejfried

I think Chintan Shah wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> I have used JBoss app-server to create a Rules MBean that uses a Rete
> object. It was not difficult (<500 lines of code) to implement this using
> JBoss ServiceMBean
> and other helper classes.

Would you like to share this with the user community? I'd be glad to
post it on the Jess web site.

-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Date: Fri, 23 Apr 2004 11:37:39 -0700

2004-04-23 Thread ejfried
I think Francisco wrote:
>  
> C:\Program Files\Apache Software Foundation\Tomcat
> 5.0\work\Catalina\localhost\Order\org\apache\jsp\catalog_jsp.java:50:
> java.util.Iterator is abstract; cannot be instantiated
>   queryResult = new java.util.Iterator();

Curiously enough, this was just asked (and answered) on Manning's
support forum for this book: see 

http://www.manning-sandbox.com/thread.jspa?forumID=35&threadID=10121

Short version: the code works in Tomcat 4 because, while my code is
wrong, so is Tomcat 4. Tomcat 5 is "more correct" but breaks my code
in the process. To fix, edit each of the TekMart JSPs to change the
"class" attribute of any  tags that you find to a "type"
attribute instead.


-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: newbie wants to run a java-class from jess

2004-04-25 Thread ejfried
I think [EMAIL PROTECTED] wrote:
> Hi,
> 
> I have written a java-class and i want to run this class from Jess. I tried "call" 
> but this seems to be not for classes at all.
> 


Well, you'd have to define what you meant by "running a class." If you
mean that you've got a Java class with a main() that you can invoke
from the command line, then to "run the class" you can simply call
main(), just as you would from another Java program. You have to pass
the correct argument -- an array of String. An empty array is fine:

  (call MyClassName main (create$))



-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: problems writing defrule...

2004-05-11 Thread ejfried
I think Katie Truong wrote:
> Dear Jess Support Team,
>  
> I started writing a program that develops a small knowledge system for health 
> assessment and longevity planning.  The health assessment system will evaluate a 
> persons current health status based on input values for predefined risk factors and 
> behavioral influences on longevity.  The program will ask the user a number of 
> questions about his vital statistics and lifestyle habits.  Based on the answers 
> provided, the system will predict the persons longevity.
>  
> I am having problems understanding how to translate my rules into jess codes.  
> Therefore, I would like to ask for your assistance in getting me started with this 
> part. I've attached my codes to this e-mail; also, I've made a list of the rules I 
> need to add to my program.  
>  
> Thank you for your help in advance!
> Katie Truong


It looks like you started with the Tax Forms Advisor from "Jess in
Action", but you removed a lot of code -- actually you removed too
much. If you're going to use this framework, then you need to leave
everything in the "ask" module intact.

In any case, the point of the framework you're adopting is that
there's a list of questions, some of which depend on the answers to
other questions; after all the relevant questions are asked, the
system makes some decisions based on the answers.

In the book, the requirements for and dependencies between the
questions are encoded in rules in the "interview" module, while the
rules that make the final decisions are in the "recommend" module.

If you're going to use the framework, then you need to do things the
same way. I'd recommend re-reading chapter 11 and working from there.
Now, it's an open question whether you need to use this framework or
not; if you always want to ask te same questions in the same order, it
would be simpler just to write code that asks them straightaway. Only
then, once you've written the code to ask the questions and gotten
things set up such that the working memory includes the answers in
some useable form, can you proceed to write the rules that encode the
decision table listed below. But once all the answers are in working
memory (and you've also chosen a representation for the results of the
decisions) writing those rules is easy.


>  
> Rule No.If 
> Then1relative_weight=normalval=yes2heart_disease_risk=below_averagehddanger=low3age=25_or_less
>  and gender=mthen base_longevity=724weight=110_or_less and frame=small and 
> gender=frelative_weight=normal5cholesteral=low and 
> fat=highheart_desease_risk=below_average6salt=highblood_pressure=above_average7relative_weight=obese
>  and heart_disease_risk=above_average and blook_pressure=above_average and 
> smoker=yesoutlook=bleak8race=black and 
> origin=mediterraneanrisk=high9personality=aggressivepersonality_type=type_a10alcohol_consumption=moderateadd=good11outlook=bleak
>  and risk=unknown and add=goodfactor=none12base_longevity=72 and 
> factor=nonelongevity=67_years
> 

-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Pausing the execution cycle without returning

2004-05-07 Thread ejfried
I think Steffen Luypaert wrote:
> 
> What is the best solution to this problem? I was trying to use a lock. 
> The main thread would call wait() on it, while the event thread would 
> call notify() on it when the answer fact was generated. But this didnt 
> work.

That's pretty much what you want to do; you just have to be careful
about what Threads are involved, and use the right lock. Jess is
actually set up to help you do exactly this. Chapter 13 in "Jess in
Action" explains how it works. As it turns out, this chapter is
available free from Sun's web site:

http://java.sun.com/developer/Books/javaprogramming/Friedman-Hill/jess_ch13.pdf

(but I hope you'll run out and buy the book anyway, if you don't
already have it; it shows you how to do all sorts of useful stuff.)

The basic trick is this:

>From one rule, set up the GUI to ask a question, then call ((engine)
waitForActivations), which pauses the (run) thread until a new rule is
activated.

Write the GUI event handler so that when the question is answered, it
is asserted as a fact, and write one or more rules which will match
the answer fact so that as soon as the question is answered, some rule
becomes activated.

Thus the engine pauses until the question is answered; when it's
answered, the engine wakes up automatically.

The program being discussed in the book actually has a few more
wrinkles; there's a fancy system for asking questions using backward
chaining that I'm not mentioning here. But basically you just need to
follow the checklist on page 212.


-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




JESS: Announcing Jess 6.1p7

2004-05-07 Thread ejfried
Hi Folks,

I am pleased to announce that version 6.1p7 of Jess, the rule engine
for the Java platform, is now available for download at the usual
place:

  http://herzberg.ca.sandia.gov/download.shtml

This is a bug fix release with some improved performance
characteristics. From the change log:

Fixed deadlock problem (thanks Paul Kaib). Better
performance with huge numbers of templates (thanks
Travis Nelson.) Fix NPE when parsing empty (not)
patterns. Fix PrettyPrinter bug with (not) and
pattern bindings. 

As usual, question, comments, or concerns welcome at
[EMAIL PROTECTED] or to the mailing list at
[EMAIL PROTECTED] 

-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Pausing the execution cycle without returning

2004-05-07 Thread ejfried
I think Steffen Luypaert wrote:
> 
> > The basic trick is this:
> > 
> > >From one rule, set up the GUI to ask a question, then call
> > ((engine)
> > waitForActivations), which pauses the (run) thread until a new rule
> > is
> > activated.
> > 
> 
> 
> The problem is that waitForActivations will still fire the activations 
> left on the agenda, and then wait for new activations to execute them.

Only in the focus module, but yes, you're right.

You could, instead, just use

  (bind ?s ((engine) getActivationSemaphore))
  (synchronized (?s)
  (?s wait))
  
which won't allow any more rules to fire at all until a new activation
comes in.



-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: logical and groups of patterns

2004-05-06 Thread ejfried
I think Steffen Luypaert wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]

> Now, the problem isn't to get the correct sum. In a former version of 
> my application I calculated it by getting all accounts with a defquery 
> and then using the returned Iterator object to get the desired sum. My 
> problem is to make the sum fact logically dependent of all account 
> facts used to compute it. If an old account fact is modified or 
> retracted, or a new one is asserted, I want the sum fact to be 
> retracted automatically.

The easiest way to do this would be with an event handler. Just watch
for any FACT events, and if the Fact object is an "account" fact, then
retract the sum fact. A lot simpler than what you showed here.

-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: logical and groups of patterns

2004-05-06 Thread ejfried
I think Steffen Luypaert wrote:
> 
> I didnt think of this. But to understand the retraction, one has to see 
> the code of the JessListener Java class. So if u look at the Jesscode, 
> you won't understand or or when the retraction happens. In a sense, it 
> happens 'outside' the reasoning of Jess. 

Actually, you can write event handlers in Jess, too. There's a
jess.JessEventAdapter class that you can use like this:

  Jess> ((engine) setEventMask (get-member jess.JessEvent FACT))
  Jess> (deffunction my-handler (?evt)
   (printout t EVENT: (?evt getObject) crlf))
  TRUE
  Jess> ((engine) addJessListener
  (new jess.JessEventAdapter my-handler (engine)))
  Jess> (assert (foo))
  EVENT:
  


This kind of "multiparadigm" support is one of Jess's real
strengths. Event-driven "rule engines" are what IBM (but nobody else)
usually means when they talk about rules. Jess lets you combine
forward and backward chaining, events, and other stuff all in one
package. 



-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Rules not firing

2004-05-04 Thread ejfried
I think [EMAIL PROTECTED] wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Good mornig,
> i m working in java and jessi need to set a message (string) in
> java with a jess command how i can do?  for example my class for
> send massage is Send_message("ID","message_to_send"); working in
> jess i do a rule engine and the out of rules set-up the
> "message_to_send" in the class (java).

It's pretty easy to call Java methods from Jess; section 2.6 of the
manual covers the basics and refers you to chapter 8 for details. I
can't show you *exactly* what to do in your specific case, of course.

By the way: when you want to post a question to a mailing list, please
send mail directly to the list; don't reply to someone else's message.

-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Method not found

2004-05-04 Thread ejfried
I think [EMAIL PROTECTED] wrote:
> what is my mistake? 

No idea, as you haven't shown us any code. 



-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Cryptarithmic exercise

2004-05-04 Thread ejfried
I think Mitch Christensen wrote:
> Hey,
> 
> I'm reading "Expert Systems Principles and Programming" by Giarratano and I
> decided to try using Jess to solve the cryptarithmic problem at the bottom
> of page 39.  I've got a rule that produces no valid solutions :(.  I've
> spent several hours looking over the code can't see my fault.  I was
> wondering if someone else might be interested in having a look.
> 

Well, first of all, note that Jess comes with a solution to this exact
problem, although that solution takes a different approach than the
one you've taken here. This isn't wrong, though, and I'd think it'd be
possible to make it work.

A (The?) "right" answer is

  G = 1
  E = 9
  R = 7
  A = 4
  L = 8
  D = 5
  O = 2
  N = 6
  B = 3
  T = 0


So what I did was load up your facts and your rule, and use the "view"
command to visualize the network, and then double-clicked on the green
join nodes to see what was happening in each one. If you look at the
ones near the bottom, you'll see that the left memories don't contain
any facts for B=3; they allow other values of B, but not 3. So
something's wrong with the rule. If you open up each node one at a
time, you can see that it's the tests for G that eliminate the correct
values of B. That makes sense, as if you look lower down, G is getting
assigned the value 3. So it looks as though one of your assumptions
about G is wrong.

Looking at the rule, we see in the "G" pattern that ?Rn being used
before it's bound to a value. Jess' static analyzer is fairly weak,
and this kind of error is generally reported at runtime; in this case
it looks like Jess may be trying to do the right thing anyway, but
failing. These tests have to be moved down to the "R" pattern; this
may or may not be the only problem, but it's one problem, anyway. I'll
have to look at why you weren't getting an error message.

-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: initial problems

2004-05-04 Thread ejfried
I think MAtt Farmer wrote:
> Hi,
> I am new to this list. I had a few questions regarding jess that were confusing me.
> I was wondering if someone could help me out. I am using the book JESS IN ACTION
>  

Great book. Remember, folks, you can still order at Amazon in time for
Mother's Day! 

>  
> 1> The author says

Brilliant, isn't he? I understand he's very handsome, too.

> to add jess.jar to the CLASSPATH to start jess. I have windows xp
> and so I added "C:\jess61p4\jess.jar" to the Path variable.

PATH is used by Windows to find .EXE, .BAT, .COM and .DLL
files. CLASSPATH is something that's used only by Java to file .JAR
and .CLASS files. Java doesn't care about PATH at all, and Windows
doesn't care about CLASSPATH.

> I even tried adding C:\jess61p4 to the Path. I even made a CLASSPATH variable and 
> added that, but I can only start using
> java -classpath jess.jar jess.Main

Note that the way Windows works is that existing command windows don't
see changes to environment variables; you have to open a new one. If
you've set the CLASSPATH correctly, then this final step should do it.

>  
> 2> I am trying to use jess with java beans as shown in chapter 6. I created a 
> DimmerSwitch.java class, compiled it, but .class file on the Path...so
> C:\temp\DimmerSwitch.class on the Path but it still throws me a Class Not Found 
> Exception.

Again, PATH doesn't matter -- only CLASSPATH does. Also note that when
you use the -classpath switch to Java, the CLASSPATH environment
variable is ignored.

>  
> 3> Also I cannot run those examples in the jess\examples\pumps directory. The minute 
> I start up pumps.clp, it throws me an error saying that the java Tank class is not 
> found.
>  

Probably the same thing. If you say "-classpath jess.jar", then the
classes in jess/examples/pumps won't be found. A minimal class path
(switch or environment variable) should include both jess.jar and "."
(dot), which stands in for the current-buffer directory.

Here's a page at JavaRanch (an excellent site for Java newbies, by the
way) that explains all this CLASSPATH stuff fairly well:

http://faq.javaranch.com/view?HowToSetTheClasspath


-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Scoping in Jess: Are local vars local?

2004-05-05 Thread ejfried
   I think Eric Wang wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> 1.  Are local variables created using bind within a function body,
>   locally scoped to that function?
> 2.  Are function argument names locally scoped to that function?

The answer is "yes, but."  As you observed, "top-level" variables are
essentially global variables, and behave in seemingly strange (and
deliberately undocumented) ways. You've more or less deduced the rule
that if a top-level variable exists, then any reference to a variable
by that same name in any function will refer to the one global
copy. They're fairly lame globals, though, as the (reset) function
makes them disappear. 

None of this is really deliberate; it's more or less a historical
accident related to Jess's origins as a clone of the CLIPS expert
system shell. If I were to officially document this, then I couldn't
change the behavior without notice. It's actually quite likely that
this undocumented behavior will be gone in Jess 7.


-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Cryptarithmic exercise

2004-05-05 Thread ejfried
I think [EMAIL PROTECTED] wrote:
> 
> 
> 
> 
> What tool did you use to perform this analysis?
> 

The built-in "view" command. You can say "(view)" to get a picture of
the whole Rete network, or "(view rule-name)" to get just the nodes
that belong to the rule "rule-name". The pictures are "interactive" --
you can hover the mouse over the nodes to get info, or double-click
them to get even more.



-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Performance in a multi-threaded environment...

2004-05-05 Thread ejfried
I think Jin Lian wrote:
> 
> How would a singleton Jess engine do in a multi-threaded environment, such
> as in a Web container. In this environment, each incoming request is being
> served by a thread allocated by the container.

Jess is used this way very often. We keep this kind of application in
mind during Jess's development.

> 
> If multiple threads are executing rules in the rule-base, would all these
> requests be processed in parallel or sequentially?
> 

First note that a rule engine is a Java object, and you can
instantiate as many as you want; separate engines are completely
independent. It's possible to have one engine per client, or one per
each small group of clients, for example.

Each individual rule engine has basically two mutexes: one for the
working memory, and one for the execution engine. One
execution thread can be firing rules, while other threads are
adding/removing/modifying data in the working memory. Rules can be
firing while working memory is being modified, but only one thread can
be firing rules at a time, and only one thread can be modifying
working memory at a time.

There are broadly two different architectures you can use to use Jess
in a Web container in which one engine services multiple clients. In
one, each individual client thread manipulates the working memory,
then calls run() to fire the rules. This is fine if rule execution
time is expected to be short; it depends on the application, but often
this is adequate.

The other way is to have a single thread dedicated to running the
engine non-stop, while the individual client threads manipulate the
working memory. 

In either case, the key to concurrent use is that each client-specific
item in the working memory has to be identifiable as such -- i.e., if
there's a ShoppingCart object, it needs to have a Client property, so
many independent ShoppingCarts can exist simultaneously.

> Where would evaluation results (both intermediary and final) be kept for
> each thread?

All the information Jess is working with is held in "working memory."
There are some tricks you can do to use a database as a "backing
store" so that data can be paged in as needed, giving you a sort of
"virtual working memory".

Many rule engines expect you to load working memory, run the rules,
and then extract the contents of working memory to get an "answer."
The Jess rule language gives you full access to all of Java, so in
Jess, it's more typical to have rules that explicitly call a Java
function to report a result. Instead of a load-run-extract cycle, you
get more of a "continuous operation" pattern, which can be much more
efficient. In the case of the Web container, it would be most natural
if the Client or ShoppingCart objects (whatever form they take)
included methods that the rules could call to report results.


-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Clarification of Jess Performance in a multi-threaded environment...

2004-05-05 Thread ejfried
I think Jin Lian wrote:

> It seems that the default Java synchronization mechanism has been used to
> coordinate which thread will be able to fire rules. If 10 threads come in
> simulstaneously and all want to fire a different rule, then 9 of them will
> have to wait while the execution engine is serving the request from one
> chosen thread.

If that's how you architect it, yes. Alternatively, as I said, one
thread can be dedicated to firing rules continuously, so that rule
firing for the various clients can be interspersed. And if you need
even more concurrency (on a multiprocessor machine, for example) then
you can use multiple engine objects.

> >In either case, the key to concurrent use is that each client-specific
> >item in the working memory has to be identifiable as such -- i.e., if
> >there's a ShoppingCart object, it needs to have a Client property, so
> >many independent ShoppingCarts can exist simultaneously.
> 
> Let's say the Shopping cart is wrapped in a JavaBean, and this JavaBean will
> be passed into Jess working memory for processing. In order for each bean to
> be independently "identifiable," each must be given a unique label while it
> is being passed into the working memory. Is this right?

If a shopping cart belongs to a specific session, and there will be
multiple simultaneous sessions, then that shopping care must be
identified with the session somehow, yes. The shopping cart beam might
just have a property containing the session cookie, for example.

> Also, the "working memory" of Jess is shared between all clients, right?

The working memory belongs to a single rule engine object. You can
have as many completely independent rule engine objects as you'd like
in a single process.


-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Combining the logical CE and backward chaining

2004-05-05 Thread ejfried
I think Steffen Luypaert wrote:
> Hi all,
> 
> No backward chaining will occur for patterns inside a conditional 
> element. I was wondering that this will change in a future version of 
> Jess, especially for the logical conditional element.

This is basically an oversight in the rule compiler; nobody's ever
pointed this out before. The problem is that, because everything in
Jess is driven by pattern-matching, for a pattern to trigger backward
chaining, there has to be a preceding pattern; i.e., for Jess to
notice that there's no fact that satisfies pattern 1 of a rule, there
has to be a pattern 0 that is satisfied. Imagine that the deftemplate
"foo" is backwards chaining reactive. Then if you write a rule

(defrule bar
  (foo (a 1))
  => )

Jess will rewrite it like this to provide that needed preceding
pattern:

(defrule bar
  (initial-fact)
  (foo (a 1))
   => )

(you can confirm this with ppdefrule.) The problem you're seeing is
that a rule like

(defrule foo
  (logical (foo (a 1)))
   => )

isn't being rewritten automatically. No worries, though -- you can
actually do it yourself:

(defrule foo
  (logical
(initial-fact)
(foo (a 1)))
   => )

You'll find that if you do this, logical patterns will indeed trigger
backward chaining. I'll log a bug on this and we'll get it fixed.


> Will it ever be possible to make Jess automatically retract the
> need-fact, whenever the needed fact is computed?

When Jess's backward chaining feature was first added, that's what it
did, actually, but we changed it because it led to infinite loops. You
can of course retract the need-X facts on the RHS of your rules that
satisfy them, and deal with the loops some other way.


-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Facts function not showing declared facts

2004-05-06 Thread ejfried
I think Michael Knapik wrote:
> 
> Funcall f = new Funcall("definstance", rete);
> 
> f.add(new Value("event", RU.ATOM));
> 
> f.add(new Value(e));
> 
> f.execute(rete.getGlobalContext());

I know that there's an example in the Jess 6.1 manual that shows how
to call "definstance" this way, but there's also a definstance()
method in the Rete class which is much more convenient to use.

> 
> rete.executeCommand("(facts)");
> 

The only thing I can think of is that you've defined one or more of
your own defmodules, but there are no facts that belong to the
defmodule that is the current module when (facts) is called. By
default, (facts) reports only the facts in the current module
(usually, the current module is the last one to be defined); you can
supply an argument (a module name, or "*" for "all") to change what
gets reported.

If you haven't defined any defmodules, and you're sure that this exact
code is really being executed, then I'm utterly stumped.

-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Jess agenda function

2004-05-03 Thread ejfried
I think Michael Knapik wrote:

> 
> So when does the agenda have all 5 rules in it such that it can be managed
> accordingly?
> 


The agenda is a "to-do list." It is an ordered list of rules that have
been "activated" but not yet fired. Properly, it's not a list of rules
at all; it's a list of {rule, token} associations (a "token" is the
list of facts that match the complete LHS of a rule.) These
associations are called "activations."

You might define 100 rules, but the agenda could still be empty if
there are no facts that match those rules. If you then subsequently
assert some facts, then those activations that are created by matching
the facts to the rules are placed on the agenda; there will often be
fewer activations than rules, and there can be more than one
activation per rule.

When the engine runs, activations are removed from the agenda one at a
time and then "fired." Each time a rule fires, the agenda can change;
if Jess is being used in a multithreaded program, the agenda can
change at any time. The changes are driven by facts being added,
modified, or removed.

The (agenda) function lists all the activations on the agenda at the
time the function is called. If you call (agenda) on the RHS of a
rule, the current activation -- i.e., the association between the rule
that called "agenda" and the list of facts that made it fire -- will
already have been removed from the agenda, which hopefully helps you
to understand your observations. If you want to see all the
activations created based on a set of facts and a set of rules, you
can execute the (agenda) command from the Jess> prompt before calling
(run). 




-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: JESS defmodules and focus

2004-05-03 Thread ejfried
I think Michael Knapik wrote:
> 
> 
> Question: why are they fired/reported in reverse order of the focus
> statements? 

As the manual explains at the end of section 2.10.3, there's a "focus
stack" containing the list of modules from which rules will be fired;
rules will be fired only from the module on top of the stack. "focus"
pushes a new module onto the stack (sectiom 8.64). So if you say

(focus A)
(focus B)
(focus C)

then rules from module C will fire until there are no more
activations, followed by B, followed by A.




-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Determine when a fact is retracted

2004-05-03 Thread ejfried
I think [EMAIL PROTECTED] wrote:

> 
> if there is a (B ?a)
> such that ?a doesn't exist


(defrule the-rule
  (B ?a)
  (not ?a <- (A))
  =>)

actually works fine.



-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Rules not firing

2004-05-03 Thread ejfried
I think Rajani Sadasivam wrote:
> ==> f-1 (MAIN::book (name "Java for beginners") (keyword "Java") 
> (publisher "oreilly") (price 15))

-vs-

> ==> f-5 (MAIN::book (name samplebook) (keyword Java) (publisher oreilly) 
> (price 14))

Jess has both a "String" type and a "symbol" or "atom" type (this is
covered over the first few paragraphs of chapter 2 of the manual;
worth a look.) The quoted string "Java" and the unquoted symbol Java
are two different things. If you write a rule to match symbols, then
this rule won't match strings. If you write it to match strings, then
it won't match symbols. You just have to pick one and be
consistent. You wrote your rule to not use quotes around the
publisher and keyword, but you asserted the facts (from Jess anyway)
with the quotes included, and this is why your rule doesn't match.

Because book titles and publisher names will both often have spaces in
them, you are required to use Strings -- i.e., double-quoted
characters.  Just do this consistently; when you assert the fact from
Jess, or from Java, and when you write the rule: always use the
quotes. For keywords, you might choose to use symbols instead, and so
omit the quotes, but again, you have to be consistent.




-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Java and Jess

2004-05-13 Thread ejfried
I think [EMAIL PROTECTED] wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> 
> 
> Hi there,
> 
> i made the board game Stratego with java. and i want to use agents for every 
> piece.  my quastion is: 
> 
> i have now the complete game done with java. And someone else made all the 
> Agents CLIPS with Jess and i have now like 10 ".clp" files. is it possible use 
> Jess with not changing all the java source code of the game?   

No, not really. You're going to need to write Java code to create one
or more rule engine objects, load the rules into them, transfer
information from the game into the rule engines, run them, and then
take action based on the results. The last two steps could be
eliminated if you modified the rules to do them instead -- i.e., the
rules could be changed to "pull" the needed data from your code, and
"push" the results by calling some Java methods you provide.

None of this is rocket science, but you do have to understand what's
what, and you do have to do a bit of design.

> and please tell me what i need and how. becouse i am very newbie with Jess.
> 

The Jess manual is a good place to start. If you want more
information, there's the book "Jess in Action." And this list is
pretty helpful when it comes to answering specific questions.


> i hope someone can help.
> 
> thx
> 
> here is an example of one of thos clips
> 
> 
> ; captain.clp
> ; the rule-engine of the captain
> ;
> ; makes use of the action available in agent.clp
> ; available actions are:
> ;   flee
> ;   attack
> ;   attack-general
> ;   attack-bomb
> ;   stay
> ;   avoid
> ;   wander
> ;
> (batch agents/agent.clp)
> 
> ;these are the specific globals for the captain
> ;upon change, call the assert-globals function
> ;to assert the new corresponding facts
> (defglobal ?*i-have-moved* = false)
> (defglobal ?*my-rank-revealed* = false)
> 
> (deffunction assert-globals()
> (if (eq ?*i-have-moved* true) then
> (assert (i-have-moved))
> )
> (if (eq ?*my-rank-revealed* true) then
> (assert (my-rank-revealed))
> )
> )
> 
> ;these are the specific rules for the captain
> 
> ;abstract rules 1 and 2
> (defrule enemy-unknown-1
>(i-have-moved)
>(my-rank-revealed)
>(enemy-unknown ?enemy)
>=>
>(assert (stay))
> )
> 
> ;abstract rules 9 and 10
> (defrule enemy-unknown-2
>(i-have-moved)
>(not (my-rank-revealed))
>(enemy-unknown ?enemy)
>=>
>(assert (attack ?enemy))
> )
> 
> ;abstract rules 13 and 14
> (defrule enemy-unknown-3
>(not (i-have-moved))
>(not (my-rank-revealed))
>(enemy-unknown ?enemy)
>=>
>(assert (stay))
> )
> 
> 
> 
> ;abstract rules 3 and 4
> (defrule enemy-higher-rank-1
>(my-rank-revealed)
>(enemy-higher-rank ?enemy)
>=>
>(assert (flee ?enemy))
> )
> 
> ;abstract rule 11
> (defrule enemy-higher-rank-2
>(not (my-rank-revealed))
>(enemy-higher-rank ?enemy)
>(distance ?enemy 1)
>=>
>(assert (stay))
> )
> 
> ;abstract rule 11
> (defrule enemy-higher-rank-3
>(not (my-rank-revealed))
>(enemy-higher-rank ?enemy)
>(distance ?enemy 2)
>=>
>(assert (attack ?enemy))
> )
> 
> 
> ;abstract rules 5 and 6
> (defrule enemy-captain
>(enemy-captain ?enemy)
>=>
>(assert (stay))
> )
> 
> ;abstract rules 7 and 8
> (defrule enemy-lower-rank-3
>(not (my-rank-revealed))
>(enemy-lower-rank ?enemy)
>=>
>(assert (attack ?enemy))
> )
> 
> 
> ;abstract rules 15 and 16: avoid the bomb
> (defrule enemy-bomb
>(enemy-bomb ?enemy)
>=>
>(assert (avoid ?enemy))
> )
> 
> ;abstract rule 17: wander behavior
> (defrule wander
>(initial-fact)
>=>
>(assert (wander))
> )
> 
> 
> 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]
> 
> 



-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: calling bsave after adding a Userfunction

2004-05-14 Thread ejfried
I think Korbinian Lindemann wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Hi,
> I tried to call rete.bsave() after I have added a Userfunction ExMyUpCase and I get 
> the following Exception:
> 
> java.io.NotSerializableException: ExMyUpCase


Just declare that your Userfunction class implements Serializable:

public class ExMyUpCase implements Userfunction, java.io.Serializable {
 ...




-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: asserting javabeans

2004-05-14 Thread ejfried
I think =?iso-8859-1?Q?Diego_Alonso_Gonz=E1lez?= wrote:

> 
> I'm really confused, by "shadow" concept.


There are two kinds of definstances: static and dynamic. Dynamic ones
use PropertyChangeEvents, static ones don't. If you use (modify) in
Jess, both kinds of JavaBeans will be immediately updated. But it
doesn't necessarily work the other way -- i.e., if you call setFoo()
on a JavaBean that's a static definstance, Jess won't hear about
it. Jess will, on the other hand, know instantly about changes to a
dynamic definstance. 

But to answer your actual question: if you modify any kind of shadow
fact, the associated JavaBean is always immediately updated, so all
clients of that one Bean object will see the changes immediately.


-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Free variables

2004-05-14 Thread ejfried
I think Steffen Luypaert wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]

> The solution I use now first binds the variables by using regular 
> patterns, for which no backward chaining is done. For example, if all 
> faa facts are present in working memory, the constraint (faa (id ?
> id&~2)) (foo (?id)) will assert need-foo facts for every id for which a 
> faa fact exists, except for the faa fact with id 2, which will result 
> in the desired behaviour for the sample rule.
> 
> I am sure the values of the slots of facts(not patterns) have to be 
> bound in the current version of Jess, but I was just wondering that 
> this will ever change, or at least, was ever considered?
> 

You've got some interesting ideas here. As I think you've guessed, the
issue is that things like "~2" or "red|blue" are compiled when a
rule is defined into structures in the Rete network; there's currently
no code in Jess that could interpret these at runtime.

But I could imagine a new Value subclass named TestValue, which could
wrap constraints such that they could indeed be evaluated at
runtime. I agree that this would make Jess's backward chaining much
more powerful.

This is something we could consider for Jess 7.1. I'll make a note of it.



-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Rule for Multi-Slot

2004-05-14 Thread ejfried
I think [EMAIL PROTECTED] wrote:

> 
> (defrule Function-Parameter-Required-Passed
>   "Check current Function Required Parameter"
>   (Input (name Function) (value ?functionName))
>   (Function (name ?functionName)(requiredParameter
> $?requiredParameterList))
> 
>   ;; 1. check for each parameter in the "requiredparameterList" there
> is an Fact
>   ;;"Param" with matching "name" slot.
> 

OK, let's look at this. To match a Function and one corresponding
Param, you'd write

  (Function (requiredParameter $?before ?param $?after))
  (Param (name ?param))

"$?before" matches zero or more items in the list before the item of
interest, "?param" is the item of interest, and "$?after" matches zero
or more items after the item of interest.

Now, to match the case where there's a parameter in the list and
there's no Param fact, we'd say:

  (Function (requiredParameter $?before ?param $?after))
  (not (Param (name ?param)))

Now, this will match once for each non-existent Param. What we want is
something that will match if there are no non-existent Param facts; so
we just put "not" around this whole thing (we need an "and" to group
them first:)

  (not (and (Function (requiredParameter $?before ?param $?after))
(not (Param (name ?param)

Which you could read as "It's not the case that there's a ?param in
this Function with no corresponding ?param fact."

Note that this will also match if there's no appropriate "Function"
fact, so you could precede this with a separate pattern to match the
Function fact. So the whole rule might look like

 (defrule Function-Parameter-Required-Passed
   "Check current Function Required Parameter"
   (Input (name Function) (value ?functionName))
   (Function (name ?functionName))
   (not (and (Function (name ?functionName)
   (requiredParameter $?before ?param $?after))
  (not (Param (name ?param)
   => ...


>   =>
>   (printout t "All Parameter Passed" crlf)
> )
> 
> 
> (defrule Function-Parameter-Required-NOT-Passed
>   "Check current Function Required Parameter"
>   (Input (name Function) (value ?functionName))
>   (Function (name ?functionName)(requiredParameter
> $?requiredParameterList))
> 
>   ;; 2. check


This one is the opposite of the above, so we could actually just
enclose the whole thing in yet another not; (not (not)) is "exists",
though, so let's use that:


 (defrule Function-Parameter-Required-Passed
   "Check current Function Required Parameter"
   (Input (name Function) (value ?functionName))
   (Function (name ?functionName))
   (exists (and (Function (name ?functionName)
  (requiredParameter $?before ?param $?after))
(not (Param (name ?param)
   => ...


> 
>   =>
>   (printout t "Parameter Missing : (missing parameters)" crlf)
> 
> )

Make sense?

-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: DimmerSwitchDynamic error

2004-05-14 Thread ejfried
I think Michael Knapik wrote:

> Nested exception is:
> DimmerSwitchDynamic.addPropertyChangeListener(java.beans.PropertyChangeListe
> ner)
> java.lang.NoSuchMethodException:
> DimmerSwitchDynamic.addPropertyChangeListener(java.beans.PropertyChangeListe
> ner)


You might use the windows "Find File" dialog to find and delete all
copies of DimmerSwitchDynamic.class on your system, then try compiling
the known good file again.


-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Newbie: parsing string result of a Jess command from Java

2004-05-15 Thread ejfried
I think Mike Coburn wrote:
> Hi Jess-Users,
>  
> >From the following snippet:
>  
> Rete engine = new Rete();
>  
> Value val = engine.executeCommand("(facts)");
>  
> how can I get the result of the jess command (facts) for example,
>  but really from any command, as a string or stringbuffer in order
>  to parse the result?


All Jess functions have a return value (which is the Value you get
from executeCommand above,)  and some Jess functions also print output
to the screen. In the case of "facts" the return value is always TRUE
(not interesting) and the list of facts is printed.

You can capture what Jess prints to the screen by redirecting the
standard I/O routers. Section 4.4.6 of the Jess manual talks about
this in detail. It can be as simple as

  StringWriter writer = new StringWriter();
  engine.addOutputRouter("WSTDOUT", writer);

Now the output of "facts" will end up in this StringWriter.

But it's rare that you actually want to do this just so you can parse
the output; most of the time the only reason to do it is to embed Jess
in a GUI and force the output to appear in a JTextArea or similar. The
reason it's rare is because it's silly to make Jess turn this
information into text, and then parse the text, when the information
is available directly from Jess in a more useful form. In the case of
the "facts" function, there's the method listFacts() in the Rete
class, which returns an Iterator over all the Fact objects in working
memory. Instead of doing the above, just call listFacts() and you have
the same information much more efficiently.


-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Rule not firing

2004-04-26 Thread ejfried
I think Greg Biegel wrote:


> And I have the following rule:
> 
> (defrule InUse-BottomLeft
> ?ac <- (active-context InUse)
> ?cu <- (context-updated true)
> (and
> (and
> (LoadCellSensor1_MassEvent_Bean (sensorID 1))
> (LoadCellSensor1_MassEvent_Bean (mass ?LoadCellSensor1_MassEvent&:(>
> ?LoadCellSensor1_MassEvent ?*averageweight*)))
> )
...

Two comments. First, regarding writing rules efficiently: you can, and
most certainly should, match multiple slots in a single pattern. Using
multiple patterns this way consumes more memory and does more
computational work (and of course, if there were more than one
LoadCellSensor1_MassEvent_Bean object, then the above would match all
the possible permutations of matches based only on single-slot
matching, which I'm sure you wouldn't want. Also, there's an implicit
"and" around the whole LHS of a rule, and furthermore, an "and" inside
an "and" is just extra work for the parser, as (and (and X Y) (and P
Q)) is precisely equivalent in meaning to (and X Y P Q). So drop all
the "and"s, combine the multiple patterns, and just write:

(defrule InUse-BottomLeft
 ?ac <- (active-context InUse)
 ?cu <- (context-updated true)
 (LoadCellSensor1_MassEvent_Bean
(sensorID 1)
(mass ?mass1&:(> ?mass1 ?*averageweight*)))

I picked a shorter variable name for you, too.

Secondly, pattern-matching is driven by fact assertions,
modifications, and deletions; as you observed, if you match with a
global variable, the matches won't be updated until the facts are
modified. From the end of section 2.8.2 of the manual:

  "If you match to a defglobal with a pattern like (foo ?*x*), the match
  will only consider the value of the defglobal when the fact is
  asserted. Subsequent changes to the defglobal's value will not
  invalidate the match - i.e., the match does not reflect the current
  value of the defglobal, but only the value at the time the matching
  fact was asserted."

If you need matches to respond to changes in the average weight in
real time, then simply store the average weight in a fact (or a
dynamic definstance) rather than in a defglobal.





-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Problem updating shadow fact data

2004-04-27 Thread ejfried
I think Michael Knapik wrote:

> 
> ;;(call event setConditionCodeId )

Variables always have a "?" in their name:

(call ?event setConditionCodeId )

> 
> (modify 2 (conditionCodeID ))
> 

Slot names are case-sensitive:

(modify 2 (conditionCodeId ))



-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Problem updating shadow fact data

2004-04-27 Thread ejfried
I think Michael Knapik wrote:
> 
> 
> Why is it referring to jess.FACT instead of the eventImpl that is the
> defClassed class:

Because that's just how it works. The defclassed object is held in a slot
named OBJECT; if you want the object, bind that slot to a variable on
the LHS.

-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Problem updating shadow fact data

2004-04-27 Thread ejfried
I think Michael Knapik wrote:

> 
> 
> How do I do that  - how do I get the shadow fact data to change (so that
> Java code that is executing this Jess code knows about it).


"(modify ?e (conditionCodeId ))" would do it.



-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Problem updating shadow fact data

2004-04-27 Thread ejfried
I think Michael Knapik wrote:
> 
> (defrule report-subject-and-event-status
> ?s <- (subject (subjectId ?sId) (caseStatusId ?csId))
> ?e <- (event (eventId ?eId) (conditionCodeId ?ccId)(eventDescriptor ?evtDescriptor))
> =>
> (modify ?e (conditionCodeId ))
> (printout t "* Event " ?eId " has a condition code: " ?ccID crlf)
> 
> produces
> 
> Event 100017 has a condition code: 1008
> 
> which is the original value.
> 

Imagine a JavaBean class Foo with a property X. Now, what does this print?

Foo f = new Foo();
f.setX(23);
int x = f.getX();
f.setX(37);
System.out.println(x);

It prints 23, right? Even though the X property of the Foo bean is 37,
because you read the property, changed it, and then printed the value
you read earlier.

That's exactly what you're doing in your Jess code. The variable ?eId
gets bound on the rule LHS; then you modify the value of that property
in the bean; then you print the value of the variable which, not
surprisingly, still has the same value. If you want to see the new
value, you need to read it back from the object.






-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Modifying an unordered fact

2004-04-28 Thread ejfried
I think Greg Biegel wrote:

> However, with the average-weight
> fact included as above, everything goes mad and this rule just seems to fire
> constantly! Am I performing the modification wrong?

Nope, you're fine. This is a classic problem with Rete-based production
systems like Jess. Modifying a fact re-activates a rule, which
modifies the fact, which reactivates the rule...

In the present case, on the second and subsequent firing, you're not
actually modifying the slot value, so it's easy enough to prevent
this. Just put the "modify" call inside an "if" which tests if the
modify would actually change the value:

(if (<> ?*averageweight* ?X) then
  (modify ...

The forthcoming Jess 7.0 has the nifty "no-loop" declaration, which
can automatically break these kinds of infinite loops.



-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: JessAgentTab

2004-04-28 Thread ejfried
I think Chintan Shah wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Can you please provide the fully qualified server name in the url.
> http://www-i4 does not work for anybody outside your DNS.

It the same as his email;

http://www-i4.informatik.rwth-aachen.de/agentcities/main/tools/JessAgentTab/doc/jat.html




-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Embedded executeCommand() performance problem

2004-04-28 Thread ejfried
I think Douglas Pearson wrote:

> The problem is that loading a list of about 2,000 facts this way is taking
> 30 seconds and I'm just wondering why?
> 
> For debugging we dump the same commands to a file which we can then load
> into a standalone instance of Jess through the (batch ) command and
> there loading the same list of facts takes less than a second.  


Most people new to Jess don't realize that all the actual computation
-- deciding which rules apply, and in what order they should fire --
happens during calls to assert, retract, and modify. The amount of
work these functions have to do depends on the Rete network, which is
compiled from the rules in the system. You can assert hundreds of
thousands of facts per second if no rules are defined. Once you add
rules, it can slow down. How slow it gets depends on how the rules are
written. Chapter 10 of the manual, and chapter 8 of the book, goes
into a lot of detail on this topic.

So anyway, my suspicion is that the performance difference has nothing
to do with either the embeddedness or the use of executeCommand(), but
rather that the two installations contain different sets of
rules. 2000 asserts in 30 seconds is very slow, so there's definitely
at least one rule with quadratic or worse performance that could stand
to be improved.

> 
> Now, obviously we could (and probably will eventually) move to call
> Rete.assertFact() instead of executeCommand() and I assume the performance
> will improve.

There should be virtually no difference. Everyone always seems to
think parsing the code is slow. It's not, really. The Eclipse plugin
we're developing uses Jess's regular parser for syntax highlighting,
completion, and intention actions, and it can parse an entire large
source file after every keystroke, in real time, with no noticeable
delay.


> The other question is whether there's an equivalent function to "batch"
> that's available in the API so we could load the commands from a file as
> presumably that would be fast again.

You can, of course, say "executeCommand("(batch ..." If you want to
get fancy, you can use a Funcall object (manual section 4.6), or use
the parser directly. This one-liner:

  Rete engine = ...
  FileReader reader = ...
  new Jesp(new FileReader(reader, engine).parse(false);

will parse and execute a file.


-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Embedded executeCommand() performance problem

2004-04-29 Thread ejfried
I think Douglas Pearson wrote:
> 
> Then just as I was starting to write this message a thought occurred to me
> and I can now say that the problem is running Jess inside the Eclipse
> debugger.  If I run the same app outside of the debugger the load time is
> less than a second not 30 seconds.

I did a search at eclipse.org for "debugger performance" and similar,
and got a lot of hits. According to the posts I read, it sounds like
the typical application runs 3-4 times slower under the 2.x debugger
(some even slower; depends on whether the app is compute- or
I/O-bound) and that there are known problems with the 3.x debugger
being another factor of 2-4 slower than that. So we're easily in the
10-20x times slower category already, just from the known
characteristics of the 3.x debugger. I'm sure they're working on the
3.x issue, anyway.


-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Q on comparing the head of facts

2004-04-29 Thread ejfried
I think Littell, Todd R ERDC-CERL-IL wrote:
> 
> I came up with:  (eq (call ?fact getName) "MAIN::house")   but I suspect
> there is a much
> more intuitive way than this.?


Not really. Just as in Java, it's better not to lose the type
information in the first place. If you cast something to Object, then
you have to unse the inelegant "instanceof" operator to figure out
what it really is and get the information back.

> For example, suppose I simply have a fact set like:
> 
> (deffacts myfacts
>(house 34 "abc" 1995)
>(house (builtin 1993) (roofAge 19) (company "def") (ac "yes"))
>(house "ghi"))

You can't. A particular template is either ordered or unordered. You
can can't have both.

> 
> What are the basic methods for exploring the structure of a returned fact?

Remember that a fact is an instance of the Java class jess.Fact.
Given a jess.Fact, you can call getDeftemplate() on it, and then ask
that jess.Deftemplate for the number of slots and their names. Once
you know the name of a slot of interest, you can call getSlotValue()
on the Fact to get its value.

But in practice, you'll find that doing anything like this is only
very rarely necessary -- about as often as using the java.lang.reflect
package is in Java programming. I'd go so far as to say that if you
need to do anything like this, especially as a newbie, then you're
doing something wrong. Procedural manipulation of facts is not
something that you should regularly need to do; facts should mostly be
things you match on the LHS of rules, and that's all.




-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: 2 Questions: - Charlemagne engine and Backward Chaining

2004-05-05 Thread ejfried
I think Anu Raj Pradhan wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Hi all
> 
> 1. I bought a copy of Jess in Action and am using the Jess engine 
> downloaded from Manning website.  I want to try Charlemagne engine.  If 
> I can dowload the Charlemagne engine, please do provide me the weblink 
> for that.

It's not available yet. Keep an eye on the Jess web site.

> 
> 2.  I am working on a personal project that uses backchaining very 
> heavily.  How good is JESS for backchaining?

If your application consists of nothing but backward chaining, then
you should consider using Prolog, which was designed for that
purpose. If you need to use a mixture of backward and forward chaining
in one program, then you actually can't do better than Jess!




-
Ernest Friedman-Hill  
Science and Engineering PSEsPhone: (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]




Re: JESS: Problem with Jess wake up in multi-threaded environment

2005-08-19 Thread ejfried
Which version of Jess? It does sound like a race condition where
notifications are getting lost.

I think Steven Goncalo wrote:
> I think I am seeing an occasional problem with Jess not waking up properly
> when a Java Bean changes value.
>  
> I am using Jess in a multi-threaded Java program and connecting the Jess and
> Java parts of the program with a handful of Java beans using the dynamic
> change notification. I have a deadicated jess thread in my program that
> calls the Rete engine with the runUntilHalt command. I have a simple GUI
> tied into the java beans as a PropertyChangeListener, so my display sees the
> same change notices as Jess does. On overnight runs, I sometimes see the
> program hang up unexpectedly. The display shows that the last Java task
> completed normally and set the Java Bean properties to show that it had gone
> idle and Jess should evaluate its results. Both my display and a save-facts
> dump with the system in this hung state show that all the conditions look
> correct for Jess to fire the evaluation rules and sechedule another Java
> task, but the rules did not fire. If I used a GUI button that asserted a
> fact to tell jess to change one of my program parameters, the logjam cleared
> up and things restarted. Since this fact did interact with my other rules, I
> really couldn't convince my self that I wasn't somehow changing my data to
> make the dormant rules file.
>  
> I finally added a separate button to assert a totally unrelated fact and
> added an arbitraty rule to detect it.
>  
> (defrule wake-up "no interactions with other rules"
> ?f<-(cattle-prod)
> =>
> (retract ?f)
> (printout t "Woke up" crlf)
> )
>  
> the button just called
> engine.assertString("(cattle-prod)");
>  
> With the system in the locked up state, asserting the wake fact would print
> the expected message and suddenly cause Jess to notice that the conditions
> of my other scheduling rules had been met and start firing them. At a
> minimum, this tells me that the changes in my beans did actually get
> delivered to Jess and that I don't have the Jess thread in some circular
> deadlock with other parts of my code. I wish I had a simple test case to
> demonstrate the problem, but so far I've only seen it in a large program
> that typically runs for many hours before hitting on whatever race condition
> triggers the problem.
>  
> As a temporary work-around, I can write a trivial Java thread that
> periodically hits Jess with a cattle-prod, but that seems ugly, even by my
> standards. 
>  
> Does any of this sound familar? It looks like a Jess bug to me, but I'd be
> just as happy to find a fixable problem in my code. Are there any
> pathological issues with threading and Jess that I should check for in my
> code?
>  



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




Re: JESS: How to stop firing rules (again)

2005-08-27 Thread ejfried
Felix,

The error is happening during pattern-matching, which is driven by
working memory changes (i.e., all matching involving a given fact
happens whenever that fact is asserted, retracted, or modified.)

The problems are happening during calls to fact-slot-value. It's easy
enough to fix this: don't do that, ever. There is never a reason to
call fact-slot-value on the left hand side of a rule -- you've already
got ahold of a fact (or if you don't, you can get it) and so you can
match the slots directly. Your problem is that you're calling fact-id
to get ahold of some nonexistent fact, then passing that nonexistent
fact's id (-1) to fact-slot-value, which is reporting that, indeed,
there's no such fact.

As an aside, the fact-id function is virtually never needed: it turns
a real integer into a Fact by doing a slow lookup. It's useful when
debugging from the command line, but there's never a need to use it
during normal Jess coding (although you might use it to restore links
when loading interconnected facts in from a flat file of some kind.)
If you're actually got a number and need a jess.Fact object, then use
it. But if you're got a fact binding, then it's already a jess.Fact
object.

I untangled your code extract into this, which *really* doesn't belong
on the LHS of a rule. Apparently this is part of a deffunction that
you're calling from a test CE -- i.e., from the LHS of a rule.

(if (or (eq (fact-slot-value (fact-id ?fact) template) imple-method)
(eq (fact-slot-value (fact-id ?fact) template) global-method))
 then
(return ?fact)
 else 
(if (eq (fact-slot-value (fact-id ?fact) template) class)
 then (return "-1")
 else
(bind ?p-id (fact-slot-value (fact-id ?fact) parent-id))
(get-method-id ?p-id)))

Now, you *could* simply add some "guard clauses." Just as in Java
code, you'd check things for null before using them, here you need to
check that ?fact isn't "-1" before continuing with this routine. But
the right thing to do is to break this all up and do it as pattern
matching instead. It would not only be vastly simpler, but it'd
probably be vastly more efficient, too.

I can't tell you exactly what to do, because you really need to
rethink the fundamental design. You've got this whole system designed
in a procedural way. Instead of using if-then logic on the LHS of a
rule, you instead what to write multiple rules, one for each case you
need to handle.

Something like

  (if (or (eq (fact-slot-value (fact-id ?fact) template) imple-method)
  (eq (fact-slot-value (fact-id ?fact) template) global-method))

could instead be written as something like

  (call-method (template imple-method | global-method))

if you followed my advice.

I think =?iso-8859-1?Q?F=E9lix_G=F3mez_Cordero?= wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Hi Jason,
> 
> thanks for your answer, one of errors I get is throwed when I try to assert 
> the next fact: (MAIN::call-method (id "13") (template call-method) 
> (parent-method-id "9") (parent-id "12") (params "10")). 
> 
> Error Message is: 
> Jess reported an error in routine factid
> 
> while executing (fact-id ?fact)
> 
> while executing deffunction fact-slot-value
> 
> while executing (fact-slot-value (fact-id ?fact) template)
> 
> while executing (eq (fact-slot-value (fact-id ?fact) template) imple-method)
> 
> while executing (or (eq (fact-slot-value (fact-id ?fact) template) 
> imple-method) (eq (fact-slot-value (fact-id ?fact) template) global-method))
> 
> while executing (if (or (eq (fact-slot-value (fact-id ?fact) template) 
> imple-method) (eq (fact-slot-value (fact-id ?fact) template) global-method)) 
> then (return ?fact) else (if (eq (fact-slot-value (fact-id ?fact) template) 
> class) then (return "-1") else (bind ?p-id (fact-slot-value (fact-id ?fact) 
> parent-id)) (get-method-id ?p-id)))
> 
> while executing deffunction get-method-id
> 
> while executing (get-method-id ?p-id)
> 
> while executing (if (eq (fact-slot-value (fact-id ?fact) template) class) 
> then (return "-1") else (bind ?p-id (fact-slot-value (fact-id ?fact) 
> parent-id)) (get-method-id ?p-id))
> 
> while executing (if (or (eq (fact-slot-value (fact-id ?fact) template) 
> imple-method) (eq (fact-slot-value (fact-id ?fact) template) global-method)) 
> then (return ?fact) else (if (eq (fact-slot-value (fact-id ?fact) template) 
> class) then (return "-1") else (bind ?p-id (fact-slot-value (fact-id ?fact) 
> parent-id)) (get-method-id ?p-id)))
> 
> while executing deffunction get-method-id
> 
> while executing (get-method-id ?parent-id)
> 
> while executing (str-compare (get-method-id ?parent-id) (get-method-id 
> ?param-id))
> 
> while executing (= (str-compare (get-method-id ?parent-id) (get-method-id 
> ?param-id)) 0)
> 
> while executing 'test' CE
> 
> // The above functions are part of my rules, but the engine should not be 
> running 
> 
> while executing rule LHS (Node2)
> 
> while executing rule LHS (MTELN)
> 
> while executing ru

Re: JESS: How to stop firing rules (again)

2005-08-28 Thread ejfried
I'm not sure how to say this any more clearly. Pattern matching
happens while facts are being asserted, modified, and retracted, and
*not* during a call to runUntilHalt(). "Running" means firing rules,
nothing more. There is no way to add facts to working memory and then
say "process them" -- it just doesn't work that way.

So beyond an overall redesign (which is by far the best choice here)
you have several other choices. First, you can simply rewrite things
so that they work if some of the facts are missing. This would be the
best thing to do, as it is in any kind of software development. If you
must call a Java method that can return null, then you have to check
for null before proceeding, right? This is the same thing. Simply
rewrite things to assume that some of the needed facts may be missing.

The problem is that because you're looking up facts in a deffunction
rather than matching them, the patterns won't be evaluated when the
later facts are asserted, so this option may not work for you.

A second, easy but very very ugly choice would be to use the "try"
function inside your deffunction to catch and hide the exceptions you
get from the missing facts. Again, this probably won't work because of
the lookup issue.

A third, more complex, choice would be to be sure to assert the facts
in an order such that the errors don't happen. It looks like you have
some facts referring to other facts, and the errors happen when the
referers have been asserted but not the referees. Make sure you assert
the referees first. This might mean doing a postorder traversal of
an object tree instead of an preorder traversal.


I think =?iso-8859-1?Q?F=E9lix_G=F3mez_Cordero?= wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Hello Ernest,
> 
> thanks for your really good explanation, now I realize that I have a problem
> desinng because I have placed on the LHS some responsibilities which weren't
> its... That's due to I have to keep reference between facts and I do that
> using a 'id' slot... That would be better done from Java... but I think that
> it's too late becase my piece of software is almost finished... except for
> this "little" lapse :). So I'd like to fix the problem in other manner so
> that I wouldn't need to break up all my code...
> 
> Anyhow, if I add all my facts in one batch there are no exceptions. I find
> problems problems just when running the engine (Rete#RunUntilHalt()) in
> order to check constraints, then I wait the engine to stop and afterwards
> adding/modifing/retracting facts. Is there any reason to think that I'm
> re-running the engine when I call 'modify','retrarct' or 'assert' from Java?
> If I can keep stopped the engine while processing the facts (because they
> are inconsistent until the last one has been processed, for that reason I
> get a nonexistent fact's id in fact-slot-value), I think that all will work
> fine.
> 
> Thank for your help,
> 
> Filix.
> 
> PS. I'm sorry if my explanitions are too confused, it might be my english's
> fault, although I'm not sure if they would be better in spanish...
> 
> 
> - Original Message - 
> From: <[EMAIL PROTECTED]>
> To: 
> Sent: Saturday, August 27, 2005 9:42 PM
> Subject: Re: JESS: How to stop firing rules (again)
> 
> 
> > Felix,
> >
> > The error is happening during pattern-matching, which is driven by
> > working memory changes (i.e., all matching involving a given fact
> > happens whenever that fact is asserted, retracted, or modified.)
> >
> > The problems are happening during calls to fact-slot-value. It's easy
> > enough to fix this: don't do that, ever. There is never a reason to
> > call fact-slot-value on the left hand side of a rule -- you've already
> > got ahold of a fact (or if you don't, you can get it) and so you can
> > match the slots directly. Your problem is that you're calling fact-id
> > to get ahold of some nonexistent fact, then passing that nonexistent
> > fact's id (-1) to fact-slot-value, which is reporting that, indeed,
> > there's no such fact.
> >
> > As an aside, the fact-id function is virtually never needed: it turns
> > a real integer into a Fact by doing a slow lookup. It's useful when
> > debugging from the command line, but there's never a need to use it
> > during normal Jess coding (although you might use it to restore links
> > when loading interconnected facts in from a flat file of some kind.)
> > If you're actually got a number and need a jess.Fact object, then use
> > it. But if you're got a fact binding, then it's already a jess.Fact
> > object.
> >
> > I untangled your code extract into this, which *really* doesn't belong
> > on the LHS of a rule. Apparently this is part of a deffunction that
> > you're calling from a test CE -- i.e., from the LHS of a rule.
> >
> > (if (or (eq (fact-slot-value (fact-id ?fact) template) imple-method)
> >(eq (fact-slot-value (fact-id ?fact) template) global-method))
> > then
> >(return ?fact)
> > 

Re: JESS: JessDE Feature Request

2005-08-29 Thread ejfried
I think Alan Moore wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Ernest,
> 
> I've been using JessDE recently and found myself spending a considerable 
> amount of time checking to make sure my variables were bound and used in 
> the right places in the patterns. It seems to me that having a simple 
> way to verify/highlight the bindings visually would help in this regard.
> 

Sorry for the delay -- I've been on vacation for a week.

Your color-coding ideas are interesting but I think it's probably
better to do things according to precedent.  Wouldn't the "Eclipse
way" be to have you Alt-click on a variable name and be sent to the
definition? So you'd Alt-click on a variable and the cursor would move
to the place where it was first bound.


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




Re: JESS: Problem calling java methods from Jess with Object parameters

2005-08-30 Thread ejfried
I think Richard, Kevin R. wrote:

>   ;; Jess complains about not finding the constructor
>   (bind ?thickness_throw (new MyObject elem "PDF_ATR_MARKING_LINE_CURVE"))
> 
> The rule above attempts to generate a new object using the object that I
> retrieved from the fact as an argument to its constructor.  However,
> Jess can't find the constructor.

In the constructor call, that ought to be the variable "?elem", not
the symbol "elem", right?  If this is just a typo in your email, as
opposed to the rule itself, then can you show me the declaration of
the constructor you're trying to call, and also let me know what
version of Jess you're using?


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




Re: JESS: Problem calling java methods from Jess with Object parameters

2005-08-30 Thread ejfried
I think Richard, Kevin R. wrote:
> Yup, my mistake; the first argument should be '?elem'.  Here is the
> constructor:
> 
>   public void MyObject(MyObject parent, String type)

That's not a constructor -- it's a method returning void whose name
just happens to be the same as the class. You couldn't construct an
object with this from Java code, either. Remove that "void" and you
should be OK.

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




Re: JESS: Changing the value of Defglobal variables

2005-08-30 Thread ejfried
I think Richard, Kevin R. wrote:
> I'm planning on using a defglobal variable to reflect the state of a
> checkbox in the UI for my application.  The value of this variable,
> therefore will be set and modified in Java.  Looking at the Jess API, I
> don't see any means of changing the value of a Defglobal object once it
> has been set.  The value of this variable will influence many of the
> rules that I'll be running.  Am I missing something in the interface and
> is this the proper way to handle this type of construct?  

To set the value of a defglobal ?*g* to 1 from Java, you can say

  Rete engine = ...;
  engine.getGlobalContext().setVariable("*g*", new Value(1, RU.INTEGER));

But note that your proposed architecture probably won't work the way
you expect. From the manual:

  "If you match to a defglobal with a pattern like (foo ?*x*), the
  match will only consider the value of the defglobal when the fact is
  asserted. Subsequent changes to the defglobal's value will not
  invalidate the match - i.e., the match does not reflect the current
  value of the defglobal, but only the value at the time the matching
  fact was asserted.

Therefore, what you probably want to do instead is have a fact that
represents the state of the checkbox. Assert it from Java and store a
reference to the jess.Fact object someplace, then use Rete.modify() to
change it as needed in the event handler for the checkbox.



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




Re: JESS: Modifying JavaBeans

2005-08-31 Thread ejfried
Hi Scott, 

Rules only fire during a call to run(). Your call to run() returns
immediately because when you call it, there are no rules eligible to
fire yet. Then you make some changes to the fact, and the
PropertyChangeEvents update the working memory, but you never call
run() again, so even when it is activated, the rule never fires.

You could call run() in your for loop, and then the rule would fire
and update the slot as expected. Note that it makes sense for this
rule to fire only once -- no reason to fire once the qualRng slot is
TRUE, so you might write the pattern like this:


 (defrule dummy-range-doctrine
 ;; set qualRng to true if trk is in range
 ?fact <- (testTrkClass (range ?x&:(<= ?x 20)) (qualRng ~TRUE))
 =>
 (modify ?fact (qualRng TRUE)))


I think Krasnigor, Scott L (N-AST) wrote:
> Sorry to bother everyone. I am trying to play around with JESS embedded
> in Java to get an understanding of JESS. I created a simple Java bean
> which contains two properties: range and qualRng. I create the fact
> within Jess utilizing defclass and definstance. Executing engine.facts()
> shows that the fact has been created in Jess's memory with the
> appropriate slots. I created a simple rule to check to see if range is
> below 20, if true, modify the qualRng slot to TRUE. I added code to
> main() decrement the initial value of range in order to fire the rule.
> Watching the results shows that the range slot decrements properly and
> the rule fires, but the qualRng field never gets updated to show TRUE. I
> am sure it is something simple, but I just don't see the problem. I've
> modified the RHS of the rule with all the different iterations I could
> think of but to no avail. The code is listed below (minus the java bean
> class). Thanks for your assistance.
> 
> import jess.*;
> 
> public class testFacts 
> {
>   public static void main(String[] args) 
>   {
>   Value fact;
>   try
>   {
>   Rete engine = new Rete();
>   engine.watchAll();
> 
>   engine.defclass("testTrkClass", "testTrack",
> null);
>   testTrack trkOne = new testTrack(30, 45, 5);
>   fact = engine.definstance("testTrkClass",
> trkOne, true);
>   
>   // Load rules clip file
>   engine.executeCommand("(batch testTrk.clp)");
>   engine.run();
>   
>   // change range until it triggers a dummy doct
> rule
> 
>   int i;
>   for(i = trkOne.getRange(); i > 5; i--)
>   {
>   trkOne.setRange(i);
>   try 
>   {
>   Thread.sleep(500);
>   }
>   catch (InterruptedException ie){}
>   }
>   }
>   catch (JessException je)
>   {
>   System.out.print("An error occurred at line " +
> je.getLineNumber());
>   System.out.println(" which looks like " +
> je.getProgramText());
>   System.out.println("Message: " +
> je.getMessage());
>   }
>   }
> 
> }
> 
> The clp file:
> 
> (defrule dummy-range-doctrine
> ;; set qualRng to true if trk is in range
> ?fact <- (testTrkClass (range ?x&:(<= ?x 20)))
> =>
> (modify ?fact (qualRng TRUE)))
> 
> 
> 
> Scott L. Krasnigor
> Principal Engineer/Scientist
> Atlantic Science & Technology
> Lockheed Martin - MS2
> ' 856-359-3094
> * [EMAIL PROTECTED]
> * 770-2
> 



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




Re: JESS: Rule firing twice

2005-09-01 Thread ejfried
I think Nicolas Fortin wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Hi everybody,
> 
> I have a rule which fires twice and I just can't see why. So any hint would 
> be appreciated.

The details suggest to me that there are two Controller facts. Are you
sure there's only one?



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




Re: JESS: Rule firing twice

2005-09-01 Thread ejfried
I went back and looked over your first message and this time paid
attention to the deffunction canBeginProcessing. Holy corrupted data
structures, Batman! You can't modify a fact on the *left* side of a
rule! The Rete network is *not* re-entrant, which is why it's
carefully protected against interference from other threads. But that
protection doesn't help if a predicate function changes the object
it's working on, sending a PropertyChangeEvent which modifies the fact
that's being pattern-matched!

This is something like writing a Java equals() method that changes the
object and its hashCode() when you call it. Try to store such an
object in a HashMap!

Change canBeginProcessing to be a pure predicate function; call
setProcessedEntity (and beginProcessing) on the *right* side of the
rule, after you've made this decision.


(deffunction canBeginProcessing(?station)
 (if (and (neq ?station nil)) then
 ;; Get the entity that can be processed.
 (bind ?entity (call ?station beginProcessing))
 ;; Assign the entity to the current station.
 (call ?station setProcessedEntity ?entity)
 ;; Return true if there is an entity.
 (return (neq ?entity nil))
 else
 (return FALSE)))


I think Nicolas Fortin wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Dr. Friedman-Hill,
> 
> I've been curious and I've had another idea. Just before to call the 
> Rete.run() method in my Java program, I have checked the agenda activations. 
> It has strengthened my doubt about something wrong, since for the 
> troublesome rule (process-entity), there are two activations with the same 
> facts :
> 
> PROCESS:
> [Activation: PROCESS::process-entity  f-15, f-42 ; time=45 ; salience=0]
> [Activation: PROCESS::process-entity  f-15, f-42 ; time=45 ; salience=0]
> STATUS:
> For a total of 7 activations in all modules.
> 
> Is it really abnormal ?
> 
> Thanks in advance,
> 
> Nicolas 
> 
> 
> 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]
> 
> 



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




Re: JESS: Rule firing twice

2005-09-02 Thread ejfried
I think Locksley Woo, CLSA wrote:
> On a related subject, if I have a multi-threaded program in which one thread
> modifies facts in real time according to some external events and another
> thread call run() on the engine periodically, do I have to synchronize the
> two threads so that no facts are modified when the engine is inside run()?


No, no worries. Jess takes care of this for you. 


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




Re: JESS: JessML and non-ruleset statements/funcalls

2005-09-08 Thread ejfried
I think Alan Moore wrote:
> > 
> > I guess I don't want JessML to support more than it needs to, unless
> > there are some good reasons why it should. But I'm listening!
> 
> My immediate interest in JessML is as a target for Jess code generation 
> by a tool. 

I received several other responses off-list saying basically the same
thing, and expressing interest in JessML as a complete programming
language. There are really no major barriers to this, so it sounds
like that's the direction we should go. I'm still not sure how things
are going to pan out vis-a-vis XSLT scripts to translate between
JessML and other rule languages; maybe the XMLPrinter has an option to
translate rules only, or maybe it could emit warnings when emitting
nonportable constructs -- or maybe someone has some other thoughts?



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




Re: JESS: Comparing string

2005-09-09 Thread ejfried
Jess doesn't have an explicit else-if feature; if you put an "if" into
the "else" of another "if", then that second "if" is a separate
function call, so it needs its own parentheses. 

If I may, I will point out a few other things here: You don't need to
spell out the names of any classes in java.lang, as it's implicitly
imported, just as in Java. Second, you don't actually need to
construct Strings at all; you can call Java String methods on Jess
strings. Third, you can (and should) always omit "call" when calling a
Java instance method; it's really only needed when you're invoking a
static method. So you could clean your function up like this:

(deffunction compare-comptment-function(?s1 ?s2)
  (if (eq ?s1 ?s2) then
(return "FFF")
else (if (?s1 contains ?s2) then
  (printout t "COMES 1" crlf)
  (return ?s1)
  else (if (?s2 contains ?s1) then
(printout t "COMES 2" crlf)
(return ?s2)
else
  (printout t "COMES 3" crlf)
  (return (str-cat ?s1 , ?s2))  

I think Amit Jain wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Hi all 
> I'm trying to compare two strings
> 
> (deffunction compare-comptment-function(?s1 ?s2)
> (bind ?str-buff1 (new java.lang.String ?s1))
> (bind ?str-buff2 (new java.lang.String ?s2))
> (if (eq ?s1 ?s2) then
> (return "FFF")
> else if (call ?str-buff1 contains ?str-buff2) then
> (printout t "COMES 1" crlf)
> (return ?s1)
> else if (call ?str-buff2 contains ?str-buff1) then
> (printout t "COMES 2" crlf)
> (return ?s2)
> else
> (printout t "COMES 3" crlf)
> (return (str-cat ?s1 , ?s2
> 
> SO when i call (compare-comptment-function "CSEE" "CS") it should return 
> "COMES 1" "CSEE"
> 
> (compare-comptment-function "CSE" "CSEEE") it should return "COMES 2" 
> "CSEEE"
> and (compare-comptment-function "AE" "CSE") it should return "COMES 3" 
> "AE,CSE" 
> 
> but it keeps going into first elseif loop in all the cases. please tell me 
> what i'm doing wrong. thanks for the help.
> -amit



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




Re: JESS: Pattern Binding for CE

2005-09-09 Thread ejfried
I think Krasnigor, Scott L (N-AST) wrote:

> I have an ID slot defined for the Bean object used to define the facts
> but can't seem to figure out how to get the fact that triggered the rule
> so I can modify it for this particular case (all my other rules allow
> pattern binding). 

I formatted your rule to make it easier to understand.

(defrule doctrine-untripped
;; sets qualDoctrine to FALSE if any check flags are FALSE
?docFact <- (or
(and (testTrkClass (qualRng FALSE))
 (testTrkClass (qualDoctrine ~FALSE)))

(and (testTrkClass (qualBrg FALSE))
 (testTrkClass (qualDoctrine ~FALSE
=>
(modify  ?docFact (qualDoctrine FALSE)))

So the "or" has two branches, each of which is an "and". Those "and"s,
in turn, each match two facts (the two could, in fact, be the same
one, or they could be different.)

Based on your comment, and on your problem description, my guess is
that you didn't realize that, and you intend the "and" to simply group
together multiple tests on the same fact. It doesn't work that way:
you should write all the tests for a single fact in a single pattern,
or else the rule can match bits and pieces from multiple facts. So
really I think you mean

(defrule doctrine-untripped
;; sets qualDoctrine to FALSE if any check flags are FALSE
?docFact <- (or
(testTrkClass (qualRng FALSE) (qualDoctrine ~FALSE))
(testTrkClass (qualBrg FALSE) (qualDoctrine ~FALSE))
=>
(modify  ?docFact (qualDoctrine FALSE)))

Because each branch of the "or" matches a single branch, the pattern
binding is OK.



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




Re: JESS: Problem with "not CE"

2005-09-14 Thread ejfried
Yuri,

Interesting problem. As soon as I track it down, I'll let you know
what's going on. Thanks for the report!

I think Yura wrote:
[Charset koi8-r unsupported, filtering to ASCII...]
> Hi everyone
> 
> I've got some strange problem with Jess engine. A simple code below 
> illustrates it. The code iteratevily forms a sorted list. It does this quite 
> well when the number of entities is small enough (<=10). But as it increases 
> Jess engine failes to find matches (I've tried 7.0b2).
> 
> (clear)
> 
> (deftemplate entity (slot id))
> 
> (deftemplate value (slot id) (slot val))
> 
> (deftemplate group (multislot ids))
> 
> (defrule form-sorted-group
>   (entity (id ?id))
>   (value (id ?id) (val ?val))
> 
>   ?fact <- (group (ids $?ids&:(not (member$ ?id $?ids
> 
>   (not
> (and
>   (entity (id ?id2&~?id&:(not (member$ ?id2 $?ids
>   (value
> (id ?id2)
> (val ?val2&:(< ?val2 ?val))
>   )
> )
>   )
>  =>
>   (modify ?fact (ids (create$ $?ids ?id)))
> )
> 
> (reset)
> 
> (assert (group (ids (create$
> (for (bind ?id 0) (< ?id 10) (++ ?id) ;this one works
> ;(for (bind ?id 0) (< ?id 11) (++ ?id) ;this one fails
>   (assert
> (entity (id ?id))
> (value (id ?id) (val ?id))
>   )
> )
> 
> Using sematically equivalent "forall" instead of "not CE":
>  
> (forall
>   (entity
> (id ?id2&~?id&:(not (member$ ?id2 $?ids)))
>   )
>   (value
> (id ?id2)
> (val ?val2&:(>= ?val2 ?val))
>   )
> )
> 
> gives the same result.
> 
> Yuri Gribov
> 
> 



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




Re: JESS: Problem with "not CE"

2005-09-14 Thread ejfried
I think Yura wrote:
[Charset koi8-r unsupported, filtering to ASCII...]
> Hi everyone
> 
> I've got some strange problem with Jess engine. A simple code below 
> illustrates it. The code iteratevily forms a sorted list. It does this quite 
> well when the number of entities is small enough (<=10). But as it increases 
> Jess engine failes to find matches (I've tried 7.0b2).


We've found and fixed the bug. It affected all Jess 7 alpha and beta
versions, but not Jess 6.1 or earlier. The patch will be in the 7.0b3
release -- tomorrow!


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




Re: JESS: How to write constraint for shadow fact list/set properties ?

2005-09-14 Thread ejfried
I think robert fields wrote:
> 
> Classes are loaded from java by
> 
> Jesp j = new Jesp(new StringReader("(defclass {Role,
> ...} package.{Role,})"), aEngine);
> j.parse(false);
> 

The Rete class has a "defclass" method which would be much more
convenient to use! Barring that, it also has an "executeCommand"
method that takes a String of Jess code and runs it -- basically the
equivalent of the above, only shorter and faster.

> 
> I have no problem in writing constraints with simple
> attributes. It is List/Set/Array properties I am
> having trouble with.


Jess has no special way of treating Collections; the only thing you
need to do is call the collection's methods. For example, if a class Foo
has a property aSet which is (predictable enough) a Set, and you want
to match a Foo object if aSet contains "bar", then you might write a
pattern like this:

  (Foo (aSet ?s&:(?s contains "bar")))

Jess *does* treat arrays specially; arrays are mapped to Jess
lists. You can use "multifield variables" to match sections of
lists. As it turns out, this is quite badly documented in the current
manual, although that should be remedied soon. In the meantime, you
can look at the section on multifields on page 103 of the book "Jess
in Action", or look at how they're used in the "stack.clp" example in
the Jess distribution.


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




JESS: Announcing Jess 7.0b3

2005-09-15 Thread ejfried
Hi Folks, 

The 7.0b3 release of Jess, the rule engine for the Java platform, is
available for download at

http://www.jessrules.com/jess/download.shtml

The final release of Jess 7 is drawing near. Most of the changes in
this release are ease of use features and bug fixes. Work still
remains to be done, but the end is in sight. As we approach the 7.0
milestone, comments and suggestions are especially encouraged.

>From the change log:

   Continued work on manual and javadocs. JSR94 driver
   available in demo jar. (help) gives help on constructs
   and is generally more helpful. list-functions$ doesn't
   list static imports. Deprecate the term "external
   address" in favor of "Java object", and deprecate all
   names based on this term. Add the "auto" qualifier for
   definstance, and change the default behavior to
   "auto". Swing versions of Canvas,
   TextAreaWriter. Debugger handles spaces in path
   names. Reverse ill-considered "optimization" in NodeNot2
   (thanks Yuri Gribov).

As always, comments and questions are welcome at
jess-users@sandia.gov, or directly to me at [EMAIL PROTECTED] 

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




Re: JESS: Facts and modules

2005-09-30 Thread ejfried
I think Henrique Lopes Cardoso wrote:
> 
> In the Jess documentation (more specifically in "The Jess Language" 
> section) the following is written:
> +If you don't specify a module, all deffacts, templates and rules 
> you define will automatically become part of the current module;
...
> 
> Are all these results ok, is there a bug in Jess, or am I missing something?

You're trying to make something very simple into something very
complicated. You *do* have to understand a few things, first, but all
of these things are documented:

1) When you assert a fact, Jess first looks for an existing
defftemplate it can use (we'll talk about this searching below, in
point #2.)  If Jess finds no matching template, then if the fact
appears to be an ordered fact -- i.e., no slots are given -- then Jess
will automatically create an appropriate deftemplate (we'll also say
more about this in a moment in point #3). If it's an unordered fact --
one with slots -- and there's no matching template, then that's an
error.

2) When looking for a deftemplate, whether it's parsing a rule or an
assert function call, Jess always looks in the current module
first. If the template isn't in the current module, MAIN is
searched. If the template isn't in MAIN, then the search fails.

3) When creating a template, Jess will always create it in the current
module -- unless, of course, its name explicitly contains a module name.

That's it. Using these three points, you should be able to explain all
of your observations. Generally, the rules are designed to make MAIN
into a "global template space"; templates defined in MAIN can be
easily used from any other module without writing "MAIN::" all the
time. Templates defined in modules beside MAIN have to be explicitly
qualified by the module names to be used outside of the module they're
defined in.

Note that the quote you give above is from section 2.10.1 of the Jess
6 manual; section 2.10.2 contains much of the additional information
I've shown here.







-
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




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




Re: JESS: Facts and modules

2005-09-30 Thread ejfried
I think Henrique Lopes Cardoso wrote:
> 
> So, if I understood correctly, facts can only be asserted in the module 
> where their templates are defined 

Yes.

> 
> Therefore, if I have a template defined in MAIN, I cannot create a fact 
> based on that template in another module.

Right.

> Another observation: using a module name at a deftemplate definition 
> (e.g. (deftemplate m::the-facts ...)), if that module is the current 
> module, is irrelevant.

Redundant, yes. The effect will be the same without it.

A fact and a template are related in exactly the same way that a Java
object and a Java class are related. In this scheme, a module is like
a Java package. Every object must belong to a class; every class must
be in some package. Every fact must belong to a template; every
template must be in some module. So facts don't belong to modules any
more than Java objects belong to packages, right? You can't "create a
java.lang.String in the java.util package;" it just doesn't make
sense, in the same way that you can't "create an X::foo fact in the Y
module." You can use Strings in code in the java.util package, or you
can use X::foo facts in a rule in the Y module.


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




Re: JESS: Matching a static variable

2005-10-03 Thread ejfried

Hi Erich,

First, let me mention that I'm happy to see someone using the
brand-new "static imports" feature -- the thing that lets you use
(CarClass.MINI) as a constant.

Second, your code looks fine except that the defclass defines a short
template tag RentalCarReservation, but the rules are using the long
com form; I'll assume this is a transcription error, because the
rules won't compile unless you're consistent here.

Third, let me mention, as I often do on this list (I really need to
make this point more strongly in the manual) that direct matching
should always be preferred to function calls, and anything else should
be preferred to the "test" CE; this is not only a style issue but a
performance issue. Although your rules are both correct, it's better
style and will perform better to write them as

(defrule car_class_is_compact

(RentalCarReservation (carClass ~=(CarClass.COMPACT)))
=>
(printout t "Car Class is not COMPACT" crlf)
)

(defrule one_hundred_miles

(RentalCarReservation (freeMiles 100))
=>
(printout t "100 free miles" crlf)
)

Finally, I can't say for sure what the problem is, but I'll guess
(since you've mentioned equals()) that you've written a class whose
hashCode() is not consistent with its equals() method (perhaps simply
by  not overriding hashCode().) Jess is rather sensitive to this
error, as are many of the java.util container classes.

I think erich.oliphant wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> 
> 
> Hi I am a new jess user and I'm running into a problem trying to match an java
> object value in a rule.  Here are 2 rules and their setup, the first is the
> one with the problem.  The other I added to verify that it would match on a
> primitive type and it seems to work fine:
> (import CarClass)
> 
> (defclass RentalCarReservation 
>  RentalCarReservation nil)
> (bind ?tmpRentalCarRes (new RentalCarReservation))
> (definstance  RentalCarReservation 
> ?tmpRentalCarRes
> static)
> (call ?tmpRentalCarRes setCarClass (CarClass.MINI))
> (call ?tmpRentalCarRes setFreeMiles 100)
> (reset)
> 
> (facts)
> 
> 
> (defrule car_class_is_compact
> 
> (com.ngc.dts.domain.reservation.car.RentalCarReservation (carClass ?x))
> (test (neq ?x (CarClass.COMPACT)))
> =>
> (printout t "Car Class is not COMPACT" crlf)
> )
> 
> (defrule one_hundred_miles
> 
> (com.ngc.dts.domain.reservation.car.RentalCarReservation (freeMiles ?x))
> (test (eq ?x 100))
> =>
> (printout t "100 free miles" crlf)
> )
> 
> --
> 
> CarClass is an enum type i.e.:
> 
> class CarClass
> {
> ...
>static public MINI = new CarClass("MINI");
> ...
> }
> 
> --
> 
> equals() has been overridden in CarClass as well.  The one_hundred_miles rule
> works fine so I know there's a specific problem using the object.  Any help
> would be greatly appreciated.
> 
> 
> 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]
> 
> 



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




Re: JESS: JessML ParseException

2005-10-03 Thread ejfried
I think Wong Dong wrote:
> Our team is developing a rule-based system, and we worked out a clp 
> version. After converting the clp rules into JessML format using XMLPrinter, 
> we found there was an exception when we used "batch" command to execute the 
> JessML rules.

Anytime the parser can't parse something the XMLPrinter wrote, that's a
bug. I'd appreciate it if you could send me a .clp file that triggers
this error, so I can fix the problem.



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




Re: JESS: Matching a static variable

2005-10-03 Thread ejfried
I think Alan Moore wrote:
> 
> > Third, let me mention, as I often do on this list (I really need to
> > make this point more strongly in the manual) that direct matching
> > should always be preferred to function calls, and anything else should
> > be preferred to the "test" CE; this is not only a style issue but a
> > performance issue.
> 
> [alan]
> I'm probably missing something here but isn't this the kind of thing the 
> Jess parser could (eventually) optimize out? Given a test CE with only 
> one variable it seems like Jess could automatically move the conditional 
> up into the pattern the variable is bound in.

Yes, Jess could do this for some patterns. One of these days, it
will. Actually, Jess could also optimize "eq" calls to direct
matching in some cases, too. Since I personally think the optimized
form looks better anyway, though, this hasn't been a high priority --
I'd rather get people to write the code the faster way initially.


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




Re: JESS: Rules Management

2005-10-04 Thread ejfried
I think Brian Corbin wrote:

> How do you manage your rules?  Do you bundle the rule sets with the
> application?  Are they stored in a database that the application
> references?  Maybe even using an interface to CVS or Subversion?

Since nobody has answered yet, I'll tell you some of the ways I've
heard of that people have managed rules with Jess. Obviously a single
fixed file is one way. In an app server, this might mean a redeploy,
but if you get the file from a file server at a known location or from
a URL, then you could avoid that.

But I've also seen people putting rules into a database (generally a
single table with rule-name and rule-text, then another table with
rule-name and rule-attribute; this lets you use JDBC to look up all
the rules with a certain attribute.) Because Jess makes Java
integration very easy, you can do this with a few lines of JDBC code
in Java, or the same few lines in Jess. A turnkey version of this will
probably be added to Jess 7 in an early patch, but it really is very
simple to roll your own.

I haven't seen people use CVS, but I have seen a directory full of
tiny rule files and code to load in these specific "mini-modules" as
needed. Again, this is fairly simple to do. Given that, you could
easily use a VCS of your choice to publish rules for the rule engine
to use.

Because Jess 7 natively supports an XML rule language, you could use
any sort of XML data service, as well.

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




Re: JESS: Jess DE & JSR-94

2005-10-05 Thread ejfried
I think erich.oliphant wrote:
> Hi,
> We are using the JSR-94 interface but would like to use JessDE for
> debugging,etc.  Will jessDE support the XML formatted files required by the
> JSR-94 interface ?

There are two JSR94 drivers. There's the reference implementation that
comes with the JSR94 package from Sun. It only supports a weird XML
rule format in which Jess language code is "wrapped" with XML
tags. This driver works with Jess 6 and I do not encourage anyone to
use it. It was just a proof-of-concept.

There also the new JSR94 driver that is packaged with recent versions
of Jess 7. It supports JessML *and* Jess language code. In fact, the
example given in the manual show it being used with Jess language
code, not JessML. If you're using the JessDE, then you'll need to use
this new Jess 7 driver.

So tell me where you got the idea that JessML was required if you were
using javax.rules? I'd like to change it if I can to make it clear
that it's not.

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




Re: JESS: Problem with definstance

2005-10-05 Thread ejfried
I think David Firmin wrote:

> I'm trying to create shadow facts that subclass a deftemplate that's
> already been added to the Rete. When I try and add the java bean using
> definstance I get a ClassCastException as follows:
> 
> java.lang.ClassCastException
>   at jess.DefinstanceList.createNewShadowFact(DefinstanceList.java:206)
>   at jess.DefinstanceList.definstance(DefinstanceList.java:275)

Jess is assuming that the given class "looks like" a subclass of the
deftemplate -- i.e., if the template has slots foo and bar, then the
class had better have getFoo() and getBar() methods. It can have
additional properties as well, of course, as befits a subclass.

In any case, this is a lousy error message -- Jess should explicitly
detect and report this problem.


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




Re: JESS: Problem with definstance

2005-10-05 Thread ejfried
I think David Firmin wrote:
> 
> Hi,
> Thanks for this, although I'm still missing something I think.
> 
> The Order class I'm trying to define as an instance does have accessors and
> modifiers for all its properties, including the two defined on the
> superclass deftemplate that's already been created in the Rete.

To clarify, yes or no: does the template define any slots that
*don't* correspond to properties in the Order class?


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




Re: JESS: Firing on subsets (again)

2005-10-05 Thread ejfried
I think Jerome Butchergreen wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Thanks again Alan and I understand what your saying,
> but the fields where the blank values will be unknown.

You need to think clearlt about what you're trying to accomplish. I
think on reflection you'll realize that you've got some logical
loopholes. Here is the rule you're trying to write:

(defrule run-service
   ?inputservice <- (inputservice ?service ?project
  ?org ?analystname ?analystrole
  ?priority ?reldatetime ?location)
   ?newserv <- (webservice (service ?service) (project ?project)
   (org ?org) (analystname ?analystname)
   (analystrole ?analystrole) (priority ?priority)
   (reldatetime ?reldatetime) (location ?location)
   (action run) )
  =>
  (store RETURN "run")
  (printout t "JESS: Found an existing service = " ?service crlf)

Now, what this rule says is that if there are an inputservice fact and
a webservice fact, and all of the data in the ordered inputservice
fact matches the contents of the webservice fact exactly, then the
rule should fire.

What you're saying is that maybe the inputservice fact will contain
some nil values, and you want the rule to still fire. First, consider
the corner case: what if all the values in inputservice are nil?
Should the rule match? I suspect not.

Now, what if "service" is nil, but all the others match. Should the
rule fire? I suspect not, although I don't know for sure. So there are
some fields that *must* match, and some that don't need to. If they
don't need to, why check them at all? Why not just check the ones that
must match? Why not write, for example, 

(defrule run-service
   ?inputservice <- (inputservice ?service ?project ?org ? ? ? ? ?)
   ?newserv <- (webservice (service ?service) (project ?project)
   (org ?org) (action run))
  =>
  (store RETURN "run")
  (printout t "JESS: Found an existing service = " ?service crlf)

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




Re: JESS: Central data storage for multiople Jess instances

2005-10-05 Thread ejfried
I think Bogdan Werth wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Hello everybody,
> I working on the model from the field of social simulation. I am
using RePast and Jess to make my agents think in a declarative way. At
the moment I have a separate Jess instance for every agent (300 agents
= 300 Rete instances).

Don't do that. Just use one Jess instance. Facts that are specific to
one agent should include an agent-specific identifier, and rules that
operate on these facts should take care to match them as needed to
keep the various agent's logical processes separate.


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




Re: JESS: Central data storage for multiople Jess instances

2005-10-06 Thread ejfried
I think Bogdan Werth wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Great thanks for the quick answer.
> Your advise led me another idea/question. You say it should be realized with 
> agent-specific identifiers and rules that distinguish these identifiers. In 
> your book Jess In Action you describe modules as a kind of namespace for 
> templates and rules. I was just wondering whether it wouldn't be the easiest 
> solution to use the same rules and facts as I use now and just to separate 
> them in module - each agent will have his rules and facts stored in his "own" 
> modules? This way I would be able to use old code and same rules for all 
> agents. The other question is the performance. I don't know how Jess will 
> cope with several hundreds (maybe thousand) of modules.
> 

That's really not what modules are for: they're for separating groups
of distinct rules into processing phases, not for partitioning copies
of the same rules. 


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




Re: JESS: Firing on subsets (again)

2005-10-06 Thread ejfried

Again, I think you're not quite grasping what ? means. ? and ?x mean
exactly the same thing; the only difference is that ?x you can refer
to again, while ? is a value that exists but that you're going to
ignore. So the single patterns

(foo ?x ?y ?z)

and

(foo ? ? ?)

match exactly the same facts. 

Perhaps the problem is that you're trying to do with one rule
something that actually ought to be more. For example, In your
description below, I see something about the location field needing to
match, and the 'homework' field being irrelevant -- and by
implication, everything else is irrelevant, too, since you didn't
mention it. That's a rule. "If the location field matches, then do X."
You presumably have other rules in mind, too.


I think Jerome Butchergreen wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> This is very true, but the only field that *must*
> match is the service. Clearly Im not just throwing out
> a text area and letting the user go crazy, there are
> certain conditions that must be met long before any
> interaction with the rule engine. At this time the
> only logical flaw that Im considering is that when
> fields are left blank the rule may fire multiple
> times, but I believe Ill simply have the results added
> to a vector and handle that later. So the values of
> inputservice will be inserted by a Java function
> before the engine is run then those values will be
> compared to the working memory through the
> webservices pattern.
> 
> Perhaps a run through of just what exactly Im trying
> to do:
> We are developing a clipee-type service, when
> resources that may or may not be useful to a user
> become relevant they will be notified of it. Then
> given the opportunity to decide weather or not they
> wish to use the service at that time and in that
> situation ...also choose to have that action done in
> that situation in the future. So if one of these
> services is to display information about the author of
> a piece of data the user may want this to happen when
> the file is opened, regardless of the project or
> location of that project. In this situation the
> context included with the service 'getauthorinfo'
> would simply be to run it and the remaining fields
> would be left blank. Oppositely, if the service in
> question is to contact with the author (somehow Im
> trying to make a convincing argument here) then the
> location would also be filled in, as chatting with
> someone in China would need a little planning and
> financial consideration.
> So again we would have to return to a rule that looked
> like this:
> (inputservice ?service ? ?? ? ? ? ?)
> 
> And would fire every time and for every entry
> pertaining to ?service. So what Im trying to express
> is that the fields are important just not in every
> situation.
> In plain English I want an entry set to run the
> service in DC, to still fire when I also include the
> fact that I am doing homework. Yet this service
> shouldnt fire unless I am in DC.
> 
> Im very sorry about how vague or inaccurate I have
> been on this whole subject but this is still my first
> year at this whole computer science, research
> assistant ...thing.
> -Jerome BG
> 
> 
> --- [EMAIL PROTECTED] wrote:
> 
> > I think Jerome Butchergreen wrote:
> > [Charset iso-8859-1 unsupported, filtering to
> > ASCII...]
> > > Thanks again Alan and I understand what your
> > saying,
> > > but the fields where the blank values will be
> > unknown.
> > 
> > You need to think clearlt about what you're trying
> > to accomplish. I
> > think on reflection you'll realize that you've got
> > some logical
> > loopholes. Here is the rule you're trying to write:
> > 
> > (defrule run-service
> >?inputservice <- (inputservice ?service ?project
> >   ?org ?analystname
> > ?analystrole
> >   ?priority
> > ?reldatetime ?location)
> >?newserv <- (webservice (service ?service)
> > (project ?project)
> >(org ?org) (analystname
> > ?analystname)
> >(analystrole
> > ?analystrole) (priority ?priority)
> >(reldatetime
> > ?reldatetime) (location ?location)
> >(action run) )
> >   =>
> >   (store RETURN "run")
> >   (printout t "JESS: Found an existing service = "
> > ?service crlf)
> > 
> > Now, what this rule says is that if there are an
> > inputservice fact and
> > a webservice fact, and all of the data in the
> > ordered inputservice
> > fact matches the contents of the webservice fact
> > exactly, then the
> > rule should fire.
> > 
> > What you're saying is that maybe the inputservice
> > fact will contain
> > some nil values, and you want the rule to still
> > fire. First, consider
> > the corner case: what if all the values in
> > inputservice are nil?
> > Should the rule match? I suspect not.
> > 
> > Now, what if "service" is nil, but all the others
> > match. Should t

Re: JESS: Problems with Jess and Eclipse

2005-10-07 Thread ejfried

In the screenshot, you show that you've defined two "classpath
variables", one named source pointing to the "source" directory, and
one named "jess" pointing to jess.jar. This is no guarantee that
you've *used* those classpath variables for anything. This is like
defining a Windows environment variable named MY_JARS and expecting
them to automatically show up on the CLASSPATH: it won't happen, of
course, unless your CLASSPATH includes %MY_JARS% .

Anyway, what's really relevant is not these global preferences, but the
individual project properties. Right-click on your project and choose
"Properties." Click "Java Build Path". On the Source tab, you want to
have any source folders in your project. This would be a place you
could use your "source" variable, although this would actually be
somewhat unconventional. Eclipse should automatically put entries for
the actual source folders in your project, so your project may not be
set up properly as a Java project in the first place.



I think Matthew Hutchinson wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> G'day everyone,
> 
> First of all I'd like to say I'm starting to get into the programming aspect
> of my PhD and its really interesting to learn JESS; great product and great
> support.
> Having set up eclipse with the jess plugin, I was dissapointed to find
> something was not working. I've set my windows classpath to match where my
> code is, and even set the project class path (in eclipse) to the same
> directory. For some reason it just keeps telling me that it can't find the
> "Address" class... which is quite obviously there.
> 
> Perhaps I've just missed something obvious?
> 
> Thanks,
> Matt
> 



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




Re: JESS: Defining default rules

2005-10-07 Thread ejfried
You don't need to avoid salience at all costs; you should avoid
excessive use of it, and you should avoid trying to force all rules to
fire in some specified order using it.

The higher-priority rules need to make some change in working memory
that the lower-priority rules can detect. For example

(defrule default-rule
  ?a <- (a)
  (not (processed ?a))
  =>
  (default-action)
  (assert (processed ?a)))

(defrule special-rule
  (declare (salience 100))
  ?a <- (a)
  (not (processed ?a))
  =>
  (special-action)
  (assert (processed ?a)))

For each fact ?a, special-rule will fire, and default-rule won't.

I think Henrique Lopes Cardoso wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Hi,
> 
> I am trying to develop a Jess program that considers the use of default 
> rules.
> Here goes a simple example.
> 
> I have a rule in the MAIN module, but I want that rule to fire only if 
> no other rule fires.
> Since the Jess 6 manual discourages the use of salience definitions, I 
> am thinking on using modules.
> 
> That is, I have a module where I have some rules that are meant to fire 
> when a fact appears in MAIN. If no rule fires, then the default rule in 
> MAIN should fire.
> 
> Example:
> 
> (defrule default-rule (a) => (printout t "This is the default rule." crlf))
> 
> (defmodule m)
> (defrule m-rule (a) => (printout t "This is the rule in m." crlf))
> 
> (assert (a))
> (focus m)
> 
> (run)
> 
> Now, both rules fire: first the one inside module m and then the 
> default-rule in MAIN. If I do not want the default-rule to fire, must I 
> retract fact (a)?
> 
> (defrule m-rule
> ?x<- (a)
> =>
> (retract ?x) (printout t "This is the rule in m." crlf)
> )
> 
> What if I want to keep a history of all the facts?
> 
> Thanks.
> 
> Henrique
> 
> 
> 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]
> 
> 



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




Re: [JESS:Problem with Running the Jess T][ab without the Prot_g_ User Interface]

2005-10-08 Thread ejfried
I think Eunice Palmeira wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> I don't get to run my application in Eclipse, because the line under
> report the error:
> java.lang.NoClassDefFoundError:
> edu/stanford/smi/protege/model/Instance, but i get run direct in
> protege.
> 
> rete.executeCommand("(load-package JessTab.JessTabFunctions)");
> 
>  What's wrong?


You'll need to import all the Protege and JessTab jar files into
Eclipse and put them on the project's build path, so they're available
at runtime. This is more of an Eclipse question than a Jess question
-- if you need more details you should probably go to the Eclipse
documentation for help.




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




Re: JESS: Defining default rules

2005-10-08 Thread ejfried
I think Henrique Lopes Cardoso wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Thank you for the quick reply.
> But then again, I can avoid salience if I combine your approach with 
> module definitions.

There's really nothing that makes one "better" than the other. The
uses of salience and modules do overlap to some extent. Using modules
is often clearer, especially in larger systems.

> 
> Is this a bad idea?

No, using modules as "subroutines" is a fine thing to do.

> 
> Should I avoid this by using auto-focus? 

Auto-focus rules are sort of like threads or co-routines; they operate
autonomously. Manual focus is a lot like calling a subroutine. Bit
have their place.

By the way, can I apply the 
> auto-focus property to all rules inside a module at once, or must I 
> define this property in every rule inside a module?

There's no way to do this automatically for all the rules in a module,
no -- but it's a good idea.


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




Re: JESS: New to JESS

2005-10-10 Thread ejfried
I think nikita berdikov wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Hello, 
> I'm new to Eclipse and JESS, so can anyone tell me how
> to start working with JESS in Eclipse 3.1. What
> variables should i set? I did everything that is
> written in "Using the JessDE", but something is wrong.

What is wrong, exactly -- i.e., what did you do, what happened, and
what did you expect to happen instead? If you install it properly,
files named *.clp will be opened in the JessDE Editor; otherwise,
nothing much should be different.

> And please, show me an example of JESS code in
> Eclipse.

You can open any *.clp file in the JessDE editor; you can type in any
code in the manual, or open any *.clp files in the "examples" directory.

> 
> Thanks in advance.
> 
> 
>   
> __ 
> Yahoo! Music Unlimited 
> Access over 1 million songs. Try it free.
> http://music.yahoo.com/unlimited/
> 
> 
> 
> 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]
> 
> 



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




  1   2   3   >