JESS: Is there a limit for number of facts?

2004-09-21 Thread Aby
Hi,
 
Few weeks back I showed up here asking whether JESS is the right tool to use for a system which need to match 8000 commission schemes against 1 million sales record.
 
As part of my 'proof-of-concept' project to decide whether to use JESS to develop a new system, I am experimenting with 1 sales records and few commission schemes (actualy 4 schemes which means 4 rules)
 
I did it in two ways by using embedding JESS into a simple JAVA program. (I am still newbee to Java and Jess. So pardon me for my primitive way of doing things)
 
1. Load 4 rules into JESS
2. read record by record from sales file (text tile)
       assert 1 sales fact for each record.
3. do a (run). so the rules will be fired and the sales record is matched against the rules. It may match 0..4 rules. If a sales record matches a rule, then that rule-id is stored in a slot in the sales record.
   
4. Save the sales record to oracle DB.
 
Steps 2,3,4 are looped 1 times. Everything works well. 1 records are inserted. In this case, file reading and writing into DB is done in JAVA
 
I thought, this should not be the way. 1 (run)s?
 
So I changed the logic.
 
1. Load 4 rules
2. assert 1 facts.
3. do a (run). So in one shot all records are matched against the rules.
4. Then run a (defquery) get all the sales data facts and put into database in JESS itself. I wrote a small user-function which accepts facts and then inserts the values into DB.
 
Here I face a problem. It inserts only 6000+ records. So I fired (facts) immediately after asserting 1 facsts. I could see only 6000+ records. But I am sure the JAVA function asserts 1 records.
 
Why is it so? Is there a limitation for number of facts in JESS?(very unlikely) Or is this is a limitation of the evaluation copy? I downloaded the evaluation copy from Manning website after I purchased the JIA eBook. Or am I doing something wrong?
 
thanks
 
 
  Yahoo! Mobile- Download the latest ringtones, games, and more!

Re: JESS: Is there a limit for number of facts?

2004-09-21 Thread ejfried
I think Aby wrote:
>  
> Here I face a problem. It inserts only 6000+ records. So I fired (facts) immediately 
> after asserting 1 facsts. I could see only 6000+ records. But I am sure the JAVA 
> function asserts 1 records.
>  

The most likely explanation is that Jess doesn't allow duplicate
facts, and you've got duplicate identical sales records. The
assertFact() method will return null to let you know when you try to
assert a Fact that's an exact copy of an existing Fact.

In your case, the right thing to do would be to add another slot
containing a transaction number or other identifier to each sales
record fact -- if you don't already have one, you can just make one up
for Jess's benefit. The gensym() method in RU.java and the (gensym*)
function in Jess are handy for this purpose -- each time they are
called they return a unique symbol which you could use directly for a
transaction identifier.

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


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




RE: JESS: Is there a limit for number of facts?

2004-09-21 Thread Jason Morris
I think that Abby wrote:
>>Here I face a problem. It inserts only 6000+ records.

Hi Abby,

1.  If you are using made-up data, check that your records are unique.  Jess
will only assert one fact for one unique combination of its slot values.  In
other words, multiple facts with the exact same slot values cannot exist in
working memory.  Make sure that 4,000 of your 10,000 facts aren't
duplicates.

2.  If that's not the case, then send us your code.

Cheers,
Jason

Jason Morris
Morris Technical Solutions
[EMAIL PROTECTED]
www.morristechnicalsolutions.com
fax/phone: 503.692.1088





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 there a limit for number of facts?

2004-09-21 Thread Rodolfo
Hi Aby,
I don't know if there is other limit than the physical memory size, but if
it exists is far greater than 6000+.
I think your problem is that you have duplicate records in your DB, and all
the facts in the engine are unique. When asserting a new fact that is
identical to a previously asserted one only one remains.

Regards.

Rodolfo Martin.

> Hi,
>  
> Few weeks back I showed up here asking whether JESS is the right tool to
use for a system which need to match 8000 commission schemes against 1
million sales record.
>  
> As part of my 'proof-of-concept' project to decide whether to use JESS to
develop a new system, I am experimenting with 1 sales records and few
commission schemes (actualy 4 schemes which means 4 rules)
>  
> I did it in two ways by using embedding JESS into a simple JAVA program.
(I am still newbee to Java and Jess. So pardon me for my primitive way of
doing things)
>  
> 1. Load 4 rules into JESS
> 2. read record by record from sales file (text tile)
>        assert 1 sales fact for each record.
> 3. do a (run). so the rules will be fired and the sales record is matched
against the rules. It may match 0..4 rules. If a sales
record matches a rule, then that rule-id is stored in a slot in the
sales record.
>   
> 4. Save the sales record to oracle DB.
>  
> Steps 2,3,4 are looped 1 times. Everything works well. 1 records
are inserted. In this case, file reading and writing into DB is done in JAVA
>  
> I thought, this should not be the way. 1 (run)s?
>  
> So I changed the logic.
>  
> 1. Load 4 rules
> 2. assert 1 facts.
> 3. do a (run). So in one shot all records are matched against the rules.
> 4. Then run a (defquery) get all the sales data facts and put into
database in JESS itself. I wrote a small user-function which accepts facts
and then inserts the values into DB.
>  
> Here I face a problem. It inserts only 6000+ records. So I fired (facts)
immediately after asserting 1 facsts. I could see only 6000+ records.
But I am sure the JAVA function asserts 1 records.
>  
> Why is it so? Is there a limitation for number of facts in JESS?(very
unlikely) Or is this is a limitation of the evaluation copy? I
downloaded the evaluation copy from Manning website after I purchased the
JIA eBook. Or am I doing something wrong?
>  
> thanks
>  
>  
>   Yahoo! Mobile- Download the latest ringtones, games, and
more!


WebMail -
movilab.net
Telefsnica Msviles Espaqa





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: Nested objects macthing guidelines

2004-09-21 Thread Rodolfo
Hi all,
I'm a relative newbie to Jess since,I've worked previously with CLIPS for a
year, but using plain deftemplates (no nested objects).
I'm actually evaluating using Jess but I'm a bit disoriented about how to
write patterns that match
complex nested objects/facts (with Lists and Maps) as those my KB would
have.
I've read the Manual, studied the examples and also read many archived
threads of this mailing list concerning this issues (Detecting changes in
nested Objects, Working with collections, RDF...), which have been quite
instructive, but are beyond my actual point

I've tried the simplified example that follows and it works but I wonder if
is there better ways to achieve it (mapping objects to a plain templates,
RDF...), as long as the nesting level increase the rules get uglier...


Regards

Rodolfo Martin

(deftemplate Address
(slot street(type STRING))
(slot number(type INTEGER))
)

(deftemplate Complex
(slot name(type STRING))
(slot address)
)

(defrule matchFredsfromRedStreet
(Complex (name ?n&"Fred")(address ?a&:(eq (fact-slot-value ?a street)
"Red")))
=>
(printout t "Fred lives at number " (fact-slot-value ?a number) crlf)
)


WebMail -
movilab.net
Telefsnica Msviles Espaqa





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: Nested objects macthing guidelines

2004-09-21 Thread ejfried
I think Rodolfo wrote:
>
> (defrule matchFredsfromRedStreet
> (Complex (name ?n&"Fred")
   (address ?a&:(eq (fact-slot-value ?a street)  "Red")))
> =>
> (printout t "Fred lives at number " (fact-slot-value ?a number)
> crlf)
> )

Better to write it this way:

 (defrule matchFredsfromRedStreet
   (Complex (name "Fred") (address ?a))
   ?a <- (Address (street  "Red") (number ?num))
=>
   (printout t "Fred lives at number " ?num crlf))

Now, when you get into using Maps and Lists, as you mentioned, you are
going to have to start using function calls. But fact-slot-value isn't
one of them, generally: that's never really necessary except for
tool-building, and if you find yourself using it, it's generally a
sign that you're doing something the hard way.


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


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




JESS: Very large hash tables

2004-09-21 Thread Judson, Ross
Ernest, I don't know if you've come across this, but Jess is _exactly_
the kind of system that will have problems with very large hash tables
if you're not careful.

There's a weird threshold that can occur with any Java data structure
that uses large arrays of Object references (Object[]).  If the size of
the Object array exceeds the maximum size of objects that can be placed
in the "new generation", garbage collection performance can be severely
impacted.  What ends up happening (I think) is that the single "big"
object gets shoved into the old generation, and has zillions of
references to objects back in the new generation.  I think those objects
are in turn lifted out and pushed into the old generation.  So highly
"active" use of a very large hash table can result in very inefficient
garbage collections, if the situation is not addressed.  

I've seen the ordered tree collections drop garbage collection times by
a factor of four.  In my day job we have a custom-built Btree structure
that drops overall collection times by a factor of about 100, in this
situation...

In test runs I've seen everything running peachy in terms of throughput
and speed, overall...then that new generation threshold is reached, and
garbage collection becomes a real problem.  These are big hash tables,
of course (outside of Jess), but the problem's real.  The simplest way
to create it is to create a new hashtable object with a very large
initial capacity (say, 10 million).  Make a test program that pounds the
hash table with adds and deletes, in a mix.  Turn on verbose:gc and
adjust the initial size up and down.  Very shortly you'll find a
"mystery point" where GC just takes much longer to run.

The solution is moving to trees, using a chained hash table system, or
enlarging the size of the new generation.  Frankly, the Java VM seems to
prefer the trees.  

