📄 wxsys-25.txt
字号:
(deftemplate ff-current-cloud-cover 0 100 percent ( (clear (z 0 10)) (partly-cloudy (pi 16 25)) (cloudy (pi 15 55)) (mostly-cloudy (pi 10 70)) (overcast (s 78 90)) )) ;**********;Rule to fuzzify the current cloud cover fact.;**********(defrule fuzzify-current-cloud-cover (new-data-from-user (cloud-cover ?cover)) => (assert-string (format nil "(ff-current-cloud-cover %s)" ?cover)));**********;Template to hold the (fuzzy) earlier primary cloud base fact,;based on cloud height data given in [FOR67], pp. 389-391.;**********(deftemplate ff-earlier-primary-cloud-base 0 70 Kfeet ( (low (z 0 6.5)) (middle (pi 6.5 12)) (high (s 18 20)) )) ;**********;Rule to fuzzify the earlier primary cloud base fact.;**********(defrule fuzzify-earlier-primary-cloud-base (old-data-from-user (cloud-cover ~clear)) (old-data-from-user (primary-cloud-base $?cbase)) => (assert-string (format nil "(ff-earlier-primary-cloud-base %s)" (implode$ ?cbase)))) ;**********;Template to hold the (fuzzy) earlier primary cloud orientation fact.;**********(deftemplate ff-earlier-primary-cloud-orientation 0 10 ( (horizontal (z 1.5 7)) (vertical (s 3 9.5)) )) ;**********;Rule to fuzzify the earlier primary cloud orientation fact.;**********(defrule fuzzify-earlier-primary-cloud-orientation (old-data-from-user (cloud-cover ~clear)) (old-data-from-user (primary-cloud-orientation $?corientation)) => (assert-string (format nil "(ff-earlier-primary-cloud-orientation %s)" (implode$ ?corientation)))) ;**********;Template to hold the (fuzzy) earlier primary cloud direction fact.;**********(deftemplate ff-earlier-primary-clouds-moving-from 0 359 degrees ( (north (0 1) (11.25 .875) (22.5 .5) (33.75 .125) (45 0) (315 0) (326.25 .125) (337.5 .5) (348.75 .875) (359 1)) (northeast (pi 45 45)) (east (pi 45 90)) (southeast (pi 45 135)) (south (pi 45 180)) (southwest (pi 45 225)) (west (pi 45 270)) (northwest (pi 44 315)) )) ;**********;Rule to fuzzify the earlier primary cloud direction fact.;**********(defrule fuzzify-earlier-primary-clouds-moving-from (old-data-from-user (cloud-cover ~clear)) (old-data-from-user (primary-clouds-moving-from ?direction)) (test (neq ?direction unknown)) => (assert-string (format nil "(ff-earlier-primary-clouds-moving-from %s)" ?direction))) ;**********;Template to hold the (fuzzy) earlier cloud cover fact.;**********(deftemplate ff-earlier-cloud-cover 0 100 percent ( (clear (z 0 10)) (partly-cloudy (pi 16 25)) (cloudy (pi 15 55)) (mostly-cloudy (pi 10 70)) (overcast (s 78 90)) )) ;**********;Rule to fuzzify the earlier cloud cover fact.;**********(defrule fuzzify-earlier-cloud-cover (old-data-from-user (cloud-cover ?cover)) => (assert-string (format nil "(ff-earlier-cloud-cover %s)" ?cover))) ;**********;Template to hold the (fuzzy) current time-of-day.;**********(deftemplate ff-current-time-of-day 0 23 hours ( (morning (pi 4 5.5)) (afternoon (pi 3.5 14.5)) (evening (pi 2.5 20.5)))) ;**********;Rule to fuzzify the current time-of-day fact (a CRISP fact).;**********(defrule fuzzify-current-time-of-day (new-data-from-computer (time-of-day ?time)) => (fuzzify-fact ff-current-time-of-day ?time 0.5)) ;**********;Template to hold the (fuzzy) season fact (we assume;it was the same season 3 hours ago as now).;**********(deftemplate ff-season 0 12 month ( (winter (pi 1 2)) (spring (pi 1 5)) (summer (pi 1 8)) (fall (pi 1 11)) )) ;***********;Rule to fuzzify the season fact (a CRISP fact). We assume it was;the same season 3 hours ago as now.;***********(defrule fuzzify-season (new-data-from-computer (month ?month)) => (fuzzify-fact ff-season ?month 1.0)) ;**********;Template to hold the (fuzzy) current wind speed,;modified for simplicity from [WEL68], pp. 15.;**********(deftemplate ff-current-wind-speed 0 150 mph ( (calm (z 0 1)) (light-breeze (pi 3 4)) (gentle-breeze (pi 3 10)) (moderate-breeze (pi 4 16)) (fresh-breeze (pi 3 22)) (strong-breeze (pi 3 28)) (gale (pi 18 49)) (storm (pi 5 69)) (hurricane (s 73 80)))) ;**********;Rule to fuzzify the current wind speed fact (a CRISP fact).;**********(defrule fuzzify-current-wind-speed (new-data-from-computer (wind-speed ?speed)) => (fuzzify-fact ff-current-wind-speed ?speed 1.5)) ;**********;Template to hold the (fuzzy) current wind direction.;**********(deftemplate ff-current-wind-direction 0 359 degrees ( (north (0 1) (11.25 .875) (22.5 .5) (33.75 .125) (45 0) (315 0) (326.25 .125) (337.5 .5) (348.75 .875) (359 1)) (northeast (pi 45 45)) (east (pi 45 90)) (southeast (pi 45 135)) (south (pi 45 180)) (southwest (pi 45 225)) (west (pi 45 270)) (northwest (pi 44 314)) )) ;**********;Rule to fuzzify the current wind direction (a CRISP fact).;**********(defrule fuzzify-current-wind-direction (new-data-from-computer (wind-from ?direction)) => (fuzzify-fact ff-current-wind-direction ?direction 6.0)) ;**********;Rule to assert the current barometric pressure (nothing ;fuzzy here).;**********(defrule assert-current-barometric-pressure (new-data-from-computer (barometric-pressure ?pressure)) => (assert (current-barometric-pressure ?pressure))) ;**********;Rule to assert current relative humidity (nothing;fuzzy here).;**********(defrule assert-current-relative-humidity (new-data-from-computer (relative-humidity ?humidity)) => (assert (current-relative-humidity ?humidity))) ;**********;Template to hold the (fuzzy) earlier time-of-day.;**********(deftemplate ff-earlier-time-of-day 0 23 hours ( (night (z 3 5)) (morning (pi 4 8)) (afternoon (pi 3 15)) (evening (pi 3 20)))) ;**********;Rule to fuzzify the earlier time-of-day fact (a CRISP fact).;**********(defrule fuzzify-earlier-time-of-day (old-data-from-computer (time-of-day ?time)) => (fuzzify-fact ff-earlier-time-of-day ?time 0.5));**********;Template to hold the (fuzzy) earlier wind speed,;modified for simplicity from [WEL68], pp. 15.;**********(deftemplate ff-earlier-wind-speed 0 150 mph ( (calm (z 0 1)) (light-breeze (pi 3 4)) (gentle-breeze (pi 3 10)) (moderate-breeze (pi 4 16)) (fresh-breeze (pi 3 22)) (strong-breeze (pi 3 28)) (gale (pi 18 49)) (storm (pi 5 69)) (hurricane (s 73 80)))) ;**********;Rule to fuzzify the earlier wind speed fact (a CRISP fact).;**********(defrule fuzzify-earlier-wind-speed (old-data-from-computer (wind-speed ?speed)) => (fuzzify-fact ff-earlier-wind-speed ?speed 1.5)) ;**********;Template to hold the (fuzzy) earlier wind direction.;**********(deftemplate ff-earlier-wind-direction 0 359 degrees ( (north (0 1) (11.25 .875) (22.5 .5) (33.75 .125) (45 0) (315 0) (326.25 .125) (337.5 .5) (348.75 .875) (359 1)) (northeast (pi 45 45)) (east (pi 45 90)) (southeast (pi 45 135)) (south (pi 45 180)) (southwest (pi 45 225)) (west (pi 45 270)) (northwest (pi 44 315)) )) ;**********;Rule to fuzzify the earlier wind direction (a CRISP fact).;**********(defrule fuzzify-earlier-wind-direction (old-data-from-computer (wind-from ?direction)) => (fuzzify-fact ff-earlier-wind-direction ?direction 6.0)) ;**********;Rule to assert the earlier barometric pressure.;**********(defrule assert-earlier-barometric-pressure (old-data-from-computer (barometric-pressure ?pressure)) => (assert (earlier-barometric-pressure ?pressure))) ;**********;Rule to assert earlier relative humidity.;**********(defrule assert-earlier-relative-humidity (old-data-from-computer (relative-humidity ?humidity)) => (assert (earlier-relative-humidity ?humidity))) ;************************************************************;* MODULE: DETERMINE-CHANGES *;************************************************************(defmodule DETERMINE-CHANGES (import MAIN ?ALL) (import FUZZIFY ?ALL) (export ?ALL)) ;*****;The fuzzify-trend function, which includes bounds checking to make ;certain the produced values do not extend past the universe of;discourse----this function takes CRISP facts and fuzzifies them;for use in a fuzzy deftemplate or fuzzy fact.;;Again, reproduced from [ORC95], pp. 58.;*****;deffunction: fuzzify-trend;;Inputs: ?fztemplate - name of a fuzzy deftemplate; ?value - float value to be fuzzified; ?delta - precision of the value;; Asserts a fuzzy fact for the fuzzy deftemplate. The fuzzy; set is a triangular shape centered on the value provided with; zero possibility at (value+delta) and (value-delta). Note that; it checks bounds of the universe of discourse to generate a fuzzy; set that does not have values outside of the universe range.(deffunction fuzzify-trend (?fztemplate ?value ?delta) (bind ?low (get-u-from ?fztemplate)) (bind ?hi (get-u-to ?fztemplate)) (if (<= ?value ?low) then (assert-string (format nil "(%s (%g 1.0) (%g 0.0))" ?fztemplate ?low ?delta)) else (if (>= ?value ?hi) then (assert-string (format nil "(%s (%g 0.0) (%g 1.0))" ?fztemplate (- ?hi ?delta) ?hi)) else (assert-string (format nil "(%s (%g 0.0) (%g 1.0) (%g 0.0))" ?fztemplate (max ?low (- ?value ?delta)) ?value (min ?hi (+ ?value ?delta))))))) ;**********;Template to hold the (fuzzy) trend in the barometer.;**********(deftemplate ff-barometric-pressure-trend -4 4 inHg ;range of possible change in the barometric pressure ;(pressure ranges from 28.0 to 32.0 inches of mercury) (
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -