Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. (deftemplate path
  2. (slot start)
  3. (slot end)
  4. (multislot path)
  5. (slot cost))
  6. (deftemplate find_NG
  7. (slot start)
  8. (slot end))
  9. (deffacts variable_table
  10. (path (start A) (end B) (path A C R F B) (cost 6))
  11. (path (start A) (end C) (path A C ) (cost 3.6))
  12. (path (start A) (end D)(path A C R F D) (cost 5.4))
  13. (path (start A) (end F) (path A C R F ) (cost 5.5 ) )
  14. (path (start C) (end B) (path C R F B) (cost 3.6) )
  15. (path (start C) (end D) (path C R F D) (cost 3.6))
  16. (path (start C) (end E) (path C R F E) (cost 2.6))
  17. (path (start C) (end K) (path C R F K) (cost 2))
  18. )
  19.  
  20. (defrule lancesaisiepoint
  21. ?f1 <- (debut point)
  22. =>
  23. (retract ?f1)
  24. (printout t "how ma
  25.  
  26. ny point ")
  27. (bind ?point (read))
  28. (assert (point ?point))
  29. )
  30.  
  31. (defrule saisiepoint
  32. ?f <- (point ?a)
  33. (test (> ?a 0))
  34. =>
  35. (printout t "Entrer nbr point " crlf)
  36. (printout t "Point name ")
  37. (bind ?start (read))
  38. (printout t "Point Value ")
  39. (bind ?pvalue (read))
  40. (assert (positive ?start ?pvalue))
  41. (retract ?f)
  42. (assert (point (- ?a 1)))
  43. )
  44.  
  45. (defrule lancesaisiemoins
  46. ?f1 <- (point 0)
  47. =>
  48. (retract ?f1)
  49. (printout t "how many negatives ")
  50. (bind ?neg (read))
  51. (assert (moins ?neg))
  52. )
  53.  
  54. (defrule saisiemoins
  55. ?f <- (moins ?a)
  56. (test (> ?a 0))
  57. =>
  58. (printout t "Entrer nbr of negatives" crlf)
  59. (printout t "negative name ")
  60. (bind ?end (read))
  61. (printout t "negative value ")
  62. (bind ?negvalue (read))
  63. (assert (negative ?end ?negvalue ))
  64. (retract ?f)
  65. (assert (moins(- ?a 1))))
  66.  
  67.  
  68. (defrule supprnbrpoint ; compter
  69. ?x<- (point 0)
  70. =>
  71. (retract ?x)
  72. )
  73.  
  74. (defrule supprnbrmoins
  75. ?x<- (moins 0)
  76. =>
  77. (retract ?x)
  78. )
  79.  
  80. (defrule info_grid
  81.  
  82. ?M <- (positive ?start ?pvalue)
  83. ?K <- (negative ?end ?negvalue )
  84. =>
  85. (assert (start ?start end ?end))
  86. )
  87.  
  88. (defrule variable
  89. (start ?start end ?end)
  90. (path (start ?start) (end ?end) (path $?path) (cost ?cost) )
  91. =>
  92. (printout t " the PATH " ?start " to " ?end " by " ?path " cost " ?cost crlf)
  93. (assert (informations ?start to ?end path ?path cost ?cost))
  94. )
  95.  
  96. (defrule cost_low
  97. (declare (salience -10))
  98. ;; Rule needs to execute last
  99. (informations ?start to ?end path ?path cost ?cost)
  100. (not (informations ? to ? path ? cost ?cost2&:(< ?cost2 ?cost)))
  101. ;; Need to match infos facts
  102. =>
  103. (printout t "The Path from " ?start " is "?end "," ?path " and has the lowest cost : " ?cost crlf))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement