139 views

Skip to first unread message

Feb 6, 2023, 12:14:55 AM2/6/23

to CLIPSESG

Hi. I seriously need someone's help in my project in clips. I need to create a scoring system for drilling simulator in clips. Can someone help me on this. Highly appreciated

Feb 6, 2023, 1:30:55 AM2/6/23

to clip...@googlegroups.com

On 2/5/23 20:42, shoaib ayyaz wrote:

> I need to create a scoring system for drilling simulator in clips.

I don't know what that is but did you first try reading the clips
> I need to create a scoring system for drilling simulator in clips.

documentation?

--

So many immigrant groups have swept through our town

that Brooklyn, like Atlantis, reaches mythological

proportions in the mind of the world - RI Safir 1998

http://www.mrbrklyn.com

DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002

http://www.nylxs.com - Leadership Development in Free Software

http://www2.mrbrklyn.com/resources - Unpublished Archive

http://www.coinhangout.com - coins!

http://www.brooklyn-living.com

Being so tracked is for FARM ANIMALS and and extermination camps,

but incompatible with living as a free human being. -RI Safir 2013

Feb 6, 2023, 7:56:49 PM2/6/23

to CLIPSESG

- Develop a set of use cases including sample input and output and explanations detailing how the output was derived from the input.
- Read through the available CLIPS documentation: https://clipsrules.net/Documentation.html
- Look through the example programs that come with CLIPS and others that are available on GitHub: https://github.com/search?l=CLIPS&q=CLIPS&type=Repositories
- Pick the simplest use case you have and begin implementing step by step. The problem most beginners have is writing too much code initially.

Feb 6, 2023, 8:28:50 PM2/6/23

to clip...@googlegroups.com

I wrote my doctoral dissertation in Clips.

I read an earlier edition of this text:

by Joseph
C. Giarratano and Gary
D. Riley | Oct
15, 2004

ISBN-13

978-0534384470

Still have the text in my personal library.

Many test cases.

Test small pieces, establish a foundation and then move on, move up in difficulty.

--

You received this message because you are subscribed to the Google Groups "CLIPSESG" group.

To post to this group, send email to CLIP...@googlegroups.com

For more options, visit this group at http://groups.google.com/group/CLIPSESG?hl=en

--> IF YOU NO LONGER WANT TO RECEIVE EMAIL <--

Visit this group at http://groups.google.com/group/CLIPSESG?hl=en

Click on "Edit my membership" link.

Select the "No Email" radio button.

Click the "Save these settings" button.

--> IF YOU WANT TO UNSUBSCRIBE <--

Visit this group at http://groups.google.com/group/CLIPSESG?hl=en

Sign in

Click on "Edit my membership" link.

Click the "Unsubscribe" button.

Note: This appears to be the most reliable way to unsubscribe

Alternately, send email to CLIPSESG-u...@googlegroups.com. You will receive an email which you must respond to as well to unsubscribe. Clicking the link mentioned in the unsubscribe reply does not appear to work reliably.

---

You received this message because you are subscribed to the Google Groups "CLIPSESG" group.

To unsubscribe from this group and stop receiving emails from it, send an email to clipsesg+u...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/clipsesg/ad6f4f1a-d91c-4963-8043-c74ce8ddaf3an%40googlegroups.com.

You received this message because you are subscribed to the Google Groups "CLIPSESG" group.

To post to this group, send email to CLIP...@googlegroups.com

For more options, visit this group at http://groups.google.com/group/CLIPSESG?hl=en

--> IF YOU NO LONGER WANT TO RECEIVE EMAIL <--

Visit this group at http://groups.google.com/group/CLIPSESG?hl=en

Click on "Edit my membership" link.

Select the "No Email" radio button.

Click the "Save these settings" button.

--> IF YOU WANT TO UNSUBSCRIBE <--

Visit this group at http://groups.google.com/group/CLIPSESG?hl=en

Sign in

Click on "Edit my membership" link.

Click the "Unsubscribe" button.

Note: This appears to be the most reliable way to unsubscribe

Alternately, send email to CLIPSESG-u...@googlegroups.com. You will receive an email which you must respond to as well to unsubscribe. Clicking the link mentioned in the unsubscribe reply does not appear to work reliably.

---

You received this message because you are subscribed to the Google Groups "CLIPSESG" group.

To unsubscribe from this group and stop receiving emails from it, send an email to clipsesg+u...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/clipsesg/ad6f4f1a-d91c-4963-8043-c74ce8ddaf3an%40googlegroups.com.

Feb 6, 2023, 8:49:58 PM2/6/23

to clip...@googlegroups.com

These types of problems keep surfacing.

I have been teaching undergraduate CSCI for 30 years and am now teaching data science.

Data science which is computing with more tools, less custom programming, less detailed programming.

In AI when you throw a bunch of data against a NN (of any flavor), certain problems will fall apart and you can get knowledge from the data set by statistical examination (data science).

The problem with NN, if you ask the package author what is going on within the NN, they will answer in general terms. You ask in detail why is your NN able to give an answer to a problem, and they cannot answer in detail. Just in generalities. So does the data
science toolset give you an in-depth understanding of the problem or not when you cannot really describe what goes on in the NN. No one knows in detail.

Some problems do not fall apart and you need a knowledge engineer to examine the problem and work on evaluation rules. Expert systems are thus.

With my project, I spent over a year writing test cases (templates for data storage, rules for recognition of graph forms). REPEAT.

And I kept learning at every step because I was kept running into unexpected results. I said " DIDN'T EXPECT THAT" alot.

Rule programming is a different way of thinking.

Lots different.

Big expert systems are not a good place for shallow thinking.

Ronald Finkbine

To view this discussion on the web visit
https://groups.google.com/d/msgid/clipsesg/DM5PR11MB0009AF4D68C8F25B538E65FADFDB9%40DM5PR11MB0009.namprd11.prod.outlook.com.

Feb 6, 2023, 9:22:54 PM2/6/23

to clip...@googlegroups.com

So basically,

In the scoring system I need to create a system which will give marks to the students when certain conditions are met. these marks will be given once certain conditions are fulfilled at a certain time.

For example, I give you an actual example, I have values of slopes at different intervals, When slope value change from zero to positive and then zero again and then negative it means one cycle is completed and give scores to the candidate if this happen. If it makes sense.

--

You received this message because you are subscribed to the Google Groups "CLIPSESG" group.

To post to this group, send email to CLIP...@googlegroups.com

For more options, visit this group at http://groups.google.com/group/CLIPSESG?hl=en

--> IF YOU NO LONGER WANT TO RECEIVE EMAIL <--

Visit this group at http://groups.google.com/group/CLIPSESG?hl=en

Click on "Edit my membership" link.

Select the "No Email" radio button.

Click the "Save these settings" button.

--> IF YOU WANT TO UNSUBSCRIBE <--

Visit this group at http://groups.google.com/group/CLIPSESG?hl=en

Sign in

Click on "Edit my membership" link.

Click the "Unsubscribe" button.

Note: This appears to be the most reliable way to unsubscribe

Alternately, send email to CLIPSESG-u...@googlegroups.com. You will receive an email which you must respond to as well to unsubscribe. Clicking the link mentioned in the unsubscribe reply does not appear to work reliably.

---

You received this message because you are subscribed to the Google Groups "CLIPSESG" group.

To unsubscribe from this group and stop receiving emails from it, send an email to clipsesg+u...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/clipsesg/a68ed127-860e-fdb6-16ab-530ed2703354%40my.liu.edu.

Feb 7, 2023, 2:15:42 PM2/7/23

to CLIPSESG

This is the kind of small program you would start with while learning before you move on to adding more rules.

CLIPS>

(deftemplate slope

(slot candidate)

(slot value)

(slot interval))

CLIPS>

(defrule score

(slope (candidate ?c)

(interval ?i)

(value 0))

(slope (candidate ?c)

(interval =(+ ?i 1))

(value ?v1&:(> ?v1 0)))

(slope (candidate ?c)

(interval =(+ ?i 2))

(value 0))

(slope (candidate ?c)

(interval =(+ ?i 3))

(value ?v3&:(< ?v3 0)))

=>

(println "Score candidate " ?c))

CLIPS>

(assert (slope (candidate Frank) (interval 1) (value 0))

(slope (candidate Frank) (interval 2) (value 3))

(slope (candidate Frank) (interval 3) (value 0))

(slope (candidate Frank) (interval 4) (value -2)))

<Fact-4>

CLIPS> (agenda)

0 score: f-1,f-2,f-3,f-4

For a total of 1 activation.

CLIPS> (run)

Score candidate Frank

CLIPS>

Feb 8, 2023, 6:49:48 AM2/8/23

to clip...@googlegroups.com

Hi

This gives me a good direction to proceed. One ques there are no scores given to the candidate frank. The aim is to give scores at certain interval (i:e if value of slope changes). In a sinusoidal wave when values are zero to positive and than zero again and fall down to negative it means one cycle completed and if that one cycle or one incident occurs than candidate is given score 1.

To view this discussion on the web visit https://groups.google.com/d/msgid/clipsesg/dddc1c9e-fe2c-40ad-bf77-25c7a18417e1n%40googlegroups.com.

Feb 8, 2023, 12:53:32 PM2/8/23

to CLIPSESG

My mistake. Here's the rule modified to assert a fact containing the score.

CLIPS>

(defrule score

(slope (candidate ?c)

(interval ?i)

(value 0))

(slope (candidate ?c)

(interval =(+ ?i 1))

(value ?v1&:(> ?v1 0)))

(slope (candidate ?c)

(interval =(+ ?i 2))

(value 0))

(slope (candidate ?c)

(interval =(+ ?i 3))

(value ?v3&:(< ?v3 0)))

=>

CLIPS>

(assert (slope (candidate Frank) (interval 1) (value 0))

(slope (candidate Frank) (interval 2) (value 3))

(slope (candidate Frank) (interval 3) (value 0))

(slope (candidate Frank) (interval 4) (value -2)))

<Fact-4>

CLIPS> (agenda)

0 score: f-1,f-2,f-3,f-4

For a total of 1 activation.

CLIPS> (run)

CLIPS (6.4 2/9/21)

CLIPS>

(deftemplate slope

(slot candidate)

(slot value)

(slot interval))

CLIPS>

CLIPS>

(deftemplate slope

(slot candidate)

(slot value)

(slot interval))

CLIPS>

(deftemplate score

(slot candidate)

(slot value))

(slot candidate)

(slot value))

CLIPS>

(defrule score

(slope (candidate ?c)

(interval ?i)

(value 0))

(slope (candidate ?c)

(interval =(+ ?i 1))

(value ?v1&:(> ?v1 0)))

(slope (candidate ?c)

(interval =(+ ?i 2))

(value 0))

(slope (candidate ?c)

(interval =(+ ?i 3))

(value ?v3&:(< ?v3 0)))

=>

(assert (score (candidate ?c) (value 1))))

CLIPS>

(assert (slope (candidate Frank) (interval 1) (value 0))

(slope (candidate Frank) (interval 2) (value 3))

(slope (candidate Frank) (interval 3) (value 0))

(slope (candidate Frank) (interval 4) (value -2)))

<Fact-4>

CLIPS> (agenda)

0 score: f-1,f-2,f-3,f-4

For a total of 1 activation.

CLIPS> (run)

CLIPS> (facts)

f-1 (slope (candidate Frank) (value 0) (interval 1))

f-2 (slope (candidate Frank) (value 3) (interval 2))

f-3 (slope (candidate Frank) (value 0) (interval 3))

f-4 (slope (candidate Frank) (value -2) (interval 4))

f-5 (score (candidate Frank) (value 1))

For a total of 5 facts.

CLIPS>

f-1 (slope (candidate Frank) (value 0) (interval 1))

f-2 (slope (candidate Frank) (value 3) (interval 2))

f-3 (slope (candidate Frank) (value 0) (interval 3))

f-4 (slope (candidate Frank) (value -2) (interval 4))

f-5 (score (candidate Frank) (value 1))

For a total of 5 facts.

CLIPS>

Feb 10, 2023, 10:22:12 AM2/10/23

to clip...@googlegroups.com

Hi Gary

This is really a good startup for me. I just have a few questions about this. Is it possible to have an online meeting with you anytime this weekend or next week?

Muhammad

To view this discussion on the web visit https://groups.google.com/d/msgid/clipsesg/4d3b1748-d4ec-43c3-8ad4-559bde4b79f8n%40googlegroups.com.

Feb 10, 2023, 5:02:53 PM2/10/23

to CLIPSESG

The benefit of forums is to allow everyone to contribute to and benefit from the discussions. It's better that you ask your questions here so that everyone can benefit from the answers.

Feb 11, 2023, 10:33:20 PM2/11/23

to clip...@googlegroups.com

I totally understand that. So, I have attached a picture here, if you take a look every line of different color basically represents a variable so in the above program instead of candidate the specific variable name should make sense. My question is; there are some peaks and valleys now. What I want from the program is to check the values of slopes between two times i;e if values of slope are making peak or valleys means if value of slope is positive to zero and then negative which makes one peak then give score after checking.

If it make sense

To view this discussion on the web visit https://groups.google.com/d/msgid/clipsesg/39000559-299e-4230-b9e0-8f0709396e02n%40googlegroups.com.

Feb 12, 2023, 1:15:51 PM2/12/23

to CLIPSESG

Suppose my problem is to determine if quadrilateral ABCD (composed from points A, B, C, and D) is a square. The solution to this problem can be found with a web search. If line segments AB, BC, CD, and DA are the same length, and line segments AC and BD are the same length, then the quadrilateral ABCD is a square.

With this solution, I can determine with a few calculations by hand or calculator that the quadrilateral formed from points A (2,6), B (5,1), C (0,-2), and D (-3,3), is a square. With this use case, I can now implement the solution in CLIPS:

CLIPS (6.4 2/9/21)

CLIPS>

(deftemplate point

(slot id)

(slot x)

(slot y))

CLIPS>

(deffacts points

(point (id A) (x 2) (y 6))

(point (id B) (x 5) (y 1))

(point (id C) (x 0) (y -2))

(point (id D) (x -3) (y 3)))

CLIPS>

(deftemplate quadrilateral

(slot id)

(multislot points))

CLIPS>

(deffacts quadrilaterals

(quadrilateral (id ABCD)

(points A B C D)))

CLIPS>

(deffunction distance (?x1 ?y1 ?x2 ?y2)

(sqrt (+ (** (- ?x1 ?x2) 2) (** (- ?y1 ?y2) 2))))

CLIPS>

(defrule is-square

(quadrilateral (id ?q)

(points ?a ?b ?c ?d))

(point (id ?a) (x ?ax) (y ?ay))

(point (id ?b) (x ?bx) (y ?by))

(point (id ?c) (x ?cx) (y ?cy))

(point (id ?d) (x ?dx) (y ?dy))

(test (and (= (distance ?ax ?ay ?bx ?by)

(distance ?bx ?by ?cx ?cy)

(distance ?cx ?cy ?dx ?dy)

(distance ?dx ?dy ?ax ?ay))

(= (distance ?ax ?ay ?cx ?cy)

(distance ?bx ?by ?dx ?dy))))

=>

(println "Quadrilateral " ?q " is a square."))

CLIPS> (reset)

CLIPS> (run)

Quadrilateral ABCD is a square.

CLIPS>

CLIPS>

(deftemplate point

(slot id)

(slot x)

(slot y))

CLIPS>

(deffacts points

(point (id A) (x 2) (y 6))

(point (id B) (x 5) (y 1))

(point (id C) (x 0) (y -2))

(point (id D) (x -3) (y 3)))

CLIPS>

(deftemplate quadrilateral

(slot id)

(multislot points))

CLIPS>

(deffacts quadrilaterals

(quadrilateral (id ABCD)

(points A B C D)))

CLIPS>

(deffunction distance (?x1 ?y1 ?x2 ?y2)

(sqrt (+ (** (- ?x1 ?x2) 2) (** (- ?y1 ?y2) 2))))

CLIPS>

(defrule is-square

(quadrilateral (id ?q)

(points ?a ?b ?c ?d))

(point (id ?a) (x ?ax) (y ?ay))

(point (id ?b) (x ?bx) (y ?by))

(point (id ?c) (x ?cx) (y ?cy))

(point (id ?d) (x ?dx) (y ?dy))

(test (and (= (distance ?ax ?ay ?bx ?by)

(distance ?bx ?by ?cx ?cy)

(distance ?cx ?cy ?dx ?dy)

(distance ?dx ?dy ?ax ?ay))

(= (distance ?ax ?ay ?cx ?cy)

(distance ?bx ?by ?dx ?dy))))

=>

(println "Quadrilateral " ?q " is a square."))

CLIPS> (reset)

CLIPS> (run)

Quadrilateral ABCD is a square.

CLIPS>

The difficulty in answering your question "How do I detected trends in data using CLIPS?" is that you first have to answer the question "How do I detect trends in data?". That latter question is more of a mathematical/statistics question and you'd be better off asking that in a forum that specifically discusses those issues. StackOverflow has tags for time-series and trend which look like good places to start. Once you've found a solution for identifying trends, you can start asking questions about how you would implement it in a specific language such as CLIPS.

Feb 13, 2023, 1:54:28 PM2/13/23

to CLIPSESG

Yes, this is great if your correct solution just pops out at you and you do not have to DEVELOP it.__ __

__ __

In this sample, I would comment out a bunch of it and verify it works in small pieces.__ __

__ __

You need TDD (test driven development). __ __

__ __

Set up a SMALL fact list that will fire one SIMPLE rule and verify it works. **
TC001**__ __

__ __

(deftemplate point (slot id) (slot x) (slot y))

(deffacts points

(point (id A) (x 2) (y 5))

(point (id B) (x 5) (y 5)))__ __

__ __

(deffunction distance (?x1 ?y1 ?x2 ?y2)

(sqrt (+ (** (- ?x1 ?x2) 2) (** (- ?y1 ?y2) 2))))
__ __

__ __

(defrule rule_TC001 “isAngle”__ __

(point (id ?a) (x ?ax) (y ?ay))

(point (id ?b) (x ?bx) (y ?by))__ __

= >__ __

(println “Distance is “ (distance ?ax ?ay ?bx ?by))__ __

)__ __

__ __

I am printing out the first usage of the distance formula so that you see if it is accurate. VERIFY IT.__ __

__ __

I would keep rule_TC001 UNCHANGED forever. Even as you copy rule_TC001 to another TC and add more complications to it, you need to be able to regression test
this thing, keep all these simple test case rules, and when things go wrong, rerun them so you can see which of the simple test cases still run when you messed it up in TC034 or whatever.__ __

for TC002, I would make the distance formula part of the CE.__ __

__ __

(defrule rule_TC002 “isAngle2”__ __

(point (id ?a) (x ?ax) (y ?ay))

(point (id ?b) (x ?bx) (y ?by))__ __

(test (= 3 (distance (distance ?ax ?ay ?bx ?by))__ __

= >__ __

(println “Distance is 3” )__ __

)__ __

__ __

Yes, I know the distance between (2,5) and (5,5) is 3, so you are testing the “test distance” CE.__ __

Make this TC002 and keep it forever.__ And keep TC001 forever too.__

__ __

Even though this is a rules-based program, you must develop it sequentially.__ __

__ __

Expert systems are not magic, they are developed.__ __

__ __

Keep at it, add more test cases, one piece at a time, just like how you eat an elephant (American joke).__ __

Now go back and add addition slots to the deftemple, new rule TC003.

Ron__ __

To view this discussion on the web visit
https://groups.google.com/d/msgid/clipsesg/cb8c9630-6fdc-46d7-bdd7-3730914a6e81n%40googlegroups.com.

Feb 21, 2023, 10:39:30 AM2/21/23

to clip...@googlegroups.com

So I was looking for some example that give level of abstraction and reach to a certain result which in this case is giving scores to candidate. So I'll give an example below;

(if slope +ve at t

if slope 0 at t+1

if slope -ve at t+2)

=> (assert (pressure peak at time t ))

THAN

(if peak at t1

if peak at t2

if peak at t3)

=>

(assert (pressure change at t1, t2, t3))

THAN

(if three peaks t1, t2,t3)

=> (assert(marks given on basis of change in pressure at certain time))

To view this discussion on the web visit https://groups.google.com/d/msgid/clipsesg/DM5PR11MB000950448050F4A2E905E1D2DFDD9%40DM5PR11MB0009.namprd11.prod.outlook.com.

Feb 23, 2023, 11:20:26 AM2/23/23

to clip...@googlegroups.com

Gary

I need your help on this; hear me out, I am trying to find out the point where slope changes to the maximum value of variable change. For example variable is pressure and we are calculating the slope of pressure curve now i want to assert into my fact list that point at which the pressure is maximum because slope is zero.

if that make sense

On Wed, Feb 8, 2023 at 5:53 PM CLIPS Support <garyd...@gmail.com> wrote:

To view this discussion on the web visit https://groups.google.com/d/msgid/clipsesg/4d3b1748-d4ec-43c3-8ad4-559bde4b79f8n%40googlegroups.com.

Feb 23, 2023, 7:43:41 PM2/23/23

to CLIPSESG

To reiterate, I think you're putting the cart before the horse. You're asking implementation questions (about a specific programming language) when you should be asking questions about how to write a design specification for detecting peaks (in a general programming forum and a data analysis forum). If you have to ask if your written specification makes sense and is sufficient to begin implementation, the answer is no.

(slot x)

(slot y))

CLIPS>

This is a specification that you can ask implementation questions about: Given N points with x and y values, where for every point n, the x value of point[n] is always greater than the x value of point[n-1], a point m is a peak if the slope of the line from point[m-1] to point[m] is greater than or equal to 0, and the slope of the line from point[m] to point[m+1] is less than or equal to zero. For example, given point[1] with { x = 0, y = 0 }, point[2] with { x = 1, y = 1 }, and point[3] with { x = 5 , y = -1 }, point[2] is a peak because the slope from point[1] to point[2] is 1, and the slope from point[2] to point[3] is -0.5.

CLIPS (6.4 2/9/21)

CLIPS>

(deftemplate point

(slot index)

I don't know if this specification satisfies what you need because your questions are too vague, but for me this specification has enough detail that I could discuss implementation details in languages like C, Java, and CLIPS. And even having putting in 5 minutes of thought about what represents a peak, I can already see that there are edge cases that need to be addressed such as when the plot of points begins with a horizontal line.

This is a CLIPS implementation of the specification that identifies the first and maximum peak:

CLIPS (6.4 2/9/21)

CLIPS>

(deftemplate point

(slot index)

(slot x)

(slot y))

CLIPS>

(deftemplate peak

(slot index))

CLIPS>

(deffacts points

(point (index 1) (x 0) (y 0))

(point (index 2) (x 1) (y 1))

(point (index 3) (x 5) (y -1))

(point (index 4) (x 6) (y -1))

(point (index 5) (x 9) (y 12))

(point (index 6) (x 11) (y 10)))

CLIPS>

(defglobal ?*output* = -10)

CLIPS>

(deffunction slope (?x1 ?y1 ?x2 ?y2)

(/ (- ?y2 ?y1) (- ?x2 ?x1)))

CLIPS>

(defrule peak

(point (index ?i1) (x ?x1) (y ?y1))

(point (index ?i2&=(+ ?i1 1)) (x ?x2) (y ?y2))

(test (>= (slope ?x1 ?y1 ?x2 ?y2) 0))

(point (index ?i3&=(+ ?i1 2)) (x ?x3) (y ?y3))

(test (<= (slope ?x2 ?y2 ?x3 ?y3) 0))

=>

(assert (peak (index ?i2))))

CLIPS>

(defrule first-peak

(declare (salience ?*output*))

(peak (index ?i1))

(point (index ?i1) (x ?x1) (y ?y1))

(not (peak (index ?i2&:(< ?i2 ?i1))))

=>

(println "First peak is (" ?x1 "," ?y1")"))

CLIPS>

(defrule max-peak

(declare (salience ?*output*))

(peak (index ?i1))

(point (index ?i1) (x ?x1) (y ?y1))

(not (and (peak (index ?i2&~?i1))

(point (index ?i2) (y ?y2&:(> ?y2 ?y1)))))

=>

(println "Max peak is (" ?x1 "," ?y1")"))

CLIPS> (reset)

CLIPS> (run)

First peak is (1,1)

Max peak is (9,12)

CLIPS>

(slot index))

CLIPS>

(deffacts points

(point (index 1) (x 0) (y 0))

(point (index 2) (x 1) (y 1))

(point (index 3) (x 5) (y -1))

(point (index 4) (x 6) (y -1))

(point (index 5) (x 9) (y 12))

(point (index 6) (x 11) (y 10)))

CLIPS>

(defglobal ?*output* = -10)

CLIPS>

(deffunction slope (?x1 ?y1 ?x2 ?y2)

(/ (- ?y2 ?y1) (- ?x2 ?x1)))

CLIPS>

(defrule peak

(point (index ?i1) (x ?x1) (y ?y1))

(point (index ?i2&=(+ ?i1 1)) (x ?x2) (y ?y2))

(test (>= (slope ?x1 ?y1 ?x2 ?y2) 0))

(point (index ?i3&=(+ ?i1 2)) (x ?x3) (y ?y3))

(test (<= (slope ?x2 ?y2 ?x3 ?y3) 0))

=>

(assert (peak (index ?i2))))

CLIPS>

(defrule first-peak

(declare (salience ?*output*))

(peak (index ?i1))

(point (index ?i1) (x ?x1) (y ?y1))

(not (peak (index ?i2&:(< ?i2 ?i1))))

=>

(println "First peak is (" ?x1 "," ?y1")"))

CLIPS>

(defrule max-peak

(declare (salience ?*output*))

(peak (index ?i1))

(point (index ?i1) (x ?x1) (y ?y1))

(not (and (peak (index ?i2&~?i1))

(point (index ?i2) (y ?y2&:(> ?y2 ?y1)))))

=>

(println "Max peak is (" ?x1 "," ?y1")"))

CLIPS> (reset)

CLIPS> (run)

First peak is (1,1)

Max peak is (9,12)

CLIPS>

Mar 1, 2023, 11:10:22 PM3/1/23

to clip...@googlegroups.com

Hi Gary. Hope you are fine. First of all, thanks for all your help. Your answers to the questions are very very helpful. I need to check something with you, I wrote this program and expected an output to give me the time at which variable peak have maximum value and also the value of that peak as well.

I dont know if I wrote it correctly but its not asserting the new fact in the list. Basically I have a variable called "drill" that have some values from 0 to 200 and values in form of sinusoidal wave. I am needing that time stamp where the value are maximum. I named them peak.

CLIPS (6.4 2/9/21)

CLIPS> (clear)

CLIPS> (deftemplate slope

(slot variable)

(slot value)

(slot time)

(slot peak))

CLIPS> (deftemplate output

(slot variable)

(slot time)

(slot peak))

CLIPS> (clear)

CLIPS> (deftemplate slope

(slot variable)

(slot value)

(slot time)

(slot peak))

CLIPS> (deftemplate output

(slot variable)

(slot time)

(slot peak))

(defrule score

(slope (variable ?v)

(time ?t)

(value 0)

(peak 0))

(slope (variable ?v)

(time =(+ ?t 1))

(slope (variable ?v)

(time ?t)

(value 0)

(peak 0))

(slope (variable ?v)

(time =(+ ?t 1))

(value ?v1&:(> ?v1 0))

(peak ?p1&:(> ?p1 0)))

(slope (variable ?v)

(time =(+ ?t 2))

(value 0)

(peak ?p2))

(slope (variable ?v)

(time =(+ ?t 3))

(slope (variable ?v)

(time =(+ ?t 2))

(value 0)

(peak ?p2))

(slope (variable ?v)

(time =(+ ?t 3))

(value ?v3&:(< ?v3 0))

(peak ?p3&:(< ?p2 ?p3)))

(test (and(> ?p1 ?p2)(< ?p2 ?p3)))

=>

(assert (output (variable ?v)(time ?t) (peak ?p2))))

(test (and(> ?p1 ?p2)(< ?p2 ?p3)))

=>

(assert (output (variable ?v)(time ?t) (peak ?p2))))

To view this discussion on the web visit https://groups.google.com/d/msgid/clipsesg/7fc6849b-ce4b-44f3-8f95-6fed2c04a043n%40googlegroups.com.

Mar 1, 2023, 11:46:36 PM3/1/23

to CLIPSESG

What are a set of example facts for which you're expecting the rule to be activated?

Mar 2, 2023, 7:08:48 AM3/2/23

to clip...@googlegroups.com

Gary, Here are some facts.

(slope (variable drill) (time 2) (value 3) (peak 200))

(slope (variable drill) (time 3) (value 0) (peak 300))

(slope (variable drill) (time 4) (value -2) (peak 100)))

To view this discussion on the web visit https://groups.google.com/d/msgid/clipsesg/40dccc5e-6452-4df0-a46b-8d61e9eaa593n%40googlegroups.com.

Mar 2, 2023, 10:20:19 AM3/2/23

to clip...@googlegroups.com

Gary, anything?

Message has been deleted

Mar 2, 2023, 2:37:14 PM3/2/23

to CLIPSESG

The fourth pattern of your rule won't be satisfied by your data because the value bound to ?p2 must be less than ?p3, but ?p2 is bound to 300 and ?p3 is bound to 100. The test conditional element also checks that ?p1 is greater than ?p2, but ?p1 is 200 and ?p3 is 300.

CLIPS (6.4 2/9/21)

CLIPS>

(deftemplate slope

CLIPS>

(deftemplate slope

(slot variable)

(slot value)

(slot time)

(slot peak))

CLIPS>

(deftemplate output

(slot variable)

(slot time)

(slot peak))

CLIPS> (slot value)

(slot time)

(slot peak))

CLIPS>

(deftemplate output

(slot variable)

(slot time)

(slot peak))

(deffacts example

(slope (variable drill) (time 1) (value 0) (peak 0))

(slope (variable drill) (time 2) (value 3) (peak 200))

(slope (variable drill) (time 3) (value 0) (peak 300))

(slope (variable drill) (time 4) (value -2) (peak 100)))

(defrule score

(slope (variable ?v)

(time ?t)

(value 0)

(peak 0))

(slope (variable ?v)

(time =(+ ?t 1))

(value ?v1&:(> ?v1 0))

(peak ?p1&:(> ?p1 0)))

(slope (variable ?v)

(time =(+ ?t 2))

(value 0)

(peak ?p2))

(slope (variable ?v)

(time =(+ ?t 3))

(value ?v3&:(< ?v3 0))

(peak ?p3&:(< ?p2 ?p3)))

(test (and (> ?p1 ?p2)

(< ?p2 ?p3)))

=>

(assert (output (variable ?v)(time ?t) (peak ?p2))))

CLIPS> (reset)(slope (variable ?v)

(time ?t)

(value 0)

(peak 0))

(slope (variable ?v)

(time =(+ ?t 1))

(value ?v1&:(> ?v1 0))

(peak ?p1&:(> ?p1 0)))

(slope (variable ?v)

(time =(+ ?t 2))

(value 0)

(peak ?p2))

(slope (variable ?v)

(time =(+ ?t 3))

(value ?v3&:(< ?v3 0))

(peak ?p3&:(< ?p2 ?p3)))

(test (and (> ?p1 ?p2)

(< ?p2 ?p3)))

=>

(assert (output (variable ?v)(time ?t) (peak ?p2))))

CLIPS> (facts)

f-1 (slope (variable drill) (value 0) (time 1) (peak 0))

f-2 (slope (variable drill) (value 3) (time 2) (peak 200))

f-3 (slope (variable drill) (value 0) (time 3) (peak 300))

f-4 (slope (variable drill) (value -2) (time 4) (peak 100))

For a total of 4 facts.

CLIPS> (agenda)

CLIPS> (matches score)

Matches for Pattern 1

f-1

Matches for Pattern 2

f-2

Matches for Pattern 3

f-1

f-3

Matches for Pattern 4

f-4

Partial matches for CEs 1 - 2

f-1,f-2

Partial matches for CEs 1 - 3

f-1,f-2,f-3

Partial matches for CEs 1 - 4

None

Activations

None

(5 2 0)

CLIPS>

Message has been deleted

Mar 2, 2023, 9:11:27 PM3/2/23

to CLIPSESG

Perfect. I can see my mistake. Gary, I just need to check out, for example if I have 200 values of peaks, slopes at different times will this approach be good enough to find the peaks at certain or exact intervals. Can you guide me to create that model?

I basically need all the peaks with the help of slope's (+ve, 0, -ve) values and with those peaks at a certain time I will give scores to the candidates.

Message has been deleted

Message has been deleted

Message has been deleted

Mar 11, 2023, 4:29:47 PM3/11/23

to CLIPSESG

For some reason my last three messages were deleted so I'll try a fourth time. At this point, you just need to add rules incrementally based on your spec and test to make sure it works. Work your way up to 200 values of peaks, starting instead with maybe 5 or 10.

Reply all

Reply to author

Forward

0 new messages