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: [email protected]
> To: [email protected]
> 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 [email protected]'
> in the BODY of a message to [email protected], NOT to the list
> (use your own address!) List problems? Notify [email protected]