clips

Clips multiple EnvEval queries invalidate previous result objects?

女生的网名这么多〃 提交于 2019-12-11 23:57:16
问题 I had a another strange problem that I solved already. But I'm not sure I just luckily fixed it or I really understand what's going on. So basically I have perform a query on my facts via: DATA_OBJECT decay_tree_fact_list; std::stringstream clips_query; clips_query << "(find-all-facts ((?f DecayTree)) TRUE)"; EnvEval(clips_environment_, clips_query.str().c_str(), &decay_tree_fact_list); Then I go through the list of facts and retrieve the needed information. There I also make another

Programmatically modify a fact slot using ClipsPy

微笑、不失礼 提交于 2019-12-11 17:08:08
问题 How to modify a fact of a template in CLIPS using ClipsPy. I have tried the reassigning slot value and sending modify in clips.build routine, (see py_modify function below) which did not work. This is the .clp file ;; KB.clp (deftemplate t (slot s_1 (type SYMBOL))) (defrule main-intent (initial-fact) => (assert (t (s_1 v_1))) ) (defrule rule_1 ?p<-(t (s_1 ?v)) => (printout t"BEFORE"crlf) (py_pfact) (py_modify ?p) (printout t"AFTER"crlf) (py_pfact) ) This is the python file.. # run.py import

CLIPS blocks world

假装没事ソ 提交于 2019-12-11 15:43:29
问题 I am trying to create a CLIPS program that will take any initial stack and rearrange it into any goal-stack. I am asserting this, but it doesn't seem to do anything. (assert (stack A B C) (stack D E F) (goal-stack D C B) (goal-stack A) (goal-stack F E)) This is my code so far: (defrule move-direct ;(declare (salience 10000)) ?stack1 <- (stack ?block1 $?bottom1) ?stack2 <- (stack ?block2 $?bottom2) (goal-stack ?block1 ?block2 $?goalbottom) => (retract ?stack1 ?stack2) (assert (stack ?block1

CLIPS Printout Number Of Times Rule Fired

半世苍凉 提交于 2019-12-11 15:33:17
问题 I have the following CLIPS construct below and I'm interested in tallying up how many times a particular rule fired so the output will be a series of the rules fired followed by their count (see picture for example). So it would be all those rules followed by: temperature: (times fired) seconds pressure: (times fired) seconds (deftemplate oil-measure (slot utc-time (type STRING)) (slot temperature (type INTEGER)) (slot pressure (type INTEGER))) (defrule oil-is-hot (oil-measure (temperature

CLIPS input taking and comparison

亡梦爱人 提交于 2019-12-11 12:56:56
问题 I need to take in input from the user which color and then output the flags that contain that color. I have this so far. I am pretty sure that the setup of my templates is correct. I just seem to be having issues with the input and the comparison and output part. Any help would be appreciated. I looked at a couple of other posts and used what I could be it still is not working. Thank you. (deftemplate country-info (slot country) (multislot color) ) ; setting the template for flags taking the

How to compare a global variable to a string in Clips?

家住魔仙堡 提交于 2019-12-11 11:47:28
问题 In my system the user inputs a Y or N to answer simple questions. I call this rule after every question to increment a counter. There are some general problems with my code but i can't see where (defrule QPain (initial-fact) => (printout t "Are You In Pain? " crlf) (bind ?*Answer* (read)) ) (defrule IncSym (test(=(str-compare (?*Answer*) "y")0)) => (bind ?*symcount* (+ ?*symcount* 1)) ) Thanks 回答1: The syntactic errors can be corrected as follows: CLIPS> (clear) CLIPS> (defglobal ?*Answer* =

CLIPS: modify-instance does not trigger pattern matching

我是研究僧i 提交于 2019-12-11 06:16:57
问题 Having a file test.clp: (defclass TestClass (is-a USER) (role concrete) (pattern-match reactive) (slot value) (slot threshold)) (definstances TestObjects (Test of TestClass (value 0) (threshold 3))) (defrule above-threshold ?test <- (object (is-a TestClass)) (test (> (send ?test get-value) (send ?test get-threshold))) => (printout t "*** Above threshold!! ***" crlf) (refresh below-threshold)) (defrule below-threshold ?test <- (object (is-a TestClass)) (test (> (send ?test get-value) (send

Aggregating Facts in the CLIPS Expert System to Find a Maximum

蓝咒 提交于 2019-12-08 13:17:27
问题 I'm trying to clarify my understanding of semantics in the Clips expert system, so I'm trying to write some simple rules to aggregate a list of facts to find the fact with the highest slot value. The metaphor I'm using is that of a simple agent trying to decide whether it should eat or sleep. Facts describing the agent's states are expanded into potential actions, and then a rule tries to find the final action with the highest utility. This is my code: (clear) (deftemplate state (slot name)

how to combine these two rules with CLIPS?

こ雲淡風輕ζ 提交于 2019-12-08 04:26:41
问题 I have two rules in CLIPS which I want to combine if they're both true...not sure how to do it though. I have an attribute which is called grant-eligible ....I was thinking if I set it to TRUE then I could read the next rule, and then set the 'grant-eligible' to FALSE ....but it seems that my code is getting into an infinite loop when I do this... So here are my rules: (defrule complete "rule for app completeness" ?f <- (application (transcript-received Yes) (app-complete FALSE) (gpa ?v_gpa&:

How to get response from .clp(CLIPS) file?

◇◆丶佛笑我妖孽 提交于 2019-12-07 17:11:08
问题 I am trying to load .clp file in my iPhone application. For that I am using below code NSString *filePath = [[NSBundle mainBundle] pathForResource:@"autodemo" ofType:@"clp"]; environment = CreateEnvironment(); char *clipsFileChar = (char *)[filePath cStringUsingEncoding:NSASCIIStringEncoding]; Load(clipsFileChar); Reset(); Run(-1); NSString *evalS = [NSString stringWithFormat:@"(find-all-facts ((?f state-list)) TRUE)"]; char * evalStr = (char *)evalS; DATA_OBJECT obj;// = {0,-1}; // obj.type