JESS: new jess user

2002-10-05 Thread Jason Morris



Greetings 
Jess-All,
 
If you 
are:
 

  Using Jess to 
  create expert systems for mechanical design, and/or 
  are
  Developing or 
  interested in hybrid expert systems using CBR and 
  rule-based case adaptation.
Please let me know if you would be interested 
in corresponding.  
I have many 
questions.  :-) 
 
Thanks!
 
Jason Morris, PresidentMorris Technical 
Solutionsmailto:[EMAIL PROTECTED]
www.morristechnicalsolutions.net  

 


JESS: IDEs for JESS

2003-06-20 Thread Jason Morris








All,

Eclipse is arguably one of the most popular IDEs for Java development.  One of the selling points of the Eclipse
Project http://www.eclipse.org/ is that
it is an “…open extensible IDE for anything and nothing in particular”.  Has anyone given any thought to
producing a JESS plug-in for Eclipse? 
Anybody know of any initiatives?

 

Just curious…

 

-Jason Morris

 

Morris
Technical Solutions

http://www.morristechnicalsolutions.com/

[EMAIL PROTECTED]

phone/fax: 503.692.1088

 

Engineering knowledge for small business

 






<><>

JESS: did the JESS book get published yet?

2003-06-20 Thread Jason Morris








Sorry if this is an old FAQ… I have been away from the listserver for 6
months.

Did the good doctor get his book to the presses yet?

 

Thanks!

-JM

 

Morris
Technical Solutions

http://www.morristechnicalsolutions.com/

[EMAIL PROTECTED]

phone/fax: 503.692.1088

 

Engineering knowledge for small business

 






<>

JESS: Am I on the wrong path ;-)

2003-08-25 Thread Jason Morris
All,

I was experimenting with some of the examples in Jess In Action, and I
wanted to run my own java class from the Jess prompt.

I added a simple path string to my CLASSPATH environment variable like this:

C:\com\morristechnicalsolutions\jess\projectA\test_a\classes\test_a

and I compiled a simple class called Test1.class that resides in the last
\test_a folder.

When I do an (import test_a.*) statement at the Jess prompt, it returns
TRUE, but when I try

(bind ?x (new test_a.Test1))

I get a java.lang.ClassNotFoundError

what am I missing here?  Is the redundant folder name (done by JBuilder)
causing the problem?

Thanks!

-JM


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: Amusement in the rules engineering job market

2003-08-25 Thread Jason Morris



Preach 
on, Brother Halsey!
 
Sadly, 
it's all about the bottom-line.
 
When 
will US business leaders wake from their common-sense coma and realize that the 
short-term solution of cutting costs is no substitute for growing 
revenue through better products and fostering innovation?
 
Horror 
stories about companies who throw armies of off-shore developers (at 10 
cents on a dollar) at projects to avoid paying US developers salaries and 
benefits are everywhere.  I even had an associate at our local java 
users group lose his job because his company moved an entire product to 
India.  
 
I'm 
still tickled by the ad I saw in 1990 that wanted 10 years of Java development 
experience.
 
-JM
 

Jason MorrisMorris Technical 
Solutions[EMAIL PROTECTED]www.morristechnicalsolutions.comfax/phone: 
503.692.1088 
 
 -Original 
Message-From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED]On Behalf Of Rich 
HalseySent: Monday, August 18, 2003 6:01 AMTo: 
[EMAIL PROTECTED]Subject: JESS: Amusement in the rules 
engineering job market

  Has anyone seen the job posting out on Dice where 
  they will teach you (the candidate) rules engineering while you are developing 
  their software ? Of course, the catch is that "a stipend will not be paid" for 
  the first 2 months.
   
  Somebody please help me out here, has the price 
  of offshore labor dropped to the point where we all do this for free 
  ??
   
  Other job req's ask for total rules system 
  analysis to be done in 6 weeks. From what I have seen, the analysis of a rules 
  system starts on day one and ends when the project is rolled out to the 
  customer because the engineering of a rule-based system is SIGNIFICANTLY 
  different from ordinary applications. And oh by the way, it cannot be faked 
  the way many projects do their applications - it is either VERY RIGHT or VERY 
  WRONG. The testing suites must be generated from the requirements, analysis, 
  and design work products and not pulled out of their butts.
   
  It is no wonder that the failure rate of software 
  engineering in this country has risen to 95+ % (this is documented in many of 
  the trade rags).
   
  Does management not realize that they are 
  commiting suicide with these ridiculous approaches to rules engineering ? Or 
  maybe this is the reason they are sending so much work offshore so that they 
  cannot be blamed for the certain failures to follow. If justice is to be 
  served then these managers need to spend about 6 months in some offshore 
  hellhole in order to collect their bonus.
   
  Oh well !!!


RE: JESS: Am I on the wrong path ;-)

2003-08-29 Thread Jason Morris
Ah... the dangers of Late Night Computing and its evil cousin "Cut and
Paste".

FYI: java -classpath does indeed override system %CLASSPATH%  ;-)
Sorry for the groupspam.
-JM

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

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Behalf Of [EMAIL PROTECTED]
Sent: Sunday, August 24, 2003 5:47 PM
To: [EMAIL PROTECTED]
Subject: Re: JESS: Am I on the wrong path ;-)


I think Jason Morris wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
>
> I added a simple path string to my CLASSPATH environment variable like
this:
>
>   C:\com\morristechnicalsolutions\jess\projectA\test_a\classes\test_a
>
> and I compiled a simple class called Test1.class that resides in the last
> \test_a folder.
>
> When I do an (import test_a.*) statement at the Jess prompt, it returns
> TRUE, but when I try
>
>   (bind ?x (new test_a.Test1))
>
> I get a java.lang.ClassNotFoundError
>

I think this is more of a Java question than a Jess one. If a class
named Test1 is in the package test_a, and the directory test_a is in
...\classes,  then ...\classes belongs on the CLASSPATH, *not*
...\test_a.


-
Ernest Friedman-Hill
Distributed Systems ResearchPhone: (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]



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: UltraEdit wordfile for Jess code

2003-10-04 Thread Jason Morris
All,

Here's my first (and hopefully not last) humble contribution to the Jess
community.  Many folks use UtraEdit http://www.ultraedit.com/ for random
text processing (those not using Emacs anyway).  UltraEdit uses a
"wordfile", sort of a homegrown style sheet which tells it how highlight
various text file types.  Until now, I've been using its CLIPS layout to
display Jess files.

I lifted the Jess functions from
http://herzberg.ca.sandia.gov/jess/docs/61/function_index.html and wrote
Jess its own wordfile.  My version is very JBuilder-ish in its color-coding
since that's my Java IDE.  Feel free to modify it as needed.  To use it,
simply cut and paste everything between the lines into your UltraEdit
wordfile.txt file (see bottom of email).

It should be available for download at the UltraEdit site soon.

Cheers,

Jason Morris

---

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

--- BEGIN Jess
Wordfile -

/L1"JESS6.1" Line Comment = ; File Extensions = CLP
/Delimiters = [EMAIL PROTECTED]&*()+=|\/{}[]:;"'<> , .?

/C1"Math Functions"
* ** + - / < <= <> = > >= abs div e eq eq* exp float integer log log10 long
max min mod neq pi random round sqrt

/C2"Keywords"
and
bit-and bit-not bit-or bag bind
clear-storage
fetch
gensym*
jess-version-number jess-version-string
not
or
set-factory setgen store system
time

/C3"I/O Functions"
close
format
get-multithreaded-io
list-deftemplates
open
printout ppdeffacts ppdeffunction ppdefglobal ppdefquery ppdefrule
ppdeftemplate
read readline rules
set-multithreaded-io socket
show-deffacts show-deftemplates

/C4"Control"
apply
call-on-engine
foreach
if
progn
return
while

/C5"Debug"
list-function$
matches
show-jess-listeners
unwatch
view
watch

/C6"Rete"
agenda assert assert-string
batch bload bsave build
clear clear-focus-stack count-query-results
defadvice defrule do-backward-chaining dependencies dependents duplicate
engine eval exit
focus fact-id fact-slot-value facts
get-current-module get-focus get-focus-stack get-reset-globals
get-salience-evaluation get-strategy
halt
list-focus-stack load-facts
modify
pop-focus
reset run run-until-halt run-query retract retract-string
set-current-module set-node-index-hash set-reset-globals
set-salience-evaluation set-strategy save-facts
undefadvice undefrule

/C7"Java Functions"
call context
defclass definstance
get get-member
import instanceof
load-function load-package
new
set set-member synchronized
throw try
undefinstance update

/C8"Value Functions"
asc
complement$ create$
delete$
explode$ evenp external-addressp
floatp first$
integerp implode$ insert$ intersection$
lexemep longp length$ lowcase
multifieldp member$
numberp nth$
oddp
replace$ rest$
stringp subsetp symbolp subseq$ str-cat str-compare str-index str-length
sub-string sym-cat
upcase union$

--- END Jess
Wordfile -


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: Restricted Language Query/ Natural Language Parsing in Jess

2004-02-04 Thread Jason Morris
Hi All,

Sorry for the long post, but this is an esoteric question...

I am interested in adapting the Tax Form Advisor (using it almost like a OO
design-pattern) by adding a component that can reason about information
drawn from natural-language input as well as using restricted answers to
hard-coded questions.  To make the parsing problem more tractable, I began
thinking of different ways that I could derive meaning from various input
strings without coding a huge parsing engine from scratch or writing
hundreds of extra rules.  I read a lot of parsing theory and experimented
with various BNF syntaxes, but quickly ran into trouble as the language grew
and the rules became more complex.  Since my background is in mechanical
engineering, I tried to draw parallels with what I already know.

In fluid mechanics, there is the theory of non-dimensional parameters
whereby a complex functional equation in m variables and n dimensions can be
reduced to (m-n) dimensionless parameters, which should be theoretically
easier to manipulate.  I reasoned: why couldn't I attempt to do the same
thing with words -- in other words, treat the input string as function of
tokens having a certain "dimension" or membership in semantic subsets, and
then attempt to "normalize" the string to fit a stored semantic pattern that
would have meaning to Jess.  Theoretically, this would significantly cut
down the number of rules that I'd have to write to handle various inputs,
even ambiguous ones, while letting the user type away to describe the
initial problem input.

Alas, it seems that my idea was anticipated (see pg.2):
http://www.amia.org/pubs/symposia/D005310.PDF

However, does anyone have any good suggestions as to how to implement this
approach in Jess?

Thanks!

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: Re: Restricted Language Query/ Natural Language Parsing in Jess

2004-02-05 Thread Jason Morris
Hi Rich ,

Sort of.  :-D

If you look at the article in the link, you'll see how the researchers
approached the problem.  Basically, I would like to start a Jess application
(that follows the Tax Advisor pattern, but isn't a Tax Advisor!) by allowing
the users to enter a free-text problem statement -- like when you tell your
doctor "where it hurts".  The doctor can then begin to make inferences about
what type of problem you may have by parsing your input and pattern-matching
it to syntactically similar, "pre-parsed phrases" that share the distilled
semantics of the original input (if that makes sense), and then ask more
leading questions to heuristically home-in on the solution.

As an example, in a typical BNF production, I might have a definition

::=  so that a
 is composed of a the "non-terminals"
 in that order.

And I might have a vocabulary like

 -> I | You | We
 -> ran | jumped | cried
 -> . | ? | !

For all the possible combinations of these non-terminals and terminals (all
productions), I'd have to construct a rule to deal with that production.  If
I understand the article right, what they did was to map the set of all the
synonyms of each of the non-terminals to a "key", and after doing this they
composed phrases of these keys to store the generic semantics of the input,
thereby collapsing the number of patterns for which they need to store a
meaning.

I just thought that it was a novel approach instead of parsing the string by
brute force and trying to process the results with a gazillion rules.

Hope that clarifies a bit.

Regards,

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

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Behalf Of Rich Halsey
Sent: Thursday, February 05, 2004 4:06 AM
To: [EMAIL PROTECTED]
Subject: JESS: Re: Restricted Language Query/ Natural Language Parsing
in Jess


Hi Jason,

In trying to reduce the description of your problem, I came up with the
following:

Use a Natural Language front-end for the user to interact with a rule-based
Tax Advisor where the rules derive a solution to a query based on data
derived from a free form input.

Does this sound even close to what you want to do ??

Rich Halsey

- Original Message -
From: "Jason Morris" <[EMAIL PROTECTED]>
To: "Jess-Users" <[EMAIL PROTECTED]>
Sent: Wednesday, February 04, 2004 7:07 PM
Subject: JESS: Restricted Language Query/ Natural Language Parsing in Jess


> Hi All,
>
> Sorry for the long post, but this is an esoteric question...
>
> I am interested in adapting the Tax Form Advisor (using it almost like a
OO
> design-pattern) by adding a component that can reason about information
> drawn from natural-language input as well as using restricted answers to
> hard-coded questions.  To make the parsing problem more tractable, I began
> thinking of different ways that I could derive meaning from various input
> strings without coding a huge parsing engine from scratch or writing
> hundreds of extra rules.  I read a lot of parsing theory and experimented
> with various BNF syntaxes, but quickly ran into trouble as the language
grew
> and the rules became more complex.  Since my background is in mechanical
> engineering, I tried to draw parallels with what I already know.
>
> In fluid mechanics, there is the theory of non-dimensional parameters
> whereby a complex functional equation in m variables and n dimensions can
be
> reduced to (m-n) dimensionless parameters, which should be theoretically
> easier to manipulate.  I reasoned: why couldn't I attempt to do the same
> thing with words -- in other words, treat the input string as function of
> tokens having a certain "dimension" or membership in semantic subsets, and
> then attempt to "normalize" the string to fit a stored semantic pattern
that
> would have meaning to Jess.  Theoretically, this would significantly cut
> down the number of rules that I'd have to write to handle various inputs,
> even ambiguous ones, while letting the user type away to describe the
> initial problem input.
>
> Alas, it seems that my idea was anticipated (see pg.2):
> http://www.amia.org/pubs/symposia/D005310.PDF
>
> However, does anyone have any good suggestions as to how to implement this
> approach in Jess?
>
> Thanks!
>
> 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 pr

RE: JESS: Re: Restricted Language Query/ Natural Language Parsing in Jess

2004-02-05 Thread Jason Morris
James,

Thank you for all the good links!  I figured that there was a lot more out
there, and I feared that I wasn't making myself clear.

Regards,

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

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Behalf Of James Owen
Sent: Thursday, February 05, 2004 11:25 AM
To: [EMAIL PROTECTED]
Subject: RE: JESS: Re: Restricted Language Query/ Natural Language
Parsing in Jess


Jason, Rich and Ernest:

Actually, quite a bit of work has been done in this area.  It followed
shortly after all of the speech-pattern-recognition stuff started.  A
fellow named Sankar K. Pal started a program named "MyPal" wherein he
would be able to retrieve sense from nonsense typed in from the
keyboard.  He gave a "presentation" way back in 1989 at UT Dallas in one
of the M.I.N.D. conferences co-hosted by UT Arlington.

Dr. Daniel S. Levine and Dr. Alice O'Toole from UTA were the moderators.
They had top name guys from all over the world at the conference. [Gail
Carpenter and Steve Grossberg were the top two names there but the US
Naval Surface Warfare Depart was also well represented.]  Dr. Levine is
now in the Department of Psychology at UTA because that was the only
department willing to fund his research.

Anyway, Dr. Pal co-authored a book with Paul P. Wang.  Amazon link is

http://www.amazon.com/exec/obidos/ASIN/0849394678/inktomi-bkasin-20/ref%
3Dnosim/102-1084313-6504134

I found another book at (of all places) WalMart.com on Pattern
Recognition software.

http://www.walmart.com/catalog/product.gsp?product_id=1072257&sourceid=1
500040820

Some earlier works by Sankar are available from the Indian Statistical
Institute in Calcutta.

http://www.wspc.com/books/compsci/4755.htm

but, for some reason, this one is cheaper.  Go figure...  I guess that a
Microsoft like costs more to put up than a Unix link.  :-)

http://www.wspc.com/books/compsci/4755.html

Finally, if you act now, you can get one for only $9.95 (or so) on EBay

http://half.ebay.com/cat/buy/prod.cgi?cpid=805831&domain_id=1856&ad=5398
3

enjoy.

SDG
jco

James C. Owen
Knowledgebased Systems Corporation
Senior Consultant


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Jason Morris
Sent: Thursday, February 05, 2004 10:44 AM
To: [EMAIL PROTECTED]
Subject: RE: JESS: Re: Restricted Language Query/ Natural Language
Parsing in Jess

Hi Rich ,

Sort of.  :-D

If you look at the article in the link, you'll see how the researchers
approached the problem.  Basically, I would like to start a Jess
application
(that follows the Tax Advisor pattern, but isn't a Tax Advisor!) by
allowing
the users to enter a free-text problem statement -- like when you tell
your
doctor "where it hurts".  The doctor can then begin to make inferences
about
what type of problem you may have by parsing your input and
pattern-matching
it to syntactically similar, "pre-parsed phrases" that share the
distilled
semantics of the original input (if that makes sense), and then ask more
leading questions to heuristically home-in on the solution.

As an example, in a typical BNF production, I might have a definition

::=  so that a
 is composed of a the "non-terminals"
 in that order.

And I might have a vocabulary like

 -> I | You | We
 -> ran | jumped | cried
 -> . | ? | !

For all the possible combinations of these non-terminals and terminals
(all
productions), I'd have to construct a rule to deal with that production.
If
I understand the article right, what they did was to map the set of all
the
synonyms of each of the non-terminals to a "key", and after doing this
they
composed phrases of these keys to store the generic semantics of the
input,
thereby collapsing the number of patterns for which they need to store a
meaning.

I just thought that it was a novel approach instead of parsing the
string by
brute force and trying to process the results with a gazillion rules.

Hope that clarifies a bit.

Regards,

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

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Behalf Of Rich Halsey
Sent: Thursday, February 05, 2004 4:06 AM
To: [EMAIL PROTECTED]
Subject: JESS: Re: Restricted Language Query/ Natural Language Parsing
in Jess


Hi Jason,

In trying to reduce the description of your problem, I came up with the
following:

Use a Natural Language front-end for the user to interact with a
rule-based
Tax Advisor where the rules derive a solution to a query based on data
derived from a free form input.

Does this sound even close to what you want to do ??

Rich Halsey

- Original Message -
From: "Jason Morris" <[EMAIL PROTECTED]>
To: &qu

RE: JESS: Anybody looking for a rules job ??

2004-02-12 Thread Jason Morris



No 
kidding?  What happened?  (And why would you think that anyone would 
want to pick up the gauntlet?)   What company was 
it? 
-JM
___

Jason MorrisMorris Technical 
Solutions[EMAIL PROTECTED]www.morristechnicalsolutions.comfax/phone: 
503.692.1088 

  -Original Message-From: [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED]On Behalf Of Rich 
  HalseySent: Thursday, February 12, 2004 12:53 PMTo: 
  [EMAIL PROTECTED]Subject: JESS: Anybody looking for a rules job 
  ??
   
  There is a rules project in O'Fallon, Illinois 
  looking for people. The last person that I knew working on the project just 
  left after she was reduced to tears (on the last day - at the last 
  minute) by management that must be a cross between Dilbert and the Marquis de 
  Sade. God, there must be some awfully vicious and sadistic people 
  there.
   
   
   
  "Life, liberty, and the pursuit of those who 
  threaten it"


JESS: on creating test harnesses & dev automation with Jess

2004-02-17 Thread Jason Morris
Hi All,

I have been experimenting with modifying the Tax Advisor application in
"Jess In Action".
On pg. 169 Ernest makes the comment "...You should be thinking about putting
together a complete test harness now..".

I have been structuring my Jess scripting code in modules, placing them in
separate files, and calling them from a master *.clp file like so..

;;=== pat.clp 
;; Application batch script
(clear)
(watch all)
(batch pat_main.clp)
(batch pat_ask.clp)
(batch pat_startup.clp)
(batch pat_survey.clp)
(batch pat_recommend.clp)
(batch pat_report.clp)
(batch pat_run.clp)
(start-pat)

Also, as Ernest suggested, this is called via a simple DOS batch file like:

@ECHO OFF
CLS
:BEGIN_MENU
ECHO == Jess Menu ==
ECHO A. Run Jess stand-alone
ECHO B. Run Jess/PAT
ECHO Q. Quit
ECHO ===

SET ITEM=
SET /P ITEM=Type the letter and press Enter:

IF NOT '%ITEM%'=='' SET ITEM=%ITEM:~0,1%
ECHO.

IF /I '%ITEM%'=='A' GOTO ItemA
IF /I '%ITEM%'=='B' GOTO ItemB
IF /I '%ITEM%'=='Q' GOTO End
ECHO "%ITEM%" is not valid. Please try again.
ECHO.
GOTO BEGIN_MENU

:ItemA
REM * JESS STAND-ALONE  **
@ECHO OFF
ECHO Switching to JESS6.1p6 directory
CD C:\Jess61p6
ECHO  Starting jess.Main...
java jess.Main
GOTO RESTART

:ItemB
REM * JESS / PAT **
@ECHO off
ECHO Switching to JESS6.1p6\pat directory
CD C:\Jess61p6\pat
ECHO Starting pat.clp from jess.Main...
java jess.Main pat.clp
PAUSE
GOTO RESTART

:RESTART
PAUSE
CLS
GOTO BEGIN_MENU
:END

So far, it seems to work nicely, since I can comment out files that are
in-progress and isolate bugs better.
Are there any pitfalls to this approach (namely calling batch files from
batch files in Jess) and is there a better way?

Thanks!

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]




JESS: on creating test harnesses & dev automation with Jess

2004-02-17 Thread Jason Morris
Hi All,

One of my Outlook rules my have zapped someone's reply, so please forgive me
for asking my question again - albeit a shorter version this time:

On pg. 169 of JIA, Ernest makes the comment "...You should be thinking about
putting together a complete test harness now..", so I have been structuring
my Jess scripting code in modules, placing them in separate files, and
calling them from a master *.clp file like so:

;;=== pat.clp 
;; Application batch script
(clear)
(watch all)
(batch pat_main.clp)
(batch pat_ask.clp)
(batch pat_startup.clp)
(batch pat_survey.clp)
(batch pat_recommend.clp)
(batch pat_report.clp)
(batch pat_run.clp)
(start-pat)

Q. Though it seems to run fine now, I'm wondering if there are any pitfalls
to calling batch files from batch files in Jess like this; and, is there a
better/preferred/best-practice way to automate this kind of code/run/debug
cycle?

Thanks!

-JM
---
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: on creating test harnesses & dev automation with Jess

2004-02-18 Thread Jason Morris
Thanks, James!

This was very interesting suggestion.  I'd give my eye-teeth to find such a
company that was actively using rule-based programming in mechanical design
(my specialty).  That scale of project would be fascinating to program.

Cheers!

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

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Behalf Of James Owen
Sent: Tuesday, February 17, 2004 9:37 PM
To: [EMAIL PROTECTED]
Subject: RE: JESS: on creating test harnesses & dev automation with Jess


Not to be a name-dropper (don't you just hate those guys?) but when
working with a large bank in England (OK, it was Lloyds) we ran 65,000
test cases against about 785 rules that dealt with pricing.  Also, at a
major insurance company, I ran about 5,500 test cases against less than
10,000 rules dealing with driver problems.  How?  (Why is later) Simple:


Build a spreadsheet with the all of the conditions, i.e., the slots, on
the left.  On the right, identify which rule should fire, either name(s)
or have a column for each rule labeled true/false, yes/no or something
like that.  Using Java main file, load up each row, set the slots
(attributes) and fire the rules.  Rules that should fire should match
the rules that should fire.  That's OI.  Rule's that should not fire
should match rules that should not fire.  That's OK as well.  However, a
rule that does not fire that should fire is an alpha error.  A rule that
fires that should not fire is a beta error.  This is 100% verification.

Why?  Because the loan application MUST have 100% verification if it's
on the internet.  Thousands and thousands of hits per day will be
floating in through the net.  An error that allows a loan that should
not be allowed will be quickly detected by users and thousands of
dollars (pounds sterling) would be lost.  An error that does not allow a
loan that should have been allowed will also cause the loan to go to the
competition and, again, thousands of pounds sterling would be lost.

Once the base-line was established, the 65,000 rules took just over six
hours to run whenever ANY change was made to the rules.  If only one
rule changed, we discovered that it could generate unknown effects,
unexpected things that should not have happened.  Lloyds could not
permit that.  The same way with the insurance company.  The 5,500 test
cases took only an hour or so to run.

So, whatever you do, NEVER use the 80/20 JUnit testing principle in
financial environments, medical applications or processing plants.
Failure is NOT an option.  :-)

SDG
jco

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Jason Morris
Sent: Tuesday, February 17, 2004 6:15 PM
To: Jess-Users
Subject: JESS: on creating test harnesses & dev automation with Jess

Hi All,

One of my Outlook rules my have zapped someone's reply, so please
forgive me
for asking my question again - albeit a shorter version this time:

On pg. 169 of JIA, Ernest makes the comment "...You should be thinking
about
putting together a complete test harness now..", so I have been
structuring
my Jess scripting code in modules, placing them in separate files, and
calling them from a master *.clp file like so:

;;=== pat.clp 
;; Application batch script
(clear)
(watch all)
(batch pat_main.clp)
(batch pat_ask.clp)
(batch pat_startup.clp)
(batch pat_survey.clp)
(batch pat_recommend.clp)
(batch pat_report.clp)
(batch pat_run.clp)
(start-pat)

Q. Though it seems to run fine now, I'm wondering if there are any
pitfalls
to calling batch files from batch files in Jess like this; and, is there
a
better/preferred/best-practice way to automate this kind of
code/run/debug
cycle?

Thanks!

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



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]



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: Case Based Reasoning with Rules

2004-02-27 Thread Jason Morris
Hi Rich,

Hybrid (case-based/rule-based) systems are an absolutely fascinating
concept, and I have been wondering about their implications and
possibilities for some time also.

My original interest in expert systems came by way of involvement in
developing online performance-support tools for mid-range, computer-aided
design software.  My though was:  Why can't CAD software really help an
engineer do "engineering" while he or she is creating geometry.  Right now,
CAD tools are reaching a feature-functionality parity where they basically
do all the same things inside the same performance envelope.  I was looking
for innovative product differentiators, and I saw an opportunity to add real
design intelligence to the tools.

As an example, picture a CAD tool that could:

[]  Interactively and in real-time monitor your geometry creation and point
out potential stress concentrations, point out violations of ASME  or
company standards, or other conflicts with other design constraints not
related to geometry.

[] Apply "design patterns" from existing designs or "best-practices" (use
cases), or compare geometry creation intent to standard
design-for-manufacturing (DFM) or design-for-assembly (DFA) principles to
catch problems before they occur, or deduce a best design approach given
company standards and methods (use rules).

Does this sound too far fetched?  I didn't think so then... and with tools
like Jess and FuzzyJess, I certainly don't now.  Is it a big undertaking?
Without question!  I have no illusions about how huge this would be to do.

Management will always say, "That's cool, but what's the business case?
What customer problem are you trying to solve?"  I think that one could
claim that such a system, by folding actual engineering knowledge into the
geometry creation process and leveraging accumulated corporate knowledge,
would:

* Reduce time-to-market by collapsing the overall time to design and
prototype a viable system (promote design reuse).
* Reduce manufacturing and assembly costs by catching conflicts before they
hit the production floor.
* Push risky processes further up the development process where they can be
caught and eliminated quickly before they cause problems down-stream.

Given the esoteric and very non-conventional nature of the proposal,
convincing management about the ROI enough that it ever got funded as a
project was impossible.  I hate to accuse management of being narrow-minded,
but as in most industries, there are long-established ways of doing things
in CAD, and the powers that be were (and are) loath to deviate from
following them.

So, at the time, I didn't have the programming or knowledge engineering
experience to even prototype such a system, but now I do.  I'd give my
eye-teeth to work on such a project!  I'd be very interested to hear your
further thoughts as well as anyone else's on the general hybrid subject.

Q. What companies are applying hybrid systems to mechanical design?  Does
anyone have some examples?

BTW - thanks for all your replies on other threads so far.

-JM
--
Jason Morris
Morris Technical Solutions
[EMAIL PROTECTED]
www.morristechnicalsolutions.com
fax/phone: 503.692.1088
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Behalf Of Rich Halsey
Sent: Friday, February 27, 2004 8:51 AM
To: [EMAIL PROTECTED]
Subject: JESS: Case Based Reasoning with Rules


Hi All,

I have been thinking about Case Based Reasoning (CBR) and it would seem that
if a rule-based system could (1) determine which objects it was matching on,
(2) use Java reflection to list the object methods used for the predicates,
and (3) retrieve within some repository all the objects that fit  (1) and
(2)  and assert them into working memory, then CBR would be a natural
extension of a rule-based system.

Any thoughts ??

Rich Halsey


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: Case Based Reasoning with Rules

2004-02-28 Thread Jason Morris
I think that Sionep wrote:
>>I believe that CBR has already been incorporated into CAD
>>software already since the eighties. I have seen my engineer
>>friend using AutoCAD from AutoDesk for retrieving similar design
>>patterns that has been stored in the database.

Ah... I beg to differ...

The project that I mentioned working on was, in fact, Autodesk Inventor --
Autodesk's next-generation, parametric, 3D solid/assembly modeler -- so am
familiar with how senior management viewed such things.  I'm sure that the
concept never tripped our CTO's due-diligence radar nor any of the product
designers', else my group would most likely have had a green-light to
investigate it.  If Autodesk had any inclination to include artificial
intelligence in their products, it would have been that one, not AutoCAD
proper.  Also, I'd be really surprised if the functionality that you
described came from Autodesk -- more likely it was a 3rd party add-on or
plug-in that extended vanilla AutoCAD.  AutoCAD is more of general-purpose
2D CAD engine meant to be customized by augmenting it with vertical
applications, whereas Inventor was designed to compete directly with
SolidEdge/SolidWorks/ProEngineer.  Of course, I've been out of the loop
since 2000, so things might have changed.

All that said, I am very familiar with CBR, in particular the work of Ian
Watson at the University of Salford -- which is why I suspect the conference
that you attended was held in New Zealand -- it's a hot-bed of current CBR
research.  Hybrid systems are a fascinating subject, and I hope to see a
lively thread about it.

-JM

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

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Behalf Of Sionep
Sent: Saturday, February 28, 2004 6:50 AM
To: [EMAIL PROTECTED]
Subject: Re: JESS: Case Based Reasoning with Rules




I believe that CBR has already been incorporated into CAD
software already since the eighties. I have seen my engineer
friend using AutoCAD from AutoDesk for retrieving similar design
patterns that has been stored in the database. I am no expert in AutoCAD
but the user specify design attributes and then AutoCAD retrieves the
closest match or similar match (not exact match as symbolic rules like
JESS) of any design that is close to the desired target attributes.
Other engineering tools such as Pro-Engineer are reported to have
similar capability as that of AutoCAD (search capability for similar
designs from the database).

I attended the international CBR workshop held at University of
Auckland, New Zealand here on the 12th to 14th January, 2003 and it
was amazing the number of areas that CBR can be applied. The
applications ranges from decision tool support, Customer Relation
Management (CRM), voice-print identification (analysis of similar voice
signals), Chemical identification , to data mining and many many more.
Research in Hybrids CBR & other technologies are moving at a very fast
pace. Elsevier publishers have bounded a print book for this workshop.

I saw presentation in Soft-Computing techniques such as Fuzzy-Logic,
Artificial Neural Network (ANN),Bayesian Belief Network (BBN), Support
Vector Machines (SVM), Rough Sets (RS), Evolutionary Computation (EC),
Memetic which is combined with CBR.

The cutting edge of expert systems comes from combining JESS with
Soft-Computing methods. One thing I have noticed from AutoCAD that if
the expert systems of recommending patterns to the engineer have been
using Symbolic rules like CLIPS or JESS then it would not be useful at
all. The user will specify attributes for a design pattern then the
system will either search for a MATCH or NO_MATCH of any previously
stored design. With CBR, it does not have to match exactly, but a
similar match to some degree all is required. The closest match design
can be retrieved for the user can be  adapt by the user and then stored
as a new knowledge. JESS has advantages compared to other rules engine
is that it has already combined well with FuzzyJ (FuzzyJess). It is
easier to incorporate other soft-computing techniques using FuzzyJ that
can work well with JESS. The is the established practice of
Soft-Computing hybrids (Neuro-Fuzzy, Fuzzy-Bayesian, Neuro-Genetics,
Rough Sets-Bayesian and so on). A JESS rule based systems (JESS plus
Soft-Computing) that is self-learning would be awesome. There was one
presentation for this sort of CBR + Soft-Computing hybrids at the
Auckland CBR-2003 workshop.





Jason Morris wrote:
> Hi Rich,
>
> Hybrid (case-based/rule-based) systems are an absolutely fascinating
> concept, and I have been wondering about their implications and
> possibilities for some time also.
>
> My original interest in expert systems came by way of involvement in
> developing online performance-support tools for mid-range, c

JESS: Obtaining a fact-id from an External Address

2004-05-26 Thread Jason Morris
Hello All (and most likely EJF)

GIVEN:  A java.util.Iterator of  objects
containing the results of a defquery asking for all shadow facts of a
certain type in working memory.

PROBLEM:Find the corresponding fact-ids of each  via Jess script (that is, not using the API and getFactId().
Page 311 of JIA says that there is no Jess equivalent of
findFactByFact(Fact), which is apparently what I'd normally try.

Is there a workaround?  Am I missing something simple?
I'll forward some code if it will help.

BTW - How hard would it be to add a Jess command like (fact-by-fact
|) that returns the integer value of
the Fact reference in working memory... basically a mirror image of the
(fact-id ) command.

Thanks!

-JM
----
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: Obtaining a fact-id from an External Address

2004-05-26 Thread Jason Morris
Hey thanks, Ernest.
I think that I was laboring under the misconception that not all of Jess's
API was exposed via the Jess language.
Just so I understand: All Jess API methods are accessible via Jess script as
you show below?

-JM

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Behalf Of [EMAIL PROTECTED]
Sent: Wednesday, May 26, 2004 5:56 AM
To: [EMAIL PROTECTED]
Subject: Re: JESS: Obtaining a fact-id from an External Address


I think Jason Morris wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Hello All (and most likely EJF)
>
> GIVEN:A java.util.Iterator of  objects
> containing the results of a defquery asking for all shadow facts of a
> certain type in working memory.
>
> PROBLEM:  Find the corresponding fact-ids of each  jess.Fact> via Jess script (that is, not using the API and getFactId().
> Page 311 of JIA says that there is no Jess equivalent of
> findFactByFact(Fact), which is apparently what I'd normally try.

Why not just

  (bind ?f (?iterator next))
  (bind ?id (?f getFactId))



-
Ernest Friedman-Hill
Science and Engineering PSEsPhone: (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]



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: accessing a java function

2004-05-26 Thread Jason Morris
Brenda K Hamilton wrote on May 26, 2004 6:13 AM:

I have a Java object, foo, which is not a bean.  Foo has some function,
x, that returns a Java object, say a List.  From within a Jess rules
file, I need to have access to foo, call x, obtaining the List.  Foo is
originally instantiated from a Java program that is also responsible for
initiating Jess.
-
Hi Brenda,
Was using the store()/fetch() mechanism built into Jess (See pp. 308-310 of
Jess In Action) of no use?
Jess can access external objects from the RHS of its rules, and you can call
any of their public methods with a syntax like

(call   )

See Ch. 5 of Jess In Action.
Hope this helps.  Let me know what you find, as I could use this, too.
Cheers!
-JM
-
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: calling an integer or a string

2004-05-27 Thread Jason Morris
Hi Kimos:

I'm learning Jess, too!
One thing that I do to avoid errors with (Rete) executeCommmand() is to
build a command string first.
This way I can do a "sanity check" on its components before using it in
executeCommand().

A StringBuffer works nicely... for example:

Rete engine = new Rete();
StringBuffer cmd = new StringBuffer();
cmd.append("(assert ");
cmd.append(getString());//A call to your other method somewhere - returns a
fact head at least I assume
cmd.append(")");
engine.executeCommand(cmd.toString());

A bit more code, but for some complex commands, it pays off.

However, if you are wanting a fact asserted from your getstring() method,
you don't need to use executeCommand().
Just use the (Rete) engine.assertString() method.

Rete engine = new Rete();
engine.assertString(getstring());  //Again, whatever you return from
getstring() better be at least "(fact-head)"

Hope this helps!
-JM



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





> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of [EMAIL PROTECTED]
> Sent: Thursday, May 27, 2004 2:32 AM
> To: [EMAIL PROTECTED]
> Subject: JESS: calling an integer or a string
>
>
>
>
> hi there,
>
>
> first i want to thanks Ernest Friedman-Hill for helping me and
> everyone in the
> mailing list. you are a great help.
>
> ok here is my quastion:
>
> i have an string  and i want to call it in the assert while
> executioncommand
>
> r.executeCommand("(assert (i-have-moved))");  << this is what i
> have and i want
> it
>
> r.executeCommand("(assert (getstring()))");
> its simple quastion i hope. i readed the doc's but it didnt helped
>
> i think its something with call  but im a newbie
> thanks alot
> Kimos
>
> 
> 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]
> 
>


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: not understanding this error

2004-05-27 Thread Jason Morris
Brenda,

My guess is that you are using the "=" function when you should be using
"eq" to compare object references.
The "=" is for numerical values, hence the error.

Hope this helps.

-Jason
-----
----

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



> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of Brenda K Hamilton
> Sent: Thursday, May 27, 2004 8:27 AM
> To: [EMAIL PROTECTED]
> Subject: JESS: not understanding this error
>
>
> This is from my rules file, an example that produces the error:
> (import org.w3c.dom.*)
>
> (bind ?*nd* (fetch OBJ))
>
> (defrule if-element
>   (test (= (call ?*nd* nodetype) org.w3c.node.Node.ELEMENT_NODE))
>   =>
>   (printout t (call ?*nd* tagname) crlf)
> )
>
> This is the error:
> Exception in thread "main" Jess reported an error in routine
> Value.numericValue
> while executing (= (call ?*nd* nodetype)
> org.w3c.node.Node.ELEMENT_NODE)
> while executing 'test' CE
> while executing rule LHS (TECT)
> while executing (reset).
>   Message: Not a number: "org.w3c.node.Node.ELEMENT_NODE" (type = ATOM).
>
>
> What is it complaining about?
>
> thanks,
> Brenda
>
> 
> 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]
> 
>


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 a handle to the fact that matched given pattern

2004-05-27 Thread Jason Morris
Amit,

I just did something like this yesterday

First I wrote a defquery as you suggested:

(defquery find-foo-by-name
  (declare (variables ?name))
  (foo (name ?name)))

This returns an iterator of all foos with the given name

Now, I added a function to wrap the query:

(deffunction get-foos-by-name (?name)
"Returns a foo reference of a given name"
(bind ?itt (run-query find-foo-by-name ?name))
(while (?itt hasNext)
(bind ?token (call ?itt next))
(bind ?factRef (call ?token fact 1)))
(return ?factRef)))

Now, from the RHS of a rule, you should be able to write something like:

(defrule foo-res
  (foo (name ?x))
  =>
  (call (get-foos-by-name (?name)) assign)))

Hope this works...Ernest will probably have something more elegant!  :-D

Cheers!
-JM

--
----

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





deffunction to wrap the defquery

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of Amit Chopra
> Sent: Thursday, May 27, 2004 10:58 AM
> To: [EMAIL PROTECTED]
> Subject: JESS: Getting a handle to the fact that matched given pattern
>
>
> Hi all,
>
> I am trying to find the fact that matches a given pattern in rule.
> I tried something, but it wouldn't work.
>
> I want to do something like this (this does not work in Jess, its
> pseudocode). foo is a shadow fact of a java object that has a
> method, lets say, 'assign'.
>
>  > (defrule foo-res
>(foo (name ?x)) => (call 'fact that matched' assign))
>
> I want to know how to find 'fact that matched' to be able
> to call assign on it.
>
> I suspect I'll have to use defquery to do this. But then,
> matching and searching are not atomic, in that, they'll
> be two separate operations.
>
> Help is appreciated.
>
> Sincerely,
> Amit.
>
> 
> 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]
> 
>


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 a handle to the fact that matched given pattern

2004-05-27 Thread Jason Morris
Oops... I may have misunderstood your question.  Sorry... completely mixed
up my code.
Disregard that last suggestion.

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of Amit Chopra
> Sent: Thursday, May 27, 2004 10:58 AM
> To: [EMAIL PROTECTED]
> Subject: JESS: Getting a handle to the fact that matched given pattern
>
>
> Hi all,
>
> I am trying to find the fact that matches a given pattern in rule.
> I tried something, but it wouldn't work.
>
> I want to do something like this (this does not work in Jess, its
> pseudocode). foo is a shadow fact of a java object that has a
> method, lets say, 'assign'.
>
>  > (defrule foo-res
>(foo (name ?x)) => (call 'fact that matched' assign))
>
> I want to know how to find 'fact that matched' to be able
> to call assign on it.
>
> I suspect I'll have to use defquery to do this. But then,
> matching and searching are not atomic, in that, they'll
> be two separate operations.
>
> Help is appreciated.
>
> Sincerely,
> Amit.
>
> 
> 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]
> 
>


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 a handle to the fact that matched given pattern

2004-05-27 Thread Jason Morris
Amit,
Page 90 of Jess In Action talks about the OBJECT slot of a shadow fact and
how it always contains a reference to its parent JavaBean.

so... assuming foo is a shadow fact, you could write

(defrule foo-bar
(foo (name ?name) (OBJECT ?fooBean))
=>
(call ?fooBean assign))


BTW - Just bind the LHS pattern to a variable to get a handle to that fact.

?fact <- (foo (name ?name))

Sorry for the spam code earlier.
-JM


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



> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of Amit Chopra
> Sent: Thursday, May 27, 2004 10:58 AM
> To: [EMAIL PROTECTED]
> Subject: JESS: Getting a handle to the fact that matched given pattern
>
>
> Hi all,
>
> I am trying to find the fact that matches a given pattern in rule.
> I tried something, but it wouldn't work.
>
> I want to do something like this (this does not work in Jess, its
> pseudocode). foo is a shadow fact of a java object that has a
> method, lets say, 'assign'.
>
>  > (defrule foo-res
>(foo (name ?x)) => (call 'fact that matched' assign))
>
> I want to know how to find 'fact that matched' to be able
> to call assign on it.
>
> I suspect I'll have to use defquery to do this. But then,
> matching and searching are not atomic, in that, they'll
> be two separate operations.
>
> Help is appreciated.
>
> Sincerely,
> Amit.
>
> 
> 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]
> 
>


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: your mail [REGARDING SALIENCE IN JESS]

2004-05-28 Thread Jason Morris
I think that James Owen wrote:
>As I recall, salience in rulebased programming is akin to goto statements
in BASIC; a crutch for poor programming

On that subject: Just as there are legitimate, structured uses for the GOTO
statement in some languages, salience can be used in a structured way that
doesn't violate the spirit of rule-based programming.

I've spent a lot of time studying the Jess In Action sections on salience,
modules, general flow control in Jess programs, and anything else I could
find on the subject -- and it's all very helpful.  However, ironically, I
recently came across an old ART Enterprise tutorial manual (1987) that has a
fantastically clear explanation of when it is proper to use salience and how
to do it.  (For the AI history buff: ART was one of the first commercial
expert system shells and was also the progenitor of CLIPS - Jess's
"inspiration".  See http://www.ghg.net/clips/WhatIsCLIPS.html#History )

In any case, the examples (easily extrapolated to Jess) were (quoting now):

* To stratify the rule base into classes of rules dedicated to different
tasks (filtering, pre-processing, etc.)
* To give a very important rule priority over most other or all other rules
(error conditions or "alarms").
* To keep a utility rule in the background until the rest of the program has
run to completion (final output, re-init fact base, etc.)

As far as item one goes, it's easy to implement in Jess with global
variables like this:

(defglobal ?*TASK_PRIORITY_1* = 500)
(defglobal ?*TASK_PRIORITY_2* = 200)
(defglobal ?*TASK_PRIORITY_3* = 100)

(defrule foo-1
  (declare (salience ?*TASK_PRIORITY_1*))
...
=>
...
)

(defrule foo-2
  (declare (salience ?*TASK_PRIORITY_2*))
...
=>
...
)

and so on.

Again, this would be for controlling "layers" of rules that sort of "swarm"
on completing one complex task at a time.

One other technique that I've been practicing is the notion of LHS Control
Patterns (LHSCP), that is asserting and retracting ordered facts (triggers)
to enable or disable large groups of rules simultaneously.  In other words,
in a rule having the LHSCP, if that control fact is not present in working
memory, then that rule (and all rules of its "kind") are essentially
disabled until reactivated by the assertion or modification of that control
fact or facts.  This seems to handle a wide range of control problems
without, again, violating the rule-based paradigm.

However, there was no mention of (defmodule) in ART in '87 -- although CLIPS
has had it for awhile now -- so maybe even the structured use of salience is
dated.  Clearly Dr. Friedman-Hill prefers a modular approach in JIA --
changing the focus of modules to control activations of groups of rules --
and that certainly seems the best way to go for most Jess applications.

BTW - Examples of creative uses of salience or other control mechanism in
Jess would be much appreciated.

-JM


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: Re: your mail [REGARDING SALIENCE IN JESS]

2004-05-28 Thread Jason Morris
I think that Rich Halsey wrote:
> How I engineer the control (in either the determistic or non-deterministic
> layer) is secondary to achieving a control flow architecture which
> determines which rule sets are eligible to execute.

Rich,
No argument here:  I think that it's understood that developers are not so
concerned with the firing of individual rules so much as the switching
between groups of rules to perform a component task that may have many
individual sub-tasks.  My point was that salience, diligently applied, still
has its uses and ought not be automatically disparaged.

-JM
----

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



> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of Rich Halsey
> Sent: Friday, May 28, 2004 9:02 AM
> To: [EMAIL PROTECTED]
> Subject: Re: JESS: Re: your mail [REGARDING SALIENCE IN JESS]
>
>
> I'm sorry - I just can not resist the temptation to jump in here.
>
> It would seem to me, that no matter which technique is used to
> "modularlize"
> the execution of rules (rule sets) whether it be "control flags",
> priorities, etc., the ultimate challenge of applying any control flow
> architecture will be to deal with the work-flow related aspects. In other
> words, I may have a requirement to build a tree of of independently
> executing rules (since the rule execution my be IMPLICITLY
> parallel) and see
> which successfully completes (as in rule flow A or rule flow B)
> and use that
> to move higher up in my tree of goals. In effect, I am trying to create a
> "multi-threaded" procedural control which matches the classical
> definitions
> of "work flow" with its forks and joins of independent processes.
>
> How I engineer the control (in either the determistic or non-deterministic
> layer) is secondary to achieving a control flow architecture which
> determines which rule sets are eligible to execute.
>
>
> - Original Message -
> From: "Jason Morris" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, May 28, 2004 10:13 AM
> Subject: RE: JESS: Re: your mail [REGARDING SALIENCE IN JESS]
>
>
> > I think that James Owen wrote:
> > >As I recall, salience in rulebased programming is akin to goto
> statements
> > in BASIC; a crutch for poor programming
> >
> > On that subject: Just as there are legitimate, structured uses for the
> GOTO
> > statement in some languages, salience can be used in a
> structured way that
> > doesn't violate the spirit of rule-based programming.
> >
> > I've spent a lot of time studying the Jess In Action sections
> on salience,
> > modules, general flow control in Jess programs, and anything
> else I could
> > find on the subject -- and it's all very helpful.  However,
> ironically, I
> > recently came across an old ART Enterprise tutorial manual
> (1987) that has
> a
> > fantastically clear explanation of when it is proper to use salience and
> how
> > to do it.  (For the AI history buff: ART was one of the first commercial
> > expert system shells and was also the progenitor of CLIPS - Jess's
> > "inspiration".  See http://www.ghg.net/clips/WhatIsCLIPS.html#History )
> >
> > In any case, the examples (easily extrapolated to Jess) were (quoting
> now):
> >
> > * To stratify the rule base into classes of rules dedicated to different
> > tasks (filtering, pre-processing, etc.)
> > * To give a very important rule priority over most other or all other
> rules
> > (error conditions or "alarms").
> > * To keep a utility rule in the background until the rest of the program
> has
> > run to completion (final output, re-init fact base, etc.)
> >
> > As far as item one goes, it's easy to implement in Jess with global
> > variables like this:
> >
> > (defglobal ?*TASK_PRIORITY_1* = 500)
> > (defglobal ?*TASK_PRIORITY_2* = 200)
> > (defglobal ?*TASK_PRIORITY_3* = 100)
> >
> > (defrule foo-1
> >   (declare (salience ?*TASK_PRIORITY_1*))
> > ...
> > =>
> > ...
> > )
> >
> > (defrule foo-2
> >   (declare (salience ?*TASK_PRIORITY_2*))
> > ...
> > =>
> > ...
> > )
> >
> > and so on.
> >
> > Again, this would be for controlling "layers" of rules that sort of
> "swarm"
> > on completing one complex task at a time.
> >
> > One other technique that I've been practicing is the notion of
> LHS Control
>

RE: JESS: Re: your mail [REGARDING SALIENCE IN JESS]

2004-05-28 Thread Jason Morris
Footnote
The ART manual that I "...came across" was graciously donated to my cause by
Bob Orchard.
Bob: I know I should have grabbed the "Viewpoint" manual, too! :-D

Given the pace of programming evolution, it's comforting to know that study
of something twenty years old (ART) can still give insight into programming
something modern (Jess) better.
-JM


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: your mail [REGARDING SALIENCE IN JESS]

2004-05-28 Thread Jason Morris
"If I have been able to see further, it was only
because I stood on the shoulders of giants."
Sir Isaac Newton

It's fun to wonder what a guy like Newton would have done with a tool like
Java or Jess.
Would Newton have been a programmer?  I think he'd have been fascinated by
exploring his ideas numerically.
-JM
--------

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





> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of James Owen
> Sent: Friday, May 28, 2004 11:16 AM
> To: [EMAIL PROTECTED]
> Subject: Re: JESS: Re: your mail [REGARDING SALIENCE IN JESS]
>
>
> Just a side note here:  It is most refreshing to see the "big guns"
> weigh in with their thoughts and references.  While some of it may be
> extraneous "rabbit trails" it is, nevertheless, enlightening.  I realize
> that the Jess email list is supposed to be dedicated to solving the
> so-called "real world" problems, but when folks like Bob, Jason, Rich
> and Ernest begin to philosophize and wax rhetoric - well, I think it
> gives us a sense of history that, in the words of (was it Einstein?) "We
> stand on the shoulders of Giants."  So much has gone before us that is
> still valid and, in effect, gives us the insight, sometimes, to help
> mold our minds to the process, or the why, rather than the how.   And,
> while I love just to sit in the background and read these insightful
> discourses, it's back to work to work for the plebeians such as me.
> (Such as I?)  whatever...  :-)
>
> SDG
> jco
>
> 
> 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]
> 
>


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: Listening to Jess Events

2004-06-01 Thread Jason Morris
Hi All,

If I have a class (Someclass) that I want to receive Jess events, I assume
that all I need to do (following JIA pp. 418-419 and the API) is the
following:

1.  Have that class implement the JessListener interface.
2.  Have that class implement eventHappened(JessEvent je).
3.  Instantiate a Rete object with engine = new Rete(Someclass.class) to
register the context with engine.
3.  Register that class to receive events via engine.addJessListener().
4.  Call engine.setEventMask() for each event that I want to receive.

I tried all this and didn't have any luck, so I'm obviously missing
something.

Now, for simplicity sake, let's say that Someclass contains a method called
process() where:

public void process() {
  engine.executeCommand("(batch main.clp)");
  engine.executeCommand("(batch resolve.clp)");
  engine.executeCommand("(batch schedule.clp)");
  engine.reset();
  engine.runUntilHalt();
}

Now, I have a slew of questions:

1.  While runUntilHalt() is executing, does the listening class need to be
listening on another thread to receive events while the engine is running?
2.  Does it matter at all that process() is running Jess script via
engine.executeCommand() instead of executing API code directly?
3.  Is this an acceptable way of programming in Jess?  Should all the script
be in one file?
4.  My main reason for wanting the events produced by Jess was to log them
for debugging. (Jess is being used in a webapp here, and I am using Apache
Jakarta Log4J as the logger.)  My initial thought was to put logging
statements in the implementation of eventHappened() like this:

public void eventHappened(JessEvent je) throws JessException {
switch (je.getType()) {
case JessEvent.ACTIVATION:
Activation activation = (Activation) je.getObject();
String ruleName = activation.getRule().getDisplayName();
logger.info("Activation: " + ruleName
+ " was activated or deactivated.");
break;
// ... more code
}

What's the best way of logging Jess output and events when Jess is embedded
in a web application? (I don't mean generating JSP views for input/output -
that I've got fine.)

Thanks!
-JM



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]




JESS: Logging from Jess

2004-06-01 Thread Jason Morris
Hi All,

As a follow up to my last questions on events, I did try another approach
which also mysteriously doesn't work, but seems logical.  I figured that I'd
just use store() to put a reference to the Log4J logger object in Jess like
so:

engine.store("logger", this.logger)  // there was a private field holding
the logger not shown

Then, I wrote a deffunction around calling that logger like this:

(deffunction MAIN::log-info (?message)
  (bind ?logger (fetch logger))
  (if (not (eq ?logger nil)) then
  (call ?logger info (str-cat "jess: " ?message

Then, I figured that in order to log messages all I had to do was to call
that function from the RHS of any rule like:


(defrule log-foo
  (foo)
=>
(MAIN::log-info "Some message to log")

Alas, no such luck.  The rule activates and fires, but no message comes
through.  Seems like this should work.  What am I missing?
-JM


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: Logging from Jess

2004-06-01 Thread Jason Morris
Thanks Ernest,

No...no... no cloned Rete objects running amok here  :-D ... something much
simpler.  I was calling engine.reset() after having called
engine.store("logger", logger); way up further.  I caught it with this
simple experiment (excuse the ugly hardcoded paths):

---
package edu.pdx.etm.test;
import jess.*;
import org.apache.log4j.Logger;

public class TestLoggerFromScript {
private Rete engine;
private String cmd =
"(batch \"C:/Program Files/Apache Group/Tomcat 4.1/webapps/emgt/WEB-
INF/classes/edu/pdx/etm/jess/testlog.clp\")";

private Logger logger = Logger.getLogger(TestLoggerFromScript.class);

public TestLoggerFromScript(){
engine = new Rete();
}

public static void main(String[] args) {
TestLoggerFromScript tlfs = new TestLoggerFromScript();
tlfs.run();
}

public void run(){
try{
engine.executeCommand(cmd);
engine.reset();
engine.store("logger", this.logger);
engine.run();

}
catch (JessException jex){
jex.printStackTrace(System.err);
}

}
}
-
The script is a snippet of the aforementioned
three Jess scripts in my main project
-

(clear) ;BEGIN MAIN MODULE

(watch all)

(deftemplate MAIN::psu-class
(slot id)
(slot dept)
(slot secMs)
(slot secPhd)
(slot suffix)
(slot instructor)
(slot title)
(slot credits)
(slot type)
(slot active)
(slot select)
(slot quarter)
(multislot qtrs)
(multislot prereqs))

;; A few sample facts
(deffacts load-psu-class-factbase
  (MAIN::psu-class (id 1)
  (dept "ACTG")
  (secMs 511)  (secPhd 611)  (suffix nil)
  (instructor "staff")  (title "Financial Accounting")  (credits 4)
  (type "core2")  (active FALSE)  (select FALSE)
  (quarter nil)  (qtrs 0)  (prereqs nil))

  (MAIN::psu-class (id 2)
  (dept "EMGT")
  (secMs 503)  (secPhd 603)  (suffix nil)
  (instructor "Staff")  (title "Thesis")  (credits 8)
  (type "cap")  (active FALSE)  (select FALSE)
  (quarter nil)  (qtrs 30)  (prereqs nil))

  (MAIN::psu-class (id 3)
  (dept "EMGT")
  (secMs 506)  (secPhd 606)  (suffix nil)
  (instructor "Staff")  (title "Special Projects")  (credits 4)
  (type "cap")  (active FALSE)  (select FALSE)
  (quarter nil)  (qtrs 30)  (prereqs nil)))

;; Logging function wraps reference to logger object
(deffunction MAIN::log-info (?message)
  (printout t "MAIN::log-info called..." crlf)
  (bind ?logger (fetch logger))
  (printout t "logger = " ?logger crlf)
  (if (not (eq ?logger nil)) then
  (call ?logger info (str-cat "jess: " ?message

;; Just a cheesy test rule...
(defrule MAIN::is-EMGT-503
  (MAIN::psu-class (dept "EMGT") (secMs 503) (secPhd 603))
=>
 (MAIN::log-info "EMGT 503 found in course database."))

---
Which after ...

FIRE 1 MAIN::is-EMGT-503 f-2
MAIN::log-info called...
logger = 
 INFO [main] (?:?) - jess: EMGT 503 found in course database.
 <== Focus MAIN

... produces the beautiful (to me anyway!) output in the log file...

15:22:26,343 INFOmainNativeMethodAccessorImpl ? : jess: EMGT 503
found in course database.
---

All in all, I think that this technique is an elegant way to log messages
out of Jess in webapps.  You can really see what the RHS of rules are doing
and whether the logic is working.  Thoughts?
-JM


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



> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of [EMAIL PROTECTED]
> Sent: Tuesday, June 01, 2004 1:15 PM
> To: [EMAIL PROTECTED]
> Subject: Re: JESS: Logging from Jess
>
>
> I think Jason Morris wrote:
> >
> > (deffunction MAIN::log-info (?message)
> >   (bind ?logger (fetch logger))
> >   (if (not (eq ?logger nil)) then
> >   (call ?logger info (str-cat "jess: " ?message
> >
>
> This actually should work perfectly. In combination with your other
> message, though, where you mention constructing a Rete object with a
> Defclassed object (or its Class object?) as an argument, I wonder if
> the problem is that you're inadvertently creating multiple Rete
> objects, and then storing the logger in one, while this code is
> running in another.
>
> It's fine to create multiple Rete objects, 

RE: JESS: Listening to Jess Events

2004-06-01 Thread Jason Morris
Thanks Alan,

Yes, in the interest of trimming the example, I may have trimmed too much
detail.  Let me clarify:

public class Someclass implements JessListener {
  public static Logger logger = Logger.getLogger(Someclass.class);
  private Rete engine;
  private final String cmd1 = "(batch main.clp)";
  private final String cmd2 = "(batch resolver.clp)";
  private final String cmd3 = "(batch scheduler.clp)";


  public Someclass(){
this.engine = new Rete();
  }

  public void process() {
engine.addJessListener(this); // Register this Someclass instance as a
JessListener
engine.setEventMask(JessEvent.ACTIVATION); // for example.  I assume I
can include others with a bitwise OR
engine.executeCommand(cmd1);  // run batch 1
engine.executeCommand(cmd2);  // run batch 2
engine.executeCommand(cmd3);  // run batch 3
engine.reset(); // mainly to load deffacts
engine.runUntilHalt();  // keep churning until a result is produced
  }

  public void eventHappened(JessEvent je) throws JessException {
switch (je.getType()) {
  case JessEvent.ACTIVATION:
Activation activation = (Activation) je.getObject();
String ruleName = activation.getRule().getDisplayName();
  logger.info("Activation: " + ruleName
 + " was activated or deactivated.");
   break;
  // ... more code
  }
}// end class

Now, I'd expect some code like:

Someclass objSomeclass = new Someclass();
objSomeclass.process();

to run the Jess batches and log the various events.

You also mentioned routing the Jess output to the log files, which is also
something that I'd like to do.

I'm only familiar with passing Strings to Log4J loggers, but I see that you
can pass other objects as long as you provide a ObjectRenderer
implemetation.  So assuming that Jess's addOutputRouter() accepts any Writer
object, do you have a Renderer already coded that maps Jess STDOUT to Log4J?

Thanks again, Alan!
-JM


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]




JESS: rule-based scheduling

2004-06-23 Thread Jason Morris
All,

I am looking for some good references (preferably online) about "scheduling
theory" -- especially using rules to compute various resource scheduling
scenarios.

Thanks!
-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: rule-based scheduling

2004-06-27 Thread Jason Morris
I think that Sione wrote:
> I hope this information will give you a good start.
Sione,
Thank you very much for the incredibly detailed reply!  

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: query in jess

2004-06-27 Thread Jason Morris



Hi 
Alvin,
Leave it to Dr. Friedman-Hill 
to quickly point out the simplest solution! :-D  I was going to 
suggest that a defquery might also be a solution since it 
can easily handle more general filtering.  For 
example:
 
(defquery 
find-substring-in-mail  (declare (variables ?substring))  
(mail (content ?c))  (test (not (eq (str-index ?substring ?c) 
FALSE
 
Now, a 
simple test program (I called it a.clp) could then look 
like:
 
(clear)(deftemplate mail  (slot 
content))
 
(deffacts 
mail(mail (content "AAAxxx"))(mail (content "BBByyy"))(mail (content 
"CCCxxx"))(mail (content "AAAyyy")))
 
(defquery 
find-substring-in-mail  (declare (variables ?substring))  
(mail (content ?c))
  ;; Here you use a test fact to filter 
the mail facts
  ;; by 
seeing if the substring is present in the content.  (test (not (eq 
(str-index ?substring ?c) FALSE
 
(defrule 
print-all-AAAs=>
;; Rather 
than hard-coding the AAA, you could have
;; some 
interactive input from the user.(bind ?itt (run-query find-substring-in-mail 
"AAA"))(printout t "The mail facts with " crlf)(printout t "content 
substring = AAA" crlf)
(printout t 
"id    content" crlf)(printout t "---   " 
crlf)(while (?itt hasNext)  (bind ?token (call ?itt 
next))  (bind ?fact (call ?token fact 1))
  ;; 
This is just here to remind you that you can call
  ;; 
any public methods of Java objects from Jess script.  (bind ?id 
(call ?fact getFactId))  (printout t ?id " " 
(fact-slot-value ?fact content) crlf)))  
(reset)(run)
 
The output 
is:
 
Jess> 
(batch a.clp)The mail facts withcontent substring = 
AAAid    content---   
1 AAAxxx4 
AAAyyy1Jess>
 
Hope this 
helps!
Cheers,
 
Jason

Jason 
MorrisMorris Technical 
Solutions[EMAIL PROTECTED]www.morristechnicalsolutions.comfax/phone: 
503.692.1088 
 

  -Original Message-From: [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED]On Behalf Of sun xiSent: 
  Saturday, June 26, 2004 7:36 PMTo: [EMAIL PROTECTED]; 
  [EMAIL PROTECTED]Subject: JESS: query in 
  jess
  
  Hi, everybody
   
  Given a set of facts:
  (mail (content "AAAxxx"))
  (mail (content "BBByyy"))
  (mail (content "CCCxxx"))
  (mail (content "AAAyyy"))
   
  Can somebody guide me how to find the mails whose 
  content begin with "AAA" ?
   
  Appreciate all your replies :)Thanks,Alvin 
  Swen
  
  [EMAIL PROTECTED]<~O5M3!* MSN Hotmail 
   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: rule-based scheduling

2004-06-28 Thread Jason Morris
Hi Leila ,
Thanks for the information!
Kind regards,

Jason


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



> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of Leila
> Sent: Monday, June 28, 2004 11:29 AM
> To: [EMAIL PROTECTED]
> Subject: Re: JESS: rule-based scheduling
>
>
>
> Another good book on scheduling:
>
> Constraint-based Scheduling: Applying Constraint Programming to Scheduling
> Problems (International Series in Operations Research &
> Management Science)
>
> Philippe Baptiste, Claude le Pape, Wim Nuijten, Claude le Pape
>
>
> On Sun, 27 Jun 2004 09:36:22 -0700 [EMAIL PROTECTED] wrote:
> > I think that Sione wrote:
> > > I hope this information will give you a good start.
> > Sione,
> > Thank you very much for the incredibly detailed reply!
> >
> > 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]
>
> > 
>
>
> Leila Kalantari
>
> 
> 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]
> 
>


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: new Batch() ??

2004-07-11 Thread Jason Morris
Hello Dr. Friedman-Hill:
On pp. 337-338 of JIA, you give a brief example of initializing the Catalog
servlet in the Tekmart app.

Where does the Batch() constructor under the Rete instantiation on p.338
come from?
I can't seem to find it in the Jess61p7 API.  Is this a typo or am I missing
something basic?

...
Rete engine = new Rete(this);
new Batch().batch(rulesFile, engine);
...

----

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: breaking complex rules [Zen of Jess]

2004-07-12 Thread Jason Morris
rences
to other Java objects, it can call methods of objects external to Jess.
Think critically for a minute on the flexibility that this gives your code.

5.  Sometimes it helps to think of a rule-based program as a
"state-machine", where the addition or subtraction of data (facts) from
Jess's working memory moves the machine (your program) through different
states.  Your job as a rules programmer then is to figure out rules to
transition between the states and what to do when a state is reached.

6. All other rules of good software engineering always apply to rule-based
programming (think about architecture, goals, testing, modularized
development, etc.)

I hope that this helps you in your study.  Jess is very cool technology, and
it has actually improved my Java skills tremendously (gives me more of a
reason to study Java!).

Happy inferring!
-JM


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]




JESS: comments affecting error message line numbers?

2004-07-19 Thread Jason Morris
I know JIA 4.1.1 says that the Jess parser ignores new lines and whitespace
in processing code, but it seems that if I heavily comment my batch files,
that I don't get accurate line numbers in subsequent error traces.

For most small programs, the reported line number of an error is exact or
the difference is fairly close, but for larger code like Mitch's example,
I've noticed that it can be significantly off.  Is there a best practice to
follow?
Just curious...
-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: Help ! How can i implement my Userfunction ?

2004-07-29 Thread Jason Morris
I think that Mong-Thao wrote:
>> How can i implement this function in Java code ?

See http://herzberg.ca.sandia.gov/jess/docs/61/extending.html# for a full
explanation.

Cheers,
-JM


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



> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of [EMAIL PROTECTED]
> Sent: Thursday, July 29, 2004 10:39 AM
> To: [EMAIL PROTECTED]
> Subject: JESS: Help ! How can i implement my Userfunction ?
>
>
> Hallo
> I am a new jess-user.
> i have the following function to get slot-value.
>
> (deffunction getNachweis ()
> (return (fact-slot-value (fact-id 1) nachweis))
> )
>
> The fact with slot named nachweis ist existing.
> How can i implement this function in Java code ?
>
> Thanks
> la
>
> 
> 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]
> 
>


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: Comparing Retes

2004-07-29 Thread Jason Morris
Sergio,

The Rete object is a "facade" http://en.wikipedia.org/wiki/Facade_pattern
that wraps Jess's API.  It's not really a container for computation per se,
rather it's like a convenient "control panel" for Jess.  So, as Ernest
pointed out, it's not clear why you are trying to "compare" Rete instances.
That said, it is easy to compare Jess facts using various methods, but
comparing Java objects is a basic Java technique that is not specific to
Jess.  If you can describe some details of your application (what you are
trying to do specifically), the group can offer better advice to you.

Cheers,

-Jason


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



> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of Sergio Martmn Ballesteros
> Sent: Thursday, July 29, 2004 10:21 AM
> To: [EMAIL PROTECTED]
> Subject: Re: JESS: Comparing Retes
>
>
> Hello,
> Which is the best way to compare facts and compare java Objetcs
> themselves?
>
> Thanks and sorry for my poor english.
>
>
> >From: [EMAIL PROTECTED]
> >Reply-To: [EMAIL PROTECTED]
> >To: [EMAIL PROTECTED]
> >Subject: Re: JESS: Comparing Retes
> >Date: Thu, 29 Jul 2004 05:57:12 -0700 (PDT)
> >
> >
> >I think =?iso-8859-1?B?U2VyZ2lvIE1hcnTtbiBCYWxsZXN0ZXJvcw==?= wrote:
> >[Charset iso-8859-1 unsupported, filtering to ASCII...]
> > > Hello,
> > > I am doing a search deep algorithm, and i want to know if there are
> >equals
> > > states in order to delete them.
> >
> >Hmmm.  I suspect we're having some troubles understanding one
> >another. You can't possibly be doing a search algorithm in which each
> >state along the path is represented by a separate jess.Rete
> >object. Perhaps you mean comparing facts, or comparing the Java
> >objects themselves?
> >
> >
> >-
> >Ernest Friedman-Hill
> >Science and Engineering PSEsPhone: (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]
> >
> >
>
> _
> Reserva desde ahora tus vacaciones en MSN Viajes. Mas csmodo, mas
> barato y
> mas opciones. http://www.msn.es/Viajes/
>
> 
> 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]
> 
>


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: comments affecting error message line numbers?

2004-07-30 Thread Jason Morris
Glad that you confirmed it.  I was worried that I was missing something.
On the positive side, it sure made my bug-finding eye better.




> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of [EMAIL PROTECTED]
> Sent: Friday, July 30, 2004 8:56 AM
> To: [EMAIL PROTECTED]
> Subject: Re: JESS: comments affecting error message line numbers?
>
>
> I think Jason Morris wrote:
> > For most small programs, the reported line number of an error
> is exact or
> > the difference is fairly close, but for larger code like
> Mitch's example,
> > I've noticed that it can be significantly off.
>
> Indeed, the error was reported at line 92 instead of the correct line
> 99. I've just confirmed that the Jess 7 parser gets this example right.
>
>
>
> -
> 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]
> 
>


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: FYI - Using Data Structures and Algorithms with Jess

2004-07-30 Thread Jason Morris
All,

If you need particular data structures to augment your Jess code and you are
short on resources, this web-doc and library might help.

Data Structures and Algorithms with Object-Oriented Design Patterns in Java
http://www.brpreiss.com/books/opus5/

Web book
http://www.brpreiss.com/books/opus5/html/book.html

Javadocs
http://www.brpreiss.com/books/opus5/javadoc/index.html

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]




JESS: Jess feature idea

2004-07-30 Thread Jason Morris
Jess 7.0 will have the accumulate feature, but how about some way of
accumulating by adding nodes to a tree? (If you look, you'll see that any
kind of general purpose tree class is conspicuously missing from java.util.)
For example, I'm doing some computations where I am accumulating sets of
nodes (fact-ids representing partial solutions to a scheduling problem)
after every engine cycle.  Actually, the structure is a "forest" something
like this:

 
  |   |
  +---++
+++
  || ||
|
   
 ...
  || |
|
   +--+-+  +---+ ++
++
   ||  |   | ||
||
 


  ...  ...

In my case, the solutions that Jess will eventually find are the depth-first
traversals of the trees,
e.g, solution = {,,,...}
Given how ubiquitous trees are in computing, is there any utility in having
Jess support a ready-made structure for accumulating (placing!?) output
(pattern bindings, function returns, etc.) as nodes in a tree?  Of course,
there are a thousand ways that I or any other user can roll our own (using
linked lists for example), but maybe someone else has a similar need, too.

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]




JESS: FYI - using trees in Jess code

2004-08-01 Thread Jason Morris
Hi All,
I just wanted to squash my previous query about adding a native, general
purpose, tree storage mechanism to Jess.  It's not needed -- Jess's
flexibility lets you build pretty much anything you want.

For example, I successfully tried:

a) Cross-linking facts containing Jess multislots (like using relational
tables with foreign keys).  This seemed to be the "pure" Jess way, but I'd
had to roll all my own node manipulation functions.  Ernest mentions this in
passing in JIA.
b) Using java.util.LinkedList objects (again, I had to create all my own
accessors, but it's a well-documented implementation pattern)
c) Using javax.swing.tree.* with Jess script/API code.  Specifically use
DefaultTreeModel, DefaultMutableTreeNode, and JTree if you want to display
it.  Ironically, against my initial apprehension, this turned out to be the
simplest and cleanest choice for my application.

In fact, by using Swing's trees from my Jess code, I could attach a "user
object" to each DefaultMutableTreeNode and manipulate it via
getUserObject()/setUserObject().  In my case, the user object becomes a Jess
fact reference (or anything else I want to stick in there).  Additionally, I
could take advantage of other DefaultTreeModel methods like getPath(),
getPathtoRoot(), and a whole host of useful query and enumeration methods,
which I'd otherwise have to had written from scratch.

Jess really is the "programmer's rule engine"!

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]




JESS: the extends clause in deftempates

2004-08-02 Thread Jason Morris
What ever became of the "extends" clause in the definition for deftemplates?
It is clearly mentioned in the Jess online docs, but I don't see it
mentioned at all in JIA. Section 13.4 of the Jess61p7 change history
mentions it briefly.  I just tried whipping up a sample, and it clearly
works in Jess 61p7.  Was it omitted from JIA for a reason?

-JM

--------

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: new to jess

2004-08-02 Thread Jason Morris
Hi Nirajkumar,
As the saying goes, "...you can't get there from here."

First, you'd be better off learning Jess from its command line scripting
environment, then move to programming the API when you have the basics
mastered.

In your example, you have a few things incorrect:

1. You need to use the Jess (reset) command before running the rule engine.
2. Only rules in the module having the focus will activate and fire,
provided that their left-hand side (LHS) patterns are satisfied.  In this
case, your (test ...) fact is always TRUE, but you don't have the right-hand
side (RHS) doing anything (so you won't see any effect of the rule firing if
it did, other than what the (watch) command produces.
3.  Use "eq" to compare symbols, objects, and references.  Use plain vanilla
"=" for numbers.  The danger is that you could write some code like:

  (bind ?x 2)
  (bind ?y 2.0)
  (if (eq ?x ?y) then ...

expecting the condition to be TRUE, but it is really FALSE.  Jess is
comparing both value AND type, and since an INT is never the same type as a
FLOAT, the condition is false.  If you had said (= ?x ?y) then it would have
been TRUE.  You can easily prove this yourself by running this program:

;; is-equal-or-not.clp
(clear)
(watch all)
(defrule is-equal-or-not
"Will always fire since it matches the (MAIN::initial-fact)"
=>
  (bind ?x 2)
  (bind ?y 2.0)
  (printout t "x eq y :" (eq ?x ?y) crlf)
  (printout t "x = y :" (= ?x ?y) crlf))
(reset)
(run)

Back to your example, I'd recommend this approach instead:

1. Copy this sample code below, and save it as test.clp in the same folder
as jess.jar or somewhere on Jess's CLASSPATH.

;; test.clp ;
(clear)
(defrule equality-test
  (test (= 1 1))
=>
  (printout t "equality test performed OK" crlf))
(reset)
(focus MAIN)
(run)
;;

2.  Run it by typing (batch test.clp) at the Jess command line. You should
see something like:

  Jess> (batch test.clp)
  MAIN::equality-test: +1+1+2+t
   ==> Focus MAIN
   ==> f-0 (MAIN::initial-fact)
  ==> Activation: MAIN::equality-test :  f-0,
  FIRE 1 MAIN::equality-test f-0,
  equality test performed OK
   <== Focus MAIN
  1
  Jess>

My point is:  Keep working many small examples like this until you are
comfortable with the Jess language, then try writing Java with the Jess API.
You'll learn Jess much better and more quickly.

Oh... and buy a copy of "Jess In Action"
http://www.manning.com/friedman-hill !

Cheers,

-Jason


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




> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of nirajkumar motwani
> Sent: Monday, August 02, 2004 2:33 PM
> To: [EMAIL PROTECTED]
> Subject: JESS: new to jess
>
>
> Hi All,
> I am new to using jess and was having some problems when i wrote
> a small java code...
> when i do the following (below is part of the code), i donot get
> any fired rules, why is that:
> ...
> engine.executeCommand("(watch rules)");
> String rule3 ="(defrule euality-rule (test (eq 1 1)) => )";
> engine.executeCommand(rule3);
> engine.executeCommand("(run)");
> System.out.println("run command executed...");
> ...
>
> The system.out statement is printed but thw watch rules does not
> indicate that any rule was fired? what am i doing wrong?
>
> Thanks
>
> Nirajkumar Motwani
> Graduate Student
> Computer Science Department
> University Of Southern California
>


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: new to jess

2004-08-03 Thread Jason Morris
I think that Camillo wrote:
>>How I use "eq" to compare generic objects?

Well, first off a bit of listserv etiquette... let's not do an end-run
around Ernest here.  So if you have a question personally for me, then send
it to me at my address below.  But every day that Ernest has to answer FAQs
is one day that I don't get to play with Charlemagne (Jess 7.0), so whatever
I can do (humbly) to help I will.  :-D

Seriously, this is more of a Java question.  Let me quote now from the Jess
function link for "eq"
http://herzberg.ca.sandia.gov/jess/docs/61/function_index.html

"...Uses the Java Object.equals() function, so can be redefined for external
types. "

There's your answer.  You have to roll your own.

When you write Java classes that will be compared at some point, it is
standard practice to override the equals() method to suit your need.  Again,
quoting from "Practical Java" by Peter Haggar, "...An equals method should
be provided by a class if equality of an object of that class requires more
than a comparison of its object reference."

Hope that helps.
Cheers,

-Jason


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



> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of Camillo
> Sent: Tuesday, August 03, 2004 8:06 AM
> To: [EMAIL PROTECTED]
> Subject: R: JESS: new to jess
>
>
> Hi Jason,
> I'm also a new to using jess and I have a trouble... You say to use "eq"
> to compare objects,symbols and references. I have this problem:
>
> (defrule myRule (myPattern (mySlot slotValue))=>...)
>
> where slotValue isn't a primitive type but a generic java object bounded
> to jess variable
>
> How I use "eq" to compare generic objects?
>
> I have used this:
>
> (defrule myRule (myPattern (myslot ?slotValue&:(eq (call ?slotValue
> getValue) myPrimitiveValue)))=>...)
>
> but don't works and I think is incorrect however. Can you help me?
> Thanks
>
> Camillo
>
> 
> 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]
> 
>


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: new to jess

2004-08-03 Thread Jason Morris
Oops!  Yes, James and Ernest are correct... an error of omission on my part.
You do indeed need to override the hashCode() method, too.

I was fortunate enough to win a copy of Thinking in Java 3rd ed by Bruce
Eckles at my local Java users group.  It is available *free* as an
electronic book at http://mindview.net/Books/DownloadSites .  If you look at
Chapter 11: Hashing and Hash Codes you will find the complete example that
James mentioned.  Just remember that, by default, equals() only compares
object references -- for anything else you have to write a custom
implementation.

Cheers,

-JM


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



> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of [EMAIL PROTECTED]
> Sent: Tuesday, August 03, 2004 12:42 PM
> To: [EMAIL PROTECTED]
> Subject: Re: JESS: new to jess
>
>
> I think James Owen wrote:
> > One other thing, something that most "old timers" even forget.  :-)  If
> > you re-write equals for a class that already exists or one that you
> > inherit then you have to re-write the hash map table.
>
> Of course what jco means is that if you override equals(), you should
> override hashCode() as well; the details of doing this correctly are
> spelled out quite clearly in the Javadocs for the Object class. Joshua
> Bloch's book is, indeed, good as well.
>
>
>
> -
> 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]
> 
>


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: Implementing equals() and hashCode()

2004-08-04 Thread Jason Morris
Small world -- the javapractices link cross references the same book that
Ernest mentions on the subject:
-
Implementing hashCode()
"...The following utility class allows simple construction of an effective
hashCode method. It is based on the recommendations of Effective Java, by
Joshua Bloch..."
-

The actual book is:

Effective Java Programming Language Guide
Joshua Bloch
Average Customer Review: 5 / 5  Based on 93 reviews
Publisher: Addison-Wesley Pub Co; 1st edition (June 5, 2001)
ISBN: 0201310058

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

2004-08-05 Thread Jason Morris
I think that Chirag wrote:

>>I do not want the previous rules fired, even though they may have
activation records.

If a (rule A) is activated and you want a particular (rule B) to remove it
from the agenda, simply have (rule B) make some assertion that invalidates
the pattern match that first activated (rule A).  (Rule A) will then be
removed from the agenda.  You need to use salience, (set-strategy), or some
other conflict resolution to ensure that (rule B) fires before (rule A).

>>...How would I do this?

One easy way is to use a "control pattern" -- an ordered fact that simply
acts as a constraint on the entire LHS of a rule.  For example:

(defrule controlled-rule
?control <- (control-fact)
;; add your other fact patterns here
=>
;; add what actions you want done here
(retract ?control)
(assert (next-control-fact))) ;; this will activate other rules

BTW - Facts activate rules, not the other way around.

Cheers,
-JM
--------

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: Coding (writing rules) Backward Chaining in Java

2004-08-07 Thread Jason Morris
I think that Calvin wrote:
>>...it throws null pointer exception of variable Result. PLease advice.

Hi Calvin,

I stripped down your example (merlinMain doesn't seem to supply anything but
a Rete instance -- and an oddly public one at that) and added a try/catch
block to intercept any Jess exceptions.  Sure enough, Jess complained:

Jess reported an error in routine Context.getVariable
while executing (assert (MAIN::adv-type ?x)).
  Message: No such variable x.
  Program text: ( assert ( adv-type ?x ) )  at line 1.

In your line ... (assert (adv-type ?x)) the variable ?x will not be bound to
anything until the rule (defrule r-adv-type-ask) fires, hence the null
pointer on the fact assertion.

This also indicates that there is something not quite right in your
backward-chaining implementation, too.  Ernest might give you the whole
answer here, but see if you can figure it out first.  If not, just repost
from where you get stuck.

FWIW - Again, my advice to beginners (based on bitter experience) is always
to become proficient with the Jess language via the command line before
adding another layer of complexity to one's study by programming the Jess
API.

If you run this class in your debugger, you'll see clearly where your code
blows up.

==

import jess.*;

public class TestBug {

private Rete r;

public TestBug() {
this.r = new Rete();
}

public static void main(String[] args) {
TestBug tb = new TestBug();
tb.run();
}

public void run() {

try {
r.clear();
r.executeCommand("(do-backward-chaining r-adv-type)");

r.executeCommand("(defrule r-adv-type"
+ "(need-adv-type ?x ?)"
+ "(adv-attr target audience demographically)"
+ "(adv-attr suitable to market time frame sensitive
product)"
+ "=>"
+ "(assert (adv-type radio-advertisement radio)))");

r.executeCommand("(defrule r-adv-type-ask" + "(adv-type-ask)"
+ "(adv-type ?x ?y)" + "=>" + "(store result ?x))");

r.reset();

r.executeCommand("(assert (adv-attr target audience
demographically))");
r.executeCommand("(assert (adv-attr suitable to market time
frame sensitive product))");
r.executeCommand("(assert (adv-type-ask))");
r.executeCommand("(assert (adv-type ?x))"); // offending line

r.run();

Value va = r.executeCommand("(facts)");
String str1 =
r.fetch("result").stringValue(r.getGlobalContext());
System.out.println("" + str1);
}

  // This is the important part! :-D
catch (JessException jex) {
jex.printStackTrace(System.err);
}
}
}
==


Cheers,
-JM


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: How to match Pattern in Facts

2004-08-08 Thread Jason Morris
I think that Calvin said:
>>How can I extract these 2 facts out?

Hi Calvin,
These operations are so basic to Jess that you might want to review them in
greater detail before proceeding.  If you can get a copy of Jess In Action
http://www.manning.com/friedman-hill, study chapters 1-7 thoroughly.  There
are numerous examples of how to do this very thing.  If not, go to
http://herzberg.ca.sandia.gov/jess/docs/61/ and look at Section 2:
http://herzberg.ca.sandia.gov/jess/docs/61/language.html, sub sections 2.7
and 2.8 in particular.

If you're really unsure about the number of attributes at the time that you
assert the fact, consider using "unordered" facts - facts with slots - to
store your data.  One variation (and there are so many ways to do this)
might be a generic "attributes" fact like this:

  (deftemplate adv-attributes
  (slot id)
  (multislot attribs))

Then you can assert facts like:

  (assert (adv-attributes (id 1) (attribs radio-advertisement low-budget)))
  (assert (adv-attributes (id 2) (attribs radio-advertisement
control-message-frequency)))

As for "extracting these facts out", I'm not sure if you want a reference to
the fact or one of its slot values.  To get a reference to a fact, simply
bind the LHS pattern to a variable like this

  ?fact <- (adv-attributes (id ?id) (attribs $?attribs))

For example:

  (defrule print-adv-attributes-facts
  "This rule matches all adv-attributes facts and binds their id and
attribute slots to variables"
  ;; Only use the $ prefix to match multifields in LHS patterns.  Drop it on
the RHS of rules.
  ?fact <- (adv-attributes (id ?id) (attributes $?attribs))
  =>
  (printout t "Fact-id=" ?fact crlf)
  (printout t "id=" ?fact crlf)
  (printout t "attribs=" ?fact crlf))

If you put all this in a batch file and run it, Jess will print:

Jess> (batch cal.clp)
MAIN::show-adv-attributes: +1+1+1+t
 ==> Focus MAIN
 ==> f-0 (MAIN::initial-fact)
 ==> f-1 (MAIN::adv-attributes (id 1) (attribs radio-advertisement
low-budget))
==> Activation: MAIN::show-adv-attributes :  f-1
 ==> f-2 (MAIN::adv-attributes (id 2) (attribs radio-advertisement
control-message-frequency))
==> Activation: MAIN::show-adv-attributes :  f-2
FIRE 1 MAIN::show-adv-attributes f-2
-
Fact-id=
id=2
attribs=(radio-advertisement control-message-frequency)
FIRE 2 MAIN::show-adv-attributes f-1
-
Fact-id=
id=1
attribs=(radio-advertisement low-budget)
 <== Focus MAIN
2
Jess>

Hope this gives you some traction.
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: How to match Pattern in Facts

2004-08-09 Thread Jason Morris
I think that Lars Hubner wrote:
>>There a two things wrong, I think:

Oh beware the dangers of late night cut & paste programming!
The correct code should have been

  (clear)
  (watch all)

  (deftemplate adv-attributes
  (slot id)
  (multislot attribs))

  ;; Yes, you need a rule name
  (defrule show-adv-attributes
  "This rule matches all adv-attributes facts and binds their id and
attribute slots to variables"
  ?fact <- (adv-attributes (id ?id) (attribs $?attribs))
  =>

  (printout t "-" crlf)
  (printout t "Fact-id=" ?fact crlf)
  (printout t "id=" ?id crlf)
  (printout t "attribs=" ?attribs crlf))

  (reset)
  (assert (adv-attributes (id 1) (attribs radio-advertisement low-budget)))
  (assert (adv-attributes (id 2) (attribs radio-advertisement
control-message-frequency)))
  (run)


This indeed runs as advertised.
Sorry about that!
-JM


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



> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of Lars H|bner
> Sent: Monday, August 09, 2004 1:20 AM
> To: [EMAIL PROTECTED]
> Subject: AW: JESS: How to match Pattern in Facts
>
>
> I think Calvin Pevee wrote:
>
> > (defrule
> > (adv-attribute radio-advertisement ?x)
> > =>
>
> Maybe it is usefull, to give the rules a name???
>
>
> I think Jason Morris wrote:
>
> >  (defrule print-adv-attributes-facts
> >  "This rule matches all adv-attributes facts and binds their id and
> attribute slots to variables"
> >  ;; Only use the $ prefix to match multifields in LHS patterns.  Drop it
> on the RHS of rules.
> >  ?fact <- (adv-attributes (id ?id) (attributes $?attribs))
> >  =>
> >  (printout t "Fact-id=" ?fact crlf)
> >  (printout t "id=" ?fact crlf)
> >  (printout t "attribs=" ?fact crlf))
>
>
> There a two things wrong, I think:
> First is the line ?fact... there you call attributes and not attribs
> Second are the printouts, how does JESS know, what the difference between
> the three variable ?fact are?
> I think you meant
> > (printout t "Fact-id=" ?fact crlf)
> > (printout t "id=" ?id crlf)
> > (printout t "attribs=" ?attribs crlf))
>
>
>
> Hope I'm right... not that good in programmer's stuff, just as good as in
> english, sorry about that, but I try to get better.
>
> Lars H|bner
>
>
> 
> 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]
> 
>


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: Deftemplate and Fact in java code with array !

2004-08-09 Thread Jason Morris
I think Dr. Friedman-Hill wrote:
>>So everywhere you've got a line like the above, change it to
>>   if(slotType[i].equals("double"))

Indeed.  I modified your code like Ernest suggested

import jess.*;
import java.io.*;

public class TestBug2 {

public static void main(String[] unused) throws IOException,
JessException {
Rete r = new Rete();

BufferedReader lesen = new BufferedReader(new InputStreamReader(
System.in));

//Eingabe den Namen vom Fact
System.out.println("Fact-Name ?:");
String factName = lesen.readLine();//Gibt factName= name ein

System.out.println("How many Slots ?:");
String _anzahl = lesen.readLine();

//String slotname[];
Integer i1 = new Integer(_anzahl);
int anzahl = i1.intValue();
String[] slotName = new String[anzahl];
String[] slotWert = new String[anzahl];
String[] slotType = new String[anzahl];
//Deftemplate
Deftemplate dt = new Deftemplate(factName, " Nur ein Name ", r);
for (int i = 0; i < anzahl; i++) {
System.out.println("Give a slot name:");
slotName[i] = lesen.readLine();
System.out.println("Give a value:");
slotWert[i] = lesen.readLine();
System.out.println("Give a slot type:");
slotType[i] = lesen.readLine();
if (slotType[i].equals("int")) {
Value zero = new Value(0, RU.INTEGER);
dt.addSlot(slotName[i], zero, "INTEGER");
System.out.println("Bin hier");

}
if (slotType[i].equals("double")) {
Value zero = new Value(0, RU.FLOAT);
dt.addSlot(slotName[i], zero, "FLOAT");
System.out.println("Bin hier");

}
if (slotType[i].equals("String")) {
Value zero = new Value(0, RU.STRING);
dt.addSlot(slotName[i], zero, "STRING");
System.out.println("Bin hier");

}

}

r.addDeftemplate(dt);

//Deffacts

Fact f = new Fact(factName, r);

for (int i = 0; i < anzahl; i++) {
System.out.println(slotType[i]);
if (slotType[i].equals("int")) {
Integer i2 = new Integer(slotWert[i]);
int iwert = i2.intValue();
f.setSlotValue(slotName[i], new Value(iwert, RU.INTEGER));
System.out.println("Bin hier");
} else
;
if (slotType[i].equals("double")) {
Double d1 = new Double(slotWert[i]);
double dwert = d1.doubleValue();
f.setSlotValue(slotName[i], new Value(dwert, RU.FLOAT));
System.out.println("Bin hier");
} else
;
if (slotType[i].equals("String")) {
f.setSlotValue(slotName[i], new Value(slotWert[i],
RU.STRING));
System.out.println("Bin hier");
}
//else;

}

System.out.println("Bin hier");
r.assertFact(f);
r.executeCommand("(facts)");

}
}

... and I got

Fact-Name ?:
metal
How many Slots ?:
3
Give a slot name:
name
Give a value:
steel-1020
Give a slot type:
STRING
Give a slot name:
strength-tensile-MPa
Give a value:
440
Give a slot type:
INTEGER
Give a slot name:
strength-yield-MPa
Give a value:
330
Give a slot type:
INTEGER
STRING
INTEGER
INTEGER
Bin hier
f-0   (MAIN::metal)
For a total of 1 facts.

Cheers,
JM


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: Multifield matching

2004-08-09 Thread Jason Morris
I think that Ross Judson said:
>>At this point I would like fact 2 to be retracted...I can't quite see how
to get there.

Hi Ross,
One obvious problem is that you have a logic error in your rule.  You have
the ?id variable being bound to the return value of the member$ function.
Quoting the Jess function reference:
  "Returns the position (1-based index) of a single-field value within a
multifield value; otherwise, returns FALSE."
You are expecting it to return the id value, which it's not -- it won't
necessarily correspond to the slot value.

Also, you need to do a (reset) before you run Jess so that the
(MAIN::initial-fact) gets asserted, or Jess won't run properly.  Make sure
that you do it before your assertions, else reset will wipe them out.  Using
(deffacts) is a convenient way to load a bunch of facts at once when you do
the (reset).

Cheers,

Jason

FYI/BTW - Another tricky point that Ernest has pointed out before is that
LISP dialects treat anything else than a FALSE as TRUE, so the integer
return value of member$ can be used in boolean expressions as is.
----

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






> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of Judson, Ross
> Sent: Monday, August 09, 2004 11:14 AM
> To: [EMAIL PROTECTED]
> Subject: JESS: Multifield matching
>
>
> Let's say I have two deftemplates:
>
> (deftemplate obj (slot id))
> (deftemplate dep (multislot depends-on))
>
> The depends-on multislot contains the ids of obj facts that the dep fact
> needs to exist.  If _any_ of the obj facts are missing, I want to
> retract the dep fact.  Writing a rule for this is perplexing me :)  .
>
> (defrule prune
> ?f <- (dep (depends-on $?targets))
> (not (obj (id ?id&:(member$ ?id $?targets
> =>
> (retract ?f))
>
> This doesn't work, and I really didn't think it would.  Consider:
>
> Jess> (deftemplate obj (slot id))
> TRUE
> Jess> (deftemplate dep (multislot targets))
> TRUE
> Jess> (defrule prune
> ?f <- (dep (targets $?targets))
> (not (obj (id ?id&:(member$ ?id $?targets
> =>
> (retract ?f))
> TRUE
> Jess> (assert (obj (id ross)))
> 
> Jess> (assert (obj (id judson)))
> 
> Jess> (agenda)
> For a total of 0 activations.
> Jess> (assert (dep (targets ross judson)))
> 
> Jess> (agenda)
> For a total of 0 activations.
> Jess> (assert (dep (targets ross nowhere)))
> 
> Jess> (agenda)
> For a total of 0 activations.
> Jess> (assert (dep (targets nowhere)))
> 
> Jess> (agenda)
> [Activation: MAIN::prune  f-4, ; time=5 ; salience=0]
> For a total of 1 activations.
> Jess> (run)
> 1
> Jess> (retract 0)
> TRUE
> Jess> (agenda)
> [Activation: MAIN::prune  f-3, ; time=7 ; salience=0]
> For a total of 1 activations.
> Jess> (run)
> 1
> Jess> (facts)
> f-1   (MAIN::obj (id judson))
> f-2   (MAIN::dep (targets ross judson))
> For a total of 2 facts.
> Jess>
>
> At this point I would like fact 2 to be retracted...I can't quite see
> how to get there.  The forall example seems like it might be headed in
> the right direction, but not quite...
>
> Ross Judson
>
> 
> 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]
> 
>


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: Multifield matching

2004-08-09 Thread Jason Morris
Hey Ross,
It just occurred to me that you are trying to build a cascading delete or
mimic referential integrity in your facts.  If you look at Jess In Action
pp. 115, Ernest talks about the "logical CE".  Section 2.8.8 of the online
Jess documentation also mentions this.

EJF writes, "All the facts on the RHS of a rule are logically dependent on
any facts that matched a pattern inside a logical CE on that rule's LHS.  If
any of the matches later become invalid -for instance, if one of the facts
is deleted - the dependent facts are retracted automatically".

You might want to give this a try, too.

--------

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: Multifield matching

2004-08-09 Thread Jason Morris
I think that ejfried wrote:
>>>  (defrule prune-2
>  ?f <- (dep (depends-on $? ?id $?))
>  (not (obj (id ?id&)))
>  =>
>  (retract ?f))

Very simple and elegant, Ernest!  I forgot about the $? ?id $? idea.  Glad
my "logical" constraint idea was OK.

BTW - Just so I'm clear:  Reading the code

  (not (obj (id ?id&:(member$ ?id $?targets

from inside out and ignoring the outer NOT for a minute, the expression

  (member$ ?id $?targets)

will return either the integer position of ?id in $?targets or FALSE if it's
not in there.  If it returns an INTEGER, let's say, it may or may not be
equal to an id, correct?  In that case, the predicate constraint

  ?id&:(member$ ?id $?targets)

doesn't seem correct, right?  Since id was a slot value, it could be
anything and not necessarily correspond to the position of an (obj) fact in
a (dep) fact.

-JM



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: Multifield matching

2004-08-09 Thread Jason Morris
I think that Dr. Friedman-Hill wrote:
>>"There's an obj fact, and the contents of its id slot can be found in the
list $?target."

Oh my! I need more coffee!  Of course it's clear now -- predicate
constraints take Boolean expressions only -- my mistake.  I knew
that...really.;-)
For the curious, JIA reference is pp.105.

-JM
----

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: AW: JESS: How to match Pattern in Facts

2004-08-11 Thread Jason Morris
I think Calvin Pevee wrote:
>>How can I get the activated facts out into Java variable?

Ernest's pet FAQ!  See JIA pp. 308-309 sec 18.1.2.  It talks about the
Rete.store/fetch mechanism.  You also want to look at
http://herzberg.ca.sandia.gov/jess/docs/61/library.html#xfer 4.4.4.
Transferring values between Jess and Java 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: hi All

2004-08-11 Thread Jason Morris
I think that Ross Judson said:
>> There are a couple of additional techniques you can use to control rule
firing order.

FYI - There are two more ways:
1.  Flip the order in which Jess fires facts on the agenda (first activated
= first to fire) by using the (set-strategy breadth) command -- a depth
first (last activated = first to fire) strategy is the default.
2.  You can create your own strategies by creating a class that implements
the jess.Strategy interface (JIA pp. 121 sec 7.5.1-7.5.1) then pass that
class name to (set-strategy).

Cheers,

-Jason


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: Dynamcially alloclated slot name

2004-08-11 Thread Jason Morris
I think that Chirag Mehta wrote:
>>Is there anyway of dynamically allocating a slot name?

Hi Chirag,
Jess has two functions, (build) and (eval), both of which can be used to
parse and execute strings of valid Jess code.  Using them and some other
commands plus a little Java glue if you need it, you can dynamically build
(as far as I know) any command sequence that Jess can parse -- even
dynamically creating new rules.  See JIA pp. 54-55 sec 4.3.6.

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: AW: JESS: How to match Pattern in Facts [details]

2004-08-12 Thread Jason Morris
I think that Calvin Pevee wrote:
>>I tried out the store/fetch. BUT, it return me only the latest fired
facts.

Hi Calvin,
Ernest cut to the heart of the matter already, but in your code below, note
that every time the rule fires, the value of the stored variable
"fact-in-java" gets replaced, overwriting the previous value.  You should
probably accumulate them in some sort of resizable collection like a Vector
or ArrayList.

r.executeCommand("(defrule show-adv-attributes"
+ " ?fact <- (adv-attributes (id ?id)(attribs
?attribs))"
+ "=>" + "(store fact-in-java ?attribs)"

>>How can I get the activated facts out, I mean all the fired facts?
It pays to be precise here.  Do you mean "How do I get all the a)
activations; b) fact references; or c) attribute multivariables?

If you just want a collection of fact references that caused the rule to
fire, then you could rewrite your code (I've shortened the redirections for
clarity) something like this:

import jess.*;
import java.util.Vector;



public class TestBug3 {

public static void main(String[] args) {
TestBug3 tb = new TestBug3();
tb.run();
}

private Rete r;

public TestBug3() {
this.r = new Rete();
}

public void run() {
// Catch JessException!
try {
// Like Ernest suggested... add a resizable container.
Vector factRefs = new Vector();

// Store that reference in Jess
r.store("FACT-REFS", factRefs);

// Execute your commands
r.executeCommand("(deftemplate adv-attributes" + "(slot id)"
+ "(multislot attribs))");

r.executeCommand("(defrule show-adv-attributes"
+ " ?fact <- (adv-attributes (id ?id)(attribs
?attribs))"
+ "=>" + "(bind ?fact-refs (fetch  FACT-REFS))"
+ "(bind ?ref (?fact getFactId))"
+ "(?fact-refs add ?ref)"
+ "(printout t \"-\" crlf)"
+ "(printout t \"Fact-id=\" ?fact crlf)"
+ "(printout t \"id=\" ?id crlf)"
+ "(printout t \"attribs=\" ?attribs crlf crlf))");

r.reset();

r.executeCommand("(assert (adv-attributes (id 1) (attribs
low-budget)))");
r.executeCommand("(assert (adv-attributes (id 2) (attribs
control-message-frequency)))");

r.run();

// Retrieve the stored fact refs - this may be redundant, but
you get the idea.
Value v = r.fetch("FACT-REFS");
Vector newRefs = (Vector)
v.externalAddressValue(r.getGlobalContext());
int length = newRefs.size();
for (int i = 0; i < length; i++) {
System.out.println("fact-ref:" + newRefs.get(i));
}
// Make sure that you are catching/handling JessException!
} catch (JessException jex) {
jex.printStackTrace(System.err);
}

}

}
This produces...

-----
Fact-id=
id=2
attribs=control-message-frequency

-
Fact-id=
id=1
attribs=low-budget

fact-ref:2
fact-ref:1

You can do anything you want with the facts now that you have a list of
their references.
Hope this helps.
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: few questions

2004-08-16 Thread Jason Morris
I think that Bhaskar wrote:
>> Is there a way to call one rule from another.

Hi Bhaskar,
First, make sure that you're not trying to procedurally control the rules
from firing, otherwise you violate the Zen of Jess
http://herzberg.ca.sandia.gov/jess/zen.shtml.

You might want to try using the "control pattern" technique of simply
placing an extra fact (usually a simple ordered fact) in LHS of a rule such
that it prevents the whole rule from activating unless that control fact is
present in working memory.  By binding that fact on the LHS, you can then
retract it on the RHS if the rule fires.  Repeat as needed by asserting
another control fact that can govern other rules.

>>Is it required for dynamic  bean to have m_name as property and a
constructor?

I'm not sure what you mean here.  As far as I know (having searched JIA and
the docs), if you build your beans according to spec (e.g., implement
java.io.Serializable, provide a zero argument constructor, follow field
naming convention and scoping, etc.) you shouldn't have any problems -- my
experience is that Jess is pretty forgiving.  Other than that, you can
include any properties that you want in your bean.  BTW - According to JIA
p.93, definstances are dynamic by default, unless explicitly created static.

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: Multislot with single value

2004-08-16 Thread Jason Morris
I think that Chirang wrote:
>>I need to check any of the facts have a particular slot value in the
factcollection.

Hi Chirang,
Two things:

1) You need to add a "$" to the LHS pattern when matching a multifield.
So, you have to write: (factcollection $?fc) Make sure that you drop the "$"
when using the variable on the RHS of a rule.

2) Have a look at the link below in the online Jess documentation, and
scroll down to the section named "Functions for working with multifields".
http://herzberg.ca.sandia.gov/jess/docs/61/function_index.html

If you need to check if any of a collection of facts have a particular slot
value, you want something like this:

FOREACH fact IN fact-references
  IF fact.fact-slot-value == x THEN
DO something
  END IF
NEXT fact


Cheers,
Jason
----

Jason Morris
Morris Technical Solutions
[EMAIL PROTECTED]
www.morristechnicalsolutions.com
fax/phone: 503.692.1088
confidentiality or privilege, and use is prohibited.


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: (reset) and (initial-fact)

2004-08-16 Thread Jason Morris
Well, I guess we could ask under what conditions would it be undesirable for
Rete objects to be created in a "reset" state.  If we can't think of any
negative side-effects, then no harm done and the benefits are as Ernest
stated.

As I understand it from
http://herzberg.ca.sandia.gov/jess/docs/61/functions.html#reset, (reset)
really does quite a few things:

1. Removes all facts from the fact list,
2. Removes all activations,
3. Asserts the fact (initial-fact),
4. Asserts all facts found in deffacts,
5. Asserts a fact representing each registered definstance,
and (if the set-reset-globals property is TRUE) initializes all defglobals.

So, in answer to Ernest's first question, "...would it be a good idea to
have a Rete object be born in such a state as if (reset) had just been
called?", it seems that doing so only really does #3 above since #1,2,4 and
5 don't apply yet.  Seems harmless enough.

In answer to his second question, "...In addition, should (clear) call
(reset) after wiping everything out?", again only #3 seems to apply since
(clear) deletes all rules, deffacts, defglobals, templates, facts,
activations.

Also, there are existing temporal issues about when to issue a (reset)
since...

(clear)
(reset) ;; treat this as an implicit (reset) called by (clear)
(deftemplate foo (slot id))
(deffacts load-foos (foo (id 1)) (foo (id 2)))
(defrule print-foos (foo (id ?id)) => (printout t "foo:" ?id crlf))
(assert (foo (id 3)))
(run)

...is clearly not the same as...

(clear)
(deftemplate foo (slot id))
(deffacts load-foos (foo (id 1)) (foo (id 2)))
(defrule print-foos (foo (id ?id)) => (printout t "foo:" ?id crlf))
(reset) ;; explicit reset
(assert (foo (id 3)))
(run)

So, it seems that we're really discussing whether or not instantiating a
Rete object or calling (clear) should silently assert (initial-fact).  I
don't see a reason why not.  Sounds like a nice refinement.

Anybody else?

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: Multislot problem

2004-08-17 Thread Jason Morris
I think that Chirag wrote:
>>?fact <-  (MAIN::findwherecontains productType CVBND ?fc) in the rule
always stops the rule from activating.

Hi Chirag,
You might be violating the Zen of Jess
http://herzberg.ca.sandia.gov/jess/zen.shtml.

In your code

  ?fact <-  (MAIN::findwherecontains productType CVBND ?fc)

you are trying to use the explicit pattern binding mechanism, "<-", to bind
the results of a function call to a variable, which as far as I know, won't
work.  Patterns binding are just that: a means to bind the actual fact
reference of a fact that matches a particular pattern to a variable for use
on the RHS of a rule.

>>I do not understand why.

Jess is looking for an ordered fact named (MAIN::findwherecontains)
containing a list of three values in its single slot, and it's rightly not
finding any, so the rule never activates.

Also, if you look at your function

  (deffunction MAIN::findwherecontains (?detail ?value ?col) ...

you have it returning either 0, a fact reference, or FALSE depending on
where the control flows.  Then, you're trying to bind that to a variable
that's clearly intended to hold a fact reference later... a sure source of
future bugs.

See if that helps.
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: few questions [control pattern example]

2004-08-17 Thread Jason Morris
I think that Bhaskar wrote:
>>Can you give me an example of control-patterns?

Hi Bhaskar,

Sure thing.  Try saving and running this batch file.

(clear)
(watch all)

(defrule rule-1 
"Fires only if a (control-1) fact is present." 
  ;; You might have several of these controlling the application state
  ?previous-control <-(control-1)  
  ;; Put other patterns here in your real code.
=> 
  ;; Put other function calls here in your real code.
  (retract ?previous-control)
  (assert (control-n))) 

;; And you may have many rules in this module
;; all working on some task... 

(defrule rule-n 
"Fires only if a (control-n) fact is present." 
  ?previous-control <-(control-n) 
  ;; Put other patterns here in your real code.
=> 
  ;; Put other function calls here in your real code.
  (retract ?previous-control)
  (assert (process-done))) 

;; Have the last rule done please turn off the lights :-D 

(defrule process-is-done 
"Fires only if process is complete." 
  (process-done) 
  ;; Put other patterns here if needed.
=> 
  ;; Put other function calls here if needed.
  ;; Begin the next process or halt
  (printout t "Process is finished." crlf)) 

;; Test
(reset)
(assert (control-1))
(run)
===

Jess prints out the following

Jess> (batch cc.clp)
MAIN::rule-1: +1+1+1+t
MAIN::rule-n: +1+1+1+t
MAIN::process-is-done: +1+1+1+t
 ==> Focus MAIN
 ==> f-0 (MAIN::initial-fact)
 ==> f-1 (MAIN::control-1)
==> Activation: MAIN::rule-1 :  f-1
FIRE 1 MAIN::rule-1 f-1
 <== f-1 (MAIN::control-1)
 ==> f-2 (MAIN::control-n)
==> Activation: MAIN::rule-n :  f-2
FIRE 2 MAIN::rule-n f-2
 <== f-2 (MAIN::control-n)
 ==> f-3 (MAIN::process-done)
==> Activation: MAIN::process-is-done :  f-3
FIRE 3 MAIN::process-is-done f-3
Process is finished.
 <== Focus MAIN
3
Jess>

Hope this helps!
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]




JESS: Thanks Ernest! and a note on posting

2004-08-19 Thread Jason Morris
Hi All,
Before he takes a much deserved rest, I wanted to publicly thank Ernest for
letting me help him with the Jess listserv.

I noticed that listserv traffic fell off dramatically after his hiatus
announcement.  Just because our Fearless Moderator In-Chief is on vacation
doesn't mean that you have to stop posting -- by all means keep your
questions coming.  I'm just humbly minding the store, but if I can help with
a FAQ, I'll do my best.  If you need more help, the Jess listserv boasts an
impressive array of other veteran Jess developers who are (their time
permitting of course) willing to respond.  Some of the regulars are: Alan
Moore, Rich Halsey, James Owen, Mitch Christensen, and of course Bob
Orchard.  Please forgive me if I omitted your name.

If you're still stuck, since something usually changes in the interim, just
repost your question when Ernest returns in a week or so.

Cheers,
-JM

--------

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: JESS HomePage down?

2004-08-23 Thread Jason Morris
I think that Shital Joshi wrote:
>>> I haven't been able to access Jess Home Page for couple of days. 

As far as I know, it's been up.  The correct URL however is 
http://herzberg.ca.sandia.gov/jess

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: Correct?

2004-08-23 Thread Jason Morris
I think that Camargo Anyela wrote:
>> Is this correct?
>>
>> > code=Applet1.class
>> archive="jess.jar"
>> width=600
>> height=300>


Hi Camargo,

Talk about the tip of the iceberg only showing!  Guess I'll take a stab at
this... :-D

First, though the W3C www.w3c.org has deprecated the  tag for some
time in favor of the  tag, the new Java Runtime plug-ins seem to
support the  tag much better now.  I'm not really sure which way the
political wind is blowing on this.  All I know is that is it darn difficult
to get an applet to run in an OBJECT tag compared to an APPLET tag.

You can see the full APPLET reference at
(#1) http://www.w3.org/TR/REC-html40/struct/objects.html#h-13.4 which
clearly makes this statement.
The OBJECT tag reference is at
(#2) http://www.w3.org/TR/REC-html40/struct/objects.html#h-13.3 .

Second, if you look at link #1, it says that if the CODEBASE is not
specified (which you haven't), then it defaults to the same base URI for the
current HTML document containing the applet.  So when the browser looks for
your Applet1.class, it is going to look in the same directory containing the
HTML file containing your applet.  The ARCHIVE attribute behaves the same
way: the browser will look for jess.jar in the folder containing your HTML
document.  Ordinarily you wouldn't put all these files together like this.

Now, in order to get  tags converted to  tags that Internet
Explorer can read, it's easiest to run your HTML code through the HTML
Converter included in your JDK.  See this link
http://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/html_conver
ter.html .

To run the GUI version from your command line,

1.  Navigate to your %JAVA_SDK%\lib\bin folder and run

  java -jar htmlconverter.jar -gui

2.  Browse to a source folder (select a path or files).
3.  Set the file extensions that you want converted.
4.  Browse to a BAK folder to store original files.
5.  Click Convert...

Click here http://www.morristechnicalsolutions.com/tagtest.htm to see an
example of both tags.  In your browser, you can right-click and View Source
to grab my code.

So all that said, if you look at Jess In Action, pp.288-289, you can see why
Ernest intimates that using Jess in an applet (client-side) isn't the best
web-based implementation.  I gave up on client-side Java a long time ago a
went straight to JSP/Servlets and never looked back.

Hope this helps!
Cheers,

-JM


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: Defining an order

2004-08-24 Thread Jason Morris
I think that Sven wrote:
>> How can i modify my rule so that it really picks out the right encoding?

Hi Sven,

Bob may have already given you what you need, but here's another thought.
Try this batch file and see if it's the behavior that you want.
Note that I changed your templates a bit.

;; best.clp 
(clear)
;;(watch all) ;;you can toggle this on/off

;; Devices have multiple encodings, which have their own details.
(deftemplate device
  (slot id)
  (multislot encoding-ids)) ;; a list of encoding "id"s.

;; Acts like a "linking table" in a RDBMS
(deftemplate encoding
  (slot id)
  (slot type)
  (slot rank))

;; Returns the minimum value of a numeric list.
(deffunction min-value (?list)
  (bind ?min (nth$ 1 (first$ ?list)))
  (foreach ?n (rest$ ?list)
(if (numberp ?n) then
  (if (< ?n ?min) then
(bind ?min ?n))
 else
  (printout t "Non-numeric list" crlf)
  (return nil)))
  (return ?min))

;; Load a test factbase
(deffacts devices-and-encodings
  (device (id 1) (encoding-ids 1 3 4))
  (device (id 2) (encoding-ids 1 3 4))
  (device (id 3) (encoding-ids 2 5))
  (device (id 4) (encoding-ids 1 3 5))
  (device (id 5) (encoding-ids 2 4))
  (encoding (id 1) (type MP3) (rank 1))
  (encoding (id 2) (type RM) (rank 2))
  (encoding (id 3) (type AVI) (rank 3))
  (encoding (id 4) (type WAV) (rank 4))
  (encoding (id 5) (type AU) (rank 5))
)
;; This fires for each device in inventory, printing its best quality
encoding.
(defrule find-best-encoding-for-each-device
"For each device, print its best (lowest) encoding rank."
  (device (id ?dev-id) (encoding-ids $?enc-ids))
  (encoding (id ?id) (type ?t) (rank =(min-value $?enc-ids)))
=>
;; Get the best encoding for this device
(printout t "The best quality encoding for device id " ?dev-id " is " ?t
crlf))

(reset)
(run)
;;==

Jess prints out...
Jess> (batch best.clp)
The best quality encoding for device id 5 is RM
The best quality encoding for device id 3 is RM
The best quality encoding for device id 4 is MP3
The best quality encoding for device id 2 is MP3
The best quality encoding for device id 1 is MP3
5
Jess>


Hope this helps!
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: calling defclass from Java behavior verification

2004-08-24 Thread Jason Morris
I think that PierceJ wrote:
>>It appears I must first call Rete.defclass(...)  BEFORE loading the rules
file.  What I am seeing is a
>>deftemplate is created when the rules file is loaded.

Hi Pierce,
You may be violating the Zen Of Jess
http://herzberg.ca.sandia.gov/jess/zen.shtml here. :-D

The Rete.defclass method is intended for creating a deftemplate of a
JavaBean to be "shadowed" in working memory as a "shadow fact".  Note that
the private fields of a JavaBean correspond to the slots in a shadow-fact,
and that Jess is expecting your class to be like a JavaBean (proper field
names, getters and setters, etc. so that Jess can use reflection to "read"
the bean) -- you certainly shouldn't pass Rete.defclass an Integer and
expect this to work.

Once Jess "knows" how to store your bean as a fact, then you can use that
deftemplate to add shadow-facts to working memory using Rete.definstance.
If you really want to try this via the API now, I recommend reading Jess In
Action section 6.5 or click here
http://herzberg.ca.sandia.gov/jess/docs/61/language.html#definstance_facts
and work through the examples.  If you do that, I'll be happy to hack
through some examples with you afterward.

IMHO - You're always better off learning Jess from the command line using
the Jess language before trying to program Jess's API directly.  Why?
Because you'll develop a better feel for when it's more efficient to write
Jess script, when to program the API itself, or when to integrate the two.
This flexibility is what separates Jess from other rule languages and
shells.

Hope this helps!
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: if rule

2004-08-24 Thread Jason Morris
I think that [EMAIL PROTECTED] wrote:

>>I am wondering if there is another way to make a rule other than the
if-then-else format I can think of for my program.

Hi,

Looking at your expressions, I'm not following what you're trying to do.
Consider for example the line:

  (if (eq ?pd1 ?pd2) (eq ?pd2 ?pd3) (neq ?pr1 ?pr2)  ... )

You're saying "if pd1==pd2 AND pd2==pd3 AND pd1!=pd2" which is illogical.
If the first expression evaluates to TRUE, then the third one will NEVER be
TRUE.

I'm going with my gut on this one and say that you may be violating the Zen
Of Jess
http://herzberg.ca.sandia.gov/jess/zen.shtml here. :-D

Would you please describe for the group what your goal is so that we can
better assist you.

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: calling defclass from Java behavior verification

2004-08-25 Thread Jason Morris
I think that PierceJ wrote:

>>It's obvious then you must define your classes to Jess before loading the
rules.
Indeed.  Glad that you figured it out.  I'm a big fan of self-reliance.

>>I regularly use the command line, Web references & forum, and have
practically wore the cover off my JIA.
As I've often stated, my JIA is now held together with duct tape and a
rubber band.  I cracked the binding after the first three months (Dover
publishing is about the only publisher that I know of that sews the
paperback pages in "signatures" then glues them to the spine so that this
doesn't happen)!

BTW - as an exercise, you might want to try what you just did with the API
from the command line using just the Jess language, and see which one is
easier to do.

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: Defining an order

2004-08-25 Thread Jason Morris
I think that Sven wrote:
>>that's also exactly what I tried to realize. I thought it could be shorter
;-)

Hi Sven,

Like I said, I'm just "holding down the fort" here. :-D   I'm glad that my
solution helped you out -- I'm sure there are several good ways to do it.

If you want the one-line solutions, you have to wait for Ernest to return!
;-)

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: if rule

2004-08-25 Thread Jason Morris
I think that Holly wrote:
>> Sorry for the confusion caused. My objective is to find a better way of
making a rule,
>> a much much shorter rule than what I have right now.

Hi Holly,
No need to apologize... we're all here to learn!

Let's agree to be very specific here regarding notation, symbols, and
operations so that we can understand each other.  For example, it makes a
difference if you really mean that each variable -- in this case, your ?pd,
?pr, ?m, and ?add -- is restricted to *one* of three discrete values like...

  x is an element of the set {x1, x2, x3}
  y is an element of the set {y1, y2, y3}
  u is an element of the set {u1, u2, u3}
  v is an element of the set {v1, v2, v3} ...and so forth.

A true "set" does not allow duplicate values, so x1 will never == x2 or x3.
In fact, x1 will always != x2 and != x3.

Now, if instead you mean that x, y, u, and v are "lists", then we can use an
array that holds three values (we'll assume of the same type) like...

  X = [x1, x2, x3]  Y = [y1, y2, y3]  U = [u1, u2, u3]  V = [v1, v2, v3]

This will in turn dictate what structure our facts should take. :-D  See
where I'm going with this?  If the data structures that we chose to model
our problem space are incorrect, then the rules that we write will be no
better.  If we find ourselves writing humongous, "Give-Ernest-An-Aneurysm"
size rules, then maybe we should do a reality check about our data (since
after all facts do drive the rules, right? ;-D ) and our over-all approach
to the problem.

So let's try this:
Give us the high-level problem context with no implementation details, just
the "what" and "why" of your program, and then I think that we'll get some
traction.  :-D

Cheers,
Jason

FWIW - Since my undergrad days, I still adhere to a rigorous, yet simple
methodology for writing algorithms and solving abstract problems.  I write a
one page sheet that looks like this...

==
  GIVEN: State what initial data, facts,
 parameters you currently know --
 all known input (quantity and type).

  FIND:  State explicitly what output
 (quantity, type, format) you are
 trying to produce, calculate, or
 solve for.

  APPROACH:  Describe step by step how you will
 use what you are given and what else
 you know about the problem type to
 output the desired answer.
======

Perhaps this might help give us the Big Picture better.  :-D


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: if rule[correction]

2004-08-25 Thread Jason Morris
Holly,

I just noticed that you originally had 
  (if (eq ?pd1 ?pd2) (eq ?pd2 ?pd3) (neq ?pr1 ?pr2)  ... ), 

not the 

  if pd1==pd2 AND pd2==pd3 AND pd1!=pd2 as I replied originally.  

Sorry about that!
Still, my second reply holds.

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: if rule [code and output]

2004-08-26 Thread Jason Morris
I think Holly wrote:
>> Hope this will make my problem more clear.

Ah ha!  :-D  Now we're getting somewhere!

So, if I understand you right, we have that

  (1) mixing_formula = f(pd, pr, m, add)  and
  (2) equation = f(weight, pH, mixing_formula)

In (1), I'm not seeing where it's relevant that a function argument is *not*
present (e.g., pd == nil), only that it *is* present.  In other words, if I
enter in the parameters x, y, u, v of different types and most likely
values, then there is no sense comparing them since they can never be equal
(5 oranges will never equal 3 apples), right?  And there is no sense testing
if input values don't exist, since I assume that they are all required,
right?  So, what we're really talking about is a mapping of your input data
to a particular mixing-formula type.

Precisely because you can reduce this problem to an algorithm (as you nicely
did below) strongly indicates that you don't really need rules to find a
solution.  I even think that you mentioned that there is a 1:1
correspondence between what equation is chosen and what the conditions are.
If this is the case, just map all the input conditions vs. the equations
into a HashMap, and then write code to look up the correct one when you run
your program.

Now, if you really want to use rules, you ought not start by writing one
monolithic rule that tries to encompass all possibilities, but rather write
a rule for each possibility -- much easier to maintain and test.  Since
there appears to be an algorithm to construct each rule, that suggests that
we might be able to automate the generation of the rules so that we don't
have to write each one by hand.  Jess has the (eval) and (build) functions
to construct Jess code on-the-fly.

What we need then is a way of having Jess automatically generate all the
possible combinations of {pd, pr, m, add} that result in a valid
mixing_formula and just load them for us.  Since you have 3 values for each
of the 4 variables, this will result in (3)^4 = 81 rules -- better than 200
if my assumptions are OK.  If you have some insights into how to select the
formulas (e.g., how they are grouped according to input combinations), we
can obviously collapse these rules further.

I've attached my try at the code and the output.  Hopefully they will give
your some hints as to how to proceed.
Let me know how it goes!  If the attachments don't come through, email me at
my address.

Cheers,
Jason



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


build.clp
Description: Binary data
(defrule choose-formula-1 ?f <- (input-state (id ?id) (pd pd1) (pr pr1) (add add1) (m 
m1)) => (use-formula ?id))

(defrule choose-formula-2 ?f <- (input-state (id ?id) (pd pd1) (pr pr1) (add add1) (m 
m2)) => (use-formula ?id))

(defrule choose-formula-3 ?f <- (input-state (id ?id) (pd pd1) (pr pr1) (add add1) (m 
m3)) => (use-formula ?id))

(defrule choose-formula-4 ?f <- (input-state (id ?id) (pd pd1) (pr pr1) (add add2) (m 
m1)) => (use-formula ?id))

(defrule choose-formula-5 ?f <- (input-state (id ?id) (pd pd1) (pr pr1) (add add2) (m 
m2)) => (use-formula ?id))

(defrule choose-formula-6 ?f <- (input-state (id ?id) (pd pd1) (pr pr1) (add add2) (m 
m3)) => (use-formula ?id))

(defrule choose-formula-7 ?f <- (input-state (id ?id) (pd pd1) (pr pr1) (add add3) (m 
m1)) => (use-formula ?id))

(defrule choose-formula-8 ?f <- (input-state (id ?id) (pd pd1) (pr pr1) (add add3) (m 
m2)) => (use-formula ?id))

(defrule choose-formula-9 ?f <- (input-state (id ?id) (pd pd1) (pr pr1) (add add3) (m 
m3)) => (use-formula ?id))

(defrule choose-formula-10 ?f <- (input-state (id ?id) (pd pd1) (pr pr2) (add add1) (m 
m1)) => (use-formula ?id))

(defrule choose-formula-11 ?f <- (input-state (id ?id) (pd pd1) (pr pr2) (add add1) (m 
m2)) => (use-formula ?id))

(defrule choose-formula-12 ?f <- (input-state (id ?id) (pd pd1) (pr pr2) (add add1) (m 
m3)) => (use-formula ?id))

(defrule choose-formula-13 ?f <- (input-state (id ?id) (pd pd1) (pr pr2) (add add2) (m 
m1)) => (use-formula ?id))

(defrule choose-formula-14 ?f <- (input-state (id ?id) (pd pd1) (pr pr2) (add add2) (m 
m2)) => (use-formula ?id))

(defrule choose-formula-15 ?f <- (input-state (id ?id) (pd pd1) (pr pr2) (add add2) (m 
m3)) => (use-formula ?id))

(defrule choose-formula-16 ?f <- (input-state (id ?id) (pd pd1) (pr pr2) (add add3) (m 
m1)) => (use-formula ?id))

(defrule choose-formula-17 ?f <- (input-state (id ?id) (pd pd1) (pr pr2) (add add3) (m 
m2)) => (use-formula ?id))

(defrule choose-formula-18 ?f <- (input-state (id ?id) (pd pd1) (pr pr2) (add add3) (m 
m3)) => (use-formula ?id))

(defrule choose-formula-19 ?f <- (input-state (id ?id) (pd pd1) (pr pr3) (add add1) (m 
m1)) => (use-formula ?id))

(defrule 

RE: JESS: if rule

2004-08-26 Thread Jason Morris
I think that Holly wrote:
>>Thank you very much.  I am working on it right now and very hopeful.

Hi Holly,
You're welcome!  Let me know how it works out for you.
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]




JESS: Is JESS the right tool? [fwd from moderator-jess-users from Rich Halsey]

2004-08-26 Thread Jason Morris
You may hate my answer, but here it goes.  What you are asking about is
definitely possible to do.
First you already have the schemes, the data, and the actors persisted in a
storage.  Second, you already have a system that works (in whatever way it
was intended to).  Third, the challenge is to understand how rule-based
systems can be employed to accomplish something on a Match-Evaluate-Act
basis.

The approach that I would most likely take is to view the design as a
dynamically configurable system, i.e., the rules are not statically written,
but use other (parameter) objects to define object attribute values to test
the actual data object that has been matched on.

Actually, the parameter objects can hold attribute names and Java reflection
can be used to discern the actual attribute and then use the attribute value
for conditional testing.   Where you are using an object-oriented rules
engine (which JESS supports), polymorphism also comes into play in your
design and must be accounted for.  This can be beneficial (and also
dangerous if you don't understand how it is working in the rules).

The concept of forward-chaining may also be part of the effects in your
system.  This necessitates a THOROUGH understanding of how the rule engine
works BEFORE you begin to build anything.  If you have forward-chaining in
your rules, don't need it, and don't understand why it is happening then you
will probably think "the lunatics are running the asylum", get discouraged
and give up.

My advice is this: (1) buy the author's book "Jess in Action", read it
multiple times, (2) buy the book "Business Rules Applied" by Barbara Von
Halle to gain an understanding of how to engineer a rule-based system, (3)
build some simple prototypes, and (4) hire a rules engineer who can
demonstrate expertise (with sample programs) that is related to your
problem.  If the rules engineer can "talk the talk" but cannot "walk the
walk" then keep looking ! Doin' rules ain't easy - but you'll be amazed at
the awesome power of rules (when they are done correctly).

Rich Halsey







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: note from moderator on HTML messages

2004-08-26 Thread Jason Morris
Hi All,

As Ernest has pointed out before, it's best if you post to the Jess listserv
in plain text format, not HTML.

Two immediate reasons are that not everyone has HTML email readers and that
some recent HTML postings have been inadvertently filtered by the listserv
approval script.

Thanks for complying so that we don't miss your posts.

Cheers,
-JM

----

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: Jess In Action code sample [from moderator jess-users]

2004-08-26 Thread Jason Morris
I think that Nicolas wrote:
>>... the code sample is not included.  Does anybody know where I can get it
?

Hi Nick,

Just go to
http://www.manning.com/catalog/view.php?book=friedman-hill&item=source and
answer the question.

If you have trouble, send me the name of the math teacher in section 1.1 of
your e-book, and I'll send you the source code.
I think that Ernest would prefer it that way.
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]




JESS: Not Jess but...i need help !

2004-08-28 Thread Jason Morris
I think that Mong-Thao La wrote:
>>i have following method in java code:
>>public String getVerificationDescription(String verificationID) {
>>   if(verificationID.equals("Knicknachweis"))
>>return "Test" ;
>>}

>>I will not work !
>>It is not a big problem, but i can not find the error.


Hi Mong-Thao,
Well, while this most definitely a basic Java question and *not* a Jess
question, Ernest does follow an unwritten Hippocratic Oath about such
matters.

So...

The problem is that your code does not account for what happens if
verificationID is *not* equal to "Knicknachweis", so the method does nothing
if it's not equal.  Since the method must return a String, this is not going
to work.

Run this class and see if it's what you want:

// 
public class TestMethod {

public static void main(String[] args) {
// A bunch of test calls
TestMethod tm = new TestMethod();
tm.getVerificationDescription("fooBAr");
tm.getVerificationDescription("Knicknachweis");
tm.getVerificationDescription("");
}

public TestMethod() {
}

public String getVerificationDescription(String verificationID) {
StringBuffer message = new StringBuffer();

if (verificationID.equals("Knicknachweis")) {
message.append("Test");
System.out.println(message.toString() + ": Verified "
+ verificationID);
} else {
message.append("Failed!");
System.err.println(message.toString() + ": Could not verify "
+ verificationID);
}
// Only return from method in one statement
return message.toString();
}
}
// 

Output:

Failed!: Could not verify fooBAr
Test: Verified Knicknachweis
Failed!: Could not verify

Some suggestions would be:
(1) If you use an IDE like Eclipse www.eclipse.org, you will see errors like
this immediately as you write your code.
(2) Only return from your methods in one statement.  In other words, don't
have multiple return statements in your methods (if you can avoid them).
(3) Use brackets on your control statement blocks even if they only contain
one statement right now...this can always change later and it makes your
code more organized.

In the future, you may want to post this type of question to a more general
Java users group.  One that I can recommend is the one to which I belong
www.pjug.org and http://www.pjug.org/mailman/listinfo/javamail -- a very
knowledgeable and friendly bunch of folks.

Hope this helps!
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: if rule

2004-08-30 Thread Jason Morris
I think that Holly said:
>>Thank you very much. It is working and running now. I just made few
modifications to address other inputs and facts.

Hi Holly,
Hey, another satisfied customer!  You're most welcome.  :-D
I'm glad that it worked for you and that my approach made sense.
Post anytime that you need to.

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: HELP....

2004-08-30 Thread Jason Morris
I think that djordje wrote:
>>I'd like to write an expert system which would guide user to choose right
configuration of his pc.
>>Is there any demo written in Jess about this expert system???

Hi djordje,

Maybe, but what you really need is the definitive Jess reference -- Jess In
Action, http://www.manning.com/friedman-hill .
In it, you will find numerous examples and several very illustrative,
complete projects that should point you in the right direction.

As a historical reference, one of the very first commercial expert systems
was DEC's R1/XCON, which was designed to configure computing solutions.
See:
  V. E. Barker and D. E. O'Connor. Expert Systems for Configuration at
Digital: XCON and beyond. Communications of the ACM, 32(3):298-318, 1989.

A word of caution:  Writing any non-trivial expert system is a lot of
work -- in many ways more complex than other most software projects.  You
also might want to read this before you begin:
http://herzberg.ca.sandia.gov/jess/zen.shtml

Feel free to post to the group if you need more help, and best of luck on
your project.

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: Help to get it started

2004-08-31 Thread Jason Morris
I think that Jinlin Wang wrote:
>>Exception in thread "main" java.lang.NoClassDefFoundError: jess/Main

Hi Jinlin,

You need to put the full path to the actual JAR on the CLASSPATH, not just
the JESS root.
See Jess In Action p.34 for the reference.

Try...

set CLASSPATH=C:\Jess61p7\jess.jar;%CLASSPATH%

. and the problem should go away.

Also, you should be running Jess 6.1 patch 7 not patch 4.

Click on http://herzberg.ca.sandia.gov/jess/bindist/Jess61p7.zip to download
the 30-day trial binary.

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: problem using jesstab and protégé...

2004-08-31 Thread Jason Morris
I think that Bertrand.Gille said:
>>May someone helpme on a simple problem i have ?
>>The problem is fully explained at this adress (with screenshots) :
>>http://promethai.free.fr/dforum/nav.php3?page=3Dvoirsujet&boardid=3D4&p=os
tid=3D182&overcount=3D1

Hi Bertrand,

I get a moderator gold star for this one!  You guys should just simply move
your whole forum over to this listserv -- it would make it much easier to
help you! :-D

So... after hunting down your posting on your forum (your link didn't get me
there - sorry), the problem seems to be that in the highlighted line in your
Protigi editor, you have:

(MAIN::object (is-a-Poudre_p)(:NAME ?nn)(prenom ?pp))
  ^

Slot identifiers are symbols in Jess, and as such, they have a restricted
set of characters that can be used to create them.  The ":" is not one of
them.  See JIA pp. 42-43 for the reference.  My guess is that Jess is quite
rightly complaining about the : on the NAME slot.  Also, make sure that you
use proper spacing between symbols, atoms, and other Jess bits.

See if this helps!
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: function for removing deftemplate facts

2004-08-31 Thread Jason Morris
I think that Jeremic Zoran wrote:
>>I need the function that will remove all facts of specific deftemplate =
>>from Jess memory. It should be written as java function ...

Hi Zoran,

My class is attached (most of it is just a test harness).
Run it and see if this is what you want and let me know either way.
One thing that I didn't do was check if the deleted facts had children
(facts that inherited from a parent fact) -- I'll leave that for you to
code! :-D  If you're not using inheritance, then the code works fine.

Cheers!

Jason
----

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

import jess.*;
import java.util.*;

public class FactRetractor {

public static void main(String[] args) {

FactRetractor fr = new FactRetractor();
// Retract by name
fr.retractAllFactsOfType("MAIN::foo");
// Retract by reference to deftemplate object
Deftemplate deftemplate = fr.getDeftemplateByName("MAIN::bar");
fr.retractAllFactsOfType(deftemplate);
}

StringBuffer batch;
Rete engine;

public FactRetractor() {
init();
}

public Deftemplate getDeftemplateByName(String name) {
Iterator itt = engine.listDeftemplates();
Deftemplate deftemp = null;
while (itt.hasNext()) {
Deftemplate next = (Deftemplate) itt.next();
if (next.getName().equals(name)) {
deftemp = next;
}
}
return deftemp;
}

public void init() {
this.engine = new Rete();
batch = new StringBuffer();
try {
engine.watchAll();
// Get a deftemplate loaded
batch.append("(deftemplate foo");
batch.append(" (slot id)");
batch.append(" (slot data))\n");
batch.append("(deftemplate bar");
batch.append(" (slot id)");
batch.append(" (slot data))\n");
engine.executeCommand(batch.toString());
batch.setLength(0);
engine.reset();

// Generate some random facts
for (int i = 0; i < 5; i++) {
engine.assertString("(foo (id " + i + ") (data "
+ Math.random() + "))");
}
for (int j = 0; j < 5; j++) {
engine.assertString("(bar (id " + (j) + ") (data "
+ Math.random() + "))");
}

} catch (JessException jex) {
jex.printStackTrace(System.err);
}
}

public void retractAllFactsOfType(Deftemplate deftemplate) {
try {
Iterator itt = engine.listFacts();
while (itt.hasNext()) {
Fact fact = (Fact) itt.next();
if (fact.getDeftemplate().equals(deftemplate)) {
engine.retract(fact);
}
}
} catch (JessException jex) {
jex.printStackTrace(System.err);
}
}

public void retractAllFactsOfType(String qualifiedDeftemplateName) {
try {
Iterator itt = engine.listFacts();
while (itt.hasNext()) {
Fact fact = (Fact) itt.next();
if (fact.getDeftemplate().getName().equals(
qualifiedDeftemplateName)) {
engine.retract(fact);
}
}
} catch (JessException jex) {
jex.printStackTrace(System.err);
}
}
}

JESS: problem using jesstab and protégé...

2004-09-01 Thread Jason Morris
I think that Bertrand Gille wrote:
>> Thank you for the answer. (and congratulation for your gold star ;-)

Hi Bertrand,
You're welcome!  Glad that I could help.

>> I already used this kind of command in the past without any problem...
>> so i wonder why it doesn't want to work now...?

All I can say is that
http://herzberg.ca.sandia.gov/jess/docs/61/language.html#atoms clearly says
what are and what are not allowed as characters in a Jess atom (symbol).

This is what I sometimes refer to as "By The Grace Of God" programming,
meaning that what you're doing is technically or syntactically incorrect,
and but for the Grace of God causing just the right circumstances to allow
your code to compile and produce a result, it would crash to the ground in a
pile of bytes.  :-D

I've pinged Ernest on it to confirm my suspicions.

BTW - I'm assuming that the : exists in your deftemplate definition?  I
couldn't see it in the Protege screen shot.
Also, I wasn't clear if you meant that you'd found the solution to be a
capitalization error in the slot symbol in your rule.  Was that the case?

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: RE: problem_using_jesstab_and_protege

2004-09-01 Thread Jason Morris
>>I think that ejfried wrote:
> Regarding the O.P.'s original problem: what is the error you are seeing?

Hi Ernest,
Have a look at ...
http://promethai.free.fr/dforum/nav.php3?page=voirsujet&boardid=4&postid=182
&overcount=1

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]




JESS: Author of FuzzyJess Talks About AI and Java

2004-09-01 Thread Jason Morris
Hi All,

Here is my latest interview with Bob Orchard about lots of AI stuff.
http://www.devx.com/Java/Article/21848/0/page/1

DevX dropped the last part where I personally thanked Bob for all his
support -- he really bent over backwards to make my trip to IEA/AIE 2004
possible -- so THANKS AGAIN BOB!

BTW - Any good reviews would be most appreciated!
Thanks!

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: Re: Author of FuzzyJess Talks About AI and Java

2004-09-01 Thread Jason Morris
I think that Rich Halsey wrote:
>> I think the article with Bob Orchard was like a breath of fresh air -
your
>> questions were good and Bob's answers were very insightful with
absolutely
>> no hype of the subject, just the facts man !

Hey Rich,

High praise indeed!  Thanks!  I am glad that you found the piece insightful.
The time is nearing when I will be picking your brains too on all your
experience, so be ready.  :-D

BTW - Don't forget to give it a review rating ;-)  Keeps my editor happy!

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: Muilti-line comments

2004-09-03 Thread Jason Morris
Hi Ernest,
I have to agree with Ross... multiline comments would be great.  I don't
have a problem using /* ... */ , but perhaps you can provide an option based
on the current comment character (;).

Thanks,
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: Significant digits

2004-09-04 Thread Jason Morris
I think that Holly wrote:
>>How can I reduce the number of significant digits in the result of a
function?

Hi Holly,
In the java.text package, you can use the java.text.DecimalFormat class to
format your numbers.
One way to do it would be this little function:

;; = format.clp
(clear)
;; formatNumber (Double ?n int ?decimals)
(deffunction formatNumber (?n ?decimals)
"Returns a formatted floating point number of specified decimal places."
  (import java.text.DecimalFormat)
  ;; You can change the pattern to whatever you want here.
  ;; See the java.text.DecimalFormat javadocs for details.
  ;; I'm just borrowing similar terms to constructing rules -- so don't be
confused.
  (bind ?patternLHS "#,##0.")
  (bind ?patternRHS "-#,##0.")
  (bind ?digit 0)
  (while (< ?digit ?decimals)
(bind ?patternLHS (str-cat ?patternLHS "0"))
(bind ?patternRHS (str-cat ?patternRHS "0"))
(bind ?digit (+ ?digit 1)))
  (bind ?pattern (str-cat ?patternLHS ";" ?patternRHS))
  (bind ?df (new DecimalFormat ?pattern))
  (bind ?bf (new StringBuffer (?df format ?n)))
  (return (?bf toString)))

;; Test code
(printout t "PI to four places is : " (formatNumber (pi) 4) crlf)
(printout t "PI to ten places is : " (formatNumber (pi) 10) crlf)
;; Notice how it will do correct rounding
(printout t "-0.034524 to 2 places is : " (formatNumber -0.034524 2) crlf)
(printout t "-0.036424 to 2 places is : " (formatNumber -0.036424 2) crlf)
;; =

. and Jess happily prints out:

Jess> (batch format.clp)
PI to four places is : 3.1416
PI to ten places is : 3.1415926536
-0.034524 to 2 places is : -0.03
-0.036424 to 2 places is : -0.04
Jess>

Pehaps there is a simpler way that I'm overlooking, but this came to mind
first.
In any case, remember that Jess does what it does best: processing rules and
facts.
You always have the entire Java API at your disposal from Jess for the
mundane chores!

Hope this helps!
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: FW: JESS: Reading data on file [code + notes]

2004-09-16 Thread Jason Morris
Hi All,

Regarding my last post:  Many of your anti-virus programs are choking on my
code attachment (perhaps because of the included JAR file).  I scan all my
out-bound attachments, so I assure you that they are safe.  If the
attachment didn't come through for you and you would like it see it, please
email me directly.

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: Problem with defquery

2004-09-17 Thread Jason Morris
I think that Zoltan wrote:
>>I am trying to use a defquery in RHS of a rule, but for some
>>reason it returns an empty iterator only... What could be the reason?

Hi Zoltan,

I looked at your code, and the main problem that I see is the line:

  (bind ?it (run-query find-threshold '?eventSource')) ;; this won't find
anything! :-D

You are passing the argument to the (defquery find-threshold) as a string
and not a variable as expected.

Also, have you defined deftemplates elsewhere for the RawEvent and
BaseServiceObject facts?
In your rule as coded, Jess complains that these are ordered facts, and it
doesn't like that you've added slots to them.

BTW - One thing that I learned early was that defqueries, while powerful,
can be easily abused.  If I found myself wanting to  procedurally iterate
over a collection of facts rather than let a rule pick them off one by one,
then I was usually violating my Zen of Jess
http://herzberg.ca.sandia.gov/jess/zen.shtml .  I suspect that Ernest will
ask you, "Why aren't you letting the rule do this for you?".

So, if you have to do it this way, I'd suggest wrapping it in a function
call rather than cram all that code into the RHS of your rule.  I poked
around with this but quickly realized that I can't offer you any meaningful
working code unless I know more about your deftemplates and what your
application is supposed to do.

Hope this all helps!

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]




JESS: RE: Reading Excel files in Jess

2004-09-18 Thread Jason Morris
I think that Holly wrote:
>>It is running very well. Thank you very much.

No problem!  Glad to be of service.

>>I noticed that the order of reading and appending values is not the same
as the order of values in a row in the excel file.

Correct. If you think of a spreadsheet as a 2x2 array, where the rows are
indexed by i and the columns are indexed by j, then you're right to expect
the more typical algorithm:

for (int i = 0; i < number_of_rows; i++) {
  for (int j = 0; j < number_of_columns; j++) {
// cellValue =  Get cell (i,j)
// do something with the cellValue
  } // next column
} // next row

I could have done this with POI, but for your problem the order in which the
data was read didn't matter since we were calculating averages and stdevs.
In that case, it was more economical to have POI return a Java Iterator over
the rows and then a cell Iterator for each row.  The order of the elements
in a Java Iterator is not guaranteed.  What I was envisioning was that you'd
run (deffunction process-file) first to set working memory, then do (reset)
and (run) to let your further processing rules operate on the result facts.
In that case, assertion order shouldn't matter.

>>...is it because of the way the "append" function is written?

The little (deffunction append) I tossed in there was probably redundant
given my claim above.
I just like programming in Jess and got carried away -- what can I say?  :-D

>>...what if I want to calculate the average and standard deviation of a
specific row only.
To modify (deffunction process-data) to process a particular row...

Sure.  One way to do it would be to modify (deffunction process-data) like
this:

(deffunction process-data-by-row-name (?file ?label)
"Asserts (result) fact contain the computations for a named Excel row."
  (import org.apache.poi.poifs.filesystem.POIFSFileSystem)
  (import org.apache.poi.hssf.usermodel.HSSFWorkbook)
  (import org.apache.poi.hssf.usermodel.HSSFSheet)
  (import org.apache.poi.hssf.usermodel.HSSFRow)
  (import org.apache.poi.hssf.usermodel.HSSFCell)
  (import java.io.*)

  (bind ?file (new File ?file-path))
  (bind ?fs (new POIFSFileSystem (new FileInputStream ?file)))
  (bind ?wb (new HSSFWorkbook ?fs))
  (bind ?sheet (?wb getSheetAt 0))
  (bind ?row-itt (?sheet rowIterator))
  (bind ?this-label "")
  (bind ?rowIsValid FALSE) ;; Just a check for bad labels

  ;; Iterate over the rows to find the labeled row
  (while (?row-itt hasNext)
(bind ?row (call ?row-itt next))
(bind ?cell (?row getCell 0))
(bind ?this-label (?cell getStringCellValue))
(if (eq ?this-label ?label) then (bind ?rowIsValid TRUE)))

  ;; If the data row does exist then process it
  (if (eq ?rowIsValid TRUE) then
(bind ?values (create$))
(bind ?cell-itt (?row cellIterator))
(while (?cell-itt hasNext)
  (bind ?cell (call ?cell-itt next))
  (if (eq (?cell getCellType) (get-member HSSFCell CELL_TYPE_NUMERIC))
then
(bind ?values (append (?cell getNumericCellValue) ?values
  (assert-result-fact ?label ?values) else
  (printout t "Data row " ?label " could not be found!" crlf)))

;; Program
(watch all) ;; Need this to see the fact get asserted :-D
(reset)
(bind ?file-path "C:/Jess61p7/data.xls")
(process-data-by-row-name ?file-path "mach1")
(process-data-by-row-name ?file-path "Bob")

And Jess will printout:
 ==> Focus MAIN
 ==> f-0 (MAIN::initial-fact)
 ==> f-1 (MAIN::result (label "mach1") (ave 3.595) (stdev
0.20424658299875345))
Data row Bob could not be found!

Phew!

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




  1   2   3   >