clips

How can I run the clips with out reset the fact when using CLIPS

房东的猫 提交于 2019-12-13 21:17:35
问题 Here is my situation: I want to run the CLIPS periodically and the system can record how many times it runs. for example: I type in the terminal "run" many times to call the system periodically. then the system can record how many the system runs and show it on the screen. Here is my .clp file (defglobal ?*lock* = 0) (deftemplate counter (slot number)) (deffacts initial_data (counter (number 0)) ) (defrule set_counter ?f<-(counter (number ?x)) (test (= ?*lock* 0)) => (bind ?*lock* 1)

How can I get the sum of items in a multislot

走远了吗. 提交于 2019-12-13 04:08:21
问题 I have a template like the one shown bellow. How can I get the sum of items in the multislot grades? (deftemplate student (multislot name) (multislot grades) ) 回答1: You can use the expand$ function. Check in the Basic Programming Guide the Multifield Expansion Function chapter to know more. (deftemplate student (multislot name) (multislot grades)) (defrule grades-sum (student (grades $?grades)) => (printout t "Student grades sum is " (+ (expand$ ?grades)))) (assert (student (grades (create$ 1

Increment or change variable each time Jess rule fires

北城以北 提交于 2019-12-13 03:32:06
问题 Is there a way to increment or change value of some variable each time rule fires? I need that for every time rule fires introduce new value of the slot, since I will use this value for connectivity in the following example: I have an electric circuit and rule that transforms delta to star. For every transform product is additional node. For simple network I have named it T, but for more complicated network I end up with network that is full of T nodes, since every time rule is triggered for

CLIPS. To count students and prinout sum

无人久伴 提交于 2019-12-13 03:25:28
问题 deftemplate: (deftemplate student (multislot fio (type SYMBOL)(cardinality 1 3)) (slot den_rozhdeniya (type INTEGER)) (slot mecyaz_rozhdeniya (type SYMBOL)) (slot god_rozhdeniya (type INTEGER)) (slot den_postupleniya (type INTEGER)) (slot mecyaz_postupleniya (type SYMBOL)) (slot god_postupleniya (type INTEGER)) (multislot data_postupleniya (type SYMBOL NUMBER)) (slot facultet (default fit)(type SYMBOL)) (slot gruppa (type SYMBOL INTEGER)) (multislot adress (type SYMBOL INTEGER)) (multislot

How to do a logical or in CLIPS?

前提是你 提交于 2019-12-13 03:08:54
问题 Updated code: where to add the check for ?f<-(practice-is-on-off OFF) (defrule no-practice "Rules for when practice cannot be held" (or ?f <- (practice (number-of-paddlers ?p&:(< ?p 6))) ?f <- (practice (number-of-coaches ?c&:(< ?c 1)))) => (modify ?f (practice-is-on-off OFF))) ;end I am defining a template in CLIPS and I am using logical operator OR. However, when I load the template, it is throwing an error saying [TMPLTDEF1] Invalid slot or not defined in corresponding deftemplate practice

CLIPS incrementing a variable with a rule

烈酒焚心 提交于 2019-12-12 19:10:00
问题 I want to increment security when the rule is run. Right now it changes nothing. The fact (human_resources n) does exist. (defglobal ? security = 0) (defrule rule1 (human_resources n) => (defglobal ? security = (+ ? security 1)) ) This results in ?*security = 1: (defglobal ? security = 0) (defglobal ? security = (+ ? security 1)) 回答1: CLIPS> (defglobal ?*security* = 0) CLIPS> (defrule rule1 (human_resources n) => (bind ?*security* (+ ?*security* 1))) CLIPS> (reset) CLIPS> ?*security* 0 CLIPS>

Checking a object property in LHS

拟墨画扇 提交于 2019-12-12 05:06:57
问题 I need to check the existence of a value for an o'bject's property in a LHS. (defrule check-property ?room <- (object (is-a ROOM)) (integerp (send ?room get-property)) ; #1 => (printout ?*debug-print* "Room " ?room " has property" crlf)) But it seems to me that #1 is not valuated in LHS. Instead if I put it in RHS, it returns TRUE. Where am I wrong? Thx, Nic 回答1: Use the test conditional element to evaluate an expression in the LHS of a rule: (defrule check-property ?room <- (object (is-a

CLIPS C code that read a value from the fact (Answer-is value) if it is known first field Answer-is?

半城伤御伤魂 提交于 2019-12-12 03:03:02
问题 I try to connect CLIPS to my C program. Set of rules will be loaded from external .clp file into CLIPS. My new C program will in fixed time intervals set new facts (example (temperature 35C)) which will represent current measurements from some temperature sensors. Then expert system will be started and make some conclusions and give necessary actions based on provided measurements. Conclusions will be in the form of facts (Answer-is x). How I can read desired fact field from CLIPS in the form

CLIPS Validate Text Entry

笑着哭i 提交于 2019-12-12 01:32:45
问题 Morning, Excuse the silly question but I am busy building a expert system much like the "21 Questions" game that uses questions asked to the user in order to determine the right dog for them. The expert system is coded in CLIPS / .CPS language and one of the requirements I am looking to include is that when the user is asked a yes/no question they are required to input "y" or "n". In all the resources we have been taught we have only been tough number validation and not a specific character

CLIPS: Finding the most common of facts based on the number of occurences

守給你的承諾、 提交于 2019-12-12 00:36:49
问题 I am new to CLIPS and I am having difficulties understanding the language. I am aware of the rather confusing title so I will try to be as clear and precise as I can. I have a base of facts represented by student entries and I want to find out which city is the most common (appears most frequent) among the enlisted students. This is my base of facts: (deftemplate student (slot name) (slot city) (slot age) (multislot subjects) (multislot grades) ) (deffacts students (student (name John) (city