JESS: [EXTERNAL] Docstrings in from-class deftemplates

2013-11-26 Thread Henrique Lopes Cardoso
Hi,

Is there a limitation on the use of documentation strings on deftemplates
using the from-class declaration?
I have something like:

(deftemplate Foo extends Bar
"Documentation string for Foo"
(declare (from-class Foo)) )

Whe accessing the docstring as per Deftemplate.getDocstring(), I am getting
something like "$JAVA-OBJECT$ Foo", instead of the documentation string
proper.

Am I missing something?

Thanks.

Henrique


Re: JESS: [EXTERNAL] Adding facts that are instances of from-class deftemplates

2013-05-21 Thread Henrique Lopes Cardoso
Got that, thanks a lot.

Henrique



On Thu, May 16, 2013 at 3:24 PM, Friedman-Hill, Ernest
wrote:

> The thing is that after this code:
>
>   (deftemplate Person (declare (from-class Person)))
>   (bind ?f (assert (Person (name "Henrique") (age 38
>
> There's no way to transfer those property values to a Person object; i.e.,
> if you then said
>
> (modify ?f (OBJECT (new Person)))
>
> Then the Person's name and age would NOT be "Henrique" and "38"; they'd be
> something else. The only way to get a shadow fact and a Java object synced
> up automatically is to let Jess copy the properties to the fact from the
> object.
>
>
>
>
>
>
> 
> To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
> in the BODY of a message to majord...@sandia.gov, NOT to the list
> (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
> ----
>
>


-- 

- - - - - -  -  -  -  -  -   -   -

Henrique Lopes Cardoso
DEI/FEUP
Rua Dr. Roberto Frias | 4200-465 Porto
PORTUGAL
 VoIP: (+351) 220413355
Phone: (+351) 225081400 ext.1315...@fe.up.pt | www.fe.up.pt/~hlc
- - - - - -  -  -  -  -  -   -   -


Re: JESS: [EXTERNAL] Adding facts that are instances of from-class deftemplates

2013-05-16 Thread Henrique Lopes Cardoso
Thanks for the dog analogy...

But going back to practical uses, one aspect that I like when creating a
fact directly from a from-class template (i.e., a doghouse without a dog --
I can still make some reasoning over the doghouse) is that the Jess code to
do it is much more readable and compact, since you provide values for named
slots.
Something like:


(deftemplate Person (declare (from-class Person)))
(assert (Person (name "Henrique") (age 38)))

When using definstance, I would have to go:
(bind ?p (new Person "Henrique" 38)); assuming there is such a
constructor
(definstance Person ?p)

or
(bind ?p (new Person))
(?p setName "Henrique")
(?p setAge 38)
(definstance Person ?p)

Now, when you have a class with many data members this becomes quite
complex.

Any comments? Thanks!

Henrique



On Fri, May 10, 2013 at 3:21 PM, Friedman-Hill, Ernest
wrote:

>  The **real** way to add shadow facts is using the “definstance”
> function. It has a number of options that aren’t available with “add”. The
> “add” function was added to Jess to support the simplified semantics of
> JSR-94 (the javax.rules API) but the intent is that most Jess users will
> use “definstance.”
>
> ** **
>
> Asserting a fact directly from a from-class template is like buying a
> doghouse; you don’t expect to go out the next morning and find that somehow
> it has a dog in it, right? It’s certainly something you can do, but in
> normal life it’s not very useful; usually you get a doghouse when you buy a
> dog, and “add” and “definstance” will both get you a doghouse for your Java
> object “dog” automatically.
>
> ** **
>
> *From:* owner-jess-us...@sandia.gov [mailto:owner-jess-us...@sandia.gov] *On
> Behalf Of *Henrique Lopes Cardoso
> *Sent:* Friday, May 10, 2013 4:54 AM
> *To:* jess-users
> *Subject:* JESS: [EXTERNAL] Adding facts that are instances of from-class
> deftemplates
>
> ** **
>
> Hi,
>
> ** **
>
> I am concerned with the at least two different ways in which you can add,
> to working memory, facts that are instances of from-class deftemplates.***
> *
>
> Lets say I have:
>
> ** **
>
> (deftemplate FC (declare (from-class FC)))
>
> ** **
>
> I can add a shadow fact like this:
>
> ** **
>
> (bind ?fc (new FC))
>
> (add ?fc)
>
> ** **
>
> This is the general approach described in Section 5.3.2 of the Jess manual.
> 
>
> But I can also simply go like:
>
> ** **
>
> (assert (FC))
>
> ** **
>
> I guess in this case I do not get a shadow fact, since the OBJECT slot is
> nil.
>
> ** **
>
> So, my question is: if my facts are not supposed to be changed from Java
> code, is there any difference in using each of these approaches?
>
> Section 5.3 from the Jess manual does not even mention that instances of
> from-class deftemplates can be created using the second approach above.***
> *
>
> ** **
>
> Thanks!
>
> ** **
>
> Henrique
>
> ** **
>



-- 

- - - - - -  -  -  -  -  -   -   -

Henrique Lopes Cardoso
DEI/FEUP
Rua Dr. Roberto Frias | 4200-465 Porto
PORTUGAL
 VoIP: (+351) 220413355
Phone: (+351) 225081400 ext.1315...@fe.up.pt | www.fe.up.pt/~hlc
- - - - - -  -  -  -  -  -   -   -


JESS: [EXTERNAL] Adding facts that are instances of from-class deftemplates

2013-05-10 Thread Henrique Lopes Cardoso
Hi,

I am concerned with the at least two different ways in which you can add,
to working memory, facts that are instances of from-class deftemplates.
Lets say I have:

(deftemplate FC (declare (from-class FC)))

I can add a shadow fact like this:

(bind ?fc (new FC))
(add ?fc)

This is the general approach described in Section 5.3.2 of the Jess manual.
But I can also simply go like:

(assert (FC))

I guess in this case I do not get a shadow fact, since the OBJECT slot is
nil.

So, my question is: if my facts are not supposed to be changed from Java
code, is there any difference in using each of these approaches?
Section 5.3 from the Jess manual does not even mention that instances of
from-class deftemplates can be created using the second approach above.

Thanks!

Henrique


JESS: [EXTERNAL] No cast needed when inspecting shadow facts' data members?

2013-05-10 Thread Henrique Lopes Cardoso
Hi,

I've just noticed an interesting behavior of Jess.
I was working with a couple of classes like this:

public class X {
Object obj;
// getter and setter for obj
...
}

public class Y {
int i;
// getter and setter for i
...
}

Then in Jess I wrote:

(deftemplate X (declare (from-class X)))
(deftemplate a (slot s))

(defrule r
(X (obj ?o))
(test (eq ((?o getClass) getSimpleName) "Y"))
(a (s ?o.i))
=>
(printout t ?o.i crlf))

(bind ?x (new X))
(bind ?y (new Y))
(?y setI 123)
(?x setObj ?y)
(add ?x)
(run)

This actually works! My surprise is related with the fact that the obj data
member is declared as an Object, and the _i_ data member only exists for
instances of Y. Despite this, the rule is able to get ?o.i in both the LHS
adn the RHS (no cast needed). Of course if I remove the test in the rule
and add to working memory an instance of X for which the obj is not an Y, I
get a runtime exception.

Is there anything I should know about the appropriateness of
implementations such as this? Best practices?

Thank you in advance.

Henrique


Re: JESS: Nested not conditional element with slots referring to facts

2010-09-07 Thread Henrique Lopes Cardoso
Yes, but of course I do not have such a rule in my application. Besides,
that "patch" will only apply to this case, not to the one originally
pointed out in thie mail thread...

If there is no way to prevent Jess from transforming rules, I guess I'll
have to wait until the bug is fixed...

Henrique


Ernest Friedman-Hill wrote:
> It's definitely a bug, and no patch has been released yet. To work
> around it, you could add an extra pattern to the rule right before the
> test and after the "or":
>
> (defrule r3
>(s)
>(or (not (a))
>(and ?x <- (a)
> (b ?x) ) )
>(initial-fact)
>(test (= qwe asd))
> => ...
>
> Alternatively you could move the test before the "or".
>
>
>
> On Sep 7, 2010, at 5:10 AM, Henrique Lopes Cardoso wrote:
>
>> Hi,
>>
>> Is there any update on this issue?
>> Since I did not get any answer to my last question in the previous
>> e-mail (below), I am asking again:
>> - Is there a way to stop Jess from transforming rules and keep the
>> original coding, possibly with some loss of performance?
>> Or even better: is the bug solved?
>>
>> Thanks,
>>
>> Henrique
>>
>>
>>
>> Henrique Lopes Cardoso wrote:
>>> Hi again,
>>>
>>> In the sequel of this problem, I've fond another (possibly related)
>>> situation where the rule does not seem to compile correctly.
>>> I managed to simplify the example to the following rule:
>>>
>>>(defrule r3
>>>(s)
>>>(or (not (a))
>>>(and ?x <- (a)
>>> (b ?x) ) )
>>>(test (= qwe asd))   ; stupid test, just to expose the problem
>>>=>
>>>(printout t "t!" crlf) )
>>>
>>> Using (ppdefrule), we see that this rule compiles to:
>>>
>>>(defrule MAIN::r3
>>>   (or
>>> (and
>>>   (s)
>>>   (not (a)))
>>> (and
>>>   (s)
>>>   ?x <- (a)
>>>   (and (b ?x)
>>>(test (= qwe asd)
>>>   =>
>>>   (printout t "t!" crlf))
>>>
>>> Therefore, the test is not done in the first branch of (or).
>>>
>>> Is there a way to stop Jess from transforming rules and keep the
>>> original coding, possibly with some loss of performance? The point here
>>> is to avoid the apparently buggy transformations that are being made.
>>>
>>> Thanks.
>>>
>>> Henrique
>>>
>>>
>>> Ernest Friedman-Hill wrote:
>>>
>>>> Indeed, the rule doesn't seem to compile correctly; the two ?x's are
>>>> not merged.
>>>>
>>>> Jess> (ppdefrule r)
>>>> "(defrule MAIN::r
>>>>   (initial-fact)
>>>>   (not ?x <- (and ?x <- (a ?_021__blank_2) (not (b ?_0022_x
>>>>   =>
>>>>   (printout t \"sure thing!\" crlf))"
>>>>
>>>>
>>>> On Jul 20, 2010, at 4:04 PM, Henrique Lopes Cardoso wrote:
>>>>
>>>>
>>>>> Actually, asserts do work, because (deffacts) are added to working
>>>>> memory by a call to (reset). This is wy I am calling (facts) before
>>>>> (run), to make sure facts are in working memory as intended.
>>>>>
>>>>> Anyway, I tried (assert)ing them one by one and it still does not
>>>>> work
>>>>> as expected.
>>>>>
>>>>> It must be something else.
>>>>>
>>>>> Henrique
>>
>>
>> 
>> To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
>> in the BODY of a message to majord...@sandia.gov, NOT to the list
>> (use your own address!) List problems? Notify
>> owner-jess-us...@sandia.gov.
>> 
>
> -
> Ernest Friedman-Hill
> Informatics & Decision Sciences  Phone: (925) 294-2154
> Sandia National Labs
> PO Box 969, MS 9012ejfr...@sandia.gov
> Livermore, CA 94550 http://www.jessrules.com
>
>
>
>
>
> 
> To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
> in the BODY of a message to majord...@sandia.gov, NOT to the list
> (use your own address!) List problems? Notify
> owner-jess-us...@sandia.gov.
> 
>
>

-- 
- - - - - -  -  -  -  -  -   -   -
Henrique Lopes Cardoso
DEI/FEUP
Rua Dr. Roberto Frias | 4200-465 Porto
PORTUGAL
 VoIP: (+351) 225574199 ext.3355
Phone: (+351) 225081400 ext.1315
h...@fe.up.pt | www.fe.up.pt/~hlc
- - - - - -  -  -  -  -  -   -   -




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




Re: JESS: Nested not conditional element with slots referring to facts

2010-09-07 Thread Henrique Lopes Cardoso
Hi,

Is there any update on this issue?
Since I did not get any answer to my last question in the previous
e-mail (below), I am asking again:
- Is there a way to stop Jess from transforming rules and keep the
original coding, possibly with some loss of performance?
Or even better: is the bug solved?

Thanks,

Henrique



Henrique Lopes Cardoso wrote:
> Hi again,
>
> In the sequel of this problem, I've fond another (possibly related)
> situation where the rule does not seem to compile correctly.
> I managed to simplify the example to the following rule:
>
> (defrule r3
> (s)
> (or (not (a))
> (and ?x <- (a)
>  (b ?x) ) )
> (test (= qwe asd))   ; stupid test, just to expose the problem
> =>
> (printout t "t!" crlf) )
>
> Using (ppdefrule), we see that this rule compiles to:
>
> (defrule MAIN::r3
>(or
>  (and
>(s)
>(not (a)))
>  (and
>(s)
>?x <- (a)
>(and (b ?x)
> (test (= qwe asd)
>=>
>(printout t "t!" crlf))
>
> Therefore, the test is not done in the first branch of (or).
>
> Is there a way to stop Jess from transforming rules and keep the
> original coding, possibly with some loss of performance? The point here
> is to avoid the apparently buggy transformations that are being made.
>
> Thanks.
>
> Henrique
>
>
> Ernest Friedman-Hill wrote:
>   
>> Indeed, the rule doesn't seem to compile correctly; the two ?x's are
>> not merged.
>>
>> Jess> (ppdefrule r)
>> "(defrule MAIN::r
>>(initial-fact)
>>(not ?x <- (and ?x <- (a ?_021__blank_2) (not (b ?_0022_x
>>=>
>>(printout t \"sure thing!\" crlf))"
>>
>>
>> On Jul 20, 2010, at 4:04 PM, Henrique Lopes Cardoso wrote:
>>
>> 
>>> Actually, asserts do work, because (deffacts) are added to working
>>> memory by a call to (reset). This is wy I am calling (facts) before
>>> (run), to make sure facts are in working memory as intended.
>>>
>>> Anyway, I tried (assert)ing them one by one and it still does not work
>>> as expected.
>>>
>>> It must be something else.
>>>
>>> Henrique



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




Re: JESS: Nested not conditional element with slots referring to facts

2010-07-24 Thread Henrique Lopes Cardoso
Hi again,

In the sequel of this problem, I've fond another (possibly related)
situation where the rule does not seem to compile correctly.
I managed to simplify the example to the following rule:

(defrule r3
(s)
(or (not (a))
(and ?x <- (a)
 (b ?x) ) )
(test (= qwe asd))   ; stupid test, just to expose the problem
=>
(printout t "t!" crlf) )

Using (ppdefrule), we see that this rule compiles to:

(defrule MAIN::r3
   (or
 (and
   (s)
   (not (a)))
 (and
   (s)
   ?x <- (a)
   (and (b ?x)
(test (= qwe asd)
   =>
   (printout t "t!" crlf))

Therefore, the test is not done in the first branch of (or).

Is there a way to stop Jess from transforming rules and keep the
original coding, possibly with some loss of performance? The point here
is to avoid the apparently buggy transformations that are being made.

Thanks.

Henrique


Ernest Friedman-Hill wrote:
> Indeed, the rule doesn't seem to compile correctly; the two ?x's are
> not merged.
>
> Jess> (ppdefrule r)
> "(defrule MAIN::r
>(initial-fact)
>(not ?x <- (and ?x <- (a ?_021__blank_2) (not (b ?_0022_x
>=>
>(printout t \"sure thing!\" crlf))"
>
>
> On Jul 20, 2010, at 4:04 PM, Henrique Lopes Cardoso wrote:
>
>> Actually, asserts do work, because (deffacts) are added to working
>> memory by a call to (reset). This is wy I am calling (facts) before
>> (run), to make sure facts are in working memory as intended.
>>
>> Anyway, I tried (assert)ing them one by one and it still does not work
>> as expected.
>>
>> It must be something else.
>>
>> Henrique
>>
>>
>




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




Re: JESS: Can't use funcalls in backchained patterns?

2010-07-21 Thread Henrique Lopes Cardoso
That's correct.

Furthermore, I want to generate (time) facts only if they are used in
the LHS of a rule, not in other uses of (k) patterns. That was the point
of using back-chain.
Another issue is that rules are added at runtime. I may have some rules
of the form

   (k (when ?w)
   (time (when =(+ ?w ...)))
   => ...

but also some other rules of the form

   (k (when ?w)
   => ...

Doing the
&:(progn (schedule-time-alert (+ ?w 3000)) TRUE)
thing in all rules of the former type is just more troublesome.

But if that's the only solution, maybe I'll stick to it.

Thanks.

Henrique



Ernest Friedman-Hill wrote:
> It would, but then you'd need a second rule to actually act on the
> alert. I think Henrique was looking for a way to do it in one rule,
> imagining that there would be many triggers like this.
>
>
> On Jul 21, 2010, at 10:05 AM, Wolfgang Laun wrote:
>
>> Why wouldn't a simple
>>
>> (defrule r
>>   (k (when ?w))
>> =>
>>   (schedule-timer-alert (+ ?w 3000))
>> )
>>
>> be sufficient?
>>
>> -W
>>
>
> -
> Ernest Friedman-Hill
> Informatics & Decision Sciences, Sandia National Laboratories
> PO Box 969, MS 9012, Livermore, CA 94550
> http://www.jessrules.com
>
>
>
>
>
>
>
> 
> To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
> in the BODY of a message to majord...@sandia.gov, NOT to the list
> (use your own address!) List problems? Notify
> owner-jess-us...@sandia.gov.
> 
>
>

-- 
- - - - - -  -  -  -  -  -   -   -
Henrique Lopes Cardoso
DEI/FEUP
Rua Dr. Roberto Frias | 4200-465 Porto
PORTUGAL
(+351)225081400 ext.1315
h...@fe.up.pt | www.fe.up.pt/~hlc
- - - - - -  -  -  -  -  -   -   -




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




JESS: Can't use funcalls in backchained patterns?

2010-07-21 Thread Henrique Lopes Cardoso
Hi,

I was trying to make a rule that fires a few seconds after a fact is
asserted. Here is my experiment:

(deftemplate time (slot when))
(do-backward-chaining time)

(defrule do-time
(need-time (when ?w))
=>
(schedule-time-alert ?w) )

(deftemplate k
(slot when (default-dynamic (call System currentTimeMillis))) )

(defrule r
(k (when ?w))
(time (when =(+ ?w 3000)))   ; a time fact 3 seconds after k is expected
=>
(printout t "3 seconds after k!" crlf) )

Function schedule-time-alert is implemented in Java and is supposed to
add a fact at the indicated time.
While this approach looks pretty clean to me, it does not even compile.
I am getting a "Can't use funcalls in backchained patterns when", in
rule r. This does not seem to be documented (at least I did not find it).

There is a work arround described in
http://www.jessrules.com/jess/FAQ.shtml#Q9
That approach has been suggested in previous e-mail threads, I have noticed.
But while it seems to work, it is also much more CPU-intensive, as a
number of time events (idle facts in faq Q9) would be added for no reason.

Any thoughts?

Thanks.

Henrique




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




Re: JESS: Nested not conditional element with slots referring to facts

2010-07-21 Thread Henrique Lopes Cardoso
Actually, asserts do work, because (deffacts) are added to working  
memory by a call to (reset). This is wy I am calling (facts) before  
(run), to make sure facts are in working memory as intended.


Anyway, I tried (assert)ing them one by one and it still does not work  
as expected.


It must be something else.

Henrique


Citando Wolfgang Laun :


When (deffacts) is evaluated to build the facts, (fact-id) won't
return a fact since only the (reset) inserts
the defined facts. You'll have to use dynamic insertion with (assert)
to insert a fact referring to another
fact.

-W

On 20 July 2010 19:23, Henrique Lopes Cardoso  wrote:

Hi,

I have just reproduced the example of section 6.10 of the Jess manual:

   (defrule forall-example
       (not (and (a ?x)
                 (not (b ?x)) ) )
       =>
       (printout t "whassup?" crlf) )

   (deffacts qwe
       (a 1)
   ;    (a 2)
       (b 1) )

   (reset) (facts) (run)

So in this case, if I comment out fact (a 2), the rule stops firing.
But then I tried to implement the following rule:

   (defrule r
       (not (and ?x <- (a ?)   ; variable binding
                 (not (b ?x)) ) )   ; check if there is a b referring
to the a fact
       =>
       (printout t "sure thing!" crlf) )

   (deffacts qwe
       (a 1)
   ;    (a 2)
       (b (fact-id 1)) )   ; fact b referring to fact (a 1)

   (reset) (facts) (run)

It's quite similar to the previous one, but now I am inspecting if fact
b contains a reference to fact a.
In this case the rule does not cease to fire when I comment out (a 2).

Am I missing something?

Thanks,

Henrique




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









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











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




JESS: Nested not conditional element with slots referring to facts

2010-07-20 Thread Henrique Lopes Cardoso
Hi,

I have just reproduced the example of section 6.10 of the Jess manual:

(defrule forall-example
(not (and (a ?x)
  (not (b ?x)) ) )
=>
(printout t "whassup?" crlf) )
   
(deffacts qwe
(a 1)
;(a 2)
(b 1) )
   
(reset) (facts) (run)

So in this case, if I comment out fact (a 2), the rule stops firing.
But then I tried to implement the following rule:

(defrule r
(not (and ?x <- (a ?)   ; variable binding
  (not (b ?x)) ) )   ; check if there is a b referring
to the a fact
=>
(printout t "sure thing!" crlf) )
   
(deffacts qwe
(a 1)
;(a 2)
(b (fact-id 1)) )   ; fact b referring to fact (a 1)
  
(reset) (facts) (run)

It's quite similar to the previous one, but now I am inspecting if fact
b contains a reference to fact a.
In this case the rule does not cease to fire when I comment out (a 2).

Am I missing something?

Thanks,

Henrique




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




Re: JESS: Java object inside slots -- checking matches

2010-07-13 Thread Henrique Lopes Cardoso
Thanks!
Actually there was a bug in my Fact.equals() method, as it was receiving
a Fact instead of an Object :p
I also confirmed that I must implement Fact.hashCode() as well, so that
rule r1 works properly.

Henrique


Ernest Friedman-Hill wrote:
> Jess will call Fact.equals() to evaluate the first rule -- if Fact
> doesn't override equals(), then of course Object's version is used,
> which is based on identity. Jess may also call Fact.hashCode() as part
> of computing a hashcode for the jess.Fact objects.
>
>
> On Jul 12, 2010, at 4:56 AM, Henrique Lopes Cardoso wrote:
>
>> Hi,
>>
>> I have 2 deftemplates, each of which includes a slot with a Java object.
>> I want to have a rule that fires when the objects inside those slots are
>> equal. This is my implementation:
>>
>> (deftemplate t1 (slot o))
>> (deftemplate t2 (slot o))
>>
>> (defrule r1
>>(t1 (o ?obj))
>>(t2 (o ?obj))
>>=>
>>(printout t "--r1--->" (call ?obj getX) crlf) )
>>
>> (defrule r2
>>(t1 (o ?obj1))
>>(t2 (o ?obj2))
>>(test (= (call ?obj1 equals ?obj2) TRUE))
>>=>
>>(printout t "--r2--->" (call ?obj1 getX) crlf) )
>>
>> (reset)
>> (assert (t1 (o (new Fact 1
>> (assert (t2 (o (new Fact 1
>> (facts)
>> (run)
>>
>> As can be easily seen, my Fact class has an x attribute accessible via
>> getX(). I have also implemented equals().
>> Rule r2 works fine.
>>
>> I was just trying to better understand the contents of section 8.4 of
>> the manual, where it is said that "Jess may call the equals and hashCode
>> methods of any objects in working memory". This does not mean that rule
>> r1 should fire, right? Rule r1 really demands for the references to
>> refer to the same object, not equal objects, am I right?
>> So, in this case should I implement hashCode()? It does not seem to be
>> necessary. Is it crucial only when using shadow facts?
>>
>> Thanks.
>>
>> Henrique




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




JESS: Java object inside slots -- checking matches

2010-07-12 Thread Henrique Lopes Cardoso
Hi,

I have 2 deftemplates, each of which includes a slot with a Java object.
I want to have a rule that fires when the objects inside those slots are
equal. This is my implementation:

(deftemplate t1 (slot o))
(deftemplate t2 (slot o))

(defrule r1
(t1 (o ?obj))
(t2 (o ?obj))
=>
(printout t "--r1--->" (call ?obj getX) crlf) )

(defrule r2
(t1 (o ?obj1))
(t2 (o ?obj2))
(test (= (call ?obj1 equals ?obj2) TRUE))
=>
(printout t "--r2--->" (call ?obj1 getX) crlf) )

(reset)
(assert (t1 (o (new Fact 1
(assert (t2 (o (new Fact 1
(facts)
(run)

As can be easily seen, my Fact class has an x attribute accessible via
getX(). I have also implemented equals().
Rule r2 works fine.

I was just trying to better understand the contents of section 8.4 of
the manual, where it is said that "Jess may call the equals and hashCode
methods of any objects in working memory". This does not mean that rule
r1 should fire, right? Rule r1 really demands for the references to
refer to the same object, not equal objects, am I right?
So, in this case should I implement hashCode()? It does not seem to be
necessary. Is it crucial only when using shadow facts?

Thanks.

Henrique




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




JESS: Checking status: backward-chaining or logical?

2010-07-02 Thread Henrique Lopes Cardoso
Hi,

I was trying to figure out a way of checking the "status" of some system.
To make things simpler, I have two kinds of facts, start and end, which
are added along time:
(deftemplate start)
(deftemplate end)

Then I want to say that I have an "active" system if it has started and
not ended yet. However, I want to avoid doing like
(start) (not (end))
in every rule where I need to check if the system is active.

My first approach was to try backward chaining. In Prolog I would do
something like:
active :- start, not(end).

However in Jess this gets more complicated, since doing something like:
(deftemplate active
(declare (backchain-reactive TRUE)) )
(defrule do-active
(need-active)
(start)
(not (end))
=>
(assert (active)) )

will assert the active fact, but then I need another rule to retract
active when end occurs...

I then turned to using the logical conditional element, which seems to
work fine:
(defrule active-ctx
(logical (not (end)))
(start)
=>
(assert (active)) )

Is this the best way of doing it?

Thanks.

Henrique




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




Re: JESS: Explicit pattern bindings when using dotted notation in slots with fact reference

2010-06-29 Thread Henrique Lopes Cardoso
Thanks for the clarification.

By the way, in section 3.7.1 of the Jess manual: "You can use dotted
variables in any procedural code, but they won't generally work in the
pattern matching parts of a rule."
Does this mean that the use of dot notation is discouraged in the LHS of
rules? Section 6.2.1 seems to provide an example where it is used in the
LHS, although with a Java pattern.

Henrique


Ernest Friedman-Hill wrote:
>
> On Jun 29, 2010, at 6:42 AM, Henrique Lopes Cardoso wrote:
>
>>
>> Does this mean that when using dotted variables a pattern binding should
>> always be included before they are used?
>>
>
> This isn't really limited to dotted variables; you'd see the same
> issue if you wrote the code using fact-slot-value, or reflection. For
> a match to be made or unmade, the particular Rete node that performs
> the test needs to be notified that the relevant fact(s) have changed.
> That won't happen unless those relevant facts are explicitly matched
> by patterns. If the facts are dynamic -- i.e., if the slot values will
> change at runtime -- then I'd prefer to write this rule as
>
> (defrule r2
>(a (b ?b))
>?b <- (b (s ?s))
>(c (s ?s))
>=>
>
>
>
> -
> Ernest Friedman-Hill
> Informatics & Decision Sciences, Sandia National Laboratories
> PO Box 969, MS 9012, Livermore, CA 94550
> http://www.jessrules.com




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




JESS: Explicit pattern bindings when using dotted notation in slots with fact reference

2010-06-29 Thread Henrique Lopes Cardoso
Hi,

I was strugling with the following code, until I remembered that rule
activations are only affected when you assert/retract or modify facts
that can match a rule's patterns. Anyway, I think I'd better share this
problem and get further advice.

; I have 3 deftemplates:
(deftemplate a (slot b))   ; This slot _b_ will contain a reference to a
fact _b_.
(deftemplate b (slot s))   ; I want to check if there are facts _b_ and
_c_ with the same slot _s_,
(deftemplate c (slot s))   ; where _b_ will be referred to in a fact _a_.

; Then I have a rule to get a matching of slot _s_ of both _b_ and _c_
facts, where _b_ must be referred to by an _a_ fact:
(defrule r2
(a (b ?b))
?b <- (b)   ; Apparently useless
(c (s ?b.s))   ; Using dot notation
=>
(printout t "abc! " ?b.s crlf) )

; Some initial facts:
(deffacts my-facts
(b (s 1))
(a (b (fact-id 1)))   ; This is a shortcut to have slot _b_ of fact
_a_ refer to fact _b_ in the line above.
(c (s 1)) )

; Let's do it:
(reset)
(facts)
(modify 1 (s 2))   ; Here I modify fact _b_, changing its slot _s_ to 2.
(facts)
(run)

Now, this version works as expected: rule r2 does *not* fire. However,
if I comment the "Apparently useless" pattern binding, the rule *will
fire*, although slots _s_ of both _c_ and _b_ facts no longer have the
same value!

Does this mean that when using dotted variables a pattern binding should
always be included before they are used?

Thanks.

Henrique




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




JESS: Redefining default values in deftemplates

2009-08-03 Thread Henrique Lopes Cardoso
Hi,

Is there a way to change a default value in a deftemplate?
Declaring a deftemplate twice for the same deftemplate name issues an
error (strangely, unless you define the deftemplate exactly as before).

I managed to do the following work arround:

;---
(deffunction f () return 0 )

(deftemplate t (slot s (default-dynamic (f))) )

(assert (t))

(deffunction f () return 1 )

(assert (t))

(facts)
;---

Redefining a function seems to work ok (although the Jess editor issues
a warning message). In this case, I get two facts, one with each
intended default value.

Is there a simpler way of doing this, e.g. by changing the deftemplate
directly?

Thanks.

Henrique




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




Re: JESS: Retract all facts belonging to Deftemplate

2009-02-09 Thread Henrique Lopes Cardoso
Yes, you're right.
Then, you have two options:
a) wait for the cleaning task to become active:

(defrule retract-them-all
   (cleaning-time)
   ?x <- (MappingName)
   =>
   (rectract ?x))

b) Create a function to do it and invoke it when needed:

(defquery get-them-all
?f <- (MappingName))

(deffunction retract-them-all ()
(bind ?result (run-query* get-them-all))
(while (?result next)
   (retract (?result get f)) ) )


Cheers,

Henrique


Wolfgang Laun wrote:
> On Mon, Feb 9, 2009 at 3:51 PM, Henrique Lopes Cardoso  <mailto:h...@fe.up.pt>> wrote:
>
> How about::
>
> (defrule retract-them-all
>?x <- (MappingName)
>=>
>(rectract ?x))
>
>
> Basically, yes, that'll do it - but then these facts won't stay around
> long enough for any useful purpose.
> -W
>  
>
>
> Cheers,
>
> Henrique
>
>
> nikita shah wrote:
> > I want to remove all facts beloging to one particular template.
> > How can this be done ?
> >
> > For eg:
> > (deftemplate MappingName (slot mappingName))
> >
> > Some rule fires and I want to remove all the facts belonging to
> MappingName
> > template.
> >
> >
>
>
>
> 
> To unsubscribe, send the words 'unsubscribe jess-users
> y...@address.com <mailto:y...@address.com>'
> in the BODY of a message to majord...@sandia.gov
> <mailto:majord...@sandia.gov>, NOT to the list
> (use your own address!) List problems? Notify
> owner-jess-us...@sandia.gov <mailto:owner-jess-us...@sandia.gov>.
> 
>
>

-- 
- - - - - -  -  -  -  -  -   -   -
Henrique Lopes Cardoso
DEI/FEUP
Rua Dr. Roberto Frias | 4200-465 Porto
PORTUGAL
(+351)225081400 ext.1315
h...@fe.up.pt | www.fe.up.pt/~hlc
- - - - - -  -  -  -  -  -   -   -




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




Re: JESS: Retract all facts belonging to Deftemplate

2009-02-09 Thread Henrique Lopes Cardoso
How about::

(defrule retract-them-all
?x <- (MappingName)
=>
(rectract ?x))

Cheers,

Henrique


nikita shah wrote:
> I want to remove all facts beloging to one particular template.
> How can this be done ?
>
> For eg:
> (deftemplate MappingName (slot mappingName)) 
>
> Some rule fires and I want to remove all the facts belonging to MappingName
> template.
>
>   




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




Re: JESS: Test for null

2008-10-30 Thread Henrique Lopes Cardoso
Hi,

Don't know if this is what you are looking for, but in Jess, null is
represented as nil (inherited from CLIPS).
http://www.jessrules.com/jess/docs/71/basics.html

Try this out:

(deftemplate foo
(slot bar)
(slot qwe) )

(defrule r
?f <- (foo (qwe nil))
=>
(printout t "Got a null slot: " ?f.bar crlf) )

(assert (foo (bar 1)))
(assert (foo (bar 2) (qwe null)))
(run)

Cheers,

Henrique


David Coyle wrote:
> Hello:
>
> I'm working with objects that have numerous relationships to others.
>
> There are a number of times where I need to simply check whether a
> particular relationship is or is not null, without caring about the
> actual destination object itself.
>
> I haven't found an appropriate function: does one exist, or is there
> a standard approach to determining null?
>
> thanks,
>
> -dave-
>
>
> David Coyle PhD
> Lead Web Application Architect
> m: 919.454.7770
> www.livescribe.com
> --
> LiveScribe, Inc.
> 7677 Oakport St. 12th Floor
> Oakland, CA 94621
>
>
>
>
>
> 
> 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]
> 
>
>

--
- - - - - -  -  -  -  -  -   -   -
Henrique Lopes Cardoso
DEI/FEUP
Rua Dr. Roberto Frias | 4200-465 Porto
PORTUGAL
(+351)225081400 ext.1315
[EMAIL PROTECTED] | www.fe.up.pt/~hlc
- - - - - -  -  -  -  -  -   -   -




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: Exists CE and modify

2008-10-17 Thread Henrique Lopes Cardoso

I find it interesting that in this case the second run does not fire the
rule:

---
(deftemplate foo
   (declare (slot-specific TRUE))
   (slot bar) )

(defrule r
   (exists (foo))
   => )

(reset)
(assert (foo (bar 1)))
(assert (foo (bar 2)))
(printout t (run) crlf)
(modify (fact-id 1) (bar 123))
(printout t (run) crlf)
---

Thus, I guess that 'exists' does not stick to the first fact it can
find. Also, since pattern matching is evaluated after each working
memory update, Jess keeps track that 'exists' never stops being true
(there is always at least one foo fact, even when modifying the other one).

Are my thoughts correct?

Cheers,

Henrique



Ernest Friedman-Hill wrote:

On Oct 17, 2008, at 9:06 AM, Henrique Lopes Cardoso wrote:



;---

The rule fires in both runs. Is this the intended behavior?



It's traditional behavior for Rete engines, yes.



Is there a
way to prevent the rule from firing in the second run?



Only by having the rule assert a fact indicating it's already fired,
and matching the negation of that fact on the LHS of the rule.




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]




JESS: Exists CE and modify

2008-10-17 Thread Henrique Lopes Cardoso

Hi,

After a whole morning struggling with what appeared to be a bug in my
application, I managed to create a simple example:

;---
(deftemplate foo
   (slot bar) )

(defrule r
   (exists (foo))
   => )

(reset)
(assert (foo))
(printout t (run) crlf)
(modify (fact-id 1) (bar 123))
(printout t (run) crlf)
;---

The rule fires in both runs. Is this the intended behavior? Is there a
way to prevent the rule from firing in the second run?

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]




JESS: Rule comparing slot values that can be omitted

2008-07-03 Thread Henrique Lopes Cardoso

Hi,

I have tried the straightforward example below. I define two simple
deftemplates and a rule that compares their slots, which are assumed to
be numeric. Then, I incidentally assert a fact on which I do not define
a value for a slot.
When the rule is evaluated (after the second assertion), I immediately
get an error.

Now, I understand the error. But maybe Jess should be nicer by noticing
that if the comparison cannot be made, then it should simply not fire
the rule (quietly).

Henrique

---
Jess, the Rule Engine for the Java Platform
Copyright (C) 2008 Sandia Corporation
Jess Version 7.1RC1 6/23/2008

Jess> (deftemplate a (slot s))
TRUE
Jess> (deftemplate b (slot s))
TRUE
Jess> (defrule r1 (a (s ?sa)) (b {s < ?sa}) => (printout t "Yes!" crlf))
TRUE
Jess> (assert (a))

Jess> (assert (b (s 1)))
Jess reported an error in routine <
   while executing (< ?__synth0(1,0,-1) ?sa(0,0,-1))
   while executing rule LHS (Node2)
   while executing rule LHS (TECT)
   while executing (assert (MAIN::b (s 1))).
 Message: Not a number: nil.
 Program text: ( assert ( b ( s 1 ) ) )  at line 5.
Jess>



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: Documentation bug for template properties

2008-06-26 Thread Henrique Lopes Cardoso

Hi,

In the change history for 7.1RC1: "Template properties
(backchain-reactive, slot-specific) are inherited."

In section 5.1 of the manual: "A template inherits all the slots of its
parent template, but none of its other characteristics."
And in section 17.7: "The backchain-reactive and slot-specific
declarations are inherited by child templates."

Could this be clarified?

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]




Re: JESS: Clues on the Crash-On-Save issue

2008-06-25 Thread Henrique Lopes Cardoso

Hi,

Just letting everybody know that I have the problem again...
   Eclipse EE + Jess 71RC1 + Subclipse = random crash on save

Don't know if Subclipse brings anything new, though...

Cheers,

Henrique


Jason Morris wrote:

Hi Henrique,

I just did the same thing since I was crashing Eclipse almost every
time I saved from the Jess editor.  Ernest is evaluating whether or
not the problem is coming from the MyEclipseIDE plugins or if there is
a conflict with Eclipse proper.
So far, running a pristine Eclipse Europa Winter version without the
MyEclipseIDE installed but with the stable Jess 7.0p2 plugins and not
the betas, I have not locked-up (yet).

Keep us posted on anything you find out!  :-)

Cheers,
Jason

On Mon, Mar 17, 2008 at 8:17 AM, Henrique Lopes Cardoso <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>> wrote:

Hi all,

After a morning starting with those annoying crashes, I decided to
install the latest Eclipse IDE for Java EE Developers.
Then I installed Jess 71b2 plugins for Eclipse.

Apparently the crash-on-save problems are gone! But you never know
-- it
might be too soon to open the champagne... ;)

Cheers,


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





To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]




Re: JESS: Ruleml to Jess

2008-05-20 Thread Henrique Lopes Cardoso

Hi,

I've just checked the link, which is in fact wrong. But I intuitively
tried to change the target and it works:
http://www.daml.org/2001/02/gedcom-ruleml/jess.xsl

HTH,

Henrique

Juan Ondiviela wrote:

I've been searching for a long time for a xsl translator from ruleml
to jess rules until I found this webpage,
http://www.daml.org/2001/02/gedcom-ruleml/, I tried to use the
jess.xsl but I realized the link is the same as for xsb.xsl. Have you
ever used something like that or can you send something that fixes my
problem? It would be very helpful!
Thank you very much and best regards,
   Juan






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]: Removing rules from a session.

2008-05-08 Thread Henrique Lopes Cardoso

Hi,

I thought the question was more related with putting the engine to run.
I guess that after each modify a (run) must be invoked.

What about (run-until-halt)? Will rules be evaluated in every working
memory update? What if the time fact update is faster than the
"activation semaphore": would the first modify be lost (in which rules
firing on it is concerned)?

Henrique


Ernest Friedman-Hill wrote:

On May 8, 2008, at 10:03 AM, ivo jonker wrote:


I see. That sounds good.

Does this mean Jess automatically evaluates the rules when i call the
Modify for every second i update the Time?


Pattern matching is driven by working memory changes, and it's very
smart about what to re-test. That's the whole point of the "Rete
algorithm" on which Jess is ultimately based. When the time is
updated, patterns that check the time in some way may be re-evaluated.
Jess does the minimum possible amount of computation.







2008/5/8 Ernest Friedman-Hill <[EMAIL PROTECTED]>:

On May 8, 2008, at 9:24 AM, ivo jonker wrote:

Thanks a lot, this is exactly what i was looking for.

I've just ordered the book: Jess in action and it should arrive
shortly. I'm looking forward to it and i know it will be usefull.

Anyway, while i'm at it. I was wondering how JESS would be suitable
for using Time as a fact. I believe jess is not able to respond 100%
real-time, so i guess it's useless using time as a fact when testing
for changes into seconds... I might be wrong though.




It works fairly well, actually. You have a fact like

(time (seconds 87268726))

and then have a thread, either written in Java or in Jess, which
keeps a reference to this Fact object and uses Rete.modify() or
(modify) to update the "seconds" slot periodically. Then your rules
can just match that slot however they like and when the fact is
updated the matches are evaluated.





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: Module auto-focus?

2008-03-18 Thread Henrique Lopes Cardoso

Actually, yes.
I mean, I can do exactly what I need with auto-focus in rules dispersed
among a number of modules.
I was just emphasizing that if you use modules with a merely
organizational aim (in which rules are concerned), it would be more
simple to do something like:

(defmodule m
   (declare (auto-focus TRUE)) )

which would mean that *every* rule in module 'm' would have auto-focus.
This is not possible for now.

Henrique


Jason Morris wrote:

Hi Henrique,

Do you need more than what this code does?
This example does not interfere with rule firing order or fool with
salience.


;;
;; focus.clp
;;

(clear)
;(watch all)

(defmodule module-1)

(defrule in-module-1
   =>
   (printout t "Now in module-1" crlf))

(defmodule module-2)

(defrule in-module-2
   =>
   (printout t "Now in module-2 and asserting a (foo)" crlf)
   (assert (MAIN::foo)))

(defmodule module-k)

(defrule in-module-k
   =>
   (printout t "Now in module-k" crlf))

(defmodule module-controller)

(defrule switch-to-module-k
(declare (auto-focus TRUE))
(MAIN::foo)
=>
(printout t "Foo detected in MAIN ... switching to module-k now!"
crlf)
(focus module-k))

(defmodule module-n)

(defrule in-module-n
   =>
   (printout t "Resuming focus stack in module-n" crlf)
   (halt))

; Program
(reset)
(focus module-1 module-2 module-n)
(run-until-halt)

/**
OUTPUT
Jess> (batch "focus.clp")
Now in module-1
Now in module-2 and asserting a (foo)
Foo detected in MAIN ... switching to module-k now!
Now in module-k
Resuming focus stack in module-n
5
**/

Cheers,
Jason



On Fri, Mar 14, 2008 at 8:41 AM, Henrique Lopes Cardoso <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>> wrote:

Hi,

Some time ago I discussed the possibility of using auto-focus in a
module definition, instead of in each single rule in a module.
I was told that was not possible, but that it was a good idea.

Are you planning to include this feature?
This would be interesting especially when using modules merely as
a way
of organizing rules, while not interfering with rule-firing order, and
not messing up with salience.

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]




Re: JESS: Clues on the Crash-On-Save issue

2008-03-17 Thread Henrique Lopes Cardoso

Hi all,

After a morning starting with those annoying crashes, I decided to
install the latest Eclipse IDE for Java EE Developers.
Then I installed Jess 71b2 plugins for Eclipse.

Apparently the crash-on-save problems are gone! But you never know -- it
might be too soon to open the champagne... ;)

Cheers,

Henrique


Jason Morris wrote:

Hi All,

I was running the plain vanilla Eclipse IDE  (Eclipse IDE for Java
Developers) upon which I normally run the MyEclipseIDE toolkit. On a
whim, I ripped it all out and downloaded and installed the Eclipse IDE
for Java EE Developers 3.3.1.  Then I installed the stable Jess 7.0p2
plugins instead of the latest 7.1b2 versions.

The crash-on-save problem disappeared.

I then installed the MyEclipseIDE 6.0.1 plugin set and fired up
Eclipse with the -clean switch.

The crash problem seems gone -- so far.

So, perhaps we should be running the Eclipse IDE for Java EE
Developers?  The other clue was that the Saves actually did complete,
the thread just never returned control to the Workbench and it hung
up.

Cheers,
Jason



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


To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]






--
- - - - - -  -  -  -  -  -   -   -
Henrique Lopes Cardoso
DEI/FEUP
Rua Dr. Roberto Frias | 4200-465 Porto
PORTUGAL
(+351)225081400 ext.1315
[EMAIL PROTECTED] | www.fe.up.pt/~hlc
- - - - - -  -  -  -  -  -   -   -




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: Module auto-focus?

2008-03-14 Thread Henrique Lopes Cardoso

Hi,

Some time ago I discussed the possibility of using auto-focus in a
module definition, instead of in each single rule in a module.
I was told that was not possible, but that it was a good idea.

Are you planning to include this feature?
This would be interesting especially when using modules merely as a way
of organizing rules, while not interfering with rule-firing order, and
not messing up with salience.

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]




Re: JESS: jade jess example

2008-03-12 Thread Henrique Lopes Cardoso

May I add that such a tutorial has already been written, and it is
available at:
http://jade.tilab.com/doc/tutorials/jade-jess/jade_jess.html

This link is listed at Jade's online documentation:
http://jade.tilab.com/doc/index.html
It is also listed in the Related Web Sites link list at
http://www.jessrules.com

Cheers,

Henrique


Jason Morris wrote:

Hi Giannis,

I started looking at this for you and got side-tracked -- sorry.

Before going into too much detail, one thing that I noticed right away
was that the Jess demo for Jade is built on Jess 5.0 and Jess 6.0 code
-- nearly 4 years out of date!
Many of the methods that it calls are clearly depricated, and some of
the techniques used are a little convoluted.

I would go to the Jade folks and request that they create an updated
tutorial that uses the current Jess 7.1 distribution.
Try that first.  Meanwhile, I'll try to figure out the tutorial in the
Jess 7.1 context as best as I can.

Cheers,
Jason

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


On Tue, Mar 11, 2008 at 6:50 PM, giannis tym <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>> wrote:

Hello

I try to run the example with eclipse 3.3
I have placed the plug ins of jess
but it says everything is full of mistakes in the file JadeAgent.clp
although the code runs correctly fron command line

can anyone say what is wrong


Please help
Giannis




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


--
- - - - - -  -  -  -  -  -   -   -
Henrique Lopes Cardoso
DEI/FEUP
Rua Dr. Roberto Frias | 4200-465 Porto
PORTUGAL
(+351)225081400 ext.1315
[EMAIL PROTECTED] | www.fe.up.pt/~hlc
- - - - - -  -  -  -  -  -   -   -



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 Jess handles the time elapsed from a particular event

2008-02-20 Thread Henrique Lopes Cardoso

I think you must time-stamp your facts (in an additional slot), and base
your rules in those time-stamps.

Henrique


Marco Zappatore wrote:

Dear Jess Developers,
is there a way to compare the exact time at which two
or more facts have been added to the working memory?
For instance:
-asserts fact f1 at time t
-asserts fact f2 at time t+dt
-activates some rules if dt not exceeds a given threshold
-activates some other rules if not

I'm already able to do that shifting from jess to java and
viceversa but is it possible to do that directly in Jess
without using a proper user-defined Java function.

Many thanks for your answers,
  Marco Zappatore


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]






--
- - - - - -  -  -  -  -  -   -   -
Henrique Lopes Cardoso
DEI/FEUP
Rua Dr. Roberto Frias | 4200-465 Porto
PORTUGAL
(+351)225081400 ext.1315
[EMAIL PROTECTED] | www.fe.up.pt/~hlc
- - - - - -  -  -  -  -  -   -   -


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 for detecting changes of a multislot

2008-02-20 Thread Henrique Lopes Cardoso

There is a small bug in the 'actually-remove-things-from-c' rule:
(remove ?c ?b?) should be (remove ?c ?x)

Anyway, is 'do-something-when-something-gets-removed-from-c' guaranteed
to fire? If 'actually-remove-things-from-c' fires before, then
'do-something-when-something-gets-removed-from-c' will not fire, since
?c was already modified!

Henrique



-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Ernest Friedman-Hill
Sent: woensdag 20 februari 2008 13:31
To: jess-users
Subject: Re: JESS: Rules for detecting changes of a multislot

Lars,

...

(defrule remove-something-from-c
?c <- (C (m ?a ?b ?c))
=>
(modify ?c (m ?a ?c)))

You'd say something like

(defrule want-to-remove-something-from-c
?c <- (C (m ?a ?b ?c))
=>
;; Instead of modifying ?c, issue a command to do so
(assert (remove ?c ?b)))

(defrule actually-remove-things-from-c
"Process commands to remove items from multislot m of C facts"
(declare (no-loop TRUE))
?c <- (C (m $?first ?x $?rest))
(remove ?c ?b)
=>
(modify ?c (m $?first $?rest)))

(defrule do-something-when-something-gets-removed-from-c
"This is the rule you were asking about how to write"
?c <- (C (m $?first ?x $?last))
(remove ?c ?x)
=>
(do whatever you want to do here))

(defrule clean-up-remove-commands
"A low salience rule to clean up remove commands when you're done
with them."
(declare (salience -1))
?r <- (remove ? ?)
=>
(retract ?r))

...



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: Multiple fact or's

2008-02-15 Thread Henrique Lopes Cardoso

Thanks. Of course the member$ thing was just a provocation... ;)
Just wondering if there was an efficient way in both senses (execution
and typing)...
So, while your solution is the most efficient one, Jess 7.1 will give it
for free from mine.

H.


Ernest Friedman-Hill wrote:

On Feb 15, 2008, at 9:28 AM, Henrique Lopes Cardoso wrote:


(defrule
?b1 <- (t1 (s ?s1))
?b2 <- (t2 (s ?s2))
(or (test (eq ?s1 x)) (test (eq ?s2 x)))
=>
...)

This example simplifies the general case. I may have any number of
bindings, and the common slot 's' is checked to see if at least one of
the bound facts has a certain x value. Is there a more efficient
way of
doing this? E.g. (member$ x (list ?b1 ?b2 ...)) ?



Efficient in terms of typing these out, or in terms of execution?
We're actually working on optimizing these kinds of things in the
network; by the final release of Jess 7.1, the above should actually
be equivalent to something like

(defrule
(or (and ?b1 <- (t1 (s ?s1&x))
 ?b2 <- (t2 (s ?s2)))
(and ?b1 <- (t1 (s ?s1))
 ?b2 <- (t2 (s ?s2&x
==>

which is extremely efficient. The above is the best way to write this
right now, but hopefully the two will soon be equivalent.





-
Ernest Friedman-Hill
Informatics & Decision Sciences  Phone: (925) 294-2154
Sandia National LabsFAX:   (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://www.jessrules.com


To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify
[EMAIL PROTECTED]
----




--
- - - - - -  -  -  -  -  -   -   -
Henrique Lopes Cardoso
DEI/FEUP
Rua Dr. Roberto Frias | 4200-465 Porto
PORTUGAL
(+351)225081400 ext.1315
[EMAIL PROTECTED] | www.fe.up.pt/~hlc
- - - - - -  -  -  -  -  -   -   -


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: Multiple fact or's

2008-02-15 Thread Henrique Lopes Cardoso

Hi,

I have a rule looking like this:

(defrule
   ?b1 <- (t1 (s ?s1))
   ?b2 <- (t2 (s ?s2))
   (or (test (eq ?s1 x)) (test (eq ?s2 x)))
   =>
   ...)

This example simplifies the general case. I may have any number of
bindings, and the common slot 's' is checked to see if at least one of
the bound facts has a certain x value. Is there a more efficient way of
doing this? E.g. (member$ x (list ?b1 ?b2 ...)) ?

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]




Re: JESS: Checking list equality

2008-02-13 Thread Henrique Lopes Cardoso

Yes, I had noticed that.
Thank you all.

By the way, is it heavy to have such a test in a rule's LHS?
Let me be more specific. I am trying to make a kind of "refraction"
across multiple rules. The point is to prevent two rules from firing on
the same facts. For this I use a special ordered fact "rule-fired-on"
that contains a list of fact references.
In the LHS I check to see if a rule has fired before with the facts used
to activate it:

(defrule r1
   ?b1 <- (some-fact)
   ?b2 <- (some-other-fact)
   (not (rule-fired-on $?b-list&:(equal-lists? ?b-list (list ?b1 ?b2
  =>
   (assert (rule-fired-on ?b1 ?b2))
   (printout t "r1 fired on " ?b1 ?b2 crlf) )

Is this computationally expensive?

Thanks,

Henrique



Wolfgang Laun wrote:

Given the precondition (as Henrique wrote) that the lists are sets you
don't have to consider the general case.
-W

Szymon Klarman wrote:


Yes but this function won't do the job in general. Consider:

list1 = (1 1 2),
list2 = (2 2 3),

(union$ list1 list2) = (1 2 3)

Better to check whether intersection of the two lists have the same
length
as their union.

all best,
Szymon

- Original Message -
From: "Wolfgang Laun" <[EMAIL PROTECTED]>
To: 
Sent: Wednesday, February 13, 2008 3:16 PM
Subject: Re: JESS: Checking list equality



You can apply (=) to more than 2 arguments.

(= (length$ ?list1) (length$ ?list2) (length$ (union$ ?list1 ?list2)))

kr
Wolfgang

Henrique Lopes Cardoso wrote:


Hi,

I was trying to test equality for lists seen as sets (elements with
any
order).
Is there any direct function, or any solution simpler than this:

(bind ?list1 (list 1 2 3))
(bind ?list2 (list 3 2 1))

(and (= (length$ ?list1) (length$ ?list2)) (= (length$ (union$ ?list1
?list2)) (length$ ?list1)))

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]




JESS: Checking list equality

2008-02-13 Thread Henrique Lopes Cardoso

Hi,

I was trying to test equality for lists seen as sets (elements with any
order).
Is there any direct function, or any solution simpler than this:

(bind ?list1 (list 1 2 3))
(bind ?list2 (list 3 2 1))

(and (= (length$ ?list1) (length$ ?list2)) (= (length$ (union$ ?list1
?list2)) (length$ ?list1)))

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]




JESS: Setting defaults

2008-02-11 Thread Henrique Lopes Cardoso

Hi,

I was wondering if there is a way of setting a default value for a slot
to be equal to another slot.
Something like:

(deftemplate foo
   (slot bar)
   (slot qwe (default-dynamic this.bar

(assert (foo (bar 1)))

Slot qwe would get the value of slot bar, that is, 1.

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]




JESS: Dot notation in patterns - performance issues

2008-02-06 Thread Henrique Lopes Cardoso

Hi,

I am considering rewriting my rules to maximize the use of the dot 
notation in patterns.

For instance:

(deftemplate x (slot a) (slot b) (slot c))
(deftemplate y (slot a) (slot b))

(defrule r
   ?x <- (x (a ?a) (b ?b) (c 1))
   ?y <- (y (a ?a) (b ?b))
   =>
   (printout t ?y " matches " ?x crlf) )

(defrule r_
   ?x <- (x (c 1))
   ?y <- (y {a == x.a} {b == x.b})
   =>
   (printout t ?y " matches_ " ?x crlf) )

(deffacts f
   (x (a 1) (b 2) (c 1))
   (y (a 1) (b 2))
   (y (a 10) (b 20)) )

(reset)
(facts)
(run)

The rule r_ highlights the only restriction applied to the x fact, which 
is in slot c.
Are there any performance issues related to this approach, or is it ok 
to use any of these approaches?


By the way, I was trying to use (y (a ?x.a) (b ?x.b)) inside the y 
pattern, which does not work - as explained in section 6.2.1 of the Jess 
manual, «when you refer to a pattern binding in a Java pattern, the "?" 
variable indicator is omitted». And I suppose it must be used inside 
curly-brace notation, since (y (a x.a) (b x.b)) does not work either.
However, I do not get any error, just an "unexpected" result, as the 
slot matching is ignored in the first case (rule r_ fires twice) and 
does not succeed in the second case (rule r_ does not fire)...


Thanks in advance,

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]




JESS: Redirecting the out stream

2007-12-28 Thread Henrique Lopes Cardoso

Hi,

I have a GUI with a textbox where I insert Jess commands that are sent 
to a Rete engine with the click of a button.
How can I redirect the output of the engine (in response to the 
commands) to a TextArea object that I have in the same GUI?


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]




Re: JESS: Problem with no-loop?

2007-12-21 Thread Henrique Lopes Cardoso

Why does 'no-loop' have no effect in this case? :|
Is there a conflict between both declarations?

Henrique Lopes Cardoso wrote:
I got to a possible solution, based on the answer you gave on another 
thread (related to pattern matching).

This is what I have:
;;;
(deftemplate foo
   (declare (slot-specific TRUE))
   (slot bar (default 0)) )

(defrule r2
   (declare (no-loop TRUE))
   ?f <- (foo)
   (a ?x)
  =>
   (printout t ?x " -r2- " ?f.bar crlf)
   (modify ?f (bar (+ ?f.bar 1))) )

(assert (foo))
(assert (a 1))
(assert (a 2))
(run)
;;;

Therefore, I found a way of not referring to the slot name in the LHS. 
In this case, the 'no-loop' declaration has no effect, since I am 
using 'slot-specific'. The rules fires twice, once for each 'a' fact.
But what puzzles me now is that if I remove 'slot-specific' (and keep 
'no-loop') the rule only runes once!

Why is that?

Henrique


Henrique Lopes Cardoso wrote:
Ok, I understand your technical explanation. I just think it would 
make more sense to prevent the rule from firing only *for the same 
facts*.


Is there a way of achieving what I want? That is, for the example 
given, rule 'r' should fire twice, once for each 'a' fact.
The problem is that I cannot remove the no-loop declaration, 
otherwise slot-specific is not enough to prevent a cyclic firing on 
the same 'a' fact, since the modified slot 'bar' is being referred to 
in the pattern (and needs to be, because I need to increment it).


Any idea?

Thanks.

Henrique


Ernest Friedman-Hill wrote:
When you modify a fact, the fact is removed from working memory, 
changed, and put back. In the process, all activations that depend 
on that fact are re-evaluated. no-loop guarantees that this rule 
will not be activated based on anything this rule does on its RHS. 
Therefore, the rule is activated once for each "a" fact, but when it 
fires the first time, the second activation is removed during the 
modify, and not put back because of the no-loop.


On Dec 20, 2007 10:23 AM, Henrique Lopes Cardoso <[EMAIL PROTECTED] 
<mailto:[EMAIL PROTECTED]>> wrote:


Hi,

This e-mail is a follow-up on the issue related to slot-specific
that I
discussed a couple of days ago. I am using Jess 71b1

I am trying to figure out how to properly use slot-specific and/or
no-loop.
I now got to the following simple example:

;;;
(deftemplate foo
   (declare (slot-specific TRUE))
   (slot bar (default 0)) )

(defrule r
   (declare (no-loop TRUE))
   ?f <- (foo (bar ?n))
   (a ?x)
  =>
   (printout t ?n crlf)
   (modify ?f (bar (+ ?n 1))) )

(assert (foo))
(assert (a 1))
(assert (a 2))
(run)
;;;

Now, why does the rule only fire once? There are two 'a' facts 
there.


Henrique




To unsubscribe, send the words 'unsubscribe jess-users
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>'
in the BODY of a message to [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>, NOT to the list
(use your own address!) List problems? Notify
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>.











--
- - - - - -  -  -  -  -  -   -   -
Henrique Lopes Cardoso
DEEC/FEUP
Rua Dr. Roberto Frias | 4200-465 Porto
PORTUGAL
(+351)225081400 ext.1315
[EMAIL PROTECTED] | www.fe.up.pt/~hlc
- - - - - -  -  -  -  -  -   -   -


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 no-loop?

2007-12-21 Thread Henrique Lopes Cardoso
I got to a possible solution, based on the answer you gave on another 
thread (related to pattern matching).

This is what I have:
;;;
(deftemplate foo
   (declare (slot-specific TRUE))
   (slot bar (default 0)) )

(defrule r2
   (declare (no-loop TRUE))
   ?f <- (foo)
   (a ?x)
  =>
   (printout t ?x " -r2- " ?f.bar crlf)
   (modify ?f (bar (+ ?f.bar 1))) )

(assert (foo))
(assert (a 1))
(assert (a 2))
(run)
;;;

Therefore, I found a way of not referring to the slot name in the LHS. 
In this case, the 'no-loop' declaration has no effect, since I am using 
'slot-specific'. The rules fires twice, once for each 'a' fact.
But what puzzles me now is that if I remove 'slot-specific' (and keep 
'no-loop') the rule only runes once!

Why is that?

Henrique


Henrique Lopes Cardoso wrote:
Ok, I understand your technical explanation. I just think it would 
make more sense to prevent the rule from firing only *for the same 
facts*.


Is there a way of achieving what I want? That is, for the example 
given, rule 'r' should fire twice, once for each 'a' fact.
The problem is that I cannot remove the no-loop declaration, otherwise 
slot-specific is not enough to prevent a cyclic firing on the same 'a' 
fact, since the modified slot 'bar' is being referred to in the 
pattern (and needs to be, because I need to increment it).


Any idea?

Thanks.

Henrique


Ernest Friedman-Hill wrote:
When you modify a fact, the fact is removed from working memory, 
changed, and put back. In the process, all activations that depend on 
that fact are re-evaluated. no-loop guarantees that this rule will 
not be activated based on anything this rule does on its RHS. 
Therefore, the rule is activated once for each "a" fact, but when it 
fires the first time, the second activation is removed during the 
modify, and not put back because of the no-loop.


On Dec 20, 2007 10:23 AM, Henrique Lopes Cardoso <[EMAIL PROTECTED] 
<mailto:[EMAIL PROTECTED]>> wrote:


Hi,

This e-mail is a follow-up on the issue related to slot-specific
that I
discussed a couple of days ago. I am using Jess 71b1

I am trying to figure out how to properly use slot-specific and/or
no-loop.
I now got to the following simple example:

;;;
(deftemplate foo
   (declare (slot-specific TRUE))
   (slot bar (default 0)) )

(defrule r
   (declare (no-loop TRUE))
   ?f <- (foo (bar ?n))
   (a ?x)
  =>
   (printout t ?n crlf)
   (modify ?f (bar (+ ?n 1))) )

(assert (foo))
(assert (a 1))
(assert (a 2))
(run)
;;;

Now, why does the rule only fire once? There are two 'a' facts 
there.


Henrique


To unsubscribe, send the words 'unsubscribe jess-users
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>'
in the BODY of a message to [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>, NOT to the list
(use your own address!) List problems? Notify
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>.







--
- - - - - -  -  -  -  -  -   -   -
Henrique Lopes Cardoso
DEEC/FEUP
Rua Dr. Roberto Frias | 4200-465 Porto
PORTUGAL
(+351)225081400 ext.1315
[EMAIL PROTECTED] | www.fe.up.pt/~hlc
- - - - - -  -  -  -  -  -   -   -


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 no-loop?

2007-12-21 Thread Henrique Lopes Cardoso
Ok, I understand your technical explanation. I just think it would make 
more sense to prevent the rule from firing only *for the same facts*.


Is there a way of achieving what I want? That is, for the example given, 
rule 'r' should fire twice, once for each 'a' fact.
The problem is that I cannot remove the no-loop declaration, otherwise 
slot-specific is not enough to prevent a cyclic firing on the same 'a' 
fact, since the modified slot 'bar' is being referred to in the pattern 
(and needs to be, because I need to increment it).


Any idea?

Thanks.

Henrique


Ernest Friedman-Hill wrote:
When you modify a fact, the fact is removed from working memory, 
changed, and put back. In the process, all activations that depend on 
that fact are re-evaluated. no-loop guarantees that this rule will not 
be activated based on anything this rule does on its RHS. Therefore, 
the rule is activated once for each "a" fact, but when it fires the 
first time, the second activation is removed during the modify, and 
not put back because of the no-loop.


On Dec 20, 2007 10:23 AM, Henrique Lopes Cardoso <[EMAIL PROTECTED] 
<mailto:[EMAIL PROTECTED]>> wrote:


Hi,

This e-mail is a follow-up on the issue related to slot-specific
that I
discussed a couple of days ago. I am using Jess 71b1

I am trying to figure out how to properly use slot-specific and/or
no-loop.
I now got to the following simple example:

;;;
(deftemplate foo
   (declare (slot-specific TRUE))
   (slot bar (default 0)) )

(defrule r
   (declare (no-loop TRUE))
   ?f <- (foo (bar ?n))
   (a ?x)
  =>
   (printout t ?n crlf)
   (modify ?f (bar (+ ?n 1))) )

(assert (foo))
(assert (a 1))
(assert (a 2))
(run)
;;;

Now, why does the rule only fire once? There are two 'a' facts there.

Henrique


To unsubscribe, send the words 'unsubscribe jess-users
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>'
in the BODY of a message to [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>, NOT to the list
(use your own address!) List problems? Notify
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>.
--------




--
- - - - - -  -  -  -  -  -   -   -
Henrique Lopes Cardoso
DEEC/FEUP
Rua Dr. Roberto Frias | 4200-465 Porto
PORTUGAL
(+351)225081400 ext.1315
[EMAIL PROTECTED] | www.fe.up.pt/~hlc
- - - - - -  -  -  -  -  -   -   -


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: Pattern matching with implicit slot variable

2007-12-21 Thread Henrique Lopes Cardoso
I just found a problem with pattern usage in rules. The following code 
works fine in Jess 70p1, but does not work with 71b1.

Did I miss something in the change log?

;;;
(deftemplate person
(slot firstName) (slot lastName) (slot age))

(defrule teenager
(person {age > 12 && age < 20} (firstName ?name))
   =>
(printout t ?name " is " ?age " years old." crlf) )

(assert (person (age 15) (firstName Maria)))
;;;

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]




JESS: Problem with no-loop?

2007-12-20 Thread Henrique Lopes Cardoso

Hi,

This e-mail is a follow-up on the issue related to slot-specific that I 
discussed a couple of days ago. I am using Jess 71b1


I am trying to figure out how to properly use slot-specific and/or no-loop.
I now got to the following simple example:

;;;
(deftemplate foo
   (declare (slot-specific TRUE))
   (slot bar (default 0)) )

(defrule r
   (declare (no-loop TRUE))
   ?f <- (foo (bar ?n))
   (a ?x)
  =>
   (printout t ?n crlf)
   (modify ?f (bar (+ ?n 1))) )

(assert (foo))
(assert (a 1))
(assert (a 2))
(run)
;;;

Now, why does the rule only fire once? There are two 'a' facts there.

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]




Re: JESS: Problem with slot-specific

2007-12-18 Thread Henrique Lopes Cardoso

I would expect them to be.

Henrique


Ernest Friedman-Hill wrote:


No, it's not inherited. Backchain-reactivity was never inheritable, 
either. Should they both be?



On Dec 17, 2007, at 2:01 PM, Henrique Lopes Cardoso wrote:


Hi,

Is the slot-specific declaration not inherited by a sub-deftemplate?
I tested the following:

;;;
(deftemplate D
   (declare (slot-specific TRUE))
   (slot B))

(deftemplate D1 extends D)

(defrule R1
   ?d <- (D1)
   =>
   (printout t "R1 modifying..." crlf)
   (modify ?d (B 3)))

(defmodule m)

(defrule m::R2
   (declare (auto-focus TRUE))
   ?d <- (D1)
   =>
   (printout t "R2" crlf))
;;;

It turns out that rule R2 fires twice (before and after R1).
If D is used directly inside rules R1 and R2, slot-specific works 
fine, and R2 fires only once, before R1 (because of auto-focus).


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
Informatics & Decision Sciences  Phone: (925) 294-2154
Sandia National LabsFAX:   (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://www.jessrules.com


To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify 
[EMAIL PROTECTED]

----




--
- - - - - -  -  -  -  -  -   -   -
Henrique Lopes Cardoso
DEEC/FEUP
Rua Dr. Roberto Frias | 4200-465 Porto
PORTUGAL
(+351)225081400 ext.1315
[EMAIL PROTECTED] | www.fe.up.pt/~hlc
- - - - - -  -  -  -  -  -   -   -


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: Problem with slot-specific

2007-12-18 Thread Henrique Lopes Cardoso

Hi,

Is the slot-specific declaration not inherited by a sub-deftemplate?
I tested the following:

;;;
(deftemplate D
   (declare (slot-specific TRUE))
   (slot B))

(deftemplate D1 extends D)

(defrule R1
   ?d <- (D1)
   =>
   (printout t "R1 modifying..." crlf)
   (modify ?d (B 3)))

(defmodule m)

(defrule m::R2
   (declare (auto-focus TRUE))
   ?d <- (D1)
   =>
   (printout t "R2" crlf))
;;;

It turns out that rule R2 fires twice (before and after R1).
If D is used directly inside rules R1 and R2, slot-specific works fine, 
and R2 fires only once, before R1 (because of auto-focus).


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]




JESS: Function <> - documentation bug?

2007-11-09 Thread Henrique Lopes Cardoso

Hi,

Using Jess 7.1a3 I get the following behaviour (the same with 7.0p1):

Jess> (<> 1 2 3)
TRUE
Jess> (<> 1 2 2)
FALSE
Jess> (<> 1 1 2)
FALSE
Jess> (<> 1 2 1)
TRUE

But the documentation reads: "Returns TRUE if the value of the first 
argument is not equal in value to all subsequent arguments; otherwise 
returns FALSE."


Is this a documentation bug?

Cheers,

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]




Re: JESS: Jess editor

2007-10-12 Thread Henrique Lopes Cardoso
Hi,

Just wondering if there were any news related with this subject. I am
editing a Jess file and the problem is quite annoying.
Eclipse just crashes randomly when saving my jess file.

Henrique


Jing Xu wrote:
> I found the same problem...the symptoms are the same. And I found the
> editor tends to freeze when I save to a jess file with multiple errors
> in it. 
> When I reopen Eclipse, the editor works fine for a couple of saves and
> then freeze again. I don't have a certain condition to make it happen
> though.
>
> Jing
>
>
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> On Behalf Of Henrique Lopes Cardoso
> Sent: Friday, June 29, 2007 7:29 AM
> To: jess-users@sandia.gov
> Subject: Re: JESS: Jess editor
>
>
> When saving a Jess file, Eclipse stops responding.
> I don't know if it helps, but after a forced close I get a log as
> attached to this e-mail.
>
> Unfortunately, I tried to understand when it happens, but I could not
> find it. It looks pretty random... But when I get the problem, I get it
> many consecutive times.
>
> It seems to happen only if a .java file is open, but I cannot tell this
> for sure.
>
> If I find any clues, I'll let you know.
>
> Henrique
>
>
>
> Andrei Boutyline wrote:
>   
>> I had this exact problem as well, though I never reported it because I
>> 
>
>   
>> blamed it on a mess of partially uninstalled Eclipse plugins. Deleting
>> 
>
>   
>> my Eclipse directory and reinstalling the Jess plugin fixed it for me,
>> 
>
>   
>> though that is hardly a solid solution.
>>  
>> Andrei
>>
>> --
>> --
>> *From:* [EMAIL PROTECTED]
>> [mailto:[EMAIL PROTECTED] *On Behalf Of *Jason Morris
>> *Sent:* Thursday, June 28, 2007 3:50 PM
>> *To:* jess-users@sandia.gov
>> *Subject:* Re: JESS: Jess editor
>>
>> Hey Ernest,
>>  
>> This sounds like my gremlin that I mentioned to you earlier.
>>  
>> Hopefully Henrique can get you a concrete example.  There never were 
>> any error messages that I could see.  The Jess editor just *froze* 
>> when the Save command was executed.  At first I thought that it was 
>> related to the file's code containing errors, but then it started 
>> hanging for perfectly parsed files.
>>  
>> I have some major Jess coding coming up, so I will be alert to any 
>> logs, error messages, or other data I can get for you.
>>  
>> Cheers,
>> Jason
>>
>>  
>> On 6/28/07, *Ernest Friedman-Hill* <[EMAIL PROTECTED] 
>> <mailto:[EMAIL PROTECTED]>> wrote:
>>
>>
>> On Jun 28, 2007, at 1:02 PM, Henrique Lopes Cardoso wrote:
>>
>> > Hi,
>> >
>> > I am using Eclipse SDK (Version: 3.2.1, Build id:
>> 
> M20060921-0945)
>   
>> > together with Jess70p1.
>> > The Jess editor crashes frequently, especially when I save a
>> 
> Jess
>   
>> > file.
>>
>> I think there was another report of something similar, but I
>> 
> wasn't
>   
>> able to reproduce it. Can you make it happen reliably? What kind
>> 
> of
>   
>> crash is it? Do you get any stack traces or error messages from
>> Eclipse?
>>
>> -
>> Ernest Friedman-Hill
>> Advanced Software Research  Phone: (925) 294-2154
>> Sandia National LabsFAX:   (925) 294-2234
>> PO Box 969, MS 9012 [EMAIL PROTECTED]
>> <mailto:[EMAIL PROTECTED]>
>> Livermore, CA 94550 http://www.jessrules.com
>>
>>
>> 
> 
>   
>> To unsubscribe, send the words 'unsubscribe jess-users
>> [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>'
>> in the BODY of a message to [EMAIL PROTECTED]
>> <mailto:[EMAIL PROTECTED]>, NOT to the list
>> (use your own address!) List problems? Notify
>> [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>.
>> 
>> 
>>
>>
>>
>>
>> --
>> ---
>> Jason Morris
>> Morris Technical Solutions LLC
>> http://www.morris-technical-solutions.com 
>> 
>
>   

-- 
- - - - - -  -  -  -  -  -   -   -
Henrique Lopes Cardoso
DEEC/FEUP
Rua Dr. Roberto Frias | 4200-465 Porto
PORTUGAL
(+351)225081400 ext.1315
[EMAIL PROTECTED] | www.fe.up.pt/~hlc
- - - - - -  -  -  -  -  -   -   -


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: Defmodule vs. defrule

2007-07-20 Thread Henrique Lopes Cardoso
I believe this was the second time you give me this kind of answer :).
But I don't see any improvements in Jess71a2...
Can I expect undefmodule and module-related events to be added in the
next alpha version?

Thanks.

Henrique


Ernest Friedman-Hill wrote:
> That could be added.
>
> On Jul 4, 2007, at 6:39 AM, Henrique Lopes Cardoso wrote:
>
>> I am replying to an old post of mine. It referred to the absence of a
>> method to undefine a module.
>> Now I have just realized that in the JessEvent class there isn't a way
>> of being notified of a DEFMODULE event. Why is that?
>>
>> It would seem to me that just as it is possible to add/remove/be
>> notified about defrules, the same should be possible with defmodules.
>>
>> Henrique
>>
>>
>> Henrique Lopes Cardoso wrote:
>>> friedman_hill ernest j wrote:
>>>> I think Henrique Lopes Cardoso wrote:
>>>> [Charset iso-8859-1 unsupported, filtering to ASCII...]
>>>>
>>>>> Hello,
>>>>>
>>>>> I was looking for an "undefmodule" function in Jess, but could not
>>>>> find it.
>>>>> How can I undefine a module? Does it need to be empty? That is, with
>>>>> no rules or facts?
>>>>>
>>>>>
>>>>
>>>> There isn't one. I could record this as a request for enhancement; can
>>>> you explain why it would be useful?
>>>>
>>> In my system, modules can be created at run-time in the RHS of rules,
>>> and rules are added to them. A module has a lifetime at the end of
>>> which it should be removed.
>>> Therefore, I would appreciate if I could have an "undefmodule"
>>> function.
>>>
>>> A shorter answer to your question would be: why is the undefrule
>>> useful?
>>>
>>> Thanks.
>>>
>>> Henrique
>>>>
>>>> -
>>>> 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]
>>>> 
>>>>
>>>>
>>>>
>>>
>>
>> -- 
>> - - - - - -  -  -  -  -  -   -   -
>> Henrique Lopes Cardoso
>> DEEC/FEUP
>> Rua Dr. Roberto Frias | 4200-465 Porto
>> PORTUGAL
>> (+351)225081400 ext.1315
>> [EMAIL PROTECTED] | www.fe.up.pt/~hlc
>> - - - - - -  -  -  -  -  -   -   -
>>
>> 
>> 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://www.jessrules.com
>
> 
> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the list
> (use your own address!) List problems? Notify
> [EMAIL PROTECTED]
> 
>
>

-- 
- - - - - -  -  -  -  -  -   -   -
Henrique Lopes Cardoso
DEEC/FEUP
Rua Dr. Roberto Frias | 4200-465 Porto
PORTUGAL
(+351)225081400 ext.1315
[EMAIL PROTECTED] | www.fe.up.pt/~hlc
- - - - - -  -  -  -  -  -   -   -


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: defqueries with bload - bug in Jess71a2

2007-07-20 Thread Henrique Lopes Cardoso
Hi,

This problem got into my way when I upgraded to Jess71a2. There was no
problem with 70p1.

I have this Jess file:
;---
(deftemplate a (slot s1) (slot s2))

(defquery MAIN::q (declare (variables ?id))
?z <- (a (s1 ?id) (s2 ?s2)))

(assert (a (s1 qwe) (s2 asd)))
;---

Now, if I batch() this file into a Rete object, the query works fine. If
I bload this file (previously saved with bsave), the defquery stops
working. When I do
QueryResult qr = jess.runQueryStar("MAIN::q", new
ValueVector().add("qwe"));
and then do qr.next(), this method returns false and qr is null, which I
believe means no match was found by the query.

The problem seems to be related to the (a ...) fact, since if my file
does not include it and I assert it after bload, it works fine.

I repeat: the problem was not there with Jess70p1.

Cheers,

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]




JESS: Userfunctions - memory leak?

2007-07-10 Thread Henrique Lopes Cardoso
Hi,

I thought that this problem was solved before, but I am still getting
it. I am using the stable version Jess70p1.
If I remove a Userfunction and then add it again, it stops working and
throws an exception.

E.g.:
//---
Rete jess = new Rete();
FileReader fr = new FileReader("lixo.clp");
Jesp j = new Jesp(fr, jess);
j.parse(false);
fr.close();

jess.addUserfunction(new UF());
   
jess.eval("(assert (a (s 1)))");
jess.run();
   
Userfunction uf = jess.findUserfunction("uf");
jess.removeUserfunction("uf");
jess.addUserfunction(uf);
   
jess.eval("(assert (a (s 2)))");
jess.run();
//---

; Contens of lixo.clp:
(deftemplate a (slot s))
(defrule r (a) => (uf))
;

>From the second run() call, I am getting:
//
Exception in thread "main" Jess reported an error in routine uf
while executing (uf)
while executing defrule MAIN::r.
  Message: undefined function uf.
at jess.FunctionHolder$UndefinedFunction.call(FunctionHolder.java:54)
at jess.FunctionHolder.call(FunctionHolder.java:35)
at jess.Funcall.execute(Funcall.java:320)
at jess.Defrule.fire(Defrule.java:322)
at jess.Activation.fire(Activation.java:97)
at jess.Agenda.run(Agenda.java:280)
at jess.Agenda.run(Agenda.java:256)
at jess.Rete.run(Rete.java:1505)
at jess.Rete.run(Rete.java:1500)
at UF.main(UF.java:44)


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]




Re: JESS: Problem with bload and System functions

2007-07-09 Thread Henrique Lopes Cardoso
What a nice discussion on the subject!
I am using the stable Jess70p1 version, and so I got the problem. Using
the (call System currentTimeMillis) version fixed the problem.

Henrique


Ernest Friedman-Hill wrote:
>
> On Jul 7, 2007, at 4:57 PM, Wolfgang Laun wrote:
>
>> The same problem occurs when running bin/jess, and (most likely) with
>> any other of the import-ed things...
>>
>
> Thanks for your persistence. It turns out that this issue has already
> been reported and fixed for the next release, and that's why I wasn't
> able to reproduce it with our working version. If I run a copy of the
> 7.1a1 release, then I do indeed see the problem too. As I said, it's
> already been fixed, and I believe we'll see 7.1a2 this week.
>
>
> -
> 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://www.jessrules.com
>
> 
> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the list
> (use your own address!) List problems? Notify
> [EMAIL PROTECTED]
> --------
>
>

-- 
- - - - - -  -  -  -  -  -   -   -
Henrique Lopes Cardoso
DEEC/FEUP
Rua Dr. Roberto Frias | 4200-465 Porto
PORTUGAL
(+351)225081400 ext.1315
[EMAIL PROTECTED] | www.fe.up.pt/~hlc
- - - - - -  -  -  -  -  -   -   -


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: Issues on JessEvents

2007-07-09 Thread Henrique Lopes Cardoso
Hi,

1.
The JessEvent.getObject documentation is wrong: for a DEFRULE_FIRED
event the object is an Activation, not a Defrule.

2.
I have extended the Rete class, and have implemented both
eventHappened(JessEvent) and aboutToFire(Activation).
The thing is: when a rule fires, first I get the JessEvent.DEFRULE_FIRED
event in eventHappened, and only then I get the aboutToFire invocation.
Shouldn't it be the other way around?

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]




Re: JESS: Problem with JessListener

2007-07-06 Thread Henrique Lopes Cardoso
I've figured it out.
It's a long story...
There is no problem with JessListener or JessEvents (at least not directly).
It is hard to explain, or even to understand, but I'll give it a shot.

My bsaved file had Userfunctions, which were Serializable. But the
userfunctions had a reference to an Object whose existence was lost
before the test with bloading was made. Although the userfunctions were
*not* used after bload and while doing the events tests, this was
causing the problem. Remember that the problem was not getting asserted
fact events, only retracted fact events. :|

I cannot explain it better... It is hard to understand. (I am not 
giving you the full details of my efforts, which are quite intricate.)

Anyway, I solved it by removing the Java userfunctions before bsaving,
and (optionally, since I am not using it in these tests) adding them
after bloading.

Now I got to a potentially related problem, but since it is different
from this one, I am reporting it in a separate thread.

Henrique


Ernest Friedman-Hill wrote:
> It's a puzzle to me, too. If you want to send me (not the list) the
> bsaved file, and let me know what version of Jess you're working with,
> I can have a look at it.
>
> On Jul 5, 2007, at 8:08 AM, Henrique Lopes Cardoso wrote:
>
>> No, that is not the case.
>> I tried this:
>> jel.assertString("(qwe)");
>> jel.retractString("(qwe)");
>> jel.assertString("(qwe)");
>>
>> and it still doesn't work. I only get the retract event.
>> There must be something else going on in the bsaved file. Any clue?
>>
>> Henrique
>>
>>
>> Ernest Friedman-Hill wrote:
>>> One explanation consistent with your observations is that the bsaved
>>> file already contains (qwe) and (asd) facts. If you attempt to assert
>>> a fact that already exists in working memory, the assert method
>>> returns FALSE and no event is sent.
>>>
>>>
>>> On Jul 5, 2007, at 5:47 AM, Henrique Lopes Cardoso wrote:
>>>
>>>> I just extended Rete to make the example simpler. I also tried it with
>>>> an independent JessListener implementing class, but the problem is
>>>> the same.
>>>>
>>>> I tried to do Rete.addJessListener() after bload, just as you
>>>> suggested,
>>>> but the problem remains.
>>>>
>>>> So, I ask again: what could be wrong in my bsaved file that prevents
>>>> some JessEvents from being notified?
>>>>
>>>> Henrique
>>>>
>>>>
>>>> Jonathan Sewall wrote:
>>>>> I didn't extend Rete just to create a JessListener, but I did find
>>>>> that I needed to reregister my listeners after bload.
>>>>> Henrique Lopes Cardoso wrote:
>>>>>> I am stumbling for some time now with the use of a JessListener.
>>>>>> After
>>>>>> many tries, I figured out that the listener does not work properly
>>>>>> when
>>>>>> I bload() certain files.
>>>>>>
>>>>>> Since the Rete class implements JessListener, for ease of testing I
>>>>>> extended it and got to the class below.
>>>>>> From my experiences, if the bsave file is empty, it works fine. If
>>>>>> I use
>>>>>> another bsaved file that I have, I get problems. Only the retracted
>>>>>> facts are being notified.
>>>>>>
>>>>>> Is this a bug? What should I look for in my bsaved file?
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>> Henrique
>>>>>>
>>>>>> //-
>>>>>> public class JEL extends Rete {
>>>>>> public JEL() {
>>>>>> super();
>>>>>> // set event mask
>>>>>> setEventMask(JessEvent.FACT);
>>>>>> // load file
>>>>>> try {
>>>>>> FileInputStream fis = new
>>>>>> FileInputStream("somefile.bsave");
>>>>>> bload(fis);
>>>>>> fis.close();
>>>>>> } catch (ClassNotFoundException cnfe) {
>>>>>> cnfe.printStackTrace();
>>>>>> } catch (IOException ioe) {
>>>>

JESS: Problem with bload and System functions

2007-07-06 Thread Henrique Lopes Cardoso
Hi,

If I bload a file (even an empty one), I get an "Error during execution"
when executing (System.currentTimeMillis).

Here's my code:

Rete jess = new Rete();
FileInputStream fis = new FileInputStream("the_file.bsave");
jess.bload(fis);
fis.close();
jess.eval("(System.currentTimeMillis)");

It works fine if I read a .clp jess file using Jesp.

Henrique

-- 
- - - - - -  -  -  -  -  -   -   -
Henrique Lopes Cardoso
DEEC/FEUP
Rua Dr. Roberto Frias | 4200-465 Porto
PORTUGAL
(+351)225081400 ext.1315
[EMAIL PROTECTED] | www.fe.up.pt/~hlc
- - - - - -  -  -  -  -  -   -   -


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 JessListener

2007-07-05 Thread Henrique Lopes Cardoso
No, that is not the case.
I tried this:
jel.assertString("(qwe)");
jel.retractString("(qwe)");
jel.assertString("(qwe)");

and it still doesn't work. I only get the retract event.
There must be something else going on in the bsaved file. Any clue?

Henrique


Ernest Friedman-Hill wrote:
> One explanation consistent with your observations is that the bsaved
> file already contains (qwe) and (asd) facts. If you attempt to assert
> a fact that already exists in working memory, the assert method
> returns FALSE and no event is sent.
>
>
> On Jul 5, 2007, at 5:47 AM, Henrique Lopes Cardoso wrote:
>
>> I just extended Rete to make the example simpler. I also tried it with
>> an independent JessListener implementing class, but the problem is
>> the same.
>>
>> I tried to do Rete.addJessListener() after bload, just as you suggested,
>> but the problem remains.
>>
>> So, I ask again: what could be wrong in my bsaved file that prevents
>> some JessEvents from being notified?
>>
>> Henrique
>>
>>
>> Jonathan Sewall wrote:
>>> I didn't extend Rete just to create a JessListener, but I did find
>>> that I needed to reregister my listeners after bload.
>>> Henrique Lopes Cardoso wrote:
>>>> I am stumbling for some time now with the use of a JessListener. After
>>>> many tries, I figured out that the listener does not work properly
>>>> when
>>>> I bload() certain files.
>>>>
>>>> Since the Rete class implements JessListener, for ease of testing I
>>>> extended it and got to the class below.
>>>> From my experiences, if the bsave file is empty, it works fine. If
>>>> I use
>>>> another bsaved file that I have, I get problems. Only the retracted
>>>> facts are being notified.
>>>>
>>>> Is this a bug? What should I look for in my bsaved file?
>>>>
>>>> Thanks.
>>>>
>>>> Henrique
>>>>
>>>> //-
>>>> public class JEL extends Rete {
>>>> public JEL() {
>>>> super();
>>>> // set event mask
>>>> setEventMask(JessEvent.FACT);
>>>> // load file
>>>> try {
>>>> FileInputStream fis = new
>>>> FileInputStream("somefile.bsave");
>>>> bload(fis);
>>>> fis.close();
>>>> } catch (ClassNotFoundException cnfe) {
>>>> cnfe.printStackTrace();
>>>> } catch (IOException ioe) {
>>>> ioe.printStackTrace();
>>>> }
>>>> }
>>>>public void eventHappened(JessEvent jev) {
>>>> System.out.println("EVENT:" +
>>>> JessEvent.getEventName(jev.getType()));
>>>> switch(jev.getType()) {
>>>> case JessEvent.FACT | JessEvent.REMOVED:   // retraction
>>>> Fact whatWasRetracted = (Fact) jev.getObject();
>>>> <System.out.println("- - -" + whatWasRetracted);
>>>> break;
>>>> case JessEvent.FACT:   // assertion
>>>> Fact whatWasAsserted = (Fact) jev.getObject();
>>>> System.out.println("+ + +" + whatWasAsserted);
>>>> break;
>>>> }
>>>> }
>>>>public static void main(String args[]) {
>>>> JEL jel = new JEL();
>>>> try {
>>>> jel.assertString("(qwe)");
>>>> jel.retractString("(qwe)");
>>>> jel.assertString("(asd)");
>>>> } catch(JessException je) {
>>>> je.printStackTrace();
>>>> }
>>>> }
>>>>}
>>>> //--
>>>>
>>>>
>>>>
>>>> 
>>>> 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: Module and Concurrency

2007-07-05 Thread Henrique Lopes Cardoso
What if you make the Dispatcher rule an auto-focus one?

Actually, I thought about this kind of problems before. I mean, if there
are two modules with auto-focus rules, and rules in both modules are
activated, which module gets focus? Is it related with the conflict
resolution strategy being used? If so, can this be "controlled" using
salience? I.e., the module where the activated rule with greater
salience is gets the focus?

Henrique


folderman wrote:
> Thank you very much for the quick response first of all.
>
> Actually, I'm not using the "auto-focus" keyword, instead I would focus a
> specific module in my code based on the incoming fact. 
>
> Suppose I have rules on a Fact (typed "FactX") in both ModuleA and ModuleB,
> i.e.
>
> (deftemplate MAIN::FactX
>(declare (from-class test.FactX)
>   (slot-specific TRUE)))
>
> (defrule MAIN::Dispatcher 
>"Dispatcher" 
>?context <- (MAIN::FactX(OBJECT ?contextObject) (env ?env1)) 
>=> 
>(focus ?env1))
>
> (defrule ModuleA::RulesA 
>"Dispatcher" 
>?context <- (MAIN::FactX(OBJECT ?contextObject) (env ?env1)) 
>=> 
>(print "running in moduleA"))
>
> (defrule ModuleB::RulesB
>"Dispatcher" 
>?context <- (MAIN::FactX(OBJECT ?contextObject) (env ?env1)) 
>=> 
>(print "running in moduleB"))
>
> So my concern would be that, would there be chances for a FactX with the
> "env" attribute = "ModuleB", would get running in ModuleA, when it is
> asserted into the rule engine while there is another fact already running in
> ModuleA and thus the current focus "ModuleA" during the assert time?
>
> What's more is that there might be more than 1 rules in the modules, and
> would the fact triggering the rules in the other module during execution?
>
> Thank you very much!!
>
> Best Regards,
> folderman
>
>
>
> Ernest Friedman-Hill wrote:
>   
>> If a rule is declared as "auto-focus", then when it is activated, it  
>> will change the focus module to its own module. But in the absence of  
>> this declaration, an activated rule in a non-focused module will just  
>> sit and wait for its module to be focused again; it will not fire  
>> immediately,
>>
>>
>> On Jul 3, 2007, at 11:26 PM, folderman wrote:
>>
>> 
>>> Hi everyone,
>>>
>>> I'm currently integrating JESS into my web application and the  
>>> architecture
>>> is typical; running rete.runUntilHalt() and asserting a shadow fact  
>>> for an
>>> incoming HTTP request. But as more and more rules are developed, I'm
>>> thinking to partition the rules into modules.
>>>
>>> Now, suppose I have 2 module, moduleA and moduleB, and some rules are
>>> defined to match the same set of shadow facts on the LHS. In  
>>> essence, I
>>> could "switch" the execution logic by either focusing moduleA or  
>>> moduleB,
>>> and the decision for which module gaining control is depends on the  
>>> screen
>>> the user is in.
>>>
>>> However, there is an incoming the fact which should be running in  
>>> moduleB
>>> but there might be chances that rule engine is processing another  
>>> requests
>>> and moduleA is the current focus; if the incoming fact is assert at  
>>> that
>>> time, it might be running moduleA instead of moduleB.
>>>
>>> So, might I confirm if the above scenario would happen? Is there any
>>> workarounds to avoid the unnatural execution? What would be the  
>>> orthodox way
>>> to implement the module control flow then? Any help or opinion  
>>> would be
>>> appreciated.
>>>
>>> Thank you very much, everybody!!
>>>
>>> Best Regards,
>>> folderman
>>>
>>> -- 
>>> View this message in context: http://www.nabble.com/Module-and- 
>>> Concurrency-tf402.html#a11424331
>>> Sent from the Jess mailing list archive at Nabble.com.
>>>
>>> 
>>> To unsubscribe, send the words 'unsubscribe jess-users  
>>> [EMAIL PROTECTED]'
>>> in the BODY of a message to [EMAIL PROTECTED], NOT to the list
>>> (use your own address!) List problems? Notify owner-jess- 
>>> [EMAIL PROTECTED]
>>> --------
>>>   
>> --

Re: JESS: Problem with JessListener

2007-07-05 Thread Henrique Lopes Cardoso
I just extended Rete to make the example simpler. I also tried it with
an independent JessListener implementing class, but the problem is the same.

I tried to do Rete.addJessListener() after bload, just as you suggested,
but the problem remains.

So, I ask again: what could be wrong in my bsaved file that prevents
some JessEvents from being notified?

Henrique


Jonathan Sewall wrote:
> I didn't extend Rete just to create a JessListener, but I did find
> that I needed to reregister my listeners after bload.
> Henrique Lopes Cardoso wrote:
>> I am stumbling for some time now with the use of a JessListener. After
>> many tries, I figured out that the listener does not work properly when
>> I bload() certain files.
>>
>> Since the Rete class implements JessListener, for ease of testing I
>> extended it and got to the class below.
>> From my experiences, if the bsave file is empty, it works fine. If I use
>> another bsaved file that I have, I get problems. Only the retracted
>> facts are being notified.
>>
>> Is this a bug? What should I look for in my bsaved file?
>>
>> Thanks.
>>
>> Henrique
>>
>> //-
>> public class JEL extends Rete {
>> public JEL() {
>> super();
>> // set event mask
>> setEventMask(JessEvent.FACT);
>> // load file
>> try {
>> FileInputStream fis = new FileInputStream("somefile.bsave");
>> bload(fis);
>> fis.close();
>> } catch (ClassNotFoundException cnfe) {
>> cnfe.printStackTrace();
>> } catch (IOException ioe) {
>> ioe.printStackTrace();
>> }
>> }
>>public void eventHappened(JessEvent jev) {
>> System.out.println("EVENT:" +
>> JessEvent.getEventName(jev.getType()));
>> switch(jev.getType()) {
>> case JessEvent.FACT | JessEvent.REMOVED:   // retraction
>> Fact whatWasRetracted = (Fact) jev.getObject();
>> System.out.println("- - -" + whatWasRetracted);
>> break;
>> case JessEvent.FACT:   // assertion
>> Fact whatWasAsserted = (Fact) jev.getObject();
>> System.out.println("+ + +" + whatWasAsserted);
>> break;
>> }
>> }
>>public static void main(String args[]) {
>> JEL jel = new JEL();
>> try {
>> jel.assertString("(qwe)");
>> jel.retractString("(qwe)");
>> jel.assertString("(asd)");
>> } catch(JessException je) {
>> je.printStackTrace();
>> }
>> }
>>}
>> //--
>>
>>
>>
>> 
>> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
>> in the BODY of a message to [EMAIL PROTECTED], NOT to the list
>> (use your own address!) List problems? Notify
>> [EMAIL PROTECTED]
>> ----
>>
>>
>>   
>
> 
> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the list
> (use your own address!) List problems? Notify
> [EMAIL PROTECTED]
> 
>
>

-- 
- - - - - -  -  -  -  -  -   -   -
Henrique Lopes Cardoso
DEEC/FEUP
Rua Dr. Roberto Frias | 4200-465 Porto
PORTUGAL
(+351)225081400 ext.1315
[EMAIL PROTECTED] | www.fe.up.pt/~hlc
- - - - - -  -  -  -  -  -   -   -


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: Problem with JessListener

2007-07-04 Thread Henrique Lopes Cardoso
I am stumbling for some time now with the use of a JessListener. After
many tries, I figured out that the listener does not work properly when
I bload() certain files.

Since the Rete class implements JessListener, for ease of testing I
extended it and got to the class below.
>From my experiences, if the bsave file is empty, it works fine. If I use
another bsaved file that I have, I get problems. Only the retracted
facts are being notified.

Is this a bug? What should I look for in my bsaved file?

Thanks.

Henrique

//-
public class JEL extends Rete {
public JEL() {
super();
// set event mask
setEventMask(JessEvent.FACT);
// load file
try {
FileInputStream fis = new FileInputStream("somefile.bsave");
bload(fis);
fis.close();
} catch (ClassNotFoundException cnfe) {
cnfe.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
   
public void eventHappened(JessEvent jev) {
System.out.println("EVENT:" +
JessEvent.getEventName(jev.getType()));
switch(jev.getType()) {
case JessEvent.FACT | JessEvent.REMOVED:   // retraction
Fact whatWasRetracted = (Fact) jev.getObject();
System.out.println("- - -" + whatWasRetracted);
break;
case JessEvent.FACT:   // assertion
Fact whatWasAsserted = (Fact) jev.getObject();
System.out.println("+ + +" + whatWasAsserted);
break;
}
}
   
public static void main(String args[]) {
JEL jel = new JEL();
try {
jel.assertString("(qwe)");
jel.retractString("(qwe)");
jel.assertString("(asd)");
} catch(JessException je) {
je.printStackTrace();
}
}
   
}
//--




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: Defmodule vs. defrule

2007-07-04 Thread Henrique Lopes Cardoso
I am replying to an old post of mine. It referred to the absence of a
method to undefine a module.
Now I have just realized that in the JessEvent class there isn't a way
of being notified of a DEFMODULE event. Why is that?

It would seem to me that just as it is possible to add/remove/be
notified about defrules, the same should be possible with defmodules.

Henrique


Henrique Lopes Cardoso wrote:
> friedman_hill ernest j wrote:
>> I think Henrique Lopes Cardoso wrote:
>> [Charset iso-8859-1 unsupported, filtering to ASCII...]
>>  
>>> Hello,
>>>
>>> I was looking for an "undefmodule" function in Jess, but could not
>>> find it.
>>> How can I undefine a module? Does it need to be empty? That is, with
>>> no rules or facts?
>>>
>>> 
>>
>> There isn't one. I could record this as a request for enhancement; can
>> you explain why it would be useful?
>>   
> In my system, modules can be created at run-time in the RHS of rules,
> and rules are added to them. A module has a lifetime at the end of
> which it should be removed.
> Therefore, I would appreciate if I could have an "undefmodule" function.
>
> A shorter answer to your question would be: why is the undefrule useful?
>
> Thanks.
>
> Henrique
>>
>> -
>> 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]
>> 
>>
>>
>>   
>

-- 
- - - - - -  -  -  -  -  -   -   -
Henrique Lopes Cardoso
DEEC/FEUP
Rua Dr. Roberto Frias | 4200-465 Porto
PORTUGAL
(+351)225081400 ext.1315
[EMAIL PROTECTED] | www.fe.up.pt/~hlc
- - - - - -  -  -  -  -  -   -   -


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: Jess editor

2007-06-28 Thread Henrique Lopes Cardoso
Hi,

I am using Eclipse SDK (Version: 3.2.1, Build id: M20060921-0945)
together with Jess70p1.
The Jess editor crashes frequently, especially when I save a Jess file.

Is anyone having similar problems? Is there a known way to fix this?

Henrique

-- 
- - - - - -  -  -  -  -  -   -   -
Henrique Lopes Cardoso
DEEC/FEUP
Rua Dr. Roberto Frias | 4200-465 Porto
PORTUGAL
(+351)225081400 ext.1315
[EMAIL PROTECTED] | www.fe.up.pt/~hlc
- - - - - -  -  -  -  -  -   -   -


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: On mark and resetToMark

2007-06-22 Thread Henrique Lopes Cardoso
Hi,

I tried this at Jess prompt:

(reset)
(assert (a))
(bind ?m (engine mark))
(assert (b))
(engine resetToMark ?m)
(facts)

At the end, fact (b) is still there. Shouldn't it be retracted with
resetToMark?

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]




JESS: Re: Real deftemplate of extended fact - Solved it!

2007-06-18 Thread Henrique Lopes Cardoso
Hi,

Just to let you know that I solved my own problem.
I had not realized that with a query like

(defquery q
(declare (variables ?foo))
?x <- (t (foo ?foo))
)

I can access variable ?x and turn it into a fact object (although I have
done it before). I then did something like:

QueryResult qr = jess.runQueryStar("q", new ValueVector().add(1));
qr.next();
qr.get("x").factValue(engine.getGlobalContext()).getDeftemplate().getBaseName()

Is there an easier way to do it?

Henrique



Henrique Lopes Cardoso wrote:
> Hi,
>
> I am trying to get the real deftemplate of a fact belonging to a
> sub-deftemplate. Something like this:
>
> (deftemplate t
> (slot foo) )
> (deftemplate t1 extends t
> (slot bar))
> (deftemplate t2 extends t
> (slot qwe))
>
> ; The facts
> (t1 (foo 1) (bar 2))
> (t2 (foo 2) (qwe 1))
>
> Now, I am trying to get the real deftemplate name for a fact:
>
> (defrule r
> (t (foo 1))
> =>
> (printout t "The real deftemplate name for this fact is "
> ???t1_or_t2??? crlf))
>
> I want to get this from Java, so I thought of defining a defquery and
> access its results (is there an easier way, e.g. through the Rete class
> API?).
>
> (defquery get-real-deftemplate-name
> (declare (variables ?foo))
> ?context <- (t (foo ?foo))
> ; NOW WHAT?
> )
>
> There is probably an easy way to do this, right?
>
> 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]




JESS: Real deftemplate of extended fact

2007-06-18 Thread Henrique Lopes Cardoso
Hi,

I am trying to get the real deftemplate of a fact belonging to a
sub-deftemplate. Something like this:

(deftemplate t
(slot foo) )
(deftemplate t1 extends t
(slot bar))
(deftemplate t2 extends t
(slot qwe))

; The facts
(t1 (foo 1) (bar 2))
(t2 (foo 2) (qwe 1))

Now, I am trying to get the real deftemplate name for a fact:

(defrule r
(t (foo 1))
=>
(printout t "The real deftemplate name for this fact is "
???t1_or_t2??? crlf))

I want to get this from Java, so I thought of defining a defquery and
access its results (is there an easier way, e.g. through the Rete class
API?).

(defquery get-real-deftemplate-name
(declare (variables ?foo))
?context <- (t (foo ?foo))
; NOW WHAT?
)

There is probably an easy way to do this, right?

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]




Re: [Fwd: Re: JESS: Browsing Rule LHS]

2007-06-15 Thread Henrique Lopes Cardoso
But if Jess already has a Java API to access Jess constructs, is it not
a waist of time to parse JessML? JAXB would create another API to access
JessML content objects!

Again, do you not recommend the use of Jess API to access the structure
of Jess rules?

Another way of looking at my goal would be to ask: is there an easy way
of making a "what-if" analysis of rule-firing, i.e., of asking "if this
fact is asserted, what rule will fire"?

Henrique


Henrique Lopes Cardoso wrote:
>> Hi,
>>
>> I am trying to browse, through the Java API, the contents of a rule, to
>> check when it might be applicable by inspecting its LHS. This is
>> supposed to be done before running the Rete engine, not during (i.e., I
>> do not want to look for activations, or run-time pattern matches...).
>> I started with Rete.listDefrules(), then
>> HasLHS.getConditionalElements(). The ConditionalElement interface and
>> its implementing classes are very undocumented.
>>
>> 1. Is this the only approach to do what I want, or is there an  
>> easier way?
>> 
>
> You might try parsing JessML and working with that; you could use  
> JAXB to create classes representing XML elements.
>
>
>   
>> 2. Are those classes undocumented because they are likely to change?
>> 
>
> Historically, they have changed a lot. Before Jess 7 has there was no  
> public API for this at all; now that the API is public, we'll be  
> trying not to break code that uses it, at least not too often. But we  
> don't really want to encourage their use.
>
> -
> 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://www.jessrules.com
>
> 
> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the list
> (use your own address!) List problems? Notify [EMAIL PROTECTED]
> 
>
>
>
>   

-- 
- - - - - -  -  -  -  -  -   -   -
Henrique Lopes Cardoso
DEEC/FEUP
Rua Dr. Roberto Frias | 4200-465 Porto
PORTUGAL
(+351)225081400 ext.1315
[EMAIL PROTECTED] | www.fe.up.pt/~hlc
- - - - - -  -  -  -  -  -   -   -


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: Browsing Rule LHS

2007-06-14 Thread Henrique Lopes Cardoso
Hi,

I am trying to browse, through the Java API, the contents of a rule, to
check when it might be applicable by inspecting its LHS. This is
supposed to be done before running the Rete engine, not during (i.e., I
do not want to look for activations, or run-time pattern matches...).
I started with Rete.listDefrules(), then
HasLHS.getConditionalElements(). The ConditionalElement interface and
its implementing classes are very undocumented.

1. Is this the only approach to do what I want, or is there an easier way?
2. Are those classes undocumented because they are likely to change?

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]




JESS: On Rete.listDefrules()

2007-06-13 Thread Henrique Lopes Cardoso
Hi,

There seems to be a missfuntion in Rete.listDefrules(). The
documentation says that it returns an Iterator over all the defrules in
the engine, while it seems to return an Iterator over all the HasLHS
objects (which includes both defrules and defqueries.

Henrique

-- 
- - - - - -  -  -  -  -  -   -   -
Henrique Lopes Cardoso
DEEC/FEUP
Rua Dr. Roberto Frias | 4200-465 Porto
PORTUGAL
(+351)225081400 ext.1315
[EMAIL PROTECTED] | www.fe.up.pt/~hlc
- - - - - -  -  -  -  -  -   -   -


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: JessML

2007-03-12 Thread Henrique Lopes Cardoso
Hi,

I was browsing the JessML documentation. The example in 14.2.4 does not
seem consistent with the explanation at 14.2.3: the value type should be
an attribute, not an element.

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]




JESS: Tutorial on Integrating JADE and Jess

2007-03-07 Thread Henrique Lopes Cardoso
Hi,

This is just to let you know that I prepared a tutorial on JADE and Jess
integration, which is available here:
http://jade.tilab.com/doc/tutorials/jade-jess/jade_jess.html

Comments are welcome.

Maybe a link could be added in Jess site...

Cheers,

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]




Re: JESS: How do I determine Jess engine has finished firing rules

2007-02-12 Thread Henrique Lopes Cardoso
Why don't you use Rete.run() instead of runUntilHalt() and wait for the 
method to return?

Read Ernest's reply.

Cheers,

Henrique


Shi Paul wrote:
Hmmm, I wouldn't say it's a nice solution although it might work. I 
looked through the Rete api, there is a Rete.listActivations, I'm 
wondering if I could count on that, before calling rete.halt in the 
main thread, I'd use that API in a while loop and let main thread 
sleep for a few seconds if that doesn't return 0.



From: "Krasnigor, Scott L (N-AST)" <[EMAIL PROTECTED]>
Reply-To: jess-users@sandia.gov
To: jess-users@sandia.gov
Subject: RE: JESS: How do I determine Jess engine has finished firing 
rules

Date: Fri, 09 Feb 2007 15:59:11 -0500



The easiest thing to do is add a rule with a low salience (I use -1000)
that will always match and add whatever action on the rhs that you want
to use to signal all rules are done being processed. This rule will
always be added to the end of the agenda, so when it fires, you know
there are no more rules waiting to be fired.



-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Shi Paul
Sent: Friday, February 09, 2007 1:46 PM
To: jess-users@sandia.gov
Subject: Re: JESS: How do I determine Jess engine has finished firing
rules

Hi,
Actually I have created its own thread and then in that thread I call
rete.runUntilHalt. Then I run into this issue just mentioned, can you
give
me some more specifics about the solution as how to determin if the
engine
is not busy and can safely be stopped? I'd imagine that the main thread
could just wait on some semaphore the jess thread operates or call into
some
API which does the same thing.

Thanks,
Paul


>From: "Ernest Friedman-Hill" <[EMAIL PROTECTED]>
>Reply-To: jess-users@sandia.gov
>To: jess-users@sandia.gov
>Subject: Re: JESS: How do I determine Jess engine has finished firing
rules
>Date: Fri, 9 Feb 2007 13:19:29 -0500
>
>
>On Feb 9, 2007, at 12:15 PM, Shi Paul wrote:
>
>>Hi there,
>>Is there an API to determine the rule engine has completed its  work.
I'd
>>like to call rete.halt() to stop the engine, but I'm  wondering what
if
>>the engine is still firing rules when I call  that. Can anybody shed
some
>>lights on it?
>>
>
>Jess doesn't create any threads on its own. If you call rete.run(),
then
>run() returns when, and only when, there are no more rules to  fire. If
you
>have multiple threads, then you can set up your own  notification
scheme
>based on that.
>
>
>-
>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://www.jessrules.com





To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]




JESS: Jess editor

2007-02-09 Thread Henrique Lopes Cardoso

Hi,

I have just installed Jess plugins for Eclipse, which seem to work fine.

However, I also tried installing it with IBM Rational, which runs over 
Eclipse as well. I get an error message when I try to open a jess (.clp) 
file:


   Problems Opening Editor|Cannot open default editor on 
xxx.clp. Editor could not be initialized.


Has anyone run over a similar problem?

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]




Re: JESS: simple calculation problem

2007-01-31 Thread Henrique Lopes Cardoso

Hi,

I guess you should retract the update-scores fact in the rhs of the 
update-scores rule, otherwise you will not be able to assert a new 
update-scores fact (and therefore the update-scores rule will not fire 
again).


Henrique

M Ismail wrote:

hi,

im trying to add a number to another number which keeps increasing on 
every rule


that is what i have:

(defrule fight
(object knife)
  =>
(assert (Fight))
(assert (update-scores 10))
(printout t "Fight !" crlf)
)

(defrule update-scores
  (update-scores ?c)
  =>
 (call ?s setAgr (+ (call ?s getAgr) ?c)))

and i want it to be something like:
score starts with 0

and when rule fight is fire then it should add 10   so the final score 
is 10


and if another rule is fired it will add also 10 and then the final 
score is 20 etc...


how can i do that?  what i have  now is just replacing and not adding

best regards,

m.ismail

_
Veilig & gerust mailen met de verbeterde antivirusscan van Live Mail! 
http://imagine-windowslive.com/mail/launch/default.aspx?Locale=nl-nl



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]






--
- - - - - -  -  -  -  -  -   -   -
Henrique Lopes Cardoso
DEEC/FEUP
Rua Dr. Roberto Frias | 4200-465 Porto
PORTUGAL
(+351)225081400 ext.1315
[EMAIL PROTECTED] | www.fe.up.pt/~hlc
- - - - - -  -  -  -  -  -   -   -


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: Serializing Userfunctions

2006-09-22 Thread Henrique Lopes Cardoso

Just found out what the problem was.

I was defining my Userfunction as an innerclass of the main class where 
I had the Rete instance. That main class was not Serializable, and that 
was the class getting the NotSerializableException. Something like this:

   class M {
  Rete jess;

  class F implements Userfunction, Serializable { ... }

  public static void main(String args[]) {
 ...
 jess.addUserfunction(new F());
 ...
 jess.bsave(...);
  }
   }

==> Class M was getting the NotSerializableException

I then defined the Userfunction class F as an independent class, 
implementing Serializable, and everything worked fine.


Thank you.

Henrique


friedman_hill ernest j wrote:

I think Henrique Lopes Cardoso wrote:
  
Just stating the class to be Serializable made it work, that is, bsave() 
does not complain anymore and after bload()ing the functions work as 
expected.

I then tried with a simpler example, which got me the

NotSerializableException again...



NotSerializableExceptions have the offending class name as the
exception message; what class is it complaining about? Note that Jess
can't do anything to make a serializable class non-serializable.

  

My question is: why does this approach work only sometimes?



There must be something else going on; I would double-check that all
the Userfunction class files were up to date with the source, and that
everything that's supposed to be serializable really is.

  

Is this approach recommendable[?]



Yes, definitely. Jess's "built-in" functions aren't actually special
in any way; they're just serializable Userfunctions.

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



  


--
- - - - - -  -  -  -  -  -   -   -
Henrique Lopes Cardoso
DEEC/FEUP
Rua Dr. Roberto Frias | 4200-465 Porto
PORTUGAL
(+351)225574199 ext.3355
[EMAIL PROTECTED] | www.fe.up.pt/~hlc
- - - - - -  -  -  -  -  -   -   -

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 Bug Hunt Update

2006-09-22 Thread Henrique Lopes Cardoso
I have done something similar to what your FilteringIterator is probably 
doing. I get all deftemplates using listDeftemplates(), and then iterate 
through the Deftemplates comparing the result of getModule() with the 
module I am looking for.


Henrique

friedman_hill ernest j wrote:

I think Henrique Lopes Cardoso wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
  

Hi,

Is there no way of getting (in Java) the deftemplates of a certain module?
Looks like listDeftemplates() gets all deftemplates from all modules. 
But its jess equivalent, (list-deftemplates), includes the possibility 
of providing the name for the module.





Funny you should ask that, because I recently had some private
correspondence about exactly this. There are some internal tools in
Jess that would let you do this easily, but they're not public
classes; so I've made them public and enhanced them a little bit.

In Jess70RC2, you'll be able to write this:

Iterator deftemplatesInModuleFoo =
new FilteringIterator(engine.listDeftemplates(), Filter.byModule("FOO"));

There are a few predefined filters, and you can write your own.  This
will let you work with all the listXXX() methods in the Rete 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]



  


--
- - - - - -  -  -  -  -  -   -   -
Henrique Lopes Cardoso
DEEC/FEUP
Rua Dr. Roberto Frias | 4200-465 Porto
PORTUGAL
(+351)225574199 ext.3355
[EMAIL PROTECTED] | www.fe.up.pt/~hlc
- - - - - -  -  -  -  -  -   -   -

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: Serializing Userfunctions

2006-09-21 Thread Henrique Lopes Cardoso

Hi,

I was using bsave() and bload() with an engine that includes 
Java-implemented user-functions. Since these are not serializable, I was 
using removeUserfunction() to all Java-implemented functions before 
bsave()ing. The user functions would be re-defined after bload()ing.

This approach got be to the bug reported at "Bug Hunt".

Now, in the meantime I tried just defining my functions as being 
Serializable. Something like:

   public class MyFunction implements Userfunction, Serializable { ... }
Just stating the class to be Serializable made it work, that is, bsave() 
does not complain anymore and after bload()ing the functions work as 
expected.


I then tried with a simpler example, which got me the 
NotSerializableException again. In this case, my function was very simple:


   public class MyUserfunction implements Userfunction, Serializable {

   // The name method returns the name by which the function 
appears in Jess

   public String getName() {
   return ("my-user-function");
   }

   // Called when (my-user-function ...) is encountered
   public Value call(ValueVector vv, Context context) throws 
JessException {

   // JESS calls (my-user-function ?s)
   // get the ?s (first argument) as a String
   String s = vv.get(1).symbolValue(context);
   System.out.println("*" + s + "*");
  
   return Funcall.TRUE;

   }

   } // end MyUserfunction class


My question is: why does this approach work only sometimes? Is this 
approach recommendable, or should I use my initial approach that removes 
Java-implemented user-functions before bsave()ing and adds those 
functions after bload()ing? Of course it will only work if the bug is 
corrected.


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]




Re: JESS: Jess Bug Hunt Update

2006-09-21 Thread Henrique Lopes Cardoso

Hi,

Is there no way of getting (in Java) the deftemplates of a certain module?
Looks like listDeftemplates() gets all deftemplates from all modules. 
But its jess equivalent, (list-deftemplates), includes the possibility 
of providing the name for the module.


Henrique

--
- - - - - -  -  -  -  -  -   -   -
Henrique Lopes Cardoso
DEEC/FEUP
Rua Dr. Roberto Frias | 4200-465 Porto
PORTUGAL
(+351)225574199 ext.3355
[EMAIL PROTECTED] | www.fe.up.pt/~hlc
- - - - - -  -  -  -  -  -   -   -

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: Code for my question about multiple threads and engines

2006-09-15 Thread Henrique Lopes Cardoso
The problem is due to the (run-until-halt), which will run until the 
function (halt) is called.

From the function documentation:
---
16.159. (run-until-halt)
Arguments:
   None.
Returns:
   Integer
Description:
   Runs the engine until halt is called. Returns the number of rules 
fired. When there are no active rules, the calling thread will be 
blocked waiting on the activation semaphore.

---

Henrique


Mike Stacey wrote:
Sorry, some code might be useful for the question I just asked 
concerning multiple threads and rete engines:


In java main:
-

Rete r = new Rete();
Rete r_2 = new Rete();

 r_2.eval("(batch rules/rules_2.clp)");
r.eval("(batch rules/rules_1.clp)");

In rules_1.clp:
---

; Simple rule example for detecting a level shift
; Needs to incorporate time also

(reset)
(watch facts)

; 1. Create a hardware sensor to read source data.
; Takes a parameter that is the data source name
; 2. Create a monitor that polls the hardware sensor

(bind ?hware (new HWSensor "ts-testDat.dat"))
(defclass mon Monitor)
(definstance mon (new Monitor ?hware))

; Rule for detecting + level shift over a threshold value (142)

(defrule report-high-Val
(mon (reading ?r&:(> ?r 145)))
(mon (oldReading ?y));; makes oldReading available on RHS
(mon (tstamp ?t))
=>
(printout t "Val over 142: New Val ("?r"), Old val ("?y"), timestamp: 
"?t crlf))


(run-until-halt)



One engine, one HWSensor thread and one Monitor thread works fine but 
two won't work. Help appreciated...


Mike


To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------


  


--
- - - - - -  -  -  -  -  -   -   -
Henrique Lopes Cardoso
DEEC/FEUP
Rua Dr. Roberto Frias | 4200-465 Porto
PORTUGAL
(+351)225574199 ext.3355
[EMAIL PROTECTED] | www.fe.up.pt/~hlc
- - - - - -  -  -  -  -  -   -   -

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: Undefine a module

2006-08-01 Thread Henrique Lopes Cardoso

friedman_hill ernest j wrote:

I think Henrique Lopes Cardoso wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
  

Hello,

I was looking for an "undefmodule" function in Jess, but could not find it.
How can I undefine a module? Does it need to be empty? That is, with no 
rules or facts?





There isn't one. I could record this as a request for enhancement; can
you explain why it would be useful?
  
In my system, modules can be created at run-time in the RHS of rules, 
and rules are added to them. A module has a lifetime at the end of which 
it should be removed.

Therefore, I would appreciate if I could have an "undefmodule" function.

A shorter answer to your question would be: why is the undefrule useful?

Thanks.

Henrique


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



  


--
- - - - - -  -  -  -  -  -   -   -
Henrique Lopes Cardoso
DEEC/FEUP
Rua Dr. Roberto Frias | 4200-465 Porto
PORTUGAL
(+351)225574199 ext.3355
[EMAIL PROTECTED] | www.fe.up.pt/~hlc
- - - - - -  -  -  -  -  -   -   -

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: Undefine a module

2006-07-31 Thread Henrique Lopes Cardoso

Hello,

I was looking for an "undefmodule" function in Jess, but could not find it.
How can I undefine a module? Does it need to be empty? That is, with no 
rules or facts?


Thanks.

Henrique

--
- - - - - -  -  -  -  -  -   -   -
Henrique Lopes Cardoso
DEEC/FEUP
Rua Dr. Roberto Frias | 4200-465 Porto
PORTUGAL
(+351)225574199 ext.3355
[EMAIL PROTECTED] | www.fe.up.pt/~hlc
- - - - - -  -  -  -  -  -   -   -

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: Ordering execution of a module

2006-07-24 Thread Henrique Lopes Cardoso

Hi,

I've done something similar by using the focus stack.
If you have two different modules (say M1 and M2) each with a set of 
rules, you can do something like


   (focus M1) (focus M2)
   (run)

Rules from M2 will fire, and when that module is done rules from M1 will 
fire.


Henrique

erich.oliphant wrote:
Hi, 
I know that in general, trying to impose order in the rulebase is a Very Bad

Thing.  However, I have a situation where we have an existing rule base that
updates some java objects.  We have a new requirement, whereby if a flag is
set some of these objects may need to have the previously set values
overridden by values based on a separate set of rules.   Reconciling the two
rule sets may prove to be quite tedious, wereas running the new set after the
completion of the first would be straightforward.  Is there a way to create a
defrule that say looks to see if the run() is complete then sets the new
module and runs the second set of rules?

Now that I think about it.  This is being executed from a Java program, I
think i could possibly do the check after the first Rete.run() set the module
and run again.

In any case, any insights or ideas would be greatly appreciated.

THanks

To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]



  


--
- - - - - -  -  -  -  -  -   -   -
Henrique Lopes Cardoso
DEEC/FEUP
Rua Dr. Roberto Frias | 4200-465 Porto
PORTUGAL
(+351)225574199 ext.3355
[EMAIL PROTECTED] | www.fe.up.pt/~hlc
- - - - - -  -  -  -  -  -   -   -

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 for performing key validation inside a "Web of trust"

2006-06-12 Thread Henrique Lopes Cardoso

Hi,

If all you need is some backtracking inference, why don't you do it with 
Prolog? It would be much simpler...
Jess also supports backtracking, but it is much better as a forward 
chaining engine.


Henrique

Patrick Herber wrote:

Hello,

I'm a newbie in JESS and rule engines in general (I'm finishing jet the book
'JESS in action').

I would like to use Jess for the following "PKI" problem.

Given the following statements:

Cert(A,X) : "A" certifies that the key "X" is authentic
Trust(A,X): "A" believes that "X" is trustworthy for issuing certificates

Inside a web of trust is for an entity "A" the public key "X" authentic when
the following condition is satisfied:

Cert(A,X)

or if it can be derived by the application of the following two interference
rules:

for each Y,Z: Cert(A,Y) and Trust(A,Y) and Cert(Y,Z) => Then: Cert(A,Z)

and

for each Y,Z: Cert(A,Y) and Trust(A,Y) and Trust(Y,Z) => Then: Trust(A,Z)


I thought I could simply specify my facts as

(cert "Alice" "Bob")
(cert "Alice" "Bill")
(cert "Bob" "Georg")
(trust "Alice" "Bob")
..

Now I would like to implements the two given rules in order to be able to
ask question like: "certifies Alice Georg?", hoping that JESS would perform
all the backtracking search, which otherwise I would have to implement with
very long (and inelegant) java code.

Could you kindly give me some hints for implementing them?

Thanks a lot for your help!
Regards,
Patrick



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: JADE and JESS

2006-05-23 Thread Henrique Lopes Cardoso
You can start with the examples in 
http://jade.tilab.com/doc/examples/index.html
and the Introduction to Programming with Jess in Java at 
http://www.jessrules.com/jess/docs/70/library.html


Henrique


Mai El_hadidi wrote:

I realy need some help regarding the use of JESS in JADE programs.
I need a tutorial, documentation, a link , any thing that can guide me 
through

Thankx a lot

_
Don't just search. Find. Check out the new MSN Search! 
http://search.msn.click-url.com/go/onm00200636ave/direct/01/



To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify 
[EMAIL PROTECTED]







To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]




JESS: Using modules

2005-02-11 Thread Henrique Lopes Cardoso
Hi,

Is it possible to have facts asserted inside a module fire rules defined in
MAIN?
A non-working example:

Jess> (defrule r1 (a) => (printout t "bingo!" crlf))
TRUE
Jess> (defmodule m)
TRUE
Jess> (reset)
TRUE
Jess> (assert (m::a))

Jess> (agenda)
For a total of 0 activations.
Jess>

I guess I can do something like:

   (defrule r1 (m::a) => (printout t "bingo!" crlf))

...but this forces me to create the module before creating the rule.

What if I don't even know the module name? I mean, I want to have a catch-up
rule that fires if there is no rule inside the fact's module. Must I assert
the fact in MAIN? I would like to avoid this for organizational purposes
(using modules as contexts).

Thanks,

Henrique Lopes Cardoso


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 rules based on facts subcontents

2005-02-11 Thread Henrique Lopes Cardoso
Yes, Timothy's solution worked out.
However, Ernest's one had a small problem (corrected below):
;---
(deftemplate said (slot who) (slot content))
(deftemplate content (multislot payed))

(defrule payments
(said (who ?w) (content ?content))
?content <- (content (payed ?payer ?amount ?receiver ?when))
(authority ?w)
  =>
(assert (payment-done ?amount ?receiver ?when))
)

(assert (authority me))
(bind ?content (assert (content (payed a 20 b now
(assert (said (who me) (content ?content)))
;---

I now understand that if I define the content slot as a multivalue the rule
and the assertions become much simpler.

I also found out that I can do it without templates:
;---
(defrule payments
 (said ?who ?content)
 ?content <- (payed ?payer ?amount ?receiver ?when)
 (authority ?w)
   =>
 (assert (payment-done ?amount ?receiver ?when))
)

(assert (authority me))
(bind ?fact (assert (payed a 20 b now)))
(assert (said me ?fact))
;---

And finally I tried it binding a variable to a multifield:
;---
(deftemplate said
   (slot who)
   (slot content)
)

(defrule payments
 (said (who ?w) (content ?content))
 ?content <- (payed ?payer ?amount ?receiver ?when)
 (authority ?w)
   =>
 (assert (payment-done ?amount ?receiver ?when))
)

(assert (authority me))
(bind ?c (create$ payed a 20 b now))
(assert (said (who me) (content ?c)))
;---

This last assertion works (although the content slot is not a multislot),
but the rule does NOT fire!!!
Why?

Henrique


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Timothy Redmond

How about

(deftemplate said
   (slot who)
   (slot content))

(defrule payments
 (said (who ?w) (content ?content))
 ?content <- (payed ?payer ?amount ?receiver ?when)
 (authority ?w)
   =>
 (assert (payment-done ?amount ?receiver ?when)))

(reset)
(watch all)

(bind ?fact (assert (payed a 20 b now)))
(assert (said (who me) (content ?fact)))
(assert (authority me))
(run)

?

-Timothy


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 rules based on facts subcontents

2005-02-10 Thread Henrique Lopes Cardoso
The binding does not work!


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of [EMAIL PROTECTED]
Sent: quinta-feira, 10 de Fevereiro de 2005 19:24
To: jess-users@sandia.gov
Subject: Re: JESS: Defining rules based on facts subcontents

I think Henrique Lopes Cardoso wrote:
> 
> But how do I assert a fact matching the ?content variable?
> I tried this:
> 
> Jess> (assert (said (who me) 


(bind ?content (assert (content (payed a 20 b now
(assert (said (who me) (content ?content)))


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


To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]



To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]




Re: JESS: Defining rules based on facts subcontents

2005-02-10 Thread Henrique Lopes Cardoso

But how do I assert a fact matching the ?content variable?
I tried this:

Jess> (assert (said (who me) (content (payed a 20 b now

But it does not work...


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of [EMAIL PROTECTED]
Sent: quinta-feira, 10 de Fevereiro de 2005 16:28
To: jess-users@sandia.gov
Subject: Re: JESS: Defining rules based on facts subcontents


Salots can't *be* facts, but they can *contain* facts. So while what
you've shown isn't valid, you could say somethign like

 (defrule payments
(said (who ?w) (content ?content))
?content <- (payed ?payer ?amount ?receiver ?when)
(authority ?w)
  =>
(assert (payment-done ?amount ?receiver ?when))
 )

But I'm actually not sure that's what you're even trying to do, as an
independent "payed" fact isn't necessarily useful. The "content" slot
could simply be a multislot and contain the message directly, as

 (defrule payments
(said (who ?w) (content payed ?payer ?amount ?receiver ?when))
(authority ?w)
  =>
(assert (payment-done ?amount ?receiver ?when))
 )

If you need more structure than that, though, then you have to go to a
separate fact, as above.



I think Henrique Lopes Cardoso wrote:
> Let me simplify my question. I was trying to do something like:
> 
> (deftemplate said
> (slot who)
> (slot content)
> )
> 
> (defrule payments
>(said (who ?w) (content (payed ?payer ?amount ?receiver ?when)))
>(authority ?w)
>  =>
>(assert (payment-done ?amount ?receiver ?when))
> )
> 
> That is, my problem is on defining a slot ("content") as a fact, and make
> the rule dependent on the contents of such a fact.
> 
> Henrique
> 
> 
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
> Behalf Of [EMAIL PROTECTED]
> Sent: quinta-feira, 10 de Fevereiro de 2005 15:43
> To: jess-users@sandia.gov
> Subject: Re: JESS: Defining rules based on facts subcontents
> 
> I can't say I understand what you're asking, exactly, but I think the
> answer is "no, you have to define a deftemplate."
> 
> 
> I think Henrique Lopes Cardoso wrote:
> > Hi,
> > 
> >  
> > 
> > I want to define a rule based on the contents of a fact. For instance:
> > 
> >  
> > 
> > (defrule payments
> > 
> >   (said ?who (payed ?payer ?amount ?receiver ?when) ?)
> > 
> >  =>
> > 
> >   (assert (ifact (payment ?amount ?receiver ?time)))
> > 
> >  
> > 
> > Can I do this?
> > 
> > Or must I define a deftemplate:
> > 
> > (deftemplate said
> > 
> > (slot who)
> > 
> > (slot content)
> > 
> > (slot timestamp)
> > 
> > )
> > 
> >  
> > 
> > Or something else?
> > 
> >  
> > 
> > Henrique
> > 
> >  
> > 
> 
> 
> 
> -
> Ernest Friedman-Hill  
> Advanced Software Research  Phone: (925) 294-2154
> Sandia National LabsFAX:   (925) 294-2234
> PO Box 969, MS 9012 [EMAIL PROTECTED]
> Livermore, CA 94550 http://herzberg.ca.sandia.gov
> 
> 
> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the list
> (use your own address!) List problems? Notify [EMAIL PROTECTED]
> 
> 
> 
> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the list
> (use your own address!) List problems? Notify [EMAIL PROTECTED]
> 
> 



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


To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]



To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]




RE: JESS: Defining rules based on facts subcontents

2005-02-10 Thread Henrique Lopes Cardoso
Let me simplify my question. I was trying to do something like:

(deftemplate said
(slot who)
(slot content)
)

(defrule payments
   (said (who ?w) (content (payed ?payer ?amount ?receiver ?when)))
   (authority ?w)
 =>
   (assert (payment-done ?amount ?receiver ?when))
)

That is, my problem is on defining a slot ("content") as a fact, and make
the rule dependent on the contents of such a fact.

Henrique


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of [EMAIL PROTECTED]
Sent: quinta-feira, 10 de Fevereiro de 2005 15:43
To: jess-users@sandia.gov
Subject: Re: JESS: Defining rules based on facts subcontents

I can't say I understand what you're asking, exactly, but I think the
answer is "no, you have to define a deftemplate."


I think Henrique Lopes Cardoso wrote:
> Hi,
> 
>  
> 
> I want to define a rule based on the contents of a fact. For instance:
> 
>  
> 
> (defrule payments
> 
>   (said ?who (payed ?payer ?amount ?receiver ?when) ?)
> 
>  =>
> 
>   (assert (ifact (payment ?amount ?receiver ?time)))
> 
>  
> 
> Can I do this?
> 
> Or must I define a deftemplate:
> 
> (deftemplate said
> 
> (slot who)
> 
> (slot content)
> 
> (slot timestamp)
> 
> )
> 
>  
> 
> Or something else?
> 
>  
> 
> Henrique
> 
>  
> 



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


To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]



To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]




JESS: Creating modules inside rules

2005-02-10 Thread Henrique Lopes Cardoso








Hi,

 

Is it possible to create modules in the RHS of a
rule?

Something like:

 

 

(defrule new-contract

   (deal ?ctid ?contents)

 =>

   (defmodule ?ctid)

   (assert (contract ?contents))

)

 

 

Thanks.

 

Henrique

 








JESS: Defining rules based on facts subcontents

2005-02-10 Thread Henrique Lopes Cardoso








Hi,

 

I want to define a rule based on the contents of a
fact. For instance:

 

(defrule payments

  (said ?who (payed ?payer ?amount ?receiver ?when)
?)

 =>

  (assert (ifact (payment ?amount ?receiver ?time)))

 

Can I do this?

Or must I define a deftemplate:

(deftemplate said

    (slot who)

    (slot content)

    (slot timestamp)

)

 

Or something else?

 

Henrique