Re: JESS: Is it possible to bind a Java object directly to a Jess variable without creating a new object?

2011-11-07 Thread Donald Paul Winston
Use shadow facts.

see http://www.jessrules.com/jesswiki/view?FactsVsShadowFacts

On Nov 4, 2011, at 1:08 PM, Hunter McMillen wrote:

 Hi everyone, 
 
 I am trying to assert to Jess that an object exists when I encounter a new 
 object in my Java program. Right now I am using a template to mirror that 
 object (i.e I have slot values for all of the Java objects fields)  but this 
 seems redundant to me. Is there any way to just bind a Java object to a Jess 
 variable without creating a new Java object? 
 
 A lot of the examples I see online and from JIA are of the form:
 (bind ?map (new HashMap))
 
 or
 
 (call Classname method params...)
 
 but these either create  a new object or call static methods. I already have 
 the Java object and just want to store it.
 
 But I was hoping that there was someway I could do something like this:
 public Rete engine = new Rete();
 
 public void unitDiscovered()
 {
 Unit unit = some unit encountered; //Java object
 engine.executeCommand((bind ?unit unit));
 engine.executeCommand((assert ?unit));
 }
 
 Or would I have to use the store() and fetch() methods for this?
 
 public void unitDiscovered()
 {
 Unit unit = some unit encountered; //Java object
 engine.store(UNIT, unit);
 engine.executeCommand((bind ?unit (fetch UNIT));
 engine.executeCommand((assert ?unit));
 }
 
 Basically I want to know the best practice for binding Java objects to Jess 
 variables so I can assert them to the engine.
 
 Thanks,
 Hunter McMillen




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




Re: JESS: Jess and Clojure

2011-06-03 Thread Donald Paul Winston
cognitive dissonace ? Now I have a name for all my problems.

On Jun 3, 2011, at 10:02 AM, Ernest Friedman-Hill wrote:

 Not to mention the cognitive dissonance of working with two similar-looking 
 but uncomfortably different languages at once. 






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




Re: JESS: Re: calculating benefit costs

2011-01-09 Thread Donald Paul Winston
I found this book (Giarratanno  Riley) to be of very low value for my 
purposes. I have yet to find a decent book about rule base programming. Jess 
In Action is the only one that's been useful for me. A couple of Drools books 
I've read were ridiculous. Most AI and knowledge base books are 95% fluff.

On Jan 9, 2011, at 9:33 AM, Peter Lin wrote:

 I would recommend reading books on knowledge base
 and expert systems to get a broader understanding of rule programming.
 Most of the business rule books out there are really just user manuals
 and don't go into details on the design patterns used in expert
 systems. Gary Riley's book is a great place to start.






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




Re: JESS: Re: calculating benefit costs

2011-01-07 Thread Donald Paul Winston
So many if else statements on the RHS is unruly. 

On Jan 7, 2011, at 9:15 AM, Derek Adams wrote:

 Thanks for the help guys.  Here is what I ended up with.  This works, but I'm 
 sure it's not the most efficient way to solve the problem.
 
 (defrule setCalculatedCostGCI20k5k
 (HrBenefitJoin (hrBenefitConfigId 1-76)(benefitJoinId 
 ?bjid)(calculatedCost ?cost)(OBJECT ?obj)(coveredPersonId 
 ?cPer)(payingPersonId ?pPer)(relationshipId ?rel))
 (Person (personId ?cPer)(dob ?dob)(OBJECT ?objP))
 =
 (printout t age =  (call ?objP calcAgeAsOf(call 
 com.arahant.utils.DateUtils now ))  for  ?bjid   crlf)
 
 (if (eq ?rel nil) then
 (if ( (call ?objP calcAgeAsOf(call com.arahant.utils.DateUtils now 
 )) 30) then
 (call ?obj overrideAgeCost 11.55)
  else (if ( (call ?objP calcAgeAsOf(call com.arahant.utils.DateUtils 
 now )) 40) then
 (call ?obj overrideAgeCost 18.95)
   else (if ( (call ?objP calcAgeAsOf(call 
 com.arahant.utils.DateUtils now )) 50) then
 (call ?obj overrideAgeCost 38.35)
 else (if ( (call ?objP calcAgeAsOf(call 
 com.arahant.utils.DateUtils now )) 60) then
 (call ?obj overrideAgeCost 65.95)
   else (if ( (call ?objP calcAgeAsOf(call 
 com.arahant.utils.DateUtils now )) 70) then
 (call ?obj overrideAgeCost 104.35)
 else
 (printout t age greater than 69 ...  
 (call ?objP calcAgeAsOf(call com.arahant.utils.DateUtils now ))  for  ?bjid 
   crlf))
  else (if (neq ?rel nil) then
 (if ( (call ?objP calcAgeAsOf(call 
 com.arahant.utils.DateUtils now )) 30) then
 (call ?obj overrideAgeCost 4.20)
  else (if ( (call ?objP calcAgeAsOf(call 
 com.arahant.utils.DateUtils now )) 40) then
 (call ?obj overrideAgeCost 6.05)
   else (if ( (call ?objP calcAgeAsOf(call 
 com.arahant.utils.DateUtils now )) 50) then
 (call ?obj overrideAgeCost 10.90)
 else (if ( (call ?objP calcAgeAsOf(call 
 com.arahant.utils.DateUtils now )) 60) then
 (call ?obj overrideAgeCost 17.80)
   else (if ( (call ?objP calcAgeAsOf(call 
 com.arahant.utils.DateUtils now )) 70) then
 (call ?obj overrideAgeCost 27.40)
 else
 (printout t age greater than 69 
 ...  (call ?objP calcAgeAsOf(call com.arahant.utils.DateUtils now ))  for  
 ?bjid   crlf
 (printout t setCalculatedCostGCI function fired for  ?bjid . 
 overrideAgeCost =   (call ?obj overrideAgeCost) crlf)
 ;(printout t setCalculatedCostGCI function fired for  ?bjid   crlf)
 
 )
 
 On Thu, Jan 6, 2011 at 10:32 AM, Wolfgang Laun wolfgang.l...@gmail.com 
 wrote:
 This additional information does not require a fundamentally different 
 approach.
 
 Using the same set of facts CostEmployee/CostSpouse, we can now use
 two rules, one calculating the cost for the employee, and the other
 one for the spouse.
 
 (defrule calc-self
  ?hbj - (HrBenefitJoin (hrBenefitConfigId 1-73)
 (calculatedCost 0)
 {relationshipId  == nil}
 (payingPersonId  ?pPer)
 (coveredPersonId ?cPer) )
  (Person(personId?cPer) (dob ?dob) )
  (CostEmployee  (lo ?lo:(= ?lo (yrs ?dob)))
 (hi ?hi:(= ?hi (yrs ?dob)))(cost ?cost))
 =
  (printout t Cost for  ?cPer  paid by himself:  ?cost crlf )
 )
 
 (defrule calc-other
  ?hbj - (HrBenefitJoin (hrBenefitConfigId 1-73)
 (calculatedCost 0)
 {relationshipId  != nil}
 (payingPersonId  ?pPer)
 (coveredPersonId ?cPer) )
  (Person(personId?cPer) (dob ?dob) )
  (CostSpouse(lo ?lo:(= ?lo (yrs ?dob)))
 (hi ?hi:(= ?hi (yrs ?dob)))(cost ?cost))
 =
  (printout t Cost for  ?cPer  paid by  ?pPer :  ?cost crlf )
 )
 
 The date calculation is abstracted into a
   (deffunction yrs (?dob) ... (return ?yrs) )
 
 Implementing this in Jess or in Java is a simple programming exercise,
 but it presumably it depends on some technical/legal issues, e.g., it
 may not be possible to use today as a basis for calculating the
 difference in years from the person's dob.
 
 Since there's no information what to do with the resulting cost, it's
 just printed to standard output, but updating slot calculatedCost in
 HrBenefitJoin is straightforward.
 
 Cheers
 Wolfgang
 
 
 On 05/01/2011, Derek Adams dad...@arahant.com wrote:
  the facts that I am working with are:
 
  (HrBenefitJoin (hrBenefitConfigId 1-73)(benefitJoinId
  ?bjid)(calculatedCost 

JESS: Clojure Opinions

2010-12-30 Thread Donald Paul Winston
I'm developing a kind of expert system to perform exploratory data analysis. 
I'm using R/Rserve as a data analysis scripting language within a tomcat java 
web app along with Jess. I've recently discovered something called Incanter 
and Clojure. A statistics library for Lisp implemented on a Java VM.

Does anyone here know how well Clojure performs and interoperates with java? 
(It looks like you can invoke java classes in a similar way that Jess does)The 
Java client for Rserve is quite primitive. 

It looks like the incanter stats library might not be sufficient at the moment 
anyway.
(The stats and plotting features of R are unmatched)







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




Re: JESS: Hello To Jess User Group and How Is Jess Doing?

2010-12-30 Thread Donald Paul Winston
I think the mailing list is on vacation for the holidays. I sent one message a 
couple of days ago and it fell into a black hole.


On Dec 30, 2010, at 11:26 AM, dc tech wrote:

 Rejoining the Jess community after a multi-year hiatus and notice that the 
 mailing list has been very quiet.  I am curious to see how Jess is doing now 
 a days? Any impact from things like jBoss rules or other engines? Is the 
 community still pretty active?
 
 Happy Holidays to everyone !






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