RJ




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: java reflection

2004-09-21 Thread Thao
Hi all !
I have a question.
I have a class named Parameter in package inf.verification.core, its 
constructor is :
 Parameter(String name, Object value, String unit)

And i tried to use this class in jess over java reflection:
(import inf.verification.core.*)
(import java.lang.*)
(bind ?x (new Parameter "Laenge" (new Double 125.5) "meter"))
it give the error: class Parameter not found ! Why is the path for class 
Parameter wrong ?


And is the syntax :
(bind ?x (new Parameter "Laenge" (new Double 125.5) "meter"))
correctly ?
thanks
Thao




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: java reflection

2004-09-21 Thread Jason Morris
I think that Thao wrote:
>>Why is the path for class Parameter wrong ?

Hi Thao,

In general, make sure that you have the inf.verification.core package on
your Jess classpath, else Jess can't find your class.

Send us your path so we can check it.

>>And is the syntax :(bind ?x (new Parameter "Laenge" (new Double 125.5)
"meter")) correctly?

Yes, that should work fine.

BTW - java.lang.* is implictly imported in Jess -- no need to explicitly
import it.

Cheers,
Jason



Jason Morris
Morris Technical Solutions
[EMAIL PROTECTED]
www.morristechnicalsolutions.com
fax/phone: 503.692.1088





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: java reflection

2004-09-21 Thread ejfried
I think Thao wrote:
>
> class Parameter not found ! Why is the path for class
> Parameter wrong ?
>

Just as with any other Java program, the class path needs to properly
include the Parameter class, and the class itself needs to be
public. Make sure that when you start Jess, the CLASSPATH environment
variable, or the -classpath switch, properly includes the location of
the Parameter class.


> (bind ?x (new Parameter "Laenge" (new Double 125.5) "meter"))

Looks perfect.



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


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




JESS: unimplemented function detemplate

2004-09-21 Thread Mong-Thao La
Hi all !
I have a rule like:

(defrule inputParameterSpannungsnachweis
(nachweis "Spannungsnachweis")
=>
(import java.lang.*)
(bind ?querschnitt "Querschnitt")
(bind ?Fx  "Fx" )
(bind ?Fy  "Fy" )
(bind ?My  "My" )
(bind ?querschnittValue (new java.lang.String "I120"))
(bind ?FxValue  (new java.lang.Double 150.0 ))
(bind ?FyValue  (new java.lang.Double 200.0 ))
(bind ?MyValue  (new java.lang.Double 200.0 ))
(bind ?querschnittsUnit "")
(bind ?FxUnit  "KN"  )
(bind ?FyUnit  "KN"  )
(bind ?MyUnit  "KNcm")
(deftemplate parameter
(multislot name )
(multislot value)
(multislot unit ))
(bind ?x (assert (parameter (name  ?querschnitt ?Fx ?Fy ?My)
(value ?querschnittValue ?FxValue ?FyValue
?MyValue)
(unit  ?querschnittsUnit ?FxUnit ?FyUnit ?MyUnit)


then i use :(assert (nachweis "Spannungsnachweis"))
(run)

then there is an error: unimplemented function deftemplate.
I dont know why !??:(
thanks very much
Thao




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: unimplemented function detemplate

2004-09-21 Thread Jason Morris
I think that Thao wrote:
>> then there is an error: unimplemented function deftemplate. I dont know
why !??:(

Hold on there, Thao!
You may be giving poor Ernest a stroke as I write this, not to mention
violating the Zen of Jess http://herzberg.ca.sandia.gov/jess/zen.shtml  :-D
Hopefully he's off eating dinner now.

Jess is rightly complaining because you *cannot* define a deftemplate inside
a rule like this.  Defrule and deftemplate are two separate "constructs",
not true functions as Ernest points out in JIA and in the Jess
documentation -- and the RHS of rules are supposed to be function calls.
Also, the deftemplate for a fact should come before the rules that use it.

Why don't you tell us what you're trying to do so that we can suggest
something?

Cheers,
Jason


Jason Morris
Morris Technical Solutions
[EMAIL PROTECTED]
www.morristechnicalsolutions.com
fax/phone: 503.692.1088





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: unimplemented function detemplate [debug code]

2004-09-21 Thread Jason Morris
Hi again Thao,

I moved the (deftemplate parameter) out of your rule and formatted your code
a bit.
Try this...

;; = thao.clp ===
(clear)
(watch all)
(reset) ;; See JIA pp. 79-80 about doing a (reset) when starting a program.

(deftemplate parameter
(multislot name )
(multislot value)
(multislot unit ))

(defrule inputParameterSpannungsnachweis
(nachweis "Spannungsnachweis")
=>
(import java.lang.*)
(bind ?querschnitt "Querschnitt")
(bind ?Fx "Fx")
(bind ?Fy "Fy")
(bind ?My "My")
(bind ?querschnittValue (new java.lang.String "I120"))
(bind ?FxValue (new java.lang.Double 150.0 ))
(bind ?FyValue (new java.lang.Double 200.0 ))
(bind ?MyValue (new java.lang.Double 200.0 ))
(bind ?querschnittsUnit "")
(bind ?FxUnit "KN")
(bind ?FyUnit "KN")
(bind ?MyUnit "KNcm")
(bind ?x (assert (parameter (name  ?querschnitt ?Fx ?Fy ?My)
(value ?querschnittValue ?FxValue ?FyValue ?MyValue)
(unit ?querschnittsUnit ?FxUnit ?FyUnit ?MyUnit)

(assert (nachweis "Spannungsnachweis"))
(run)
;; 

. and I got this output

 ==> Focus MAIN
 ==> f-0 (MAIN::initial-fact)
MAIN::inputParameterSpannungsnachweis: +1+1+1+1+t
 ==> f-1 (MAIN::nachweis "Spannungsnachweis")
==> Activation: MAIN::inputParameterSpannungsnachweis :  f-1
FIRE 1 MAIN::inputParameterSpannungsnachweis f-1
 ==> f-2 (MAIN::parameter (name "Querschnitt" "Fx" "Fy" "My")
 (value 


)
   (unit "" "KN" "KN" "KNcm"))
 <== Focus MAIN

Is this what you wanted?

Cheers,
Jason


Jason Morris
Morris Technical Solutions
[EMAIL PROTECTED]
www.morristechnicalsolutions.com
fax/phone: 503.692.1088






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 there a limit for number of facts?

2004-09-21 Thread Aby
Thanks Rodolfo Martin, Jason and Ernest for the replies
All of you guessed the same reason and it was the correct reason for missing facts. 
 
Actually there is a unique serial number in the sales record. I did not use it as part of the 'fact' because I was concentrating on the 'rules' (commission scheme conditions) part and, obviously, serial number is not part of of any condition. So I asserted facts with slots data that are used in the rules. 
 
Thanks again for prompt and correct replies. I really appreciate your efforts for keeping this online forum a really useful one.
I hope I will be able to convince my bosses to agree to buy JESS as I find it really fast, easy to learn, priced right and of course a very good online support.
regards
Aby
Rodolfo <[EMAIL PROTECTED]> wrote:
Hi Aby,I don't know if there is other limit than the physical memory size, but ifit exists is far greater than 6000+.I think your problem is that you have duplicate records in your DB, and allthe facts in the engine are unique. When asserting a new fact that isidentical to a previously asserted one only one remains.Regards.Rodolfo Martin.> Hi,>  > Few weeks back I showed up here asking whether JESS is the right tool touse for a system which need to match 8000 commission schemes against 1million sales record.>  > As part of my 'proof-of-concept' project to decide whether to use JESS todevelop a new system, I am experimenting with 1 sales records and fewcommission schemes (actualy 4 schemes which means 4 rules)>  > I did it in two ways by using embedding J!
ESS into
 a simple JAVA program.(I am still newbee to Java and Jess. So pardon me for my primitive way ofdoing things)>  > 1. Load 4 rules into JESS> 2. read record by record from sales file (text tile)>        assert 1 sales fact for each record.> 3. do a (run). so the rules will be fired and the sales record is matchedagainst the rules. It may match 0..4 rules. If a salesrecord matches a rule, then that rule-id is stored in a slot in thesales record.>   > 4. Save the sales record to oracle DB.>  > Steps 2,3,4 are looped 1 times. Everything works well. 1 recordsare inserted. In this case, file reading and writing into DB is done in JAVA>  > I thought, this should not be the way. 1 (run)s?>  > So I changed the logic.>  > 1. Load 4 rules> 2. assert 1 facts.&!
gt; 3. do
 a (run). So in one shot all records are matched against the rules.> 4. Then run a (defquery) get all the sales data facts and put intodatabase in JESS itself. I wrote a small user-function which accepts factsand then inserts the values into DB.>  > Here I face a problem. It inserts only 6000+ records. So I fired (facts)immediately after asserting 1 facsts. I could see only 6000+ records.But I am sure the JAVA function asserts 1 records.>  > Why is it so? Is there a limitation for number of facts in JESS?(veryunlikely) Or is this is a limitation of the evaluation copy? Idownloaded the evaluation copy from Manning website after I purchased theJIA eBook. Or am I doing something wrong?>  > thanks>  >  >   Yahoo! Mobile- Download the latest ringtones, games, andmore!WebMail
 -movilab.netTelefsnica Msviles EspaqaTo 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] Yahoo! Mobile- Download the latest ringtones, games, and more!