RE: JESS: Defglobal function.

2010-03-05 Thread Andrew Meng

Ernest,

 

Ok, I will use reset() method instead of resetToMark() at the end of each loop.

 

My question is,

 

The global varible(a fuzzyVariable)'s terms get changed due to the different 
input in each loop. Without recreating it, how can I update it in the engine 
from Java in each loop?

 

Thanks,

Andrew


 
> From: ejfr...@sandia.gov
> To: jess-us...@mailgate.sandia.gov
> Date: Thu, 4 Mar 2010 11:05:40 -0700
> Subject: RE: JESS: Defglobal function.
> 
> Nothing is utterly wrong, but I'm not sure it makes sense to reuse the Rete 
> object for each loop iteration without either (1) calling "clear", to 
> completely start over, or (2) moving some of the stuff out of the loop, like 
> the batch file. The resetToMark() call is removing all the facts except for 
> the (initial-fact) -- it seems like you could just call "reset". And of 
> course once you've defined the defglobal with a particular object as its 
> initial value, that variable doesn't need to be recreated, so the defglobal 
> can move out of the loop as well.
> 
> 
> > -Original Message-
> > From: owner-jess-us...@sandia.gov 
> > [mailto:owner-jess-us...@sandia.gov] On Behalf Of Andrew Meng
> > Sent: Wednesday, March 03, 2010 10:09 AM
> > To: jess-users
> > Subject: RE: JESS: Defglobal function.
> > 
> > 
> > Ernest,
> > 
> > 
> > 
> > Thanks a lot for helping me here!
> > 
> > 
> > 
> > Let me clarify what I try to do:
> > 
> > 
> > 
> > The internal state of the global veriable(fuzzyVariable) is 
> > keep changing because the defination of the fuzzy term gets 
> > changed according to the external input.
> > 
> > 
> > 
> > My code is like,
> > 
> > 
> > 
> > ---
> > 
> > WorkingMemoryMark marker;
> > 
> > 
> > 
> > engine = new FuzzyRete();
> > 
> > Defglobal dg;
> > 
> > 
> > 
> > FuzzyVariable var = new FuzzyVariable ("value" 0 100 "percentage");
> > 
> > 
> > 
> > engine.reset();
> > 
> > marker = engine.mark();
> > 
> > 
> > 
> > while( input){
> > 
> > 
> > 
> > var.addTerm("low", ZFuzzySet(input);
> > 
> > var.addTerm("high", SFuzzySet(input);
> > 
> > 
> > 
> > dg = new Defglobal("*v*", new Value(var));
> > 
> > 
> > 
> > engine.addDefglobal(dg);
> > 
> > 
> > engine.batch("x.clp"); //x.clp will reference the 
> > global variable
> > 
> > if (engine.run() >1){
> > 
> > //do something
> > 
> > }
> > 
> > engine.clearStorage();
> > 
> > engine.resetToMark(marker)
> > 
> > }
> > 
> > --
> > 
> > 
> > 
> > 
> > Will the defglobal part work?
> > 
> > 
> > 
> > Thanks a lot!
> > 
> > Andrew
> > 
> > > From: ejfr...@gmail.com
> > > To: jess-users@sandia.gov
> > > Subject: Re: JESS: Defglobal function.
> > > Date: Wed, 3 Mar 2010 07:08:56 -0500
> > > 
> > > Hi Andrew,
> > > 
> > > I'm not sure how subtle your question actually is, because 
> > there may 
> > > be a major issue with accomplishing what you're after here. The 
> > > initial value of a defglobal is stored exactly as it appears in the 
> > > definition of the defglobal; if the initial value is a 
> > function call, 
> > > then that function call itself is stored. This is so that when you 
> > > call (reset), the function call can be invoked to initialize the 
> > > defglobal to an appropriate new value at that time.
> > > 
> > > In any case, the point is that the function call has to be 
> > stored as 
> > > Jess code, so the code that creates the FuzzyVariable 
> > itself has to be 
> > > expressed as a Jess function call no matter what. If you want to 
> > > express exactly what you've shown here without any Jess 
> > code, then I'm 
> > > afraid you're out of luck!
> > > 
> > > If, on the other hand, it's OK for the initial value of the 
> > defglobal 
> > > to be one, specific object created in Java, then you could 
> > just create 
> > > the FuzzyVariable in Java (including the "addTerm" calls) and then 
> > > call something like
> > > 
> > > FuzzyRete engine = ...
> > > FuzzyVariable var = ...
> &

RE: JESS: Defglobal function.

2010-03-04 Thread Friedman-Hill, Ernest
Nothing is utterly wrong, but I'm not sure it makes sense to reuse the Rete 
object for each loop iteration without either (1) calling "clear", to 
completely start over, or (2) moving some of the stuff out of the loop, like 
the batch file. The resetToMark() call is removing all the facts except for the 
(initial-fact) -- it seems like you could just call "reset". And of course once 
you've defined the defglobal with a particular object as its initial value, 
that variable doesn't need to be recreated, so the defglobal can move out of 
the loop as well.


> -Original Message-
> From: owner-jess-us...@sandia.gov 
> [mailto:owner-jess-us...@sandia.gov] On Behalf Of Andrew Meng
> Sent: Wednesday, March 03, 2010 10:09 AM
> To: jess-users
> Subject: RE: JESS: Defglobal function.
> 
> 
> Ernest,
> 
>  
> 
> Thanks a lot for helping me here!
> 
>  
> 
> Let me clarify what I try to do:
> 
>  
> 
> The internal state of the global veriable(fuzzyVariable) is 
> keep changing because the defination of the fuzzy term gets 
> changed according to the external input.
> 
>  
> 
> My code is like,
> 
>  
> 
> ---
> 
> WorkingMemoryMark marker;
> 
>  
> 
> engine = new FuzzyRete();
> 
> Defglobal dg;
> 
>  
> 
> FuzzyVariable var = new FuzzyVariable ("value" 0 100 "percentage");
> 
>  
> 
> engine.reset();
> 
> marker = engine.mark();
> 
>  
> 
> while( input){
> 
>   
> 
>   var.addTerm("low", ZFuzzySet(input);
> 
>   var.addTerm("high", SFuzzySet(input);
> 
>  
> 
>   dg = new Defglobal("*v*", new Value(var));
> 
>  
> 
>   engine.addDefglobal(dg);
> 
> 
>   engine.batch("x.clp"); //x.clp will reference the 
> global variable
> 
>   if (engine.run() >1){
> 
> //do something
> 
>   }
> 
>   engine.clearStorage();
> 
>   engine.resetToMark(marker)
> 
> }
> 
> --
> 
> 
>  
> 
> Will the defglobal part work?
> 
>  
> 
> Thanks  a lot!
> 
> Andrew
> 
> > From: ejfr...@gmail.com
> > To: jess-users@sandia.gov
> > Subject: Re: JESS: Defglobal function.
> > Date: Wed, 3 Mar 2010 07:08:56 -0500
> > 
> > Hi Andrew,
> > 
> > I'm not sure how subtle your question actually is, because 
> there may 
> > be a major issue with accomplishing what you're after here. The 
> > initial value of a defglobal is stored exactly as it appears in the 
> > definition of the defglobal; if the initial value is a 
> function call, 
> > then that function call itself is stored. This is so that when you 
> > call (reset), the function call can be invoked to initialize the 
> > defglobal to an appropriate new value at that time.
> > 
> > In any case, the point is that the function call has to be 
> stored as 
> > Jess code, so the code that creates the FuzzyVariable 
> itself has to be 
> > expressed as a Jess function call no matter what. If you want to 
> > express exactly what you've shown here without any Jess 
> code, then I'm 
> > afraid you're out of luck!
> > 
> > If, on the other hand, it's OK for the initial value of the 
> defglobal 
> > to be one, specific object created in Java, then you could 
> just create 
> > the FuzzyVariable in Java (including the "addTerm" calls) and then 
> > call something like
> > 
> > FuzzyRete engine = ...
> > FuzzyVariable var = ...
> > Defglobal dg = new Defglobal("*v*", new Value(var));
> > engine.addDefglobal(dg);
> > 
> > On Mar 2, 2010, at 11:09 PM, Andrew Meng wrote:
> > 
> > > Hello,
> > >
> > > I try to follow a fuzzyJess example. It does something(in 
> Jess only) 
> > > like:
> > >
> > > (defglobal ?*v* = (new FuzzyVariable "value" 0 100 "percentage"))
> > >
> > > then
> > > (?*v* addTerm "low", (new TriangleFuzzySet (...))
> > >
> > > I am wondering how I could do the same thing totally from 
> Java using 
> > > Jess API.
> > >
> > 
> > -
> > Ernest Friedman-Hill
> > Informatics & Decision Sciences, Sandia National Laboratories
> > PO Box 969, MS 9012, Livermore, CA 94550
> > http://www.jessrules.com
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > To unsubscribe, send the words 'unsubscribe jess-users 
> y...@address.com'
> > in the BODY of a message to majord...@sandia.gov, NOT to the list
> > (use your own address!) List problems? Notify 
> owner-jess-us...@sandia.gov

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




RE: JESS: Defglobal function.

2010-03-03 Thread Andrew Meng

Ernest,

 

Thanks a lot for helping me here!

 

Let me clarify what I try to do:

 

The internal state of the global veriable(fuzzyVariable) is keep changing 
because the defination of the fuzzy term gets changed according to the external 
input.

 

My code is like,

 

---

WorkingMemoryMark marker;

 

engine = new FuzzyRete();

Defglobal dg;

 

FuzzyVariable var = new FuzzyVariable ("value" 0 100 "percentage");

 

engine.reset();

marker = engine.mark();

 

while( input){

  

  var.addTerm("low", ZFuzzySet(input);

  var.addTerm("high", SFuzzySet(input);

 

  dg = new Defglobal("*v*", new Value(var));

 

  engine.addDefglobal(dg);


  engine.batch("x.clp"); //x.clp will reference the global variable

  if (engine.run() >1){

//do something

  }

  engine.clearStorage();

  engine.resetToMark(marker)

}

--


 

Will the defglobal part work?

 

Thanks  a lot!

Andrew

> From: ejfr...@gmail.com
> To: jess-users@sandia.gov
> Subject: Re: JESS: Defglobal function.
> Date: Wed, 3 Mar 2010 07:08:56 -0500
> 
> Hi Andrew,
> 
> I'm not sure how subtle your question actually is, because there may 
> be a major issue with accomplishing what you're after here. The 
> initial value of a defglobal is stored exactly as it appears in the 
> definition of the defglobal; if the initial value is a function call, 
> then that function call itself is stored. This is so that when you 
> call (reset), the function call can be invoked to initialize the 
> defglobal to an appropriate new value at that time.
> 
> In any case, the point is that the function call has to be stored as 
> Jess code, so the code that creates the FuzzyVariable itself has to be 
> expressed as a Jess function call no matter what. If you want to 
> express exactly what you've shown here without any Jess code, then I'm 
> afraid you're out of luck!
> 
> If, on the other hand, it's OK for the initial value of the defglobal 
> to be one, specific object created in Java, then you could just create 
> the FuzzyVariable in Java (including the "addTerm" calls) and then 
> call something like
> 
> FuzzyRete engine = ...
> FuzzyVariable var = ...
> Defglobal dg = new Defglobal("*v*", new Value(var));
> engine.addDefglobal(dg);
> 
> On Mar 2, 2010, at 11:09 PM, Andrew Meng wrote:
> 
> > Hello,
> >
> > I try to follow a fuzzyJess example. It does something(in Jess only) 
> > like:
> >
> > (defglobal ?*v* = (new FuzzyVariable "value" 0 100 "percentage"))
> >
> > then
> > (?*v* addTerm "low", (new TriangleFuzzySet (...))
> >
> > I am wondering how I could do the same thing totally from Java using 
> > Jess API.
> >
> 
> -
> Ernest Friedman-Hill
> Informatics & Decision Sciences, Sandia National Laboratories
> PO Box 969, MS 9012, Livermore, CA 94550
> http://www.jessrules.com
> 
> 
> 
> 
> 
> 
> 
> 
> To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
> in the BODY of a message to majord...@sandia.gov, NOT to the list
> (use your own address!) List problems? Notify owner-jess-us...@sandia.gov

Re: JESS: Defglobal function.

2010-03-03 Thread Ernest Friedman-Hill

Hi Andrew,

I'm not sure how subtle your question actually is, because there may  
be a major issue with accomplishing what you're after here. The  
initial value of a defglobal is stored exactly as it appears in the  
definition of the defglobal; if the initial value is a function call,  
then that function call itself is stored. This is so that when you  
call (reset), the function call can be invoked to initialize the  
defglobal to an appropriate new value at that time.


In any case, the point is that the function call has to be stored as  
Jess code, so the code that creates the FuzzyVariable itself has to be  
expressed as a Jess function call no matter what. If you want to  
express exactly what you've shown here without any Jess code, then I'm  
afraid you're out of luck!


If, on the other hand, it's OK for the initial value of the defglobal  
to be one, specific object created in Java, then you could just create  
the FuzzyVariable in Java (including the "addTerm" calls) and then  
call something like


FuzzyRete engine = ...
FuzzyVariable var = ...
Defglobal dg = new Defglobal("*v*", new Value(var));
engine.addDefglobal(dg);

On Mar 2, 2010, at 11:09 PM, Andrew Meng wrote:


Hello,

I try to follow a fuzzyJess example. It does something(in Jess only)  
like:


(defglobal ?*v* = (new FuzzyVariable "value"  0 100 "percentage"))

then
(?*v* addTerm "low", (new TriangleFuzzySet (...))

I am wondering how I could do the same thing totally from Java using  
Jess API.




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








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