Michael,

Let me try to clarify a bit more. I did miss an error in
your original example.

(defrule if-load-high-then-do-something
   (currentLoad ?t&:(fuzzy-match ?t ?*resource-load* ))
   =>
   (printout t "rule ´high´ fired.")
   (assert (output (new nrc.fuzzy.FuzzyValue ?*redelegation-capacity* 
"very high")))
   )

The problem here is that in the (fuzzy-match ?t ?*resource-load*)
the ?t needs to be a fuzzyValue. This is what I was trying to 
help with in my previous message, focussing on taking the
crisp value matched by the ?t and 'fuzzifying' it. I failed to
notice that ?*resource-load* was not a fuzzyValue or a
'fuzzy expression'. I assume it is a fuzzyVariable which
describes the currentLoad concept (name of the concept,
terms, range of values, etc.).

So if we were trying to create a rule written in 
simple english as:

        IF current load is high
        THEN output is very high

we'd do something like:

(defrule if-load-high-then-do-something
   (currentLoad ?t&:(fuzzy-match (fuzzify ?t) "high"))
   =>
   (printout t "rule ´high´ fired.")
   (assert (output (new nrc.fuzzy.FuzzyValue ?*redelegation-capacity* 
"very high")))
   )

Where the fuzzify function might (in a very simplified
form) look like:

(defunction fuzzify (?t)
  (new nrc.fuzzy.FuzzyValue ?*resource-load* 
       (new nrc.fuzzy.TriangleFuzzySet (- ?t 0.01) ?t (+ ?t 0.01))
  )
)

Note that the fuzzify function is OK but could fail. First it
assumes you are creating fuzzy values for the resource load
concept. Second the resource load concept has been described 
using a universe of discource (min and max values for the 
load). So if the minimum value were 0.0 and the value for the 
current load was < 0.01 then we'd be trying to create a 
triangular fuzzy set with the lower value of the triangle less than 0.0 
(e.g. ?t-0.01) and we'd get a range exception during the 
creation of the FuzzyValue. So what I was suggesting previously is
that we generalize the fuzzify function to take as arguments,
the value plus the FuzzyVariable and the 'error' of the value. 
The function would return a fuzzyValue and would check for 
the out of range posibility, modifying the shape of the
fuzzySet generated if the value was too close to the upper 
and lower limits of the FuzzyVariable.

I hope this is a bit clearer now. Below I have included a
simple example that does something similar to what you are trying
to do.

Regards, Bob.

;;;************************* example start ***********************
;; TestJess.clp
;;
;; A simple example to test a complete FuzzyJess program (no Java code at
all).
;;
;;
;; Note: future versions (beyond 5.0a5) of Jess will allow us to use --
;;
;;             (new FuzzyValue ... )
;;       etc.
;;
;;       will no longer always need to fully qualify the classes!
;;
;; Example as shown will give result ...
;;
;; Jack is tall with degree (similarity) 0.5363321799307958
;; Jack is tall with degree (match) 0.588235294117647
;; Randy is tall with degree (similarity) 1.0
;; Randy is tall with degree (match) 1.0
;; Ralph is tall with degree (similarity) 0.4117647058823532
;; Ralph is tall with degree (match) 0.49999999999999994

;; fuzzyVariable to represent the 'height' concept
(defglobal ?*heightFvar* = (new nrc.fuzzy.FuzzyVariable "height" 0.0 10.0
"feet"))

(defglobal ?*rlf* = (new nrc.fuzzy.RightLinearFunction))
(defglobal ?*llf* = (new nrc.fuzzy.LeftLinearFunction))

;; 'person' facts have a name and a height
(deftemplate person
   (slot name)
   (slot height)
)

;; Rule 'init' completes the definition of the "height" fuzzyVariable
;; adding some terms that can be used to describe "height"
;; and defines a few people with their specific heights (note that these
;; people have a crisp height and that the height is 'fuzzified'
;; using a PI shaped fuzzySet
(defrule init 
   (declare (salience 100))
  =>
   (load-package nrc.fuzzy.jess.FuzzyFunctions)
   (?*heightFvar* addTerm "short" (new nrc.fuzzy.RFuzzySet 0.0 5.0 ?*rlf*))
   (?*heightFvar* addTerm "medium" (new nrc.fuzzy.TrapezoidFuzzySet 4.0 4.8
5.5 6.0))
   (?*heightFvar* addTerm "tall" (new nrc.fuzzy.LFuzzySet 5.5 6.0 ?*llf*))

   (assert (person (name "Ralph")
                   (height (new nrc.fuzzy.FuzzyValue ?*heightFvar*
                                (new nrc.fuzzy.PIFuzzySet 5.7 0.1)))
           )
           (person (name "Timothy")
                   (height (new nrc.fuzzy.FuzzyValue ?*heightFvar*
                                (new nrc.fuzzy.PIFuzzySet 4.0 0.1)))
           )
           (person (name "Randy")
                   (height (new nrc.fuzzy.FuzzyValue ?*heightFvar*
                                (new nrc.fuzzy.PIFuzzySet 6.5 0.1)))
           )
           (person (name "Jack")
                   (height (new nrc.fuzzy.FuzzyValue ?*heightFvar*
                                (new nrc.fuzzy.PIFuzzySet 5.75 0.1)))
           )
   )
)

;; a rule to identify the tall people and their 'degree' of tallness
;; Note that in this case ?ht matches a fuzzyValue
(defrule identify-tall-people
   (person (name ?n) (height ?ht&:(fuzzy-match ?ht "tall")))
 =>
   (printout t ?n " is tall with degree (similarity) "
(fuzzy-rule-similarity) crlf)
   (printout t ?n " is tall with degree (match) " (fuzzy-rule-match-score)
crlf)
)

;;(batch  "f:\\testjess.clp")

;;;************************* example end *************************

-----Original Message-----
From: Michael Schillo [mailto:[EMAIL PROTECTED]]
Sent: January 6, 2002 11:58 AM
To: [EMAIL PROTECTED]
Subject: RE: JESS: FuzzyJess: fuzzyfication?


On 02.01.2002 you wrote about "RE: JESS: FuzzyJess: fuzzyfication?":
>Michael,

Bob,

>The process usually involves:
>
>1 fuzzify your crisp value
>2 do some fuzzy inferencing
>3 defuzzify
>
>All you are missing is the process of fuzzifying the
>crisp value. There are many ways to do this, depending
>on what your crisp value represents and the 'error'
>or accuracy of it. For example if the crisp value is a
>temperature reading then when you fuzzify it you might
>want to represent the inherent inaccuracy of the
>temperature sensor (e.g. from t-deltaT to t+deltaT).

Ack.

>Then a simple way to do this is:
>
>;; assume the crisp value is stored in the fact
>;; (currentLoadCrisp ?x) and we have a rule to fuzzify
>;; the crisp value
>
>(defrule loadFuzzify
>   (currentLoadCrisp ?x)
>  =>
>   (assert
>     (currentLoad
>       (new FuzzyValue ?*loadFuzzyVar* (new PIFuzzySet ?x 0.1))))
>)

ok. but I do not have a fuzzyvalue ?*loadFuzzyVar*... using 
?*resource-load* yields an error:
Jess reported an error in routine fuzzy-match while executing 
(fuzzy-match ?t ?*resource-load*) while executing rule LHS (MTEQ) 
while executing rule LHS (MTELN) while executing rule LHS (TECT) 
while executing (assert (currentLoad (new nrc.fuzzy.FuzzyValue 
?*resource-load* (new nrc.fuzzy.PIFuzzySet ?x 0.1)))) while executing 
defrule loadFuzzify while executing (run).
   Message: Requires 2 arguments (both FuzzyValues or 1 a FuzzyValue 
and 1 a valid linguistic expression) .

I guess I need more help on this constructor?

>;; OR could do it in the existing rule
>
>  (defrule if-load-high-then-do-something
>     (currentLoad ?t&:(fuzzy-match (fuzzifyLoad ?t) ?*resource-load* ))
>     =>
>     (printout t "rule ´high´ fired.")
>     (assert (output (new nrc.fuzzy.FuzzyValue ?*redelegation-capacity*
>  "very high")))
>     )

Thanks for your detailed help on the second approach, but at the 
moment this is beyond me..

Thanks a lot so far,

Michael
-- 
DFKI Multi-Agent Systems Group
Stuhlsatzenhausweg 3, Geb. 43.8, D-66123 Saarbruecken
http://www.virtosphere.de/schillo   Fon: +49 681 302 4578

[EMAIL PROTECTED] is the moderated forum for DAI research in Germany.
See http://vki.first.gmd.de/group/mailing.shtml

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

Reply via email to