I hope you are doing very well? I am a beginner in regards to CLIPS. I have a graph of several nodes (start nodes (input) and of end nodes (output). I want to create a rule in t
Try combining rules info and varvar to the following:
(defrule varvar
(startnode ?start ?)
(endnode ?end ?)
(path (start ?start) (end ?end) (path $?path) (cost ?cost))
(not (and (endnode ?end2 ?)
(path (start ?start) (end ?end2) (cost ?cost2&:(< ?cost2 ?cost)))))
=>
(printout t " PATH " ?start " to " ?end " by " ?path " with a cost of " ?cost crlf)
(assert (info (start ?start) (end ?end) (path $?path) (cost ?cost))))
The results you'll get are:
PATH A to I by (A,a,m,I) with a cost of 3.5
PATH E to I by (E,n,m,I) with a cost of 4
PATH C to B by (C,c,b,B) with a cost of 5
It's not clear why you're expecting path E to B to be selected since path E to I has a lower cost.