Re: JESS: modules and facts

2001-09-26 Thread Ernest Friedman-Hill

Hi Chris,

I'm actually rather happy with how this works -- let me try to clarify 
what's happening for you.

"DeGreef, Chris J. (AIT)" wrote:
> 
> (deffact somefacts
> (head1 abc))
> is asserted as (MAIN::head1 abc)
> 
> (defmodule SUB)
> (deffact SUB::somemorefacts
> (head1 def))
> is also asserted as (MAIN::head1 def)
> 
> Shouldn't the latter be asserted as (SUB::head1 def)?

The behaviour actually depends on whether or not MAIN::head1 or
SUB::head1 were previously defined. If the template MAIN::head1 exists, but
SUB::head1 does not, then the fact is created in MAIN, as you observe. But if
SUB::head1 already exists, or if neither SUB::head1 nor MAIN::head1 exists,
then the fact is a SUB::head1 fact.

> In fact, it only gets asserted in the module only when specified like
> (deffact SUB::somemorefacts
> (SUB::head1 def))

As stated above, this isn't quite true.

> 
> More specifically, any facts in the deffact statement, defined before a fact
> definition referencing a module, are asserted to the MAIN:: module.  All
> facts after a specific module fact are asserted to that same specific
> module.

Again, that's not quite it; the facts end up in MAIN -only- if the necessary template
already exists in the MAIN module.

> 
> Effectively, all deffacts, regardless of the defmodule they follow, by
> default extend the MAIN:: repository of facts and are accessable to all
> modules.  This is unlike the assert statement, when executed in a module,
> which asserts the fact with the :: prefix on the fact as a default.
> 

No, (assert) follows exactly the same rules -- the same code is used to do
the template lookup.


> I have a related question about modules and the scope of facts.
> 
> If the same fact head is defined in both modules, like ...
> 
> (deffact MAIN::somefacts
> (head1 abc)
> ...
> (deffact SUB::someotherfacts
> (SUB::head1 def)
> 
> then a rule in module SUB will not fire with the (head1 abc) fact.  As in...
> 
> (defrule SUB:rule1
> (head1 ?a)
> =>
> (printout t ?a crlf))
> 
> This only prints "def".
> 
> Shouldn't the facts defined as MAIN:: be accessable to all modules even when
> the names of the facts are the same?
> 

MAIN::head1 and SUB::head1 are two different templates -- patterns can only
match one or the other. Which one they match is decided when the rule is compiled.
The first pp of mainual section 2.10.2 is pretty clear about this.



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

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




JESS: Announcing Jess 7.0 RC2

2006-10-10 Thread Ernest Friedman-Hill
The latest version of Jess, the Programmer's Rule Engine for the Java  
Platform, is available for download at the usual location:


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

Jess 7.0RC2 is the second and almost certainly final release  
candidate for Jess 7, code-named Charlemagne. This release fixes all  
the issues reported as part of our "Bug Hunt" T-shirt contest, and  
includes additional documentation enhancements and small bug fixes.  
In particular, the JessDE debugger is working perfectly on Windows  
again.


We are extending our popular contest until the final release of Jess  
7.0. Report a bug in this release and win a Jess T-shirt! See here  
for details:


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

As always comments and questions are welcome at [EMAIL PROTECTED] or  
to the mailing list at jess-users@sandia.gov .


---------
Ernest Friedman-Hill
Advanced Software Research  Phone: (925) 294-2154
Sandia National LabsFAX:   (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://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]




Re: JESS: calculations in JESS

2006-10-12 Thread Ernest Friedman-Hill

On Oct 12, 2006, at 9:05 AM, KUMAR, Sunil S wrote:

We have hundreds of formulae/calculations to be performed during  
the process of costing. We were just wondering if these formulae/ 
calculations should be coded in JESS or as JAVA functions and then  
be called from JESS?


If the computations are non-trivial and called often -- especially  
from the left-hand-sides of rules -- then the performance will be  
better if the calculations are written as Java Userfunctions. Jess  
was designed to make it easy to extend; writing Userfunctions is very  
simple, so there's little reason not to do it.


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




Re: JESS: Announcing Jess 7.0 RC2

2006-10-12 Thread Ernest Friedman-Hill

On Oct 10, 2006, at 7:15 PM, Greenblatt, Howard wrote:


In the latest release (7.0 RC2), it looks like the manifest file in
jess.jar in both the Jess70RC2/lib and
eclipse/plugins/gov.sandia.jess_7.0.0 folders have the wrong
"Implementation version" number in them.
They both say: Implementation-Version: 7.0RC1.


Thanks. I think that's a T-shirt worthy report right there, because  
it's a process failure here. That should have been updated, but it  
wasn't on the release checklist. Now it is.



Also could you provide some info on the use JessPlugin class and the
jessplugin.jar file?



The JessPlugin class is, I think, completely worthless. JessPlugin is  
more or less an empty class -- it's just there to activate the  
plugin. It used to contain some code, but it was all removed when  
that plugin was moved to the new OSGI architecture. Now, due to  
recent circumstances, this may change a little -- see my upcoming  
reply to Steven Goncalo.


The gov.sandia.jess plugin itself, however, can be used as a way to  
write Jess-based Eclipse plugins. Just include that plugin as a  
dependency in your own plugin manifest, and you should have access to  
jess.jar and jsr94.jar .


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




Re: JESS: 70rc2 Docs are inconsistent re version of Eclipse required : Bug Hunt

2006-10-12 Thread Ernest Friedman-Hill

On Oct 11, 2006, at 10:31 PM, Steven Goncalo wrote:


7.0 RC2 Docs are inconsistent re version of Eclipse required.



Thanks, we will make sure these stay in sync.

Upgrading to Eclipse 3.2 may be an issue with some of the other  
plugins my team uses. We will do it, but not for a while.


OK, that makes at least four people who have complained about the  
Eclipse 3.1 -> 3.2 change. As I'm sure many of you know, it's  
frustrating being a software vendor: customers want you to support  
legacy platforms, while simultaneously expecting you to embrace new  
features (I get mail all the time asking why Jess isn't using Java  
1.5's enums or generics, and the fallout from Java 1.4's introducing  
an "assert" keyword still hasn't died down!)


But enough about me. I looked into it, and the JessDE could continue  
to support 3.1 with no loss of functionality by using two methods  
deprecated in 3.2 along with a local rewrite of a new-to-3.2 utility  
routine. This isn't too bad, so I would like to do it and keep people  
happy. And Steven can have a T-shirt for his trouble, too. The  
downside is that we're going to have to have an RC3 release, so Jess  
7 final is pushed back another week. Still, we will be able to have  
the final release by the end of October.


2) Is it possible to use the 70RC2 jess.jar file with the plugin  
jars for the last JessDE that works on Eclipse 3.1?


No, because the debugger protocol evolves, and there's a component in  
Jess itself as well as in the JessDE. RC1's jess.jar and RC2's JessDE  
debugger will not interoperate.


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




Re: JESS: calculations in JESS

2006-10-12 Thread Ernest Friedman-Hill

On Oct 12, 2006, at 9:57 AM, KUMAR, Sunil S wrote:



Hi, Thank you for the response. In our case most of the  
calculations are on the RHS side of the rule. Does that mean we  
should write our calculations/formulas in Jess? Also, we are very  
familiar in Java than in Jess. At this point we are hard pressed  
for time. That is the reason we are trying to understand if there  
are any performance implications in using java/jess.




The performance of a mathematical function written in Java will be  
virtually always be a little better than the same function written in  
Jess. In a typical rule-based system, functions called on the left- 
hand-side of a rule are called much more often then those called on  
the right-hand-side, and so rewriting left-hand-side functions in  
Java is often worth the effort.


For functions called only on the right-hand-side of a rule, the small  
performance difference is unlikely to matter much. Then other factors  
are more important -- for example, you may prefer to write the  
functions in whichever language makes them easier to write.


Of course, these are generalizations, and there's no substitute for  
actual profiling. Don't put a lot of work into doing something that  
doesn't matter; the first step in any optimization should always be  
profiling the code.


---------
Ernest Friedman-Hill
Advanced Software Research  Phone: (925) 294-2154
Sandia National LabsFAX:   (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://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: Announcing Jess 7.0RC3

2006-10-13 Thread Ernest Friedman-Hill
The latest version of Jess, the Programmer's Rule Engine for the Java  
Platform, is available for download at the usual location:


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

Jess 7.0RC3 is the third and almost certainly final release candidate  
for Jess 7, code-named Charlemagne. The only changes between 7.0RC2  
and 7.0RC3 are that the JessDE now works on Eclipse 3.1, and an  
overloaded version of addMultislot() was returned to the Deftemplate  
class.


As always comments and questions are welcome at [EMAIL PROTECTED] or  
to the mailing list at jess-users@sandia.gov .


-
Ernest Friedman-Hill
Advanced Software Research  Phone: (925) 294-2154
Sandia National LabsFAX:   (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://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]




Re: JESS: Getting assertions from other Rete engine

2006-10-14 Thread Ernest Friedman-Hill


On Oct 13, 2006, at 10:17 PM, m u wrote:


Hi all,

Is there a way to transfer (get) assertions from several Rete()  
engines into a new Rete() engine?
I've constructed several rete engines. Now I want to use the  
results from the engines for further analysis in a new Rete engine.  
is this possible?




Yes, absolutely. In Java, you could just do something like

Rete engine1 = ...
Rete engine2 = ...

for (Iterator it = engine1.listFacts(); it.hasNext();) {
engine2.assertFact(((Cloneable) it.next()).clone());
}

But from the sound of it, you might want to just consider using  
different modules (defmodules)

within a single engine.

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




Re: JESS: Error notifying a preference change listener. Check the log for details.

2006-10-17 Thread Ernest Friedman-Hill

On Oct 17, 2006, at 9:18 AM, Gerhard Austaller wrote:


Hi

I installed the eclipse plugin with eclipse version 3.3.0 (Build id:
I20060922-0010). But at statup I get a message box "Error notifying a
prefernce change listener. Check the log for details." The editor  
seems

to work, because it support keyword highlighting works.

Anybody having simliar problems?
Gerhard


I think this is new with Eclipse 3.3. Once again, they're changing
the sequence of how things are initialized; lovely.

Thanks for the report; easy enough to fix.

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




Re: JESS: TIMELOCK2 in Rete()

2006-10-17 Thread Ernest Friedman-Hill


On Oct 17, 2006, at 11:52 AM, Barker, Brett A wrote:


java.lang.NumberFormatException: For input string: "__TIMELOCK2__"


There was a problem with the build server and the trial version archive
was broken. The problem has been fixed, and downloading a new file will
fix your problem.

(Many people have reported this to the list, but I've only allowed  
this one
to get sent out so as not to flood the list with redundant traffic.  
If you
sent a similar message and it hasn't shown up on the list yet, PLEASE  
don't

resend it!)

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




Re: JESS: change output router for (watch all)

2006-10-18 Thread Ernest Friedman-Hill

On Oct 18, 2006, at 9:06 AM, Helge Hartmann wrote:

Hi!

I would like to have a debug window in my application. Is it  
possible to change the output router, (watch all) is writing to. It  
would also be good to have different routers for (watch  
activations) and (watch focus) and so on.




http://www.jessrules.com/jess/docs/70/api/jess/ 
Rete.html#setWatchRouter(java.lang.String)


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




Re: JESS: Announcing Jess 7.0RC3

2006-10-20 Thread Ernest Friedman-Hill

On Oct 20, 2006, at 8:17 PM, J Michael Dean wrote:

Caused by: java.io.FileNotFoundException: rules/Glucose.clp (No  
such file or directory)

at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.(FileInputStream.java:106)
at java.io.FileInputStream.(FileInputStream.java:66)
at java.io.FileReader.(FileReader.java:41)
at jess.Batch.findDocument(Batch.java:121)
... 22 more


Jess will, as always, first look relative to the current directory,  
and then along the runtime CLASSPATH. Eclipse is quite tricky about  
how it manages the CLASSPATH when it launches Java applications;  
things do change from version to version. But the important thing to  
note here is that you're launching a Java application, not a Jess  
application, so Jess's Eclipse-related code doesn't come into play at  
all -- it's all about the runtime CLASSPATH, which in turn is going  
to be related to how you set up your Java project to be run. Make  
sure the "rules" directory is being exported when you build the  
project. You might add some extra debug code to print the CLASSPATH  
and print the current working directory (and possibly its contents)  
and you'll probably simply find that the "rules" directory is simply  
not available at runtime.


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




Re: JESS: When no rules left to be triggered?

2006-10-24 Thread Ernest Friedman-Hill


On Oct 24, 2006, at 4:33 AM, [EMAIL PROTECTED] wrote:

I'd like to know "when there is
no more rule left to be triggered " to inject another fact (or  
maybe retract
the no processed rule from working memory), I want to stay in the  
loop until
fact generator goes out of fact. How can know that there is no  
other rules to

be trigers without leaving the cycle.


The "run" function (both in Jess and in Java) returns when there are  
no more rules to fire. So you can just do


while (true) {
myRete.run();
makeSomeMoreFacts();
}


or

(while TRUE
(run)
(makeSomeMoreFacts))


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




Re: JESS: Test on a list from a JavaBean

2006-10-24 Thread Ernest Friedman-Hill

Something like this?

(defrule theRule
(theFact (theProperty ?theList&:(?theList contains "xyz")))
=> ...


On Oct 24, 2006, at 2:15 PM, Skeptic 2000 wrote:



Hi,

In my rules, I need to tests some shadows fact which have as one of  
their properties a List.


For example, let's say it's a List of String and I my test is to  
check that the string "xyz" is part of the list.


What would be the most proper way to do this ?


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




Re: JESS: Test on a list from a JavaBean

2006-10-24 Thread Ernest Friedman-Hill

On Oct 24, 2006, at 8:14 PM, Skeptic 2000 wrote:


Thanks, I missed the contains, it's not in the Jess functions list,  
where it comes from ?


It's a method in the java.util.Collections interface, yes? We're  
calling it on ?theList, which is a java.util.List.






From: "Ernest Friedman-Hill" <[EMAIL PROTECTED]>

Something like this?

(defrule theRule
(theFact (theProperty ?theList&:(?theList contains "xyz")))
=> ...


On Oct 24, 2006, at 2:15 PM, Skeptic 2000 wrote:



Hi,

In my rules, I need to tests some shadows fact which have as one  
of  their properties a List.


For example, let's say it's a List of String and I my test is to   
check that the string "xyz" is part of the list.


What would be the most proper way to do this ?


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




Re: JESS: adding (not creating) rules from Java

2006-11-01 Thread Ernest Friedman-Hill


On Oct 31, 2006, at 3:52 PM, Skeptic 2000 wrote:



Hi,

I want to have a Java program that can add rules to a Rete object  
at runtime. The rules would be entered as a String and once added,  
I would need a way to refer to them on the Java side. What would be  
the proper way to do it ?


You can just feed the "eval()" method the text of a defrule at any  
time. eval() will just return TRUE. If you know the name of the rule  
you added, then you can find the Defrule object with the  
Rete.findDefrule() method. If you don't know the name of the rule  
before you add it, then you could use the Jesp parser class directly,  
calling parseDefrule() to parse the rule. It returns the Defule itself.


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




Re: JESS: the reteview eclipse plugin not default in Jess 7.0 ga?

2006-11-01 Thread Ernest Friedman-Hill


On Nov 1, 2006, at 7:35 AM, Ellen Ning Zhao wrote:


Hi,

today I downloaded the latest Jess 7.0 ga. The reteview eclipse  
plugin is not present in the feature.xml. I edited the feature.xml  
and now the reteview is back in eclipse. But why it's not  
configured as a default plugin in the 7.0 ga? Is the reteview  
plugin no longer under development or?


If a single plugin listed as part of a feature doesn't load, then
the whole feature doesn't load. The Rete Network plugin requires the
Graph Editing Framework to be installed, or it won't load. The GEF isn't
installed by default, so for many JessDE users, the Jess feature  
wouldn't
load just because this minor plugin wasn't available. I didn't want  
to force

users to install the GEF. Therefore the Rete Network plugin was removed
from the feature -- although it's still available from the "Show  
View" menu, as

it always has been.

For those folks who don't know what an Eclipse "feature" is -- it's  
just the
thing that makes the little "Jess" button in the "About Eclipse SDK"  
dialog. The
change we're talking about is that in the plugin list you can get by  
pushing that
button, the Rete Network plugin doesn't appear. Not an earth- 
shattering item.



-
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: Announcing Jess 7.0

2006-11-01 Thread Ernest Friedman-Hill

Hello,

We're pleased to announce the general availability of the final release
of Jess 7.0, the rule engine for real programmers. Jess 7 includes  
powerful
new features like XML support, simplified APIs, new rule language  
features, and

a full-featured development environment based on the award-winning
Eclipse platform.

Visit http://www.jessrules.com to download a 30-day trial version, or
to update your licensed software. Questions and comments are welcome, as
always, to [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]




Re: JESS: Symplified syntax jess 7

2006-11-02 Thread Ernest Friedman-Hill
Only simple expressions as described in the manual are handled in  
this release. Parenthesized expressions are not implemented -- yet.


On Nov 2, 2006, at 5:36 AM, Negoita, Cristian wrote:


The simplified rule should look like below:


(defrule Rule-KDF-BDF-Promo-1

(Input

   {bestandFirma <> 5 && ((promotionalCode  
== 'M' || promotionalCode == 'X') && kontoFirma == 5)}


)

=>...

But his expression cannot be parsed by Jess.


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




Re: JESS: calling a method on a matched shadow fact

2006-11-02 Thread Ernest Friedman-Hill

On Nov 2, 2006, at 1:29 PM, Skeptic 2000 wrote:




Let's say I have something like :

(defclass xyz x.y.com.XYZ)

(defrule "x"
 ?x<-(xyz)
=>
(...)

In the RHS, I would like to call a method that is not a bean get/ 
set on the matched 'xyz', what would be the proper way? (If  
possible, this method would take a string as argument)




?x is a jess.Fact object; it has a slot named OBJECT containing the  
actual XYZ object. So you could say


((?x getSlotValue OBJECT) theMethodName "the argument")

Alternatively, you could bind the OBJECT slot on the LHS, and then  
you'd have a variable on which you could call the method directly.


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




Re: JESS: JESS vs RACER

2006-11-03 Thread Ernest Friedman-Hill

On Oct 31, 2006, at 12:22 PM, Samson Tu wrote:



No, that's what SWRL and other semantic web rule languages are about.



Samson, this is such great stuff. I've been promising to write an  
essay explaining Jess for Protege users and/or Protege for Jess  
users. There's so much wonderful source material here: would you mind  
if I quoted you liberally?


Actually, I'd like it even better if *you'd* write such an essay,  
alone or jointly with me, but that's probably too much to hope for.





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




Re: AW: JESS: Symplified syntax jess 7

2006-11-03 Thread Ernest Friedman-Hill

On Nov 3, 2006, at 3:09 AM, Negoita, Cristian wrote:

Issue is, this simplified syntax is decisive in using Jess further  
in the project. Jess 6 is used already, but, now, in another part  
of the project there is the need to change/generate rules at  
runtime, which would be much simpler with the new syntax.


Here we have to know when these parenthesized expressions will be  
supported (time und release von Jess), so we can match it with our  
release timeframe.




It would be a feature in Jess 7.1, not 8.0, so it's a near-term  
feature. I don't have a release date yet, but I would expect it to be  
in Q1 2007.


Personally, if I was writing code to generate rules, I'd be doing it  
in JessML (Jess's new XML format). Rules can be translated easily  
between the two representations, and it's much easier to generate XML  
programmatically.


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




Re: JESS: Generating rules (was: Symplified syntax jess 7)

2006-11-03 Thread Ernest Friedman-Hill


On Nov 3, 2006, at 2:46 PM, Dave Carlson wrote:



Have you considered creating a rule metamodel based on Eclipse  
EMF?  It
would be easy to bootstrap from the JessML schema (if that is a  
reasonable
metamodel structure), and the resulting Java-based EMF model would  
even
read/write the JessML xml syntax.  A customized class could be  
written that

would read/write the native Jess syntax to the EMF model.


I'm not fully up to speed on EMF, but are we talking about something  
like this?


http://www.eclipse.org/articles/Article-Rule%20Modeling%20With%20EMF/ 
article.html




Related to the recent thread on OWL, I am also working with the EMF- 
based
metamodel for OWL that reads/writes OWL or RDF ontologies, although  
this

metamodel is based on the OMG's ODM spec.  See:

http://www.eclipse.org/emft/projects/eodm/#eodm



Thanks, Dave. I'm not surprised to hear you are on the cutting edge  
of this area -- this has been your longstanding area of expertise.


---------
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 7.0 printable manuals

2006-11-06 Thread Ernest Friedman-Hill

Hi Folks,

This is just a note to let you know that our friend David Scuse has  
once again provided new, up to date printable manuals for Jess 7.0 in  
both Word and PDF formats. Thanks, David! They're available at http:// 
www.jessrules.com/docs .


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




Re: JESS: Enum or static variable support in Jess

2006-11-06 Thread Ernest Friedman-Hill


On Nov 6, 2006, at 7:58 AM, Helge Hartmann wrote:


Hello!

It read, that Jess does not allreads support Enums.


Please let me know where you read this, as it's not true. I'll see if  
I can get it fixed. We've done some experiments with Java 5 enums,  
and they can be used nicely. For example, see http://www.mail- 
archive.com/jess-users@mailgate2.sandia.gov/msg00313.html .


But I can't access these static fields from Jess. I have an Shadow  
fact, that has an int filed type. When I type


(modify ?account (type (call Type EXTENDED)))

I get an error, that there is no method called EXTENDED. Is there a  
possibility to use Enums or static fields? Or how can I work around  
this?


Well, indeed, because there is no method (static or otherwise) named  
EXTENDED. "call" is only for calling Java methods, not accessing Java  
variables.


In Jess 6 and easier, you have to use get-member to get static  
variables:



(modify ?account (type (get-member Type EXTENDED)))

But in Jess 7, importing a class creates Jess functions that return  
the value of each public static variable in the class. So, for  
example, if you say


(import Type)

you can then refer to Type.EXTENDED as (Type.EXTENDED), like this:

(modify ?account (type (Type.EXTENDED)))

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




Re: JESS: asserting identical facts

2006-11-07 Thread Ernest Friedman-Hill
The duplicate is rejected, and assert returns FALSE, as documented at  
http://herzberg.ca.sandia.gov/jess/docs/70/functions.html#assert .


On Nov 7, 2006, at 8:00 AM, Matthew J Hutchinson wrote:


G'day everyone,

Quick question - may be a no brainer, but I've never really known  
the answer - what happens if two identical unordered facts are  
asserted? Each would have a unique fact-id, so does this mean both  
would exist nicely in Jess memory? or would the second assertion  
merely overwrite the first?


Thanks,
Matt



-----
Ernest Friedman-Hill
Advanced Software Research  Phone: (925) 294-2154
Sandia National LabsFAX:   (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://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]




Re: JESS: Enum or static variable support in Jess

2006-11-09 Thread Ernest Friedman-Hill


On Nov 9, 2006, at 8:43 AM, Helge Hartmann wrote:

Using Enums in shadow facts now works finde, but I still get  
errors, when using Enums in a constructor and trying to create a  
java object. There is a constructor



..

(bind ?b (new Account Type.EXTENDED))


As I said before,

in Jess 7, importing a class creates Jess functions that return  
the value of each public static variable in the class.


So Type.EXTENDED is a function in Jess; you need to write

(bind ?b (new Account (Type.EXTENDED)))

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




Re: JESS: multislot __data question

2006-11-13 Thread Ernest Friedman-Hill


On Nov 13, 2006, at 1:22 AM, Soil inf. wrote:



"it is better practice to explicitly define an unordered fact  
template with a

multislot to hold the list."
I am using an unordered template with multislots and return "not a  
number"
error when i try to add / subtract multislot values. Sorry for such  
a basic
question but how do i handle the multislot values so that i can  
manipulate

them as numbers.


You haven't shown us what you're doing, so I can't say what you're  
doing wrong, but the following example works, so it might help  you  
figure this out on your own:


(deftemplate numbers (multislot values))

(defrule add-two-numbers
"Match numbers/values slots with exactly two entries and add the  
values"

(numbers (values ?a ?b))
=>
(printout t "The sum is " (+ ?a ?b) crlf))


-----
Ernest Friedman-Hill
Advanced Software Research  Phone: (925) 294-2154
Sandia National LabsFAX:   (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://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]




Re: JESS: First try with backward-chaining

2006-11-13 Thread Ernest Friedman-Hill


On Nov 10, 2006, at 12:11 AM, Skeptic 2000 wrote:



Hi,

I tried for the first time to use backward-chaining and I can't  
figure out why this simple example don't work :



It doesn't work because you never call "reset". It's good practice to  
call "reset" at some point before running any Jess program; in this  
case, it's a necessity, as the (initial-fact) fact drives the  
backward chaining. The example in the manual *does* say that the need- 
X facts are asserted "when the engine is reset", but that may not be  
explicit enough; I'll clarify the manual as best I can.


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




Re: JESS: command line behaviour on OSX

2006-11-15 Thread Ernest Friedman-Hill


On Nov 15, 2006, at 7:23 PM, Robert Kildare wrote:



I have just installed Jess on my fancy new macbook (OSX_4). I find  
that

using the command line is very limiting compared to the WinXP command
line. There is no up/down arrow history, in particular. Does anyone  
know

how I can get this functionality at the terminal, short of installing
Windows as well?



Actually, I have a neat solution for this; it works on all UNIX  
variants, Mac OS X included. Go to http://jline.sourceforge.net and  
download the JLine project. Unzip the thing to get yourself a  
jline-0.9.9.jar . Then start Jess with


java -classpath wherever/jline-0.9.9.jar:wherever/jess.jar  
jline.ConsoleRunner jess.Main


And, like magic, you'll get the Jess prompt with GNU-readline-like  
command-line editing. You could edit the bin/jess script that comes  
with Jess to do all this automatically, of course.



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




Re: JESS: multislot __data question

2006-11-15 Thread Ernest Friedman-Hill
You can handle the "run continuously" part using the "slot-specific"  
declaration in the "trial" deftemplate; see http://www.jessrules.com/ 
jess/docs/70/rules.html#slot-specific .


As far as the single value, that's because each modify call sets the  
slot to contain a single item, the sum of ?x and ?b. If you want to  
accumulate a set of values in a slot, you need to save all the values  
in a list, and then call modify once, at the end.



On Nov 14, 2006, at 6:45 PM, Soil inf. wrote:



For starters I am trying to add multislot values to a 2nd single  
slot value
and store the outcome in a third multislot. Eventually i will be  
trying to
add two multislot fields together, with all possible combination  
outputs

stored in a third multislot.
The following example runs but doesnt complete (it runs  
continuously). If i
run a step (run 1) then i only get one value, the last one  
evaluated, saved

to multislot c.
(deftemplate trial
(multislot a)
(slot b)
(multislot c))

(deffunction trial1 (?a ?b)
(foreach ?x ?a
(bind $?y(+ ?x ?b))
(printout t ?y crlf)
(modify 1 (c $?y
(defrule PTF
(trial (a $?x) (b ?b))
=>
(trial1 ?x ?b))
(reset)
(assert (soil (a 1 2 3) (b 5)))
--
View this message in context: http://www.nabble.com/multislot- 
__data-question-tf2146010.html#a7349169

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]




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




Re: JESS: Compiled Sequential rule evaluation

2006-11-17 Thread Ernest Friedman-Hill


On Nov 17, 2006, at 11:59 AM, Mitchell Christensen wrote:


Hey,



Can someone enlighten me as to what the ‘compiled sequential’ rule  
evaluation method provided by Blaze Advisor is all about?  It is  
advertised as a performance optimization over Rete.  I could pose  
the question to the Fair Isaac folks but IÂ’d like a somewhat more  
objective opinion (if that is possible).




What is sacrificed to achieve the performance gain?  Is something  
similar possible using Jess?  Does it represent an alternative to  
Rete, or is it simply an optimization of Rete based on the  
assumption of a FIFO conflict resolution?



There are a couple of alternatives to Rete that were proposed back in  
the early days: two of these are TREAT and LEAPS. LEAPS is a very  
clever algorithm that involves compiling a Rete-like network in such  
a way that the agenda automatically is ordered the right way, and on  
some agenda-intensive benchmarks (like the "Manners" benchmark) LEAPS  
can seem very fast. The thing is, of course, that the conflict  
resolution is rarely the rate-limiting step in real Rete  
applications, especially in business rules. What you sacrifice is  
some expressiveness (the semantics of "not" are different and a bit  
limited), the ability to add and remove rules on the fly (can't do  
this in LEAPS, as the whole network has to be assembled together) and  
sometimes you're required to provide "training data" upfront to do  
the rule compilation.


So anyway, this "compiled sequential mode" as well as ILOG's  
"optimized' mode are basically some variant of LEAPS. Jess can't do  
this right now, but we're looking at it for Jess 8.







Thanks.

-Mitch Christensen






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




Re: JESS: Using Vector of ADTs in shadow fact

2006-11-22 Thread Ernest Friedman-Hill
Basically, you need to have well-formed JavaBeans and  
PropertyChangeEvents. The same kinds of things that will cause Jess  
to have problems will cause problems for other JavaBeans containers.  
Here you have a property (history) whose type is Object[], and you're  
sending a PropertyChangeEvent claiming its value is now a Vector,  
which of course is wrong. Just leave the old and new values null --  
that's fine, Jess can figure it out. But if you mismatch the types,  
then yes, there are going to be problems.


Now, as far as matching the contents of vectors and instantiating  
objects and such: yes, setting things up so that you have to create  
objects just to match to seems potentially wasteful. You normally  
wouldn't do it in Java, so don't do it in Jess, either.


Now, as far as what a good way to design this problem would be in  
Jess: just have Bid objects, with an index or datestamp for ordering  
them, and don't try to hold them in a Vector or array at all. There's  
little point in doing so that I can see. If you put the bids  
themselves in working memory, then writing your rules should be  
vastly simpler.







On Nov 22, 2006, at 1:22 PM, Helge Hartmann wrote:


Hello

I have an Java-Class BiddingHistory containing a vector of abstract
data types (composed of an Enum and an int).
The Vector is only changed by java functions.

At the moment I convert the Vector to a jess List, translating each
entry to a jess symbol. So I can use it easily in rules.

But I think about whether it is better to use the class as a shadow
fact. I then would have a multislot by the method

public Object[] getHistory() {
return vector.toArray();
}

When I do  this in jess:

(deftemplate BiddingHistory
(declare (from-class BiddingHistory)))
(bind ?a (new BiddingHistory (PlayerPosition.SOUTH)))
(add ?a)
(facts)

I get this:
f-0   (MAIN::BiddingHistory (class )
 (dealer ) (history ) (lastNormalBid nil)
 (lastPartnerBid nil) (OBJECT ))

because the vector is empty.
When I now fill the vector

(bind ?bid (new Bid (Denomination.SPADE) 1))
(call ?a addBid ?bid)
(facts)

I get an error:

Async Error: Jess reported an error in routine  
DefinstanceList.updateShadowFact.

  Message: Invalid argument.
...
Caused by: java.lang.IllegalArgumentException: Argument is not an  
array

...

The addBid-Method looks like this:

public void addBid(Bid bid) {
Vector old = new Vector(this.bids);
this.bids.add(bid);
pcs.firePropertyChange("history", old, bids);
}

Do I something wrong? How can I use Vectors in shadow facts?

I thougt also about the performance. When I want to match the content
of the Vector, I have to create the ADT:

(defrule rulename
"description"
(MAIN::BiddingHistory (history
$?leading
?bid&:(eq ?bid (new (Bid (Denomination.SPADE) 1)))
))
=>
actions
)

So perhaps from a performance viewpoint, it could be better to use
symbols. But I think this is more error-prone than using shadow facts.
I am interested in your opinion about this.

Helge






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]

----


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




Re: JESS: Newbie-Question/Problem(?)

2006-11-23 Thread Ernest Friedman-Hill
Everything here looks quite reasonable, but of course, the devil is  
in the details. Things to make sure of:


1) The Person objects have to actually be added to working memory;  
you might use the "(facts)" function to check that.


2) The rules below will work if, and only if, Person has a "String  
getKey()" method and a "String getGebdat()" method, and they return  
precisely the values given in the rules.


3) Rules won't fire until you call "(run)" or jess.Rete.run().

4) If Person doesn't support PropertyChangeListeners, then the  
Rete.updateObject() has to be called whenever an object's property  
values change, or Jess won't know about the new values until you call  
(reset).


Feel free to follow up with questions, but try to provide evidence to  
support some of the above.


On Nov 23, 2006, at 9:34 AM, Thiele, Klaus wrote:


Hello,

i'm currently evaluating Rule-Engines. I've started with JBossRules,
currently i do some tests with Jess.

I try to port my Testrules from JBRules to Jess and i can't get  
these two

rules work:
(
 - Person is a JavaBean with getter/setter
 - there are ~5000 Person-Objects in WorkingMemory
 - behind 'data' is a getter-method which only returns string with all
attributes
)

(import com.PIAG.jess.Person)
(deftemplate Person (declare (from-class Person)))

(defrule datetest ""
(Person {gebdat == "12-Aug-1961"} (data ?data))
   =>
(printout t "datetest: " ?data crlf)
)

no matches! how to deal with 'date' datatypes?

(defrule moditest ""
?p1 <- (Person {key == "002|003|2034"} (data ?data1) (naname ? 
naname1))

?p2 <- (Person {key == "UNST|002|3"}  (data ?data2))
   =>
(printout t "moditest: " ?data1 " - " ?data2 crlf)
(modify ?p2 (reference ?naname1))
)

no matches!

please point me in the right direction. currently i'm studing the  
manuals

but i did'nt found anything
about my problem.

regards
-klaus


--
Klaus Thiele - Personal & Informatik AG
mailto:[EMAIL PROTECTED]

  "Ein wichtiger Charakterzug großartiger Programmierer ist  
konstruktive

Faulheit..."
   Eric S. Raymond



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]




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




Re: JESS: Using Vector of ADTs in shadow fact

2006-11-24 Thread Ernest Friedman-Hill


On Nov 24, 2006, at 7:20 AM, Helge Hartmann wrote:


Ok, I misspelled the deftemplate.


OK, I'm glad you figured it out.

I wanted to tell you that all the Jess language functions that  
manipulate the rule engine itself have some direct equivalent in  
Jess's Java APIs; often it's more efficient to use them from Java, or  
at least involves less code. In this case you can replace all of the  
below with the single line


this.knowledge.add(bid);



Helge Hartmann schrieb:

Thanks for that.
I have another problem. When I add a shadow fact from Java, the  
fact is not placed in the MAIN module.

I store the Bid from Java with
this.knowledge.store("latestBid", bid);
String cmd1 =
"(add (fetch latestBid))";
try {
this.knowledge.eval(cmd1);
} catch (JessException e) {
How can I set the module to which the fact shall be assertet?


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]




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




Re: JESS: Re: Dealing WIth User Input

2006-11-24 Thread Ernest Friedman-Hill
Nothing wrong with this rule. Are you using the "watch" function to  
monitor what's going on, or just relying on your printouts?


On Nov 23, 2006, at 12:51 PM, Hysteria86 wrote:




Thanks, I've had a go with that but I still can't get the output  
I'm looking

for. The structure of the defrule is

(defrule apples-now
(answer (ident thisweek) (text ?i))
(answer (ident lastweek) (text ?j))
(test (< ?i ?j))
=>
(printout t "You have less apples than last week" crlf))

ident is the question being asked and text the answer. The two  
questions are
represented in the deffacts (there is another rule that  
automatically asks
lastweek after thisweek, providing the answer to thisweek was > 0).  
The
system just doesn't seem to fire this method, and I can't figure  
out why.
Not sure if it's something to do with taking variables from two  
different

questions or something.
--
View this message in context: http://www.nabble.com/Dealing-WIth- 
User-Input-tf2595635.html#a7511935

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]

--------


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




Re: JESS: Newbie-Question/Problem(?)

2006-11-24 Thread Ernest Friedman-Hill

On Nov 24, 2006, at 10:22 AM, Thiele, Klaus wrote:


i'm playing around... - using different attributes for selecting  
the second

fact:

(defrule testit ""
?p1 <- (Person {key == "TMT|002|101"} (data ?data1))
;;?p2 <- (Person {key == "011|002|5"} (data ?data2))
?p2 <- (Person {naname == "Audi"} {vorname == "Amelia"} (data ? 
data2))

   =>
(printout t "testit: " ?data1 " - " ?data2 crlf)
)

this works! is it a bug?


Ahhh.

What's you're doing is so reasonable, that it even fooled me.

The "infix tests", the ones with the curly braces, are new in Jess 7.  
Their syntax is easier for Java folks to grasp, but they do lack some  
of the power of the full old-school Jess syntax. I expected that we  
might need to refine things over the next few point releases, and  
here, I think, is an excellent example of this. I just didn't realize  
how confusing this would be to someone new to Jess, someone who  
didn't understand the alternatives available.


Anyway, when you write an infix test like {key == "TMT|002|101"}, in  
the current version of Jess, at least, this defines a variable 'key'  
which is active for the rest of the rule. By using another infix test  
on the same property in a subsequent pattern, you've unintentionally  
unified the two patterns. Since "?key" can't be equal to two  
different values at once, the rule never matches.


A correct way to express your original rule, and one which works as  
you'd expect, is



(defrule testit ""
?p1 <- (Person (key "TMT|002|101") (data ?data1))
?p2 <- (Person (key "011|002|5") (data ?data2))
   =>
(printout t "testit: " ?data1 " - " ?data2 crlf)
)


I'm truly surprised this hasn't come up before now. We'll keep this  
in mind as work on Jess 7.1 progresses.





-

ok, i test with this workaround - next question:

(defrule geschltest ""
(Person {geschl == "X"} (data ?data))
   =>
(printout t "geschltest: " ?data crlf)
)

(defrule moditest ""
?p1 <- (Person {key == "002|003|2034"} (data ?data1) (naname ? 
naname1))

?p2 <- (Person {naname == "Weissnich"} {vorname == "Albert"} (data
?data2))
  =>
(printout t "moditest: " ?data1 " - " ?data2 crlf)
(modify ?p2 (reference ?naname1) (geschl "X"))
)

(defrule hardwork ""
(Person (naname ?naname) (data ?data1))
(Person {reference == ?naname} (data ?data2))
   =>
(printout t "hardwork: " ?data1 " - " ?data2  crlf)
)

gives folowing output:
DEBUG (jess.JessDB:101) - fireAllRules: Start [2006-11-24  
16:16:50.664]

moditest: [002|003|2034|Tierarzt|Tina|W|1960-06-06] -
[UNST|002|3|Weissnich|Albert|M|1933-02-12]
moditest: [002|003|2034|Tierarzt|Tina|W|1960-06-06] -
[UNST|002|3|Weissnich|Albert|M|1933-02-12]
hardwork: [002|003|2034|Tierarzt|Tina|W|1960-06-06] -
[UNST|002|3|Weissnich|Albert|M|1933-02-12]
geschltest: [UNST|002|3|Weissnich|Albert|M|1933-02-12]
DEBUG (jess.JessDB:103) - fireAllRules: Ende  [2006-11-24  
16:16:50.667]

Laufzeit 3ms

Why was rule moditest called twice? because of modify ?p2? but ?p1  
was not

modified so
i don't expect this behavior (it isn't in JBRules...)


This kind of "refraction" is standard behavior for the OPS/CLIPS/Jess  
family of rule engines. Jess 7 lets you modify this behavior in two  
ways: the "no-loop" declaration for rules, and the "slot-specific"  
declaration for templates. Both of these are documented in the manual.




ok, a workaround should be
?p2 <- (Person {naname == "Weissnich"} {vorname == "Albert"}  
{geschl !=

"X"} (data ?data2))
but i think, that ist not nessesary...



That was the workaround before Jess 7.


regards (and a nice weekend)
klaus


-Ursprüngliche Nachricht-
Von: Thiele, Klaus
Gesendet: Freitag, 24. November 2006 12:05
An: 'jess-users@sandia.gov'
Betreff: Re: JESS: Newbie-Question/Problem(?)


Hello Ernest,
thanks for the quick response!

1) yes, the facts are in working memory:
[...]
f-4547   (MAIN::Person (ak "ANG06") (class Object:java.lang.Class>)

(data "[OED|ANG06|2000|Gerdes|Harald|M|1961-08-12]") (gebdat
) (gebdatStr "1961-08-12") (geschl "M")  
(key
"OED|ANG06|2000") (man "OED") (naname "Gerdes") (pnr "2000")  
(reference "?")

(vorname "Harald") (OBJECT ))
For a total of 4548 facts in module MAIN.

2) for the datetest i added a string returning function to Person  
and it

works
   yes, there ist a getKey() method
3) yes, .run() was c

Re: JESS: Re: Dealing WIth User Input

2006-11-26 Thread Ernest Friedman-Hill
Well, I'd add "(watch all)" to the beginning of your program, and see  
that the facts you think are being asserted are actually being  
asserted, and the right rules are being activated, etc. This is a  
very simple rule and it would work perfectly well if the appropriate  
facts were there.


On Nov 26, 2006, at 12:39 PM, Hysteria86 wrote:



Just been going by the printouts, as all of the other questions  
have printed
out fine (most of them are yes/no), it asks the 'thisweek' question  
and
takes the number, this correctly then loads the 'lastweek'  
question, but
after I enter a value for this, the response isn't printed, it just  
comes to

the end of the program and returns the number of rules.



Ernest Friedman-Hill wrote:


Nothing wrong with this rule. Are you using the "watch" function to
monitor what's going on, or just relying on your printouts?

On Nov 23, 2006, at 12:51 PM, Hysteria86 wrote:




Thanks, I've had a go with that but I still can't get the output
I'm looking
for. The structure of the defrule is

(defrule apples-now
(answer (ident thisweek) (text ?i))
(answer (ident lastweek) (text ?j))
(test (< ?i ?j))
=>
(printout t "You have less apples than last week" crlf))

ident is the question being asked and text the answer. The two
questions are
represented in the deffacts (there is another rule that
automatically asks
lastweek after thisweek, providing the answer to thisweek was > 0).
The
system just doesn't seem to fire this method, and I can't figure
out why.
Not sure if it's something to do with taking variables from two
different
questions or something.
--
View this message in context: http://www.nabble.com/Dealing-WIth-
User-Input-tf2595635.html#a7511935
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]
--------


-
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 owner-jess- 
[EMAIL PROTECTED]







--
View this message in context: http://www.nabble.com/Dealing-WIth- 
User-Input-tf2595635.html#a7549193

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]

----


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




Re: JESS: Removing a shadow fact

2006-11-27 Thread Ernest Friedman-Hill


On Nov 27, 2006, at 7:11 PM, Skeptic 2000 wrote:


ShadowFactClass x1 = new ShadowFactClass();
ShadowFactClass x2 = new ShadowFactClass();
ShadowFactClass x3 = new ShadowFactClass();

rete.add(x1); rete.add(x2); rete.add(x3)

.

Somewhere else in the code I woule like to remove from the working  
memory of one those three shadow facts, what would be the proper  
way ? (in this place, I have access both to the rete engine and the  
x1,x2,x3 variables)




The opposite of "Rete.add()" is "Rete.undefinstance()".

There ought to be a "remove()", don't you think?

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




Re: JESS: beginner questions...

2006-11-29 Thread Ernest Friedman-Hill

On Nov 29, 2006, at 10:45 AM, John Sanabria wrote:


hi,  please someone help me with that, are silly questions.

1- JESS? What stand for? I mean J is for ??? E for ??? S for ??? S  
for ???




It's not "JESS", it's "Jess". It doesn't stand for anything.

2- There exist a publication related, in particular, to JESS  
implementation?




No, not really. There is a (dated) PowerPoint presentation available  
from the "Related Web Sites" portion of www.jessrules.com about the  
implementation of Jess 4 .


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




Re: AW: JESS: something wrong with my JavaBean?

2006-11-30 Thread Ernest Friedman-Hill


On Nov 30, 2006, at 9:38 AM, Thiele, Klaus wrote:



oops, strange
there is an additional getter on a variable, that causes this error:

private java.util.Date gebdat;

public String getGebdatStr() {
// don't work: return gebdat.toString();
return "Hello World!";// this ist Ok!  
}


If if "gebdat" is null, then calling getGebdatStr as written will  
throw a NullPointerException; that's probably what you're seeing  
here. The JavaBeans spec doesn't allow for properties to be null,  
anyway, although Jess doesn't care about that. Your properties should  
have valid default values.



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




Re: JESS: something wrong with my JavaBean?

2006-11-30 Thread Ernest Friedman-Hill

On Nov 30, 2006, at 8:06 AM, Thiele, Klaus wrote:



Jess reported an error in routine DefinstanceList.updateMultipleSlots
while executing (add ?p1).
  Message: Called method threw an exception.
  Program text: ( add ?p1 )  at line 23.

what happens?


"Called method threw an exception" means that some method in your  
JavaBean threw an exception. The specific error doesn't get printed  
out by default at the Jess prompt. To see the full stack trace and  
find out what the problem is, rerun your program using the "- 
stacktrace" command-line switch -- i.e.,


jess -stacktrace myfile.clp

or

java jess.Main -stacktrace myfile.clp

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




Re: JESS: WG: JessDE: problems with classpath resolution

2006-12-01 Thread Ernest Friedman-Hill

On Dec 1, 2006, at 5:36 AM, Bergner, Olaf (Saxonia) wrote:

With Jess 7.0 out the doors, we are starting to use its set of  
Eclipse plugins. However, the Jess editor complains about not being  
able to resolve _any_ imported java class. I suspect that this is  
related to


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

which, unfortunately, was left unanswered. So I would like to  
repeat the question: is there a workaround for the case when a  
project's name is not identical to the name of the project folder?


This is a known problem.

The current version of the JessDE uses your actual compiled class  
files. If Eclipse is set up so that the compiled class files end up  
outside the workspace (as is the case if you import a build.xml to  
create a project, for example) then for reasons that are not clear to  
me, these locations aren't included in the project classpath that's  
available to plugins like the JessDE. Even if you include these  
directories explicitly in the "Project Build Path", Eclipse does not  
pass them to the JessDE at the crucial moment; they seem to  be  
deliberately removed.


There are two possible fixes: one is for the JessDE to use Eclipse's  
classfile parser; this is a good goal and the right solution, but  
difficult to implement. The other would be for the JessDE to somehow  
find out about these additional directories by itself; it's not clear  
how to do this either.


In either case, expect a fix in a future point release.

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




Re: JESS: A problem with accumulate

2006-12-02 Thread Ernest Friedman-Hill


On Dec 2, 2006, at 2:28 AM, Skeptic 2000 wrote:



Hi,

I have a serious problem with accumulate, I wanted to use it on  
some shadow facts, but I noticed that I can't have more than one  
"contained CE".




Yes, that's a limitation of the current implementation; it should be  
lifted for Jess 7.1.


Something like (modifed from the manual):

?c <- (accumulate (bind ?list (new java.util.ArrayList))
(?list add ?o)
 ?list
(employee (OBJECT ?o))
(test (?o xyzMethod "arg1")) ; <- that can't work  
if I understand correctly :(

  =>
  (printout t (?c toString)  crlf))


In this case, there would be no problem with just adding the call to  
xyzMethod to the employee CE directly -- i.e.,


(employee (OBJECT ?o&:(?o xyzMethod "arg1")))



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




Re: JESS: agenda change in Jess 7.0 and custom Strategies

2006-12-02 Thread Ernest Friedman-Hill

A good technical question!

The method listActivations() is not used internally by Jess; it's  
just provided for use by tools of various kinds. It's a fairly  
expensive method because it makes a copy of the whole agenda, and  
iterating over this copy does a full sort. The copy is necessary; the  
process of iterating over all the activations is destructive. They're  
not kept in sorted order -- they're pulled out "just in time." Anyway  
concern over using == vs equals() may be misplaced -- this is a small  
difference compared to the overall expense of copying the whole  
agenda. This much has always been true.


What's changed in 7.0 is that an Activation object can't be part of  
more than one agenda at a time, because the Activation "knows" where  
in the agenda it lies. In older versions, the same Activation objects  
would live in the copied agenda as in the original; now copies are  
made of all the Activations, too. This new property of Activation  
objects is an optimization; it makes the process of removing  
activations from the agenda before firing them (due to a retraction,  
for example) much more efficient.


I thought of this as an internal implementation detail and so didn't  
document it, but the change is permanent.



On Dec 2, 2006, at 8:07 PM, Jonathan Sewall wrote:

I've found that the method below behaves differently in Jess 7.0b7  
and the formal v7.0 release.  In the formal release, the  
Activations provided by the Iterator in 2 successive calls to  
Rete.listActivations() are different objects, even if nothing has  
happened between the calls.  The change has ramifications for those  
with custom Strategy implementations.  In our case, we scan the  
agenda for a particular Activation to favor before calling run(),  
and then our Strategy's compare() method tests its arguments for  
that object with the == operator.
We can, with some impact on performance (presumably negligible on  
short agendas), use the Activation.equals() method instead of the  
== operator.  But I wanted to ask about the intent of the change,  
and whether it's likely to be permanent.  I hadn't seen (but could  
have simply missed) mention of it in the notes since beta 7.   
Thanks very much,


Jonathan


   public void dumpAgenda(String label) {
   Map actMap = new HashMap();
   Iterator it = listActivations();   // get the agenda and  
store Activations

   for (int i = 0; it.hasNext(); ++i) {
   Activation a = (Activation) it.next();
   actMap.put(new Integer(a.hashCode()), a);
   }
   it = listActivations(); // get the agenda again; no  
intervening activity

   for (int i = 0; it.hasNext(); ++i) {
   Activation a = (Activation) it.next();
   Activation aa = (Activation) actMap.get(new Integer 
(a.hashCode()));

   System.out.println("agenda a["+i+"]"+
   (aa == null ? " not" : "")+" in map,"+   // aa ! 
= null in both v7.0b7 and 7.0
   (a == aa ? "" : " not")+ " same obj");   // aa  
== a only in v7.0b7

   }
   }

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]




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




Re: JESS: need help

2006-12-03 Thread Ernest Friedman-Hill
First I should point out that your terminology is incorrect here.  
"red" and "blue" aren't facts, they're merely symbols; and they're  
not stored in working memory, but rather in an area simply called  
"storage". Only actual facts are stored in working memory, and this  
is done solely by using assert (or definstance, etc.)


Storage is intended for transferring things between Jess and Java, as  
you've done here. It's merely a HashMap; the first argument to  
"store" or "fetch" is the key to the map. Therefore if you store two  
things with the same key, the second one erases the first. That's  
what's happening in your code.


You could go two ways here. If "red" and "blue" are intended only for  
transmitting back to Java, then using storage makes sense; you just  
need to store things in a way that doesn't discard values. For  
example, you could store an ArrayList, then add items to that list;  
then the whole ArrayList would be available to Java code:


;; In Jess

(store first (new java.util.ArrayList))
...
((fetch first) add red)

// In Java
ArrayList firsts = (ArrayList) rete.fetch("first");


Alternatively, you could use actual facts instead of storage, and  
retrieve things from Java using either defqueries, or Rete.listFacts 
() with a filter.


On Dec 3, 2006, at 6:38 AM, Venkat Kasuganti wrote:


I have the following rules and facts in Jess:

(defrule ruleone (enter name) => (store first red) (assert (enter  
place)))
(defrule ruletwo (enter place) => (store first blue) (assert (enter  
animal)))

(reset)
(assert (enter name))

I have the following code in Java to retrieve the facts red and blue
and print them.

import jess.*;

public class ReteFirst {



  public static String forwardQuestions() throws Exception {

  Rete engine = new Rete();
  engine.executeCommand ("(batch firstrules.clp)");

  //System.out.println ("New Rete is created");
  engine.run();

  Value myValue = engine.fetch("first");

  String s = myValue.stringValue(engine.getGlobalContext 
());


  return s;
  }



  public static void main(String args[]) throws Exception {

  //ReteFirst a = new ReteFirst();


  System.out.println(ReteFirst.forwardQuestions());




  }
}

When I execute this code I get only the last fact ie blue printed.  I
need both facts printed. Is there a specific function to search the
working memory to test the existence of fact based on the head?

Please help.

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]




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




Re: JESS: a small niggle

2006-12-05 Thread Ernest Friedman-Hill


On Dec 5, 2006, at 10:32 AM, Scott Moss wrote:

When I use a block comment /*...*/ in JessDE, the automatic  
indentation

seems to fail thereafter.  Is this an idiosyncrasy of my setup or
something I am doing?  Or is it a fairly trivial -- but nonetheless
irritating -- bug in JessDE?


It's that last one. It's already on the issues list, to be resolved  
in a patch release coming soon.



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




Re: JESS: Changes to User Functions?

2006-12-07 Thread Ernest Friedman-Hill
Nothing changed that would affect this function, no; it seems more  
likely that the modify isn't being called. Have you used "watch all"  
to see that that the fact is being changed when the rule fires?


On Dec 7, 2006, at 7:26 AM, Mike Dean wrote:


I have written (or adapted from someone else) a routine to append text
to a slot in a shadow fact, which is then displayed to the user as an
explanation for a decision.  This routine worked until recent  
switch to

release version of Jess, and I cannot identify any changes in my own
code during same period.  Has there been a change that would explain
this?

Here is an example rule:

(defrule moderate-hypoglycemia-definition
"Define whether hypoglycemia is moderate"
(currentGlucoseBelowRange)
?decision <- (GlucoseDecision (serumGlucoseConcentration
?value))
=>
(if (and (< ?value ?*moderateHypoglycemiaLimit*) (>= ?value
?*extremeHypoglycemiaLimit*))
then (assert(moderateHypoglycemia))
(modify ?decision (rationaleText (append-text (fact-slot-value
?decision rationaleText)
"The patient is moderately hypoglycemic (< 60 mg/dL).")))
)   )

My function is append-text, which is loaded earlier in the clp file:

(load-function edu.utah.cdmcc.jess.extensions.TextAppendFunction)

Here is the Java code for the function:

public class TextAppendFunction implements Userfunction {
private static String NEWLINE =
System.getProperty("line.separator");

public String getName() {
return "append-text";
}

public Value call(ValueVector vv, Context context) throws
JessException {
String oldString= vv.get(1).stringValue(context);
System.out.println(oldString);
StringBuffer sb = new StringBuffer(100);
if (oldString.length() > 0) {
sb.append(oldString.toString());
sb.append(NEWLINE);}
for (int i = 2; i < vv.size(); i++) {
Value v = vv.get(i).resolveValue(context);
switch (v.type()) {
case RU.SYMBOL:
// noinspection
EqualsBetweenInconvertibleTypes
if (v.equals("crlf")) {
sb.append(NEWLINE);
break;
}
// FALL THROUGH
case RU.STRING:
sb.append(v.stringValue(context));
break;
case RU.INTEGER:
sb.append(v.intValue(context));
break;
case RU.FLOAT:
sb.append(v.numericValue(context));
break;
case RU.FACT:
sb.append(v);
break;
case RU.LIST:

sb.append(v.listValue(context).toStringWithParens());
break;
case RU.JAVA_OBJECT:
sb.append(v.toString());
break;
default:
sb.append(v.toString());
}
}
Value result = new Value(sb.toString(),RU.STRING);
return result;
}
}

There is no complaint from the program, but instead of having  
something

like:

The glucose is low.
The patient is on insulin.
Insulin should be turned off when glucose is low.

I am now just getting

The glucose is low.

The rules are firing correctly, according to the trace.

Thanks for any assistance.

- Mike



J. Michael Dean, M.D., M.B.A.
H.A. and Edna Benning Presidential Professor of Pediatrics
Professor of Family and Preventive Medicine
Professor of Biomedical Informatics
Chief, Division of Pediatric Critical Care
Vice Chairman, Department of Pediatrics
University of Utah School of Medicine

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]

--------


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

Re: JESS: Watch all from Java

2006-12-07 Thread Ernest Friedman-Hill


On Dec 7, 2006, at 11:04 PM, Mike Dean wrote:


There is no watch constant "ALL" in the API.  I have guessed that I
simply use the existing watch constants combined with bit Or
(WatchConstant.RULES | WatchConstant.FACTS |  
WatchConstant.ACTIVATIONS).
 Is there a simpler syntax, and/or is what I am doing correct?   
Thanks.




There's a separate method "watchAll()".

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




Re: JESS: User Function Question Continued

2006-12-07 Thread Ernest Friedman-Hill
Can I see a part of the "watch all" output in which these two rules  
fire (including all the modify output from the second rule?) Offhand,  
there's nothing here that seems outright wrong. Inefficient, maybe --  
combining the three successive modifies on the same fact into one  
call that including all three slot modifications would be much more  
efficient -- but not wrong.


On Dec 7, 2006, at 10:59 PM, Mike Dean wrote:


Have traced in more detail and the rules appear to be firing, but the
facts are not being properly updated, as you suspect.  But not sure  
why,
as I have not worked on the rules file for several months and this  
used

to append the advice and rationale text appropriately.

In the following two rules, the first one is intended to tell the user
to give glucose to someone with very low glucose, calculate a
recommended dose, and provide a reasonable explanation.  The second  
one

is intended to tell the user to turn off insulin, IF it is running.
When I run the program with a low glucose but no insulin being given,
the fact is altered to include the text "Administer glucose".   
When

I run the program with a low glucose and insulin IS being given, then
the fact is not actually modified to include the Administer glucose
text, but is modified to include the text "Turn OFF the insulin ...".
In both situations, interestingly, the glucose bolus (dose) IS  
properly

updated in the fact.


(defrule give-glucose-extreme
"Give glucose for extreme hypoglycemia"
(extremeHypoglycemia)
?decision <- (GlucoseDecision (patientWeight ?weight))
=>
(assert(recommendedGlucoseBolus))
(modify ?decision (recommendedGlucoseBolus (* ?weight
?*highGlucoseDosePerKg*)))
(modify ?decision (adviceText (append-text
(fact-slot-value ?decision adviceText)
"Administer glucose (0.50 gm/kg = " (format nil "%.2f" (*
?weight ?*highGlucoseDosePerKg*)) " grams).")))
)


(defrule recommend-off-insulin
"If we need the insulin off, then recommend it be turned off."
(needInsulinOff)
?decision <- (GlucoseDecision)
=>
(assert (recommendedInsulinOff))
(modify ?decision (recommendedInsulinDripRate 0.0))
(modify ?decision (adviceText (append-text (fact-slot-value
?decision adviceText)
"Turn OFF the insulin drip.")))
(modify ?decision (rationaleText (append-text (fact-slot-value
?decision rationaleText)
   "The patient is receiving insulin despite being
hypoglycemic.")))
)


J. Michael Dean, M.D., M.B.A.
H.A. and Edna Benning Presidential Professor of Pediatrics
Professor of Family and Preventive Medicine
Professor of Biomedical Informatics
Chief, Division of Pediatric Critical Care
Vice Chairman, Department of Pediatrics
University of Utah School of Medicine

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]

--------


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




Re: JESS: Problem with watch router

2006-12-08 Thread Ernest Friedman-Hill


On Dec 8, 2006, at 4:48 AM, Helge Hartmann wrote:



I have a problem with the watch router... Facts and focus is send  
to southWatchWriter, but the firing of rules is still send to  
standard output.


You're right -- it's a bug. Thanks for the report. There is going to  
be a patch release before Christmas and this will be fixed.


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




Re: JESS: User Function Question Continued

2006-12-08 Thread Ernest Friedman-Hill
t; Focus MAIN
 ==> f-0 (MAIN::initial-fact)
 ==> f-1 (MAIN::GlucoseDecision (acceptComment "") (adviceText "")
(carbohydrateStatus 1) (class )
(currentInsulinDripRate 0.0) (decisionTimeStamp
) (declineComment "")
(glucoseChangePerHour nil) (id nil) (minutesToNextEvaluation 99)
(observationDate )
(otherComment "") (patient
) (patientAgeDays 2550)
(patientHeight 72.86) (patientWeight 30.34) (pcs
)
(previousGlucoseConcentration -1) (previousObservationTime nil)
(rationaleText "") (recommendedGlucoseBolus 0.0)
(recommendedInsulinBolus 0.0) (recommendedInsulinDripRate 0.0)
(rulesFiredText "") (serumGlucoseConcentration 12) (userAction
"Pending") (valid TRUE) (version 0) (OBJECT
))
==> Activation: MAIN::is-child :  f-1
==> Activation: MAIN::current-glucose-range :  f-1
==> Activation: MAIN::is-insulin-on-or-off :  f-1
 ==> f-2 (MAIN::currentGlucoseBelowRange)
==> Activation: MAIN::mild-hypoglycemia-definition :  f-2, f-1
==> Activation: MAIN::moderate-hypoglycemia-definition :  f-2, f-1
==> Activation: MAIN::extreme-hypoglycemia-definition :  f-2, f-1
 ==> f-3 (MAIN::extremeHypoglycemia)
==> Activation: MAIN::give-glucose-extreme :  f-3, f-1
 ==> f-4 (MAIN::recommendedGlucoseBolus)
 ==> f-5 (MAIN::pediatric)
 ==> f-6 (MAIN::insulinOff)
 <== Focus MAIN
 <=> f-1 (MAIN::GlucoseDecision (acceptComment "") (adviceText
"Administer glucose (0.50 gm/kg = 15.17 grams).")  
(carbohydrateStatus 1)

(class ) (currentInsulinDripRate 0.0)
(decisionTimeStamp )
(declineComment "") (glucoseChangePerHour nil) (id nil)
(minutesToNextEvaluation 99) (observationDate
) (otherComment "") (patient
) (patientAgeDays 2550)
(patientHeight 72.86) (patientWeight 30.34) (pcs
)
(previousGlucoseConcentration -1) (previousObservationTime nil)
(rationaleText "The patient is extremely hypoglycemic (< 40 mg/dL).")
(recommendedGlucoseBolus 15.17) (recommendedInsulinBolus 0.0)
(recommendedInsulinDripRate 0.0) (rulesFiredText "")
(serumGlucoseConcentration 12) (userAction "Pending") (valid TRUE)
(version 0) (OBJECT
))
 <== f-1 (MAIN::GlucoseDecision (acceptComment "") (adviceText
"Administer glucose (0.50 gm/kg = 15.17 grams).")  
(carbohydrateStatus 1)

(class ) (currentInsulinDripRate 0.0)
(decisionTimeStamp )
(declineComment "") (glucoseChangePerHour nil) (id nil)
(minutesToNextEvaluation 99) (observationDate
) (otherComment "") (patient
) (patientAgeDays 2550)
(patientHeight 72.86) (patientWeight 30.34) (pcs
)
(previousGlucoseConcentration -1) (previousObservationTime nil)
(rationaleText "The patient is extremely hypoglycemic (< 40 mg/dL).")
(recommendedGlucoseBolus 15.17) (recommendedInsulinBolus 0.0)
(recommendedInsulinDripRate 0.0) (rulesFiredText "")
(serumGlucoseConcentration 12) (userAction "Pending") (valid TRUE)
(version 0) (OBJECT
))


Finally, I show the code below that calls Jess:

private void fireRulesEngine() {
emptyTrace.setText("");
SWTTextWriter invisibleTraceWriter = new
SWTTextWriter(emptyTrace);
Rete r = GlucosePlugin.getDefault().getRete();
r.addOutputRouter("traceOut", invisibleTraceWriter);
try {
r.reset();
r.setWatchRouter("traceOut");
} catch (JessException e1) {
displayExceptionInformation(e1);
}
try {
r.add(decision);
r.watchAll();
r.run();
r.updateObject(decision);
r.undefinstance(decision);
System.out.println(decision.getAdviceText());
} catch (JessException e) {
displayExceptionInformation(e);
}
// If no advice resulted from running the inference
engine
if (decision.getAdviceText().length() == 0) {
decision.setAdviceText("No change at this
time.");
}
// Get the rule trace text and stick it into the
decision object
decision.setRulesFiredText(emptyTrace.getText().toString());
// Fire property change so listeners can act
GlucosePlugin.getDefault().fireDecisionChanged(decision);
}

Thank you for your help with this.

- Mike

J. Michael Dean, M.D., M.B.A.
H.A. and Edna Benning Presidential Professor of Pediatrics
Professor of Family and Preventive Medicine
Professor of Biomedical Informatics
Chief, Division of Pediatric Critical Care
Vice Chairman, Department of Pediatrics
University of Utah School of Medicine
--

Re: JESS: RukleEditor convert JessML to Jess

2006-12-08 Thread Ernest Friedman-Hill


On Dec 8, 2006, at 5:38 AM, Helge Hartmann wrote:


Hi!

In the manual there is a section on converting Jess to JessML. I am  
going to write a rule editor and want to use JessML. As XML is not  
a good readable format, I am interested in converting my JessML  
results to Jess. But I don't know how to do this. Is the  
functionality included in Jess?




There's no source-to-source translator as there is for Jess to  
JessML, no. The JessSAXParser class can be used to read JessML code  
into a Rete object, and from there you could extract, e.g., the  
Defrules, and use the PrettyPrinter class to turn those into Jess code.



I also read about the article "Modeling Rule-Based Systems with  
EMF". This seems to be interesting. Do you think, this would be a  
good way to produce the Jess code? As I am not familar with EMF, I  
shy away from this approach. Where are the main advantages over  
using JessML?




I think EMF is a good thing for tool building. JessML is an  
underlying technology which could easily be used by an EMF solution;  
they're not really alternatives.


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




Re: JESS: User Function Question Continued

2006-12-09 Thread Ernest Friedman-Hill


On Dec 9, 2006, at 2:53 PM, J Michael Dean wrote:


The GlucoseDecision.setAdviceText() is a trivial setter.


OK, that's all we need to know. The GlucoseDecision class supports  
PropertyChangeListeners, and Jess takes that as a promise that  
whenever setX() is called, an "X has changed" event will come back.  
Until that event has come, Jess's working memory image of that object  
is unchanged. Since your setter breaks the contract and doesn't send  
the event, Jess loses track of the values of your object's slots.


So here's the scenario. Imagine that the "adviceText" slot contains  
something, we'll call it "?X". You call the equivalent of


(modify ?decision (str-cat ?X "more advice"))

Jess then calls setAdviceText(?X + "more advice"), and then that's  
what the object contains. But working memory isn't updated until the  
change event comes back -- and in this case, it never does. Now  
working memory and the object are out of sync, and this is bad.


Then the next rule fires and it calls

(modify ?decision (str-cat ?X "even more advice"))

and so Jess calls setAdviceText(?X + "even more advice"). The value  
of ?X is the same since working memory was never updated. The text  
"more advice" is completely lost! That's what's happening here.


So there are two different ways to fix this. First, you can  
explicitly tell Jess to ignore your PropertyChange mechanism, since  
it's broken. To do this, you could say '(definstance GlucoseDecision ? 
decision static)' instead of '(add ?decision)'. For "static"  
definstances -- those that don't have PropertyChangeListeners -- the  
'modify' function changes both working memory and the Java object.


The other way would be to fix setAdviceText so that it sends an  
appropriate event after setting the property value.


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




Re: JESS: getting the factID

2006-12-10 Thread Ernest Friedman-Hill


On Dec 10, 2006, at 11:45 PM, Robert Kildare wrote:

I have spent a couple of hours with the manual and Jess in Action, but
must be suffering from man-blindness or wrong-tree barking. Can  
someone

help me to get the factID of a fact from within JESS?


If you've got the Fact object bound to a variable ?f -- for example,  
as by


(bind ?f (assert (foo)))

or on a rule LHS

?f <- (foo)

Then to get the numeric ID, you can say

(bind ?id (?f getFactId))

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




Re: JESS: User Function

2006-12-10 Thread Ernest Friedman-Hill


On Dec 10, 2006, at 9:25 AM, Mike Dean wrote:


Adding property change event worked like a charm.  Thank you very much
for your help on this.

- Mike


Thank you, as well, for your patience. These kinds of discussions are  
very valuable to me -- they help me understand people's mindset when  
approaching Jess. Knowing what people expect to happen is useful!


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




Re: JESS: Property Change

2006-12-10 Thread Ernest Friedman-Hill


On Dec 10, 2006, at 9:16 AM, Mike Dean wrote:



Is this reasoning correct?  Thank you.



Not all of it. I have now in my head a rough draft for a new section  
of the manual to explain this stuff; I will post it here when I get  
something written down. For now I will just say that if you lay it  
all out, there are *four* different cases to consider. First, you  
must consider what happens when an object is modifying by Jess's  
modify function, or directly by calling a method on the object; and  
then you have to consider each of these two cases both when Jess is  
registered with the object as a PropertyChangeListener, and when it's  
not. Each of these four cases is different.


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




Re: JESS: RukleEditor convert JessML to Jess

2006-12-11 Thread Ernest Friedman-Hill


On Dec 11, 2006, at 3:38 AM, Helge Hartmann wrote:

Does this mean, that instead of producing Jess or JessML code, I  
could create the modules, templates and rules on an Rete object and  
then use the PrettyPrinter class to produce the code? Wouldn't this  
be the easiest way?




You *could* do that; all the needed APIs are now public, since the  
rule-creation APIs are all in jess.*, while the XML parser which uses  
them are in jess.xml.* . But it's still not recommended because the  
APIs are somewhat complex to use, largely undocumented, and change  
often. Keeping them stable, or putting effort into documenting the  
changing APIs, would restrict Jess's ability to evolve and add new  
features.


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




Re: JESS: xfer-examples

2006-12-15 Thread Ernest Friedman-Hill

We don't ship the examples in the package jess/examples anymore; the
small number of examples gave users a distorted view of what's
important about Jess, and as a result most Jess code I saw would be
based on these really inappropriate trivial examples. The mention that
you found in the manual is an error that will now be removed.

In any case, I'll paste the file here so you can see it; it's also
still available in the Jess 6.1 distro. It's very simple. It just
shows Jess calling "store" and Java calling "fetch" -- nothing earth
shattering.
-
import jess.*;
import java.awt.Point;

public class Main
{
 public static void main(String[] argv)
 {
   try
 {
   // *
   // Create engine; load in some extra functions
   Rete rete = new Rete();

   // *
   // Send initial parameters to Jess

   rete.store("A", new Value(1, RU.INTEGER));
   rete.store("B", new Value(3.14159, RU.FLOAT));
   rete.store("C", new Point(10,10));

   // *
   // Define some rules. The first rule fetches the inputs and asserts
   // them as facts; the second rule matches those facts and stores
   // a result based on the inputs. Note that the rules could just
   // as easily have come from a file, but I wanted to make this
   // example self-contained.

   rete.eval("(defrule startup" +
   " =>" +
   "  (assert (input-1 (fetch A)))" +
   "  (assert (input-2 (fetch B)))" +
   "  (assert (input-3 (fetch C");

   rete.eval("(defrule match-input" +
   "  (input-1 ?a&:(< ?a 2))" +
   "  (input-2 ?b)" +
   "  (input-3 ?c&:(external-addressp ?c))" +
   " =>" +
   "  (store RESULT (+ ?a ?b)))");

   // *
   // Run the rules
   rete.reset();
   rete.run();
   // *
   // Fetch the result (4.14159) and print it out
   System.out.println("The answer is: " + rete.fetch("RESULT"));
 }
   catch (JessException re)
 {
   re.printStackTrace();
 }
 }
}
-

On 12/15/06, Thiele, Klaus <[EMAIL PROTECTED]> wrote:




Hello,

i'm now testing transferring values between Jess an java (Manual 8.2) but
i'm missing
the examples under Jess70/jess/examples/xfer/.

How to get them?

regards
- klaus


--
Klaus Thiele - Personal & Informatik AG
mailto:[EMAIL PROTECTED]

  "Ein wichtiger Charakterzug großartiger Programmierer ist konstruktive
Faulheit..."
   Eric S. Raymond



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: Why is this rule being activated?

2006-12-17 Thread Ernest Friedman-Hill


On Dec 16, 2006, at 12:22 AM, Gary Riley wrote:


Why is this rule activated?
Why is this rule activated?


Due to a previously unreported bug; thanks for the report. The fix  
for this will  be in 7.0.1, which will be out 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]




Re: JESS: Mixing facts from Java and Jess script

2006-12-19 Thread Ernest Friedman-Hill

On Dec 18, 2006, at 10:13 PM, Mike Stacey wrote:



(defrule TA::Initiates
 (mon (reading ?r&:(>= ?r 143))
 (tstamp ?t&:(> ?t 0))
 (posLshift (truth_val false)))
 =>
 (assert posLshift(truth_val 1))
 (printout t "Initiates: Data "?r" bpm, timestamp "?t", Fluent truth
count:  "  crlf))


Error is:

"Jess reported an error in routine Jesp.parsePattern
while executing (batch rules/ec-1.clp).
Message: No such slot posLshift in template MAIN::mon at token
'posLshift'."



There's a missing close-parenthesis on the first line (three open,  
only two close) so Jess thinks you mean to test the contents of the  
"tstamp" and "posLshift" slots in a "mon" fact.


The JessDE is pretty good at helping you spot this sort of problem.  
Besides formatting your code so that your errors are more obvious,  
this kind of error will lead to a train wreck with all sorts of error  
markers from this point on in the file, giving you a strong hint that  
something is wrong. If you can't use the JessDE, use the Lisp mode in  
any programmer's editor -- it will know how to format Jess code to  
point out this error.


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




Re: JESS: Call a java function from rules in jess

2006-12-20 Thread Ernest Friedman-Hill


On Dec 20, 2006, at 4:48 AM, jaggie wrote:



//I want to call the function warning in the RHS but without  
creating a new
instantiation of the bean, I want to call the warning from the  
variable ?da

defined up there.



The template "agent", like all templates created from Java classes,  
has a slot OBJECT, which will contain the Java object that the shadow  
fact is connected to. So match the OBJECT slot to a variable on the  
LHS, and then you can call a method of the object on the RHS:


 (defrule watchlife
 (agent {life < 70} (OBJECT ?da))
 =>
 (?da warning))

I also rewrote your LHS using the new Jess 7 test syntax, which is  
much cleaner.



-----
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: Announcing Jess 7.0p1

2006-12-21 Thread Ernest Friedman-Hill
We're pleased to announce the availability of a new release of Jess,  
the Rule Engine for Java Programmers, at


http://www.jessrules.com/downloads.shtml

Jess 7.0p1 fixes a few minor issues reported since the 7.0 release  
and adds some small enhancements to the JessDE. From the change log:


New commands in JessDE: select construct, pretty-print
construct. Portable Mac keybindings. "Java patterns"
(infix test patterns) can use grouping via
parentheses. Multiline comments and strings don't
disturb JessDE formatting or damage repairer. JessDE
Rete view shows all OR branches, and node colors in
trial version (thanks Mark Proctor). "watch rules"
output goes to watch router (thanks Helge Hartmann.)
Repeated negated unifications in a multifield are kept
(thanks Gary Riley).

As always, comments are welcome to this list or to me at  
[EMAIL PROTECTED] .


-----
Ernest Friedman-Hill
Advanced Software Research  Phone: (925) 294-2154
Sandia National LabsFAX:   (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://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]




Re: JESS: eval problems

2006-12-21 Thread Ernest Friedman-Hill


On Dec 21, 2006, at 7:30 PM, Robert Kildare wrote:


I think I have updated to the latest version of Jess (as of todays
announcement) from version 70a2...


Sounds like you have still got an older version of Jess lying around.  
Try


System.out.println(engine.executeCommand("(jess-version-string)"));

to see for sure what version of Jess you're using in your project.

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




Re: JESS: equiv in clips

2006-12-27 Thread Ernest Friedman-Hill
In Jess, you can ask the active Rete instance (available in Jess from  
the "(engine)" function) to iterate over all the facts, then filter  
the result, perhaps using the jess.FilteringIterator class. For  
definstances, you can use Rete.listObjects(), which can take a  
jess.Filter as an argument. So there are a number of different ways  
to do these things.



On Dec 27, 2006, at 4:09 PM, rim wrote:



Hi
I would like to know the equivalent in jess of the following clips
statements

do-for-fact
do-for-all-facts
any-factp

I would like to iterate on facts and modify some of their slots
cheers




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




Re: JESS: dependencies jessDE

2006-12-27 Thread Ernest Friedman-Hill


On Dec 27, 2006, at 11:04 AM, rim wrote:


-using require?
require is not accepted (feature not known), I don't see the  
difference

between require and require*
and for instance adding (require* templates1.clp) to rules1.clp  
jessDE shows

a lot of errors
it seems that the slots are not recognized



"require" throws an exception if the feature you specify is not  
found. "require*" just ignores the problem. That's the only  
difference. Your "require" statements will only find files within the  
JessDE if the argument to "require" is a full path relative to an  
Eclipse source directory. If you don't know what that means, you're  
going to need a book about Eclipse.



-defining templates from java classes
Also I met more problems when defining templates from java classes
the rules are buggy, the slots are not recognized
(even after importing the package where java classes and after  
compiling the

java classes first)



Well, who knows what this means. If you have a specific question, and  
will show us the specific error messages you receive, we'll be glad  
to help; but there are a million and one things that could go wrong  
here. To make it simple: if  Jess says a template doesn't have a slot  
by some given name, then you didn't successfully define such a slot.  
Just as in CLIPS, if you use a template by name without declaring it,  
then Jess assumes it's an ordered template with no named slots at all.



besides I succeed to run the pricing example


Well, yes, because that's correct code.

-
Ernest Friedman-Hill
Advanced Software Research  Phone: (925) 294-2154
Sandia National LabsFAX:   (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://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]




Re: JESS: in a (bind

2006-12-31 Thread Ernest Friedman-Hill
Well, I can't explain the exact problem based just on what we can see  
here; there's probably a little more involved. Jess should produce  
somewhat better error messages, as well: if you're printing out your  
own exceptions, be sure to check getCause() for nested exception  
objects.


But I think your guess is probably in the right ballpark. If a fact  
already exists, then assert returns FALSE. Therefore the code you  
have here which binds the result of calling assert to a variable,  
then immediately calls methods on that variable is dangerous; you'd  
need to check for FALSE, first; i.e.,


(if (bind ?x (assert (y))) then
  (whatever))

On Dec 29, 2006, at 1:59 AM, Robert Kildare wrote:

Below are two rules used to record the occurrence of sequences 4  
and 5 as
they appear in data sets: facts which are removed and added in  
groups as

appropriate to needs. (The system is not yet working, but is
tantalizingly close - as is 2007.)

As it happens, tidy5 fires in the first data set and tidy4 fires  
after it

in the second.
;

(defrule tidy4
(declare (salience -25))
(frame (frameNumber ?framenumber))
?done <- (finishPat (patternID 4)(patComplete yes))
?previous1 <- (patPos (parentPattern 4)(position 1)(memberID
?m1)(tool_classificationID ?t1))
?previous2 <- (patPos (parentPattern 4)(position 2)(memberID
?m2)(tool_classificationID ?t2))
 =>
(bind ?pat  (assert (patInstance (factID nil)(patternID 4
(bind ?fid (?pat getFactId))(modify ?pat (factID ?fid))
(retract ?previous1 ?previous2)
(retract ?done)
(printout t "tidy pattern 4 match " crlf))

(defrule tidy5
(declare (salience -25))
(frame (frameNumber ?framenumber))
?done <- (finishPat (patternID 5)(patComplete yes))
?previous1 <- (patPos (parentPattern 5)(position 1)(memberID
?m1)(tool_classificationID ?t1))
?previous2 <- (patPos (parentPattern 5)(position 2)(memberID
?m2)(tool_classificationID ?t2))
=>
(bind ?pat  (assert (patInstance (factID nil)(patternID 5
(bind ?fid (?pat getFactId))
(modify ?pat (factID ?fid))
(retract ?previous1 ?previous2)
(retract ?done)
(printout t "tidy pattern 5 match " crlf))


FIRE 48 MAIN::tidy5 f-75, f-131, f-127, f-129
 ==> f-134 (MAIN::patInstance (factID nil) (patternID 5))
==> Activation: MAIN::pattern_11_1 :  f-75, f-134, f-67
<== Activation: MAIN::pattern_11_1 :  f-75, f-134, f-67
 <=> f-134 (MAIN::patInstance (factID 134) (patternID 5))
==> Activation: MAIN::pattern_11_1 :  f-75, f-134, f-67
 <== f-127 (MAIN::patPos (tool_classificationID 556) (memberID 30)
(parentPattern 5) (position 1) (frame 1))
 <== f-129 (MAIN::patPos (tool_classificationID 2162) (memberID 33)
(parentPattern 5) (position 2) (frame 1))
 <== f-131 (MAIN::finishPat (patternID 5) (patComplete yes))
tidy pattern 5 match

;;- [old data has been removed and new data added,  
with

considerable activation and firing ]

FIRE 49 MAIN::tidy4 f-137, f-198, f-132, f-196
 ==> f-200 (MAIN::patInstance (factID nil) (patternID 4))
An error occurred at line 1which looks like( run )
Message: '134' is an integer, not  a Java object
java.lang.NullPointerException



 What appears to be happening is that the old (patInstance (factID
nil)(patternID 5)) which was asserted is still in existence as ? 
pat

with a value of 134 and when I try to assert it a second time I am
asserting an int rather than the object representing the variable  
(is it

a ValueVector??)

Is this so ? If not, what can you tell me ?

In either case, any suggested solutions?

Rob

Robert Kildare

PhD candidate
School of Computing
University of Tasmania







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]

--------


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




Re: JESS: iterations

2006-12-31 Thread Ernest Friedman-Hill
There are many different ways you might do this. The classic (if  
ugly) solution would be to assert a fact like


(done ?interation ?query)

on the right hand side of this rule, and add a "not" condition for  
this fact to the left hand side of the rule; then remove the "no- 
loop" declaration. Then the rule would fire only once for each  
combination. This is what you usually do in CLIPS and CLIPS-like  
systems, but there are a couple of other solutions available in Jess.


Another way would be to use Jess's "accumulate" conditional element;  
for each query, you could accumulate all the interactions, then do  
the modify on the rule right hand side. Make the rule a no-loop rule,  
and that would work fine. I guess the thing you'd accumulate should  
be a Jess list; that would make it relatively easy to increment the  
list elements, since you'll be summing up three numbers for the three  
slots that will be modified.


A third way would be to use a defquery. Use a no-loop rule that  
simply matched each query, and then on the RHS of the rule invoke a  
defquery which matched all the interactions for that query. Iterate  
over them explicitly and  then modify the query fact once at the end.


On Dec 30, 2006, at 6:11 AM, rim wrote:



Hi,
I need to write a rule which iterates on 2 sets of facts of different
templates,
below the code

(defrule Compute-Queries-Weights
   (declare (no-loop TRUE))
   ?I <- (Interaction (name ?Iname) (queries $?Iqueries) (w- 
browsing ?Iwb)

(w-shopping ?Iws) (w-ordering ?Iwo))
   (test (<> (length$ $?Iqueries)  0))
   ?Q <-(Query (name ?Qname) (w-browsing ?Qwb) (w-shopping ?Qws) (w- 
ordering

?Qwo))
   (test (member$ ?Qname $?Iqueries))
=>
   (printout t  ?Iname " " ?Qname crlf)
   (modify ?Q (w-browsing (+ ?Qwb ?Iwb)) (w-shopping (+ ?Qws ?Iws))
(w-ordering (+ ?Qwo ?Iwo)))
)

the problem is the following,
without (declare (no-loop TRUE)) there'is a loop on one combination
and with (declare (no-loop TRUE)) once used a fact query is not  
used again


in the problem specification a fact 'query'  belongs to many facts
'intercation' and needs to be updated from all of them,
thanks and happy new year
--
View this message in context: http://www.nabble.com/iterations- 
tf2898209.html#a8097199

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]

----


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




Re: JESS: jess to java issues

2007-01-02 Thread Ernest Friedman-Hill
Unless you've left out some code, the "(focus interview)" should  
throw an exception, as I see no such module defined here. But aside  
from that, the other problem is that when the rules fire, the stored  
ArrayList is not the same one that's in the defglobal. You define the  
defglobal, which creates an ArrayList; then you store a reference to  
the ArrayList using the store function. Later, you call "reset",  
which, by default, resets all defglobals; here, this will create a  
new ArrayList, so that the one in the defglobal is not the same one  
that's been stored.


Either 1) wait to do the store after the reset; 2) call reset before  
loading the Jess code; or 3) use (set-reset-globals FALSE) to change  
the default behavior. Calling this function will prevent Jess from  
resetting global variables when reset is called.


On Jan 2, 2007, at 5:59 AM, Venkat Kasuganti wrote:


I have the following jess code (based on code in JESS in Action):

defglobal ?*a* = (new java.util.ArrayList))
;;(defglobal ?*b* = (new java.util.ArrayList))

(store quest ?*a*)

(deftemplate question (slot ident)(slot text)(slot type))
(deftemplate answer (slot ident) (slot ans))

(deffacts question-data
   (question
   (ident name)
   (text "What is your name?")
   (type 1))
   (question
   (ident age)
   (text "What is your age?")
   (type 2))
   (question
   (ident occupation)
   (text "What is your occupation?")
   (type 1)))


(defmodule ask)
(defrule ask-question
   (declare (auto-focus TRUE))
   (MAIN::question (ident ?id)(text ?t)(type ?type))
   ;;(not (answer (ident ?id)))
   ?ask <- (MAIN::ask ?id)
   =>
   ;;(printout t ?t crlf)
   (bind ?b (new java.util.ArrayList))
   (?*a* add ?b)
   (?b add ?id)
   (?b add ?t)
   (?b add ?type)
   (retract ?ask)
   (return))

(defmodule questions)
(defrule request-name
   => (assert (ask name)))
(defrule request-age
   => (assert (ask age)))
(defrule request-occupation
   => (assert (ask occupation)))

And the following java code calls the hashmap handle "quest" to
convert contents of the Value object as a java generic object.

import jess.*;
import java.util.*;
public class Bridge {

public static void main (String args[]) throws Exception {

Rete engine = new Rete();
String s = "(batch taxcube.clp)";
engine.executeCommand(s);


engine.reset();

String t = "(focus interview)";
engine.executeCommand(t);

engine.run();

Value myValue = engine.fetch("quest");
Object o = myValue.javaObjectValue(engine.getGlobalContext());
System.out.println(o);

ArrayList superArray = (ArrayList) o;

System.out.println(superArray);
//System.out.println(superArray.get(0));


}

}

My problem is that the ArrayList that I have fetched in the global
context is returned empty despite rules getting executed and the
arraylist being populated with the question data in the ask module.

How do i get the populated arraylist(s)?

Please help


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]

----


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




Re: JESS: Shadow facts not working

2007-01-04 Thread Ernest Friedman-Hill
Off the top of my head, I'm not sure Jess (or other clients of your  
class) will react to change events being fired during a call to a  
getter method; not only calcTime(), but also presumably Jess will be  
calling getElapsedTime(), and the results might be odd.


But from your description, I suspect the problem is more pedestrian.  
How many threads are involved? For it to work the way you're  
expecting, there would need to be two: one calling calcTime(), and  
the other calling Rete.run() (or the equivalent.) It sounds to me as  
if you just have one that calls run() after calling calcTime(). If  
I'm wrong, then will you please describe what you're doing?


On Jan 4, 2007, at 7:37 PM, Mike Stacey wrote:


I have a java class which is a bean and fires events when properties
change. My rules fire when this property attains certain values. The
property is a timer which calculates the elapsed time since some
previous event happened. This is implemented in a loop within the
java class. My jess rule needs to fire when the timer gets to a
particular elapsed time.

Problem: The rule doesn't fire until the method returns, by which
time the timer has run further than it needs to. I have checked with
watch facts and the facts are being asserted in jess continuously but
yet the rule doesn't fire until the caclTime() method exits.

In the examle below, when the Terminates rule fires the timer has
reached a bit over 1 instead of 7000. Any suggestions would be
greatly appreciated of course. I hope the following is clear enough
to follow...

The java code
-
Class PropTime

   public void calcTime()
{
long etime = getElapsedTime();
// Loop condition only for test purposes at the moment
while(etime < 1)
{
etime = getElapsedTime();
}
}

/** Returns elapsed time in milliseconds.
  * PROBLEM: 'Terminates' rule not firing until calcTime() returns
  */

public long getElapsedTime()
{
   if (startTime == -1)
   {
   elapsedTime = 0;
   System.out.println("0");
   }
   if (running)
   {
   oldElapsedTime = elapsedTime;
   elapsedTime = System.currentTimeMillis() - startTime;
   // Terminate rule should fire when this reaches a given
value
   eventSupport.firePropertyChange("elapsedTime", new
Long(oldElapsedTime), new Long(elapsedTime));   
   }
   else
   {
   elapsedTime = stopTime-startTime;
   }
   return elapsedTime;
}

The jess code
-

(defclass pTime PropTime);; create deftemplate from javabean
(bind ?pT (new PropTime));; create bean
(definstance pTime ?pT);; add bean (shadow fact) to jess memory

; PROBLEM: This rule doesn't fire until the calcTime() method
; finishes

(defrule Terminates
; Terminate when timer reaches 7000
(pTime(elapsedTime ?et&:(>= ?et 7000)))  
 =>
(printout t ">>>>>>>Terminates: Elapsed time:  "?et  crlf)
(call ?pT stopPropTimer))




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]

--------


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




Re: JESS: Shadow facts not working

2007-01-05 Thread Ernest Friedman-Hill
My explanation hinges on what happens in the startPropTimer() method.  
I'm assuming that it does not create a thread, but instead calls  
calcTime() directly or indirectly. If this is the case, then remember  
that Rete.run() contains a loop which fires the first rule on the  
agenda repeatedly until no more rules are left to fire. This loop  
invokes a Defrule.fire() method to fire each rule directly. The fire 
() method ultimately invokes all the Jess  code on that rule's right  
hand side. So if your Initiates rule fires, then ultimately run()  
calls fire() which calls calcTime(), and I hope by now you see that  
because of this, the next rule can't fire until calcTime() returns.  
Jess receives the events because they are send synchronously from  
calcTime() -- i.e., calcTime() calls firePropertyChange() which calls  
a PropertyChangeListener.propertyChanged() method in Jess which  
modifies working memory. But the next rule can't fire until fire()  
returns back to the loop in run().


For your PropTimer to function as a true timer, it has to do what the  
Hardware objects in the Jess in Action example do: spawn its own  
thread and send change events from that separate thread. This will  
allow Initiate.fire() to return promptly and continue on to fire  
additional rules as the events arrive.


On Jan 4, 2007, at 10:38 PM, Mike Stacey wrote:


Thanks for the reply Ernest.

I have a thread calling Rete.run(). Inside the jess script I create a
hardware interface and hardware monitor much the same as your example
in the temperature controller in your book - chap 14. The hardware
sensor opens a data source which are timestamped instantaneous values
and the monitor class (like the thermometer class) gets data values
from the hardware interface inside a run() method and fires events for
Jess to reason with. This all works fine.

My rules also rely on time periods. I classify data into categories
depending on their values and initiate the relevant category using a
rule. A rule input by the user might have the following semantics:

"Determine if there are any periods of time 20 seconds or more where
data values are greater than 143."

(defrule Initiates
 (mon (reading ?r&:(>= ?r 143))
 (tstamp ?t&:(> ?t 0)))
 (pTime(running ?run&:(= ?run FALSE)))
 =>
 (printout t ">>>>>>>Initiates: Data "?r" bpm, timestamp "?t", Fluent
truth val:  "?run  crlf)
 ;; start the timer which also functions as a flag to indicate
 ;; that this category is active
 (call ?pT startPropTimer))

So if the category hasn't been activated before (running is false) and
the data value is > 143 then I initiate the time dependent category by
starting the propTimer. Property 'running' and method startPropTimer()
are in a class called PropTimer. This class is connected to Jess
using:

(defclass pTime PropTime)
(bind ?pT (new PropTime)
(definstance pTime ?pT)

The Initiates rule works OK.

The terminates rule is a problem. It's function ius to terminate the
category due to the propTimer expiring.

(defrule Terminates
;Terminate when timer reaches 7000, example only
(pTime(elapsedTime ?et&:(>= ?et 7000)))
=>
(printout t ">>>>>>>Terminates: Elapsed time:  "?et  crlf)
(call ?pT stopPropTimer))

I will use some kind of flag to indicate the start and end times of
the category and may even save all the data in between these times to
a file or something.

So I guess, in response to your prompt, I have only one thread; the
one that starts the rete engine. The timer events are simply fired
from within a loop inside calcTime() - the facts are picked up by Jess
but the terminates rule won't act on them. I have a trace as follows
from watch facts:

<=> f-0 (MAIN::pTime (class )
(elapsedTime 5860) (running TRUE) (OBJECT ))
<=> f-0 (MAIN::pTime (class )
(elapsedTime 5875) (running TRUE) (OBJECT ))
<=> f-0 (MAIN::pTime (class )
(elapsedTime 5891) (running TRUE) (OBJECT ))
etc...

These facts appear after the Initiates rule has fired and before the
terminates rule fires. But, as I mentioned originally, terminates only
fires when the loop inside calcTime() finishes.

I hope this is clearer now?

Thanks again.
Mike






- Original Message -
From: "Ernest Friedman-Hill" <[EMAIL PROTECTED]>
To: 
Sent: Friday, January 05, 2007 1:50 PM
Subject: Re: JESS: Shadow facts not working


: Off the top of my head, I'm not sure Jess (or other clients of your
: class) will react to change events being fired during a call to a
: getter method; not only calcTime(), but also presumably Jess will be
: calling getElapsedTime(), and the results might be odd.
:
: But from your description, I suspect the problem is more pedestrian.
: How many threads are involved? For it to work the way you're
: expecting, there would need to be two: one cal

Livestock ES (was Re: JESS: jess to java issues)

2007-01-08 Thread Ernest Friedman-Hill

On Jan 8, 2007, at 3:45 AM, panchika rodrigo wrote:

I'm planning to develop an ES using JESS for the
Livestock sector that will be providing solutions to
the problems of Health issues.
Will I be able to do it in JESS as I've got to have
some kind of data storage. If so please provide me
with necessary details.
If not what is suitable for this purpose.
If there's any reference books pls provide me with.

You haven't given us anything to go on here, as far as letting you  
know if Jess is suitable or not for your application. Jess is used  
for a wide range of applications, and I don't know of anything  
offhand about livestock that would make Jess unsuitable.


The Jess manual itself is fairly extensive as a first resource. The  
book "Jess in Action", available from Amazon, is another good  
resource. If you can give us some more specific questions, we can  
give you some more specific answers.


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




Re: JESS: JessDE - Incomplete Installation.

2007-01-08 Thread Ernest Friedman-Hill
The "GEF" -- Graph Editor Framework -- has to be installed and  
working for the Rete Network Viewer to load; and in fact, if that  
doesn't load, the feature plugin that makes the icon in the "About  
Eclipse" window won't show up either. Install GEF from the Eclipse  
update site.


If you've done that already, then perhaps there's a conflict that's  
preventing the GEF from loading?


On Jan 8, 2007, at 1:15 PM, Philip Hart wrote:


Hi

Although I have installed JessDE according to the instructions  
given in the doco, Eclipse is not "seeing" some of the components.


Specifically, the JessDE icon is neither displayed in the "About  
Eclipse SDK" popup, nor does it appear in the "Features" list.


Similarly,  the Reteview plugin is not listed in the "Plugins"  
window. Though, interestingly, the Reteview plugin is mentioned in  
the "Configuration Details" window :-


gov.sandia.jess (7.0.0) "Jess" [Resolved]
gov.sandia.jess.debug (7.0.0) "Jess Debugger" [Resolved]
gov.sandia.jess.editor (7.0.0) "Jess Editor Plug-in" [Resolved]
gov.sandia.jess.reteview (7.0.0) "Jess Rete Network  
Viewer" [Installed]



I thought initially that there might be a version problem, so I  
updated Eclipse SDK to the "latest & greatest" (Version: 3.2.1

Build id: M20060921-0945 ), but the problem still persists.

FYI, no errors are reported in the error log, and the "-clean" flag  
is used.


Naturally, this is a bit frustrating, so I would appreciate any  
insight list members might have regarding the problem.


Cheers,
Philip



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




Re: JESS: run vs rununtilhalt

2007-01-09 Thread Ernest Friedman-Hill
For the most part, there shouldn't be any significant performance  
implications. If there are many simultaneous threads the throughput  
might be greater if you use runUntilHalt() because there will be less  
contention. I would do whichever makes the design cleaner for you.



On Jan 9, 2007, at 2:50 PM, Skeptic 2000 wrote:



Hi,

I have some java code that create ShadowFact and some rules that  
modify them at creation and when they are modified on the Java side.


I'm trying to compare two way of doing this :

First, doing a engine.runUntilHalt() and doing my java code that  
handle the shadowfact after.


Second, after each manipulation on the Java side, doing a engine.run 
().


On performance side, what is the difference between the two ?

You can probably guess that I want to do this because I need to be  
sure that Jess has runned out before doing some extra Java code. I  
don't want to go in details here of why I need this behavior, but  
I'm pretty sure that it don't go agains't the Jess spirit.


Thanks



Soyez parmi les premiers à essayer Windows Live Mail.


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




Re: JESS: list duplicate elements problem

2007-01-11 Thread Ernest Friedman-Hill
All you're trying to do is print the integers from 1 to the length of  
the list. Here's a "for" loop that does that:


(for (bind ?i 1) (<= ?i (length$ ?*a*)) (++ ?i)
(printout t ?i crlf))

Because your solution has to search the list, for long lists, the  
performance would be rather bad, proportional to the square of the  
length of the list. Presumably you want to do something with the list  
items; you can do so by fetching each one inside the loop with the  
"nth$" function, using ?i for the index. For example, this prints  
only the indexes at which "bb" appears in the list:


(for (bind ?i 1) (<= ?i (length$ ?*a*)) (++ ?i)
(bind ?item (nth$ ?i ?*a*))
(if (eq ?item bb) then
(printout t ?i crlf)))




On Jan 11, 2007, at 7:10 AM, Antonino Lo Bue (gmail) wrote:


Hi everyone,
I've problems with list members position:

 (defglobal ?*a* =  (create$ aa aa))
 thus I have the list: (aa aa)

I want to use member position, but if I write:

 (foreach ?f ?*a* (printout t (member$ ?f ?*a*)crlf ))

I obtain:
 1
 1

Otherwise I want:
1
2

This problem is because member$ function find the index of a  
element in list if this element exist in the list, thus if the  
element is duplicate in the list member$ function find the first  
element two times in the same position.


How can I obtain the position of an element in the list even if is  
a duplicate?


-- 
--

Antonino Lo Bue
Research Fellow
ICAR-CNR Palermo
Phone: 091-6809256
Web: http://medialab.pa.icar.cnr.it/Personali/personali.html
Email: [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]




Re: JESS: list duplicate elements problem

2007-01-12 Thread Ernest Friedman-Hill
In any programming language, you can rewrite a "for" loop as a  
"while" loop. Jess is no exception.


(bind ?i 1)
(while  (<= ?i (length$ ?*a*))
(printout t ?i crlf)
(bind ?i (+ ?i 1)))


On Jan 12, 2007, at 4:33 AM, Antonino Lo Bue (gmail) wrote:

Thanks, It's what I need, but, I need to implement this behaviour  
in JESS

6.1, and "for" function it's not present... this is my problem.
How can I implement this using only JESS 6.1 features?

  
-- 
--

Antonino Lo Bue
Research Fellow
ICAR-CNR Palermo
Phone: 091-6809256
Web: http://medialab.pa.icar.cnr.it/Personali/personali.html
Email: [EMAIL PROTECTED]




- Original Message -
From: "Ernest Friedman-Hill" <[EMAIL PROTECTED]>
To: 
Sent: Thursday, January 11, 2007 1:45 PM
Subject: Re: JESS: list duplicate elements problem



All you're trying to do is print the integers from 1 to the length of
the list. Here's a "for" loop that does that:

(for (bind ?i 1) (<= ?i (length$ ?*a*)) (++ ?i)
 (printout t ?i crlf))

Because your solution has to search the list, for long lists, the
performance would be rather bad, proportional to the square of the
length of the list. Presumably you want to do something with the list
items; you can do so by fetching each one inside the loop with the
"nth$" function, using ?i for the index. For example, this prints
only the indexes at which "bb" appears in the list:

(for (bind ?i 1) (<= ?i (length$ ?*a*)) (++ ?i)
 (bind ?item (nth$ ?i ?*a*))
 (if (eq ?item bb) then
 (printout t ?i crlf)))




On Jan 11, 2007, at 7:10 AM, Antonino Lo Bue (gmail) wrote:


Hi everyone,
I've problems with list members position:

 (defglobal ?*a* =  (create$ aa aa))
 thus I have the list: (aa aa)

I want to use member position, but if I write:

 (foreach ?f ?*a* (printout t (member$ ?f ?*a*)crlf ))

I obtain:
 1
 1

Otherwise I want:
1
2

This problem is because member$ function find the index of a
element in list if this element exist in the list, thus if the
element is duplicate in the list member$ function find the first
element two times in the same position.

How can I obtain the position of an element in the list even if is
a duplicate?

 
--

--
Antonino Lo Bue
Research Fellow
ICAR-CNR Palermo
Phone: 091-6809256
Web: http://medialab.pa.icar.cnr.it/Personali/personali.html
Email: [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 owner-jess- 
[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 owner-jess- 
[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]




Re: JESS: calling a method on a matched shadow fact

2007-01-15 Thread Ernest Friedman-Hill

One way to do this would be to use "progn" in a test CE:

(defrule x
  (theShadowFact (OBJECT ?o))
  (test (progn
  (bind ?xyz (?o getXYZ))
  (and (> ?xyz 10)
   (< ?xyz 100
  => ...

"progn" executes all the function calls inside it, then returns the  
value of the last one.



On Jan 15, 2007, at 4:00 PM, Skeptic 2000 wrote:


Hi,

In the LHS of a rule, could I bind to a variable a object that is  
returned from a method called on a matched fact ?



(rule x
(theShadowfact ?o)
(... ?o getXYZ ... )

The purpose of doing this is to have a variable on which to do some  
tests without having to call getXYZ for each one of them.


Thanks


> From: [EMAIL PROTECTED]
> Subject: Re: JESS: calling a method on a matched shadow fact
> Date: Fri, 3 Nov 2006 00:46:42 -0500
> To: jess-users@sandia.gov
>
> On Nov 2, 2006, at 1:29 PM, Skeptic 2000 wrote:
>
>
> >
> > Let's say I have something like :
> >
> > (defclass xyz x.y.com.XYZ)
> >
> > (defrule "x"
> > ?x<-(xyz)
> > =>
> > (...)
> >
> > In the RHS, I would like to call a method that is not a bean get/
> > set on the matched 'xyz', what would be the proper way? (If
> > possible, this method would take a string as argument)
> >
>
> ?x is a jess.Fact object; it has a slot named OBJECT containing the
> actual XYZ object. So you could say
>
> ((?x getSlotValue OBJECT) theMethodName "the argument")
>
> Alternatively, you could bind the OBJECT slot on the LHS, and then
> you'd have a variable on which you could call the method directly.
>
> -
> Ernest Friedman-Hill
> Advanced Software Research Phone: (925) 294-2154
> Sandia National Labs FAX: (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 owner-jess- 
[EMAIL PROTECTED]

> 
>


Soyez parmi les premiers à essayer Windows Live Mail.


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




Re: JESS: Decorators

2007-01-18 Thread Ernest Friedman-Hill
Do the decorators actually enlarge the API of the defclassed class?  
In that case, you'll only be able to match those additional  
properties using Java method calls. Otherwise, things would work out  
fine; you could even just defclass the interface, if that's how  
things are structured. Otherwise, can you give us a concrete example  
to discuss?


On Jan 18, 2007, at 9:17 AM, Krasnigor, Scott L (N-AST) wrote:

I am curious what the implications are of defclassing a class with  
many decorators associated with it? I need to be able to match  
various attributes of the class that are part of the decorators. Is  
there a correct/best way to handle this case? Any advice would be  
appreciated. Thanks.




Scott






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




Re: JESS: using mathematicals functions on a shadow fact

2007-01-19 Thread Ernest Friedman-Hill

On Jan 18, 2007, at 11:15 PM, Skeptic 2000 wrote:



Hi, in a LHS i'm getting a value from a shadowfact method and I  
want to compare that value using > to a fixed number, something like :


(test (> (?x domethod "param") 3)

I get the error that 3 is not a java object, so I tried to replace  
3 with : new Integer 3, but I get the same message.


How can I achieve this ?



The Jess error message should contain a stack trace of Jess function  
calls. Look carefully at this trace. The top function is the one that  
is reporting the problem. I'm betting the top function on the stack  
is actually (?x domethod "param"), and that ?x is actually the number  
3 rather than a Java object. Otherwise this wouldn't make any sense  
-- "<" doesn't want its arguments to be Java objects.



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




Re: JESS: < strange behavior

2007-01-19 Thread Ernest Friedman-Hill


On Jan 19, 2007, at 12:00 AM, Skeptic 2000 wrote:



Hi,

I have a rule looking something like :

(defrule wcooo ; exemple pour un while
(MyShadowfact (OBJECT ?o))
(test (< (str-length (?o methodreturningastring "param")) 3))
=>
(printout t "rulefired" (str-length (?o methodreturningastring  
"param")) crlf))


And I strangly get the rulefired message with values like 4, 5, 6, ...



Remember that pattern-matching is driven by facts being asserted,  
retracted, or modified. In particular, the test above will be  
evaluated only when the object is first put into working memory, or  
when a change event or modify call causes it to be reevaluated. My  
guess is that your method methodreturningastring returns a value  
which changes over time without Jess being notified in any way about  
the change. You will need to tell Jess when this value changes -- for  
example, by using the Rete.updateObject() method.


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




Re: JESS: Is JESS freely available?

2007-01-22 Thread Ernest Friedman-Hill


On Jan 22, 2007, at 2:49 AM, RVee wrote:



We are contemplating using a Rules Engine in our project.
We need the following info.
Is JESS license freely available for use in any project?


No. Jess is commercial software, although it can be licensed at no  
cost to academic institutions.



I guess JESS 6.0 is JDK1.3 compatible?



Jess 6.0 is no longer available. Jess 6.1 is indeed JDK 1.3 compatible.


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




Re: JESS: Does the idea of node sharing original to Jess?

2007-01-24 Thread Ernest Friedman-Hill

On Jan 24, 2007, at 3:38 AM, Bat-Odon wrote:


Let me reconfirm a statement in the Jess manual.

You wrote “There are two simple optimizations that can make Rete  
even better …” in the Rete Algorithm chapter.


Do you mean the idea of sharing pattern and join nodes original to  
Jess?


No, the "two simple optimizations" did not originate with Jess --  
they appear in the first paper on the Rete algorithm. Jess does do  
some unique and original things to speed up the basic Rete algorithm,  
but node sharing was an intrinsic part of the algorithm as it was  
first described.


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




Re: JESS: Conflict Resolution Question

2007-01-24 Thread Ernest Friedman-Hill

On Jan 24, 2007, at 9:15 PM, [EMAIL PROTECTED] wrote:


I
only include their numbers because I believe that is all that is  
important

- maybe that is my problem


Indeed. In OPS5 and in systems like CLIPS, the fact number is  
directly related to the recency of a fact. If you modify a fact in  
CLIPS, the old fact is removed and a new one, with a new fact number,  
is asserted.


Jess has a more object-oriented approach; a fact's fact number is a  
constant and doesn't change when the fact is modified. This lets you  
use those IDs as links between facts that survive property  
modifications. Therefore there isn't necessarily any relationship  
between the recency of a fact and the fact number. Each fact contains  
a "pseudo-time" value, basically a tag that identifies the order of  
events that happen in the engine. The agenda ordering is based on  
these pseudo-time tags. The default strategy is called "depth", and  
it orders activations according to the recency of their facts,  
weighted so that activations that include more facts are given some  
preference.


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




Re: JESS: saving to xml file

2007-01-29 Thread Ernest Friedman-Hill


On Jan 29, 2007, at 7:46 AM, M Ismail wrote:



Hi,

I would like to know if it is possible to save all the inserted  
facts to an xml file?

and what is the best way to do it?


See the (save-facts-xml) command, documented in the "Jess Function  
List", Chapter 16 in the manual.





and/or if writing the facts from java straight to xml is easier or  
not?




That's easy, too; the Rete.ppFacts() method writes facts to a stream  
you supply, either in Jess or JessML format, based on a boolean  
parameter. The Javadoc for the Jess library is in chapter 18 of the  
manual.



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




Re: JESS: Conflict Resolution Stragegy

2007-01-29 Thread Ernest Friedman-Hill


On Jan 29, 2007, at 11:08 AM, [EMAIL PROTECTED] wrote:


Greetings.

I would still like to know if there is any way to see the actual  
time tags

of the wmes while debugging and to know exactly how the conflict
resolution strategy works in detail.


You can get the time tag for a fact by calling getTime() on the  
jess.Fact object.


The built-in depth and breadth strategies work the same way, just in  
opposite senses. Remember that the conflict resolution strategy is  
comparing activations: a tuple containing a rule and a list of facts  
that activate it. They first compare salience; for rules of equal  
salience, they then compare the most recent time stamp of all the  
facts in each token.


If those are also equal, what happens next has varied in different  
versions of Jess. In Jess 7, they then compare the sum of all the  
time stamps for all the facts in each token. If those are equal, the  
order is arbitrary.


You can implement your own strategies in Java; the manual now  
contains a reasonable description of how to do this, and there are  
some better examples in the Wiki (www.jessrules.com/jesswiki ).


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




Re: JESS: is jess a declaritive language?

2007-01-30 Thread Ernest Friedman-Hill
Well, rules themselves are definitely a declarative programming  
concept. But Jess also offers an imperative language, and in fact the  
right-hand-sides of rules consist of imperative code.


So in fact, Jess, and systems like it, are hybrid declarative/ 
imperative.


On Jan 30, 2007, at 5:03 PM, Matthew J Hutchinson wrote:


Hi everyone,

I'm trying to categorize Jess in terms of the different programming  
language paradigms. Is Jess "declaritive"?


Thanks,
Matt



---------
Ernest Friedman-Hill
Advanced Software Research  Phone: (925) 294-2154
Sandia National LabsFAX:   (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://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]




Re: JESS: simple calculation problem

2007-01-31 Thread Ernest Friedman-Hill
First, I don't know what "?s" is. If it's a variable defined at the  
prompt, don't do that. It won't work reliably in Jess 6, and isn't  
even possible in Jess 7 (the fact that it's possible in Jess 6 is  
unintentional.)


Otherwise, there's nothing wrong here, per se. Every time an update- 
scores fact is asserted, the count will be set to a new value. Of  
course, once an "update-scores 10" fact exists, you can't assert  
another one until the original is retracted, so you might want to do  
that in the update-scores rule.


On Jan 31, 2007, at 6:40 AM, 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 owner-jess- 
[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]




Re: JESS: how to get the "rule text" from a defrule

2007-01-31 Thread Ernest Friedman-Hill

Use the jess.PrettyPrinter class, as described in the manual.

An aside: *please* start a new thread for your new questions; please  
don't reply to an existing message, whether or not you delete the old  
contents while editing your message, unless you're answering someone  
else's question. If you send a reply rather than a new message, then  
threaded email readers (including archives of this list) show your  
messages as related to others that they're not actually related to.  
Thanks.


On Jan 31, 2007, at 3:07 PM, Skeptic 2000 wrote:



Hi,

With Jesp I can easily get the defrule of each of my rules in  
my .clp files and display their names in a Swing application. What  
I would like to do next is to display the actual text of the rule  
in this same application, can it be easily done ?


Thanks.








> From: [EMAIL PROTECTED]
> Subject: Re: JESS: is jess a declaritive language?
> Date: Tue, 30 Jan 2007 22:03:15 -0500
> To: jess-users@sandia.gov
>
> Well, rules themselves are definitely a declarative programming
> concept. But Jess also offers an imperative language, and in fact  
the

> right-hand-sides of rules consist of imperative code.
>
> So in fact, Jess, and systems like it, are hybrid declarative/
> imperative.
>
> On Jan 30, 2007, at 5:03 PM, Matthew J Hutchinson wrote:
>
> > Hi everyone,
> >
> > I'm trying to categorize Jess in terms of the different  
programming

> > language paradigms. Is Jess "declaritive"?
> >
> > Thanks,
> > Matt
> >
>
> -
> Ernest Friedman-Hill
> Advanced Software Research Phone: (925) 294-2154
> Sandia National Labs FAX: (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 owner-jess- 
[EMAIL PROTECTED]

> --------
>


Soyez parmi les premiers à essayer Windows Live Mail.


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




Re: JESS: Fact Storage Provider Framework

2007-02-07 Thread Ernest Friedman-Hill
I  took a look at the download and you're right, there isn't much  
there, is there? I have a dim memory of once having a fairly detailed  
document for it; I haven't been able to find it but I will keep  
looking. In the meantime, there *is* an example application in the  
download; see the *.clp files in the src/ directory.



On Feb 6, 2007, at 7:38 PM, [EMAIL PROTECTED] wrote:


Is there any documentation or examples using the Fact Storage Provider
Framework as I think it is exactly what I need in order to use data  
from a
MySQL DB to apply a set of rules to i.e. the DB data is the  
deffacts? I've

downloaded the .zip file from "User Contributions" but now I have that
I've no idea what to do with it! Has anyone else successfully used  
this
for their own setup, if so could you brief me on how to go about  
using it?
I'm very much new to this and have only ever used JESS on it's own.  
Thanks

in advance.

(N.B. I don't wish to store rules in a MySQL DB I wish to retrieve  
data

from it as facts.)



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




Re: JESS: Servlet vs JSP differences

2007-02-07 Thread Ernest Friedman-Hill
vletException {
doGet(request, response);
}

protected void checkInitialized() throws ServletException {
ServletContext servletContext = getServletContext();
String rulesFile = servletContext.getInitParameter 
("rulesfile");
String factsFile = servletContext.getInitParameter 
("factsfile");

if (servletContext.getAttribute("engine") == null) {
try {
Rete engine = new Rete(this);
engine.executeCommand("(batch \"" + rulesFile +  
"\")");

engine.reset();
if (new File(factsFile).exists())
engine.executeCommand("(load-facts \"" +  
factsFile +

"\")");
servletContext.setAttribute("engine", engine);
} catch (Exception je) {
throw new ServletException(je);
}
}
}

protected void dispatch(HttpServletRequest request,
HttpServletResponse response,
String page)
throws IOException, ServletException {

ServletContext servletContext = getServletContext();
RequestDispatcher dispatcher =
servletContext.getRequestDispatcher(page);
dispatcher.forward(request, response);
}

}


**
HyperContainer servlet class:
__

package hyperJessGen;



import javax.servlet.*;
import javax.servlet.http.*;
import jess.*;
import se.liu.ida.JessTab.*;
import edu.stanford.smi.protege.*;
import edu.stanford.smi.protegex.owl.*;
import java.io.*;
import java.util.Iterator;


public class HyperContainer extends BaseServlet{

 public void doGet (HttpServletRequest request, HttpServletResponse
response)
 throws IOException, ServletException  {
  //inizializza la servlet
 checkInitialized();
  try{
  //ottiene lo userId
  String userId = (String) request.getParameter("userId");
  if (userId == null || userId.length() == 0) {
   dispatch(request, response, "/index.html");
   return;}
  //cancella le precedenti sessioni e ne crea una nuova
  request.getSession().invalidate();
  HttpSession session = request.getSession();
  session.setAttribute("userId", userId);
  ServletContext servletContext = getServletContext();
  Rete engine = (Rete) servletContext.getAttribute("engine");
  request.setAttribute("engine", engine);
   } catch (Exception je) {
   throw new ServletException(je);
   }
  dispatch(request, response, "/hyperContainer.jsp");
 }

}

**
hyperContainer.jsp :
__


<%@ page
import="jess.*,java.util.*,se.liu.ida.JessTab.*,edu.stanford.smi.prote 
ge.*,e

du.stanford.smi.protegex.owl.*" %>
 

 
  Results facts from HyperJessGen
 
 
  Results facts from HyperJessGen
  
  <% engine.addOutputRouter("page", out);
  for(Iterator e =engine.listFacts(); e.hasNext();){
   Object t =e.next();
   String fact = t.toString();
   engine.executeCommand("(printout page \""+fact+"\" crlf)");
   }
   engine.executeCommand("(printout page " + "\"Hello World from  
Jess via

JSP & Servlet!\" crlf)");

  %>


 





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]




-
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: Re: Multiple JESS engines running in the same application

2007-02-07 Thread Ernest Friedman-Hill

On Feb 7, 2007, at 7:30 PM, #NG BOON KIAT# wrote:

I'm currently working on a distributed multi-agent simulation  
system that uses JESS for behaviour inference. The behaviours are  
stored inside a Protege ontology. For each cycle of the simulation,  
each agent has to update the ontology, followed by getting the new  
behaviour from the ontology.


Ideally, each computer (node) in the system will control a number  
of agents as well as have 1 JESS engine. However, during testing of  
the framework, I had to simulate the running of 2 nodes on my  
computer. This means having more than 1 JESS engine running at the  
same time. The first engine works fine, but when the second engine  
tried to make a ontology update, I get errors such as unable to  
read/write.


Is there really no way to have more than 1 JESS engine running at  
the same time?




Of course there is -- you can create as many instance of the  
jess.Rete class as you like, and run them all independently. It says  
so in the manual, doesn't it? There's even a simple inter-engine  
communication mechanism built into Jess (the function "call-on-engine".)


Here's a tiny program in the Jess language that uses two engines. A  
rule is defined in the first engine which, when fired, prints a  
message, then defines a rule in a second engine, resets it, and runs  
it. When you run this program, first the rule fires in the first  
engine, and this causes the rule to fire in the second engine, so  
you'll see both messages printed once.


(set-reset-globals FALSE)
(defglobal ?*e2* = (new jess.Rete))
(defrule hello-1
  =>
  (printout t Hello1 crlf)
  (call-on-engine ?*e2* (eval "(defrule hello-1 => (printout t  
Hello2 crlf))"))

  (call-on-engine ?*e2* (reset))
  (call-on-engine ?*e2* (run)))
(reset)
(run)

Whenever you're reporting a problem like this, on the Jess list or  
anywhere else, it helps to be much more specific about what *exactly*  
you tried, and what *exactly* happened, including the *exact* text of  
any messages you receive. I don't know what you tried, but "unable to  
read/write" doesn't sound like any message that Jess can produce.



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




Re: JESS: Shadow facts, property updates, repetitive activation activity

2007-02-08 Thread Ernest Friedman-Hill
Check out the new "slot-specific" declaration for deftemplates; it  
does exactly what you want.

See http://www.jessrules.com/docs/70/rules.html#slot-specific .


On Feb 8, 2007, at 11:39 PM, Michael Smith wrote:


Hey,

In Jess, is there any way to trigger a change to a single property  
and have only those rules that reference the property be affected?


With property change listeners and dynamic shadow facts it appears  
the entire shadow fact is updated and all rules referencing the  
object are deactivated and reactivated.   I had hoped that the  
property change listener would *only* trigger updates to the  
properties named (at least as a default behavior).


I can see the desire to have the whole bean updated when any  
property changes (since some of the properties might be computed or  
virtual), however there's a lot of value in not forcing all the de-/ 
re-activations that seem to follow (even if more careful  
consideration of property  updating might be necessary).  If the  
whole bean is affected on effectively any property change and all  
rules that reference every bean have to re-evaluate -- regardless  
of the particular property updating, then shadow facts have a much  
narrower role than I'd hoped they could have.


Is there a way to change the behavior to only "tickle" the rules  
that reference the properties being updated?  Manual updates of  
static shadow facts allow for control over updating, but are  
documented as driving updates on all properties.   My naive  
expectation was that there was a way to have only the rules that  
reference properties named in a change event result in an update.   
Is that a capability available?


Any discussion of this is welcomed.   I don't have a nice toy  
example to present -- but if the issue isn't clear from this post,  
I suppose I can contrive both a Java/Jess example and a  
corresponding COOL/CLIPS example.


Thanks,

- Mike Smith



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]




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




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

2007-02-09 Thread Ernest Friedman-Hill


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]




Re: JESS: Inheritance, Interfaces and LHS

2007-02-10 Thread Ernest Friedman-Hill


On Feb 8, 2007, at 1:36 PM, Juergen wrote:


Hi,

I have not fully grasped how Jess deals with Java class/interface  
inheritance for LHS checks.


Jess currently handles single inheritance only; any one template can  
have just one direct parent template, which can represent a class,  
interface, or pure template. Support for multiple interface  
inheritance is currently under development.



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




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

2007-02-12 Thread Ernest Friedman-Hill
As soon as you have more than one thread, you have to be *very  
careful* with your definitions of words like "when" and "finished".


The method "runUntilHalt()" just does something like this

while (!halt) {
while there are activated rules and halt is false
fire a rule
wait for halt to become true or there to be new activations
}

So when you call "runUntilHalt()", Jess can potentially be "done"  
lots of times. If you want to do something special at that time, then  
don't call runUntilHalt() -- write your own equivalent method which  
is based on the same loop, but does something special. For example


while (!halt) {
while there are activated rules and halt is false
fire a rule
// At this point, either there are no rules to fire, or "halt"  
has been called
// This is, I think, what you're calling "a safe spot to call  
halt", although, of course,

// it's always safe to do so
if (mySpecialHaltFlag)
break;
wait for halt to become true or there to be new activations
}





On Feb 12, 2007, at 7:44 AM, Shi Paul wrote:


Hi Henrique and others,
Ernest's reply is only good for single thread execution, while I  
have at least 2 threads running. It's kinda like reproducer/ 
consumer scenario. I have Jess running in its own thread (consumer  
thread), I have my other threads running as facts-collecting  
threads (producer thread). So once those facts-collecting threads  
stop running, I need to stop Jess thread but the problem is when I  
call Rete.halt() I don't know if it's still busy.
I tried Rete.listActivations() before stopping it, it seems doesn't  
work as well (the test result revealed that). I didn't try Scott's  
suggestion since I want the solution in the API level instead of  
adding a new rule in the knowledge base as I think the solution  
shouldn't be across 2 different domains. Does anybody has othe good  
suggestions?


Thanks,
Paul



From: "Henrique Lopes Cardoso" <[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: Mon, 12 Feb 2007 09:43:05 +

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:owner-jess- 
[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  notificatio

Re: JESS: Scheduling Jess To Run Automatically On A Web Server

2007-02-12 Thread Ernest Friedman-Hill
This is really not a Jess question; removing Jess from the equation  
would still leave the same issues, I think. I can give you some  
ideas, but I think a general programming forum like  
saloon.javaranch.com is a better place to discuss this.


If the program has to run at exactly the same time each month, then  
it has to run on a computer which is on all the time. If you don't  
have one, then it has to be offsite somewhere, and yes, Web hosting  
companies are one possibility. Another would be just a shell-access  
hosting company, where you could just run a program using a cron job,  
without the added complexity of the web app.


Then, of course, it might be hard for that program to affect  
something for the user -- i.e., touch files on their own PC, or  
report back to the user.


If it just has to run "whenever", like the first time each month the  
user turns on their PC, then there are Windows tools that let you  
schedule jobs in a cron-like fashion; if you set up a job for the  
first of each month, then it would run when the PC was turned on for  
the first time each month.



On Feb 11, 2007, at 6:22 PM, [EMAIL PROTECTED] wrote:


Hi,

I have a set of Jess rules which connects to a MySQL DB and at the  
moment
I run this via a .java file that creates a Rete engine and does  
what you
would expect. Now I need to deploy it so that it can run on a web  
server

so I was going to embed it in either a servlet or a .jsp page but my
question is how can I schedule this so that it runs automatically  
(e.g.
the first day of every month)? I thought about cron jobs to  
schedule the
visiting of the url of the servlet/jsp page but I believe it only  
works
for CGI/PHP scripts. I'm at a bit of loss because the running of  
the Jess

rules has to be automatic and can't simple reside on a computer but
without this functionality my system wouldn't be much use if you  
had to

run the Jess rules yourself or leave your PC on 365/24/7. And is the
servlet/jsp necessary as it will give no output to the user nor  
needs any

input but just runs a set of rules in the background which either fire
thus executing a userfunction I've defined or doesn't fire, but I  
can see
no other option to be able to run the Jess rules online. Thanks in  
advance

and I'm open to any suggestions. Regards.


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




Re: JESS: Manipulate java.lang.String in Jess

2007-02-13 Thread Ernest Friedman-Hill
Java String objects are immutable, of course, so you can't change the  
existing one; you'd want to remove the existing one and replace it  
with a new one, something like


(defrule rule
  ?s <- (String)
  =>
  (retract ?s)
  (add (new String "test")))



On Feb 13, 2007, at 2:18 AM, [EMAIL PROTECTED] wrote:


Hello,

I'm new to Jess and i have a problem which is probably easy to  
solve but i dont know how. I'm using JSR94 StateLessRuleSession to  
execute my RuleSets written in Jess and as input parameter i have a  
simple java.lang.String. Now I want to change this String within  
the RuleSet and get back the changed String in my Java class. For  
example:


(defclass String java.lang.String)

(defrule MAIN::nextString "nextString"
(String (OBJECT ?i))
=>
(printout t "String " (?i toString) crlf)
 how to change the string -> for example: String = "test" 
)

Hope anyone can help me.

Thanks
Mathias



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




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

2007-02-14 Thread Ernest Friedman-Hill
"while there are activated rules and halt is false, fire a rule" is  
also known as Rete.run().


"wait for halt to become true or there to be new activations" is also  
known as Rete.waitForActivations().


The complete source for runUntilHalt() is something like

int runUntilHalt() throws JessException {
int count = 0;
do {
count += run();
synchronized (getActivationSemaphore()) {
if (isHalted())
break;
waitForActivations();
if (isHalted())
break;
}

} while (true);

return count;
}

All the Rete methods used here are public.

Note that most Jess licenses include the full source code.

On Feb 13, 2007, at 9:52 AM, Shi Paul wrote:


Hi Ernest,
You're so close to give me the right solution :-). Could you show  
me the code as "while there are activated rules"? I don't think  
it's "Rete.listActivations().hasMore()" since you mentioned in some  
other posts that it's not for internal use, so I'd like to see what  
you use internally so that I can apply the same theory.


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: Mon, 12 Feb 2007 19:33:10 -0700

As soon as you have more than one thread, you have to be *very   
careful* with your definitions of words like "when" and "finished".


The method "runUntilHalt()" just does something like this

while (!halt) {
while there are activated rules and halt is false
fire a rule
wait for halt to become true or there to be new activations
}

So when you call "runUntilHalt()", Jess can potentially be "done"   
lots of times. If you want to do something special at that time,  
then  don't call runUntilHalt() -- write your own equivalent  
method which  is based on the same loop, but does something  
special. For example


while (!halt) {
while there are activated rules and halt is false
fire a rule
// At this point, either there are no rules to fire, or  
"halt"  has been called
// This is, I think, what you're calling "a safe spot to call   
halt", although, of course,

// it's always safe to do so
if (mySpecialHaltFlag)
break;
wait for halt to become true or there to be new activations
}





On Feb 12, 2007, at 7:44 AM, Shi Paul wrote:


Hi Henrique and others,
Ernest's reply is only good for single thread execution, while I   
have at least 2 threads running. It's kinda like reproducer/  
consumer scenario. I have Jess running in its own thread  
(consumer  thread), I have my other threads running as facts- 
collecting  threads (producer thread). So once those facts- 
collecting threads  stop running, I need to stop Jess thread but  
the problem is when I  call Rete.halt() I don't know if it's  
still busy.
I tried Rete.listActivations() before stopping it, it seems  
doesn't  work as well (the test result revealed that). I didn't  
try Scott's  suggestion since I want the solution in the API  
level instead of  adding a new rule in the knowledge base as I  
think the solution  shouldn't be across 2 different domains. Does  
anybody has othe good  suggestions?


Thanks,
Paul



From: "Henrique Lopes Cardoso" <[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: Mon, 12 Feb 2007 09:43:05 +

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:owner-jess-  
[EMAIL PR

Re: JESS: Objects as Facts?

2007-02-16 Thread Ernest Friedman-Hill


On Feb 16, 2007, at 1:29 PM, B. Tenbergen wrote:



I have a simple Java class called "Course" with three private final  
int attributes and the corresponding get-methods. I instantiated  
three objects from this class and want to add these Objects as  
Facts to the working memory of Jess so that I can access the  
attributes (and mathods) of the objects as slots of the facts.
Using r.defclass(Course, Course, null) -(r is my Rete Object)-  
resulted in an error - the class Course wasn't found.


Jess doesn't do anything especially magical here. The class has to be  
available on the class path when the defclass is executed, and the  
class has to be accessible (i.e., public).




Instead, I used something like this:
   Fact f1 = new Fact("course", r);
   f1.setSlotValue("crn", new Value(new Integer(1)));
   f1.setSlotValue("starttime", new Value(new Integer(1110)));
   f1.setSlotValue("endtime", new Value(new Integer(1230)));
   r.assertFact(f1);
(crn, starttime and endtime or the private final int attributes)


This is not at all the same thing, of course. It can be done in a  
more streamlined way by using "eval" or "assertString":


r.assertString("(course (crn 1) (starttime 1110) (endtime 1230))");

Also, do be careful using these Integer objects; if you mean to treat  
them as numbers, then use numbers (int values.)



Also, I wonder how I can define a rule from Java in Jess that  
allows me to check whether or not two facts have the same content  
in a slot and, iff true, do something.
   r.eval("(defrule r1 (forall (course (starttime ?time)))  
=> (printout t \"Warining! Time collision!\" crlf))");
Did not work, as it terminated with an  
ArrayIndexOutOfBounceException at Index 4.




Don't know exactly what you're trying to accomplish using "forall"  
here. "forall" always includes at least two patterns, and it says  
"every time the first pattern matches, all the subsequent ones also  
match". If you just want to check if two facts match, then you just  
need a rule with two patterns, like


 (defrule r1
 ?c1 <- (course (starttime ?time))
 ?c2 <- (course (starttime ?time))
 (test (neq ?c1 ?c2))
 =>

Using the variable "time" twice "unifies" the starttime slots in the  
two facts, matching only if they're equal; and then we have to  
explicitly state that the patterns must match two separate facts.

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




Re: JESS: ADDING A GUI TO MY EXPERT SYSTEM

2007-02-16 Thread Ernest Friedman-Hill


On Feb 16, 2007, at 4:37 PM, faustoleuci wrote:



Hi to everybody. I am a student and I'm doing a expert system study.
this is the first time i have used jess in my life. I want to add a  
gui to

this expert system:

[ Lots of copyrighted code deleted by moderator ]

Could you help me? I would like to insert user a input in a frame  
and read

answer of expert system in the same frame.


This is the code from Part 3 of Jess in Action. In Part 4, a similar  
application is developed, but this one has a GUI. Chapter 13 (which  
has actually been released as a sample chapter (see  http:// 
www.manning-source.com/books/friedman-hill/friedman-hill_ch13.pdf) is  
all about putting a GUI onto that application. So either read the  
next few chapters in the book (if you have it) or just study chapter  
13 and go from there. There is also some material in the manual  
(especially in the Jess 7 manual) about integrating Jess with Java  
GUIs; spend some time studying that as well.


A good knowledge of Java GUI programming is required; Jess doesn't do  
anything to simplify Java programming for you.


-----
Ernest Friedman-Hill
Advanced Software Research  Phone: (925) 294-2154
Sandia National LabsFAX:   (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://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]




  1   2   3   4   5   6   7   8   9   10   >