JESS: Multislot problem

2004-08-17 Thread Mehta, Chirag (IT)
Title: Multislot problem




Hello,


I am having a slight problem which is really really bugging me:


I have this rule:


(defrule bondMVMaxPCOutstanding::calcifnc

(declare (auto-focus TRUE))

(rulesfired (rules bondMVMaxPCOutstanding))

?b - (grouped-facts (partitionname cusip)

   (summationvalue ?mv)

   (partitionvalue ?c)

   (factcollection $?fc:(MAIN::checkifcontains productType CVBND $?fc)))

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

(test ( (bondMVMaxPCOutstanding::compliant ?mv 1.0) ?*bondMVMaxPCOutstandingValue*))

 =

. . . . . etc



Which uses this function:


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

returns the fact with the particular details

(foreach ?fact ?col

  (if (eq (str-compare (call ?fact getSlotValue ?detail) ?value) 0) then

   (bind ?f ?fact) else 

   (return 0))

   )

(if (exists ?f) then  

 (return ?f) else

  (return FALSE))

 )


?fact - (MAIN::findwherecontains productType CVBND ?fc) in the rule always stops the rule from activating. I do not understand why. 

Factcollection is a multifield of facts. I want to retrieve the fact where productType is CVBND.

(MAIN::checkifcontains productType CVBND ?fc) succeeds so there is one in the slot, but the above line does not work. 


Any idea,


Thanks in advance for your help!



Chirag







NOTICE: If received in error, please destroy and notify sender.  Sender does not waive confidentiality or privilege, and use is prohibited.



AW: JESS: Multislot problem

2004-08-17 Thread Lars Hübner








I think Chirak wrote:

?fact -
(MAIN::findwherecontains productType CVBND ?fc)
in the rule always stops the rule from activating. I do not understand why.



Is it possible it stops because
youve forgotten to enter the $ in front of the ?fc-multislot-variable?



Lars Hübner



FH Albstadt-Sigmaringen

Institut für angewandte Forschung

Tel.:
07431/579-440

Fax.:
07431/579-439

E-Mail: [EMAIL PROTECTED]

Internet: http://www.hs-albsig.de/iaf










RE: JESS: Multislot problem

2004-08-17 Thread Mehta, Chirag (IT)



Hello,

I have tried it with $?fc with no luck. I have 
eventually figured out that if I don't use ?fact but in its place (MAIN::findwherecontains productType 
CVBND ?fc) it works fine but I do not know 
why!

Chirag


From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf Of Lars 
HübnerSent: 17 August 2004 14:41To: 
[EMAIL PROTECTED]Subject: AW: JESS: Multislot 
problem


I think Chirak 
wrote:
?fact - 
(MAIN::findwherecontains productType CVBND ?fc) in the rule always stops 
the rule from activating. I do not understand why.

Is it possible it stops 
because you've forgotten to enter the '$' in front of the 
'?fc'-multislot-variable?

Lars 
Hübner

FH 
Albstadt-Sigmaringen
Institut für angewandte 
Forschung
Tel.: 
07431/579-440
Fax.: 
07431/579-439
E-Mail: 
[EMAIL PROTECTED]
Internet: http://www.hs-albsig.de/iaf





NOTICE: If received in error, please destroy and notify sender.  Sender does not waive confidentiality or privilege, and use is prohibited.



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

2004-08-17 Thread bhaskar yallala
Thanks Ernest Friedman!
I removed m_name, it worked fine!
[EMAIL PROTECTED] wrote:
I think [EMAIL PROTECTED] wrote:  Is there a way to call one rule from another., instead of recreating non-similar conditions in another rule too? If you're worried about duplication on the right-hand-side of rules,you can write a deffunction, and call it on the right-hand-side ofboth rules. If you're worried about duplicate patterns: Jess noticesthis, and the duplication is removed while the Rete network is built;as long as the common patterns are the first patterns in the rule,duplicates will be shared between all rules automatically.Is it required for dynamic bean to have m_name as property and a constructor?No, of course they don't have to have a "name" property. Because Jessdoesn't construct your Beans itself, they don't even have to have adefault
 constructor.-Ernest Friedman-Hill Advanced Software Research Phone: (925) 294-2154Sandia National Labs FAX: (925) 294-2234PO Box 969, MS 9012 [EMAIL PROTECTED]Livermore, CA 94550 http://herzberg.ca.sandia.govTo 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]Thanks and regards,Bhaskar
[EMAIL PROTECTED][EMAIL PROTECTED]
		Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.

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]