Re: JESS: Time-varying methods inside a and in a test

2011-07-19 Thread Wolfgang Laun
(and) does a short-circuited evaluation of its operands, but it is still a
single CE. Whether it returns false due to the first or second operand does
not matter: it'll have to be reevaluated over and over again.

Using two boolean functions in two different CEs may result in less
invocations of
these functions since a true result of the first CE is not lost.

Wolfgang

On 18 July 2011 17:00, Skeptic . skeptic2...@hotmail.com wrote:

  Hi,

 Is there a good reason why a rule like this :

 (defrule r1
 [...]
 (test (and (time-varying call1) (time-varying call2))
 =
 [...])

 behave differently than one like this :

 (defrule r1b
 [...]
 (test (time-varying call1))
 (test (time-varying call2))
 =
 [...])

 Thanks !



RE: JESS: Time-varying methods inside a and in a test

2011-07-19 Thread Skeptic .


r1 is fired, r1b is not (which is the desired behavior).

 From: ejfr...@sandia.gov
 To: jess-users@sandia.gov
 Subject: Re: JESS: Time-varying methods inside a and in a test
 Date: Mon, 18 Jul 2011 13:06:56 -0400
 
 Although they do compile into different networks, the effect should be  
 basically the same. What's the difference you're observing?
 
 
 On Jul 18, 2011, at 11:00 AM, Skeptic . wrote:
 
  Hi,
 
  Is there a good reason why a rule like this :
 
  (defrule r1
  [...]
  (test (and (time-varying call1) (time-varying call2))
  =
  [...])
 
  behave differently than one like this :
 
  (defrule r1b
  [...]
  (test (time-varying call1))
  (test (time-varying call2))
  =
  [...])
 
  Thanks !
 
 -
 Ernest Friedman-Hill
 Informatics  Decision Sciences  Phone: (925) 294-2154
 Sandia National Labs
 PO Box 969, MS 9012ejfr...@sandia.gov
 Livermore, CA 94550 http://www.jessrules.com
 
 
 
 
 
 
 To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
 in the BODY of a message to majord...@sandia.gov, NOT to the list
 (use your own address!) List problems? Notify owner-jess-us...@sandia.gov

Re: JESS: Time-varying methods inside a and in a test

2011-07-19 Thread Wolfgang Laun
It would be interesting to see these functions.

Basically I'm inclined to believe that this is not possible without some
weird side effect achieved by one of the functions.

-W


On 18 July 2011 19:42, Skeptic . skeptic2...@hotmail.com wrote:



 r1 is fired, r1b is not (which is the desired behavior).

  From: ejfr...@sandia.gov
  To: jess-users@sandia.gov
  Subject: Re: JESS: Time-varying methods inside a and in a test
  Date: Mon, 18 Jul 2011 13:06:56 -0400
 
  Although they do compile into different networks, the effect should be
  basically the same. What's the difference you're observing?
 
 
  On Jul 18, 2011, at 11:00 AM, Skeptic . wrote:
 
   Hi,
  
   Is there a good reason why a rule like this :
  
   (defrule r1
   [...]
   (test (and (time-varying call1) (time-varying call2))
   =
   [...])
  
   behave differently than one like this :
  
   (defrule r1b
   [...]
   (test (time-varying call1))
   (test (time-varying call2))
   =
   [...])
  
   Thanks !
 
  -
  Ernest Friedman-Hill
  Informatics  Decision Sciences  Phone: (925) 294-2154
  Sandia National Labs
  PO Box 969, MS 9012ejfr...@sandia.gov
  Livermore, CA 94550 http://www.jessrules.com
 
 
 
 
 
  
  To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
  in the BODY of a message to majord...@sandia.gov, NOT to the list
  (use your own address!) List problems? Notify
 owner-jess-us...@sandia.gov



JESS: Basic questions about modules, context, and focus

2011-07-19 Thread Russell Thomas
I¹ve read through the documentation, JESS in Action book, and mailing list
archive, and I can¹t seem to figure out this basic question:

How do I assert facts from Java into different modules (or
??contexts??)?

To be more specific, the application is a discrete event simulation with
agents interacting with each other and objects in the environment.  Each
agent currently has two separate RETE engines, each with it¹s own CLP file
and only the MAIN module, and I use Œcall-on-engine¹ function calls to
coordinate between them.  While this functions correctly, it¹s cumbersome
and inefficient.  Plus I need to expand the categories of rules by two and
using the current scheme would get too complicated.

Most of the discrete event simulation happens in Java, with facts asserted
to the agents so they can react to the environment and each other.
Currently, this is how I assert facts:

 engine.assertFact(new Fact(found-something-interesting, engine));

I would like to move to an architecture where each agent has only one RETE
engine, one CLP file with multiple modules -- one module for each category
of rules.

But how do I assert the fact in a specific module?  Is it in the string
associated with the fact?

I found classdoc for ³public Fact assertFact(Fact f, Context c) throws
JessException -- Assert a fact, using the given execution context. ...², and
then tried to understand of Œexecution context¹ was the same thing as module
or focus stack or what.  The classdoc for Context was very unhelpful in this
regard.

Also, what¹s the difference between Œset-current-module¹ and Œfocus¹
functions?  When do you use one or the other?  I presume I¹ll be using java
methods Œengine.eval(³(focus BLARG)²);¹ if I need to change the current
module, but then what is Œset-current-module¹ for?

I really wish there was a complete worked example showing how to use a rule
set with multiple modules that are accessed and manipulated through Java.  I
need the ³dots² to be more ³connected².

Struggling,

Russ Thomas


JESS: RE: Basic questions about modules, context, and focus

2011-07-19 Thread Friedman-Hill, Ernest
Hi Russ,

Facts are assigned to modules at the template level, not at the individual fact 
level. When you define a template using deftemplate, either the template 
specifies its module by using a name like modulename::factname, or if the 
name is unqualified, the template is placed in the current module. The 
current module is the one that unqualified constructs  will be assigned to; 
usually it's only relevant during the time your code is being loaded, and not 
while your program is running.

The focus module, on the other hand, is the one from which rules are being 
fired. It's unrelated to which module things will be defined in. It is relevant 
at runtime only.

If you use assertFact with an unqualified name as you've shown below, Jess 
will first look in the current module and the default module for a template 
with that name; if one isn't found, it'll be created in the current module. As 
the current module won't necessarily be well-defined or predicatable while your 
program is running, it is always a good idea when using modules to specify the 
full name of the fact, including the module name, so that you don't 
inadvertently create templates with the same name in different modules by 
mistake.

Finally, note that when a rule or query is compiled, the unqualified template 
names it mentions are resolved in the module in which the rule or query is 
defined, or in the default module. The current module is thus effectively set 
to the rule's module while a rule is being defined. Once the rule is compiled, 
the templates are already resolved, and the current module has no effect on how 
the rule operates.




From: owner-jess-us...@sandia.gov [mailto:owner-jess-us...@sandia.gov] On 
Behalf Of Russell Thomas
Sent: Tuesday, July 19, 2011 10:00 AM
To: jess-users
Subject: JESS: Basic questions about modules, context, and focus

I've read through the documentation, JESS in Action book, and mailing list 
archive, and I can't seem to figure out this basic question:

How do I assert facts from Java into different modules (or 
??contexts??)?

To be more specific, the application is a discrete event simulation with agents 
interacting with each other and objects in the environment.  Each agent 
currently has two separate RETE engines, each with it's own CLP file and only 
the MAIN module, and I use 'call-on-engine' function calls to coordinate 
between them.  While this functions correctly, it's cumbersome and inefficient. 
 Plus I need to expand the categories of rules by two and using the current 
scheme would get too complicated.

Most of the discrete event simulation happens in Java, with facts asserted to 
the agents so they can react to the environment and each other.  Currently, 
this is how I assert facts:

engine.assertFact(new Fact(found-something-interesting, engine));

I would like to move to an architecture where each agent has only one RETE 
engine, one CLP file with multiple modules -- one module for each category of 
rules.

But how do I assert the fact in a specific module?  Is it in the string 
associated with the fact?

I found classdoc for public Fact assertFact(Fact f, Context c) throws 
JessException -- Assert a fact, using the given execution context. ..., and 
then tried to understand of 'execution context' was the same thing as module or 
focus stack or what.  The classdoc for Context was very unhelpful in this 
regard.

Also, what's the difference between 'set-current-module' and 'focus' functions? 
 When do you use one or the other?  I presume I'll be using java methods 
'engine.eval((focus BLARG));' if I need to change the current module, but 
then what is 'set-current-module' for?

I really wish there was a complete worked example showing how to use a rule set 
with multiple modules that are accessed and manipulated through Java.  I need 
the dots to be more connected.

Struggling,

Russ Thomas