Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.41 KB | None | 0 0
  1. ;;;======================================================
  2. ;;; Mobile Architecture Expert Systems
  3. ;;;
  4. ;;; This expert system diagnoses some simple
  5. ;;; problems with a car.
  6. ;;;
  7. ;;; CLIPS Version 6.3 Example
  8. ;;;
  9. ;;; To execute, merely load, reset and run.
  10. ;;;======================================================
  11.  
  12. ;;****************
  13. ;;* DEFFUNCTIONS *
  14. ;;****************
  15.  
  16. (deffunction ask-question (?question $?allowed-values)
  17. (printout t ?question)
  18. (bind ?answer (read))
  19. (if (lexemep ?answer)
  20. then (bind ?answer (lowcase ?answer)))
  21. (while (not (member ?answer ?allowed-values)) do
  22. (printout t ?question)
  23. (bind ?answer (read))
  24. (if (lexemep ?answer)
  25. then (bind ?answer (lowcase ?answer))))
  26. ?answer)
  27.  
  28. (deffunction yes-or-no-p (?question)
  29. (bind ?response (ask-question ?question yes no y n))
  30. (if (or (eq ?response yes) (eq ?response y))
  31. then yes
  32. else no))
  33.  
  34. ;;;***************
  35. ;;;* QUERY RULES *
  36. ;;;***************
  37.  
  38. ;;; LEVEL 1
  39. (defrule determine-customer-facing ""
  40. (not (customer-facing ?))
  41. (not (repair ?))
  42. =>
  43. (assert (customer-facing (yes-or-no-p "System : Is your app customer facing? (yes/no)?
  44. User : ")))
  45. (printout t "=======================================================")
  46. (printout t crlf crlf))
  47.  
  48. ;;; LEVEL 2
  49. (defrule determine-screen ""
  50. (customer-facing yes)
  51. (not (repair ?))
  52. =>
  53. (assert (single-screen (yes-or-no-p "System : Is your app single screen with lots of animations or sounds? (yes/no)?
  54. User : ")))
  55. (printout t "=======================================================")
  56. (printout t crlf crlf))
  57.  
  58. (defrule determine-sensor ""
  59. (customer-facing no)
  60. (not (repair ?))
  61. =>
  62. (assert (sensor (yes-or-no-p "System : Do you need to access the device's sensors? (yes/no)?
  63. User : ")))
  64. (printout t "=======================================================")
  65. (printout t crlf crlf))
  66.  
  67. ;;; LEVEL 3
  68. (defrule determine-multi-screen ""
  69. (customer-facing yes)
  70. (single-screen no)
  71. (not (repair ?))
  72. =>
  73. (assert (multi-screen (yes-or-no-p "System : Do you need a few screens with lots of animations or sounds? (yes/no)?
  74. User : ")))
  75. (printout t "=======================================================")
  76. (printout t crlf crlf))
  77.  
  78. (defrule determine-native-function ""
  79. (or(or(or(appstore yes)(sensor yes))(multi-os yes))(multi-screen no))
  80. (not (repair ?))
  81. =>
  82. (assert (native-function (yes-or-no-p "System : Do you need access to customer native functionality? (yes/no)?
  83. User : ")))
  84. (printout t "=======================================================")
  85. (printout t crlf crlf))
  86.  
  87. (defrule determine-appstore ""
  88. (customer-facing no)
  89. (sensor no)
  90. (not (repair ?))
  91. =>
  92. (assert (appstore (yes-or-no-p "System : Do you need your app on the store? (yes/no)?
  93. User : ")))
  94. (printout t "=======================================================")
  95. (printout t crlf crlf))
  96.  
  97. ;;; LEVEL 4
  98.  
  99. (defrule determine-poor-performance ""
  100. (customer-facing yes)
  101. (single-screen no)
  102. (multi-screen yes)
  103. (not (repair ?))
  104. =>
  105. (assert (poor-performance (yes-or-no-p "System : Do you need to support devices with poor performance? (yes/no)?
  106. User : ")))
  107. (printout t "=======================================================")
  108. (printout t crlf crlf))
  109.  
  110. (defrule determine-multi-os ""
  111. (customer-facing yes)
  112. (single-screen no)
  113. (multi-screen yes)
  114. (poor-performance no)
  115. (not (repair ?))
  116. =>
  117. (assert (multi-os (yes-or-no-p "System : Do you need to support multiple operating systems? (yes/no)?
  118. User : ")))
  119. (printout t "=======================================================")
  120. (printout t crlf crlf))
  121.  
  122. (defrule determine-branded ""
  123. (native-function no)
  124. (not (repair ?))
  125. =>
  126. (assert (branded (yes-or-no-p "System : Do you need your app branded? (yes/no)?
  127. User : ")))
  128. (printout t "=======================================================")
  129. (printout t crlf crlf))
  130.  
  131. ##CONCLUSIONS
  132.  
  133. (defrule single-screen-conclusions ""
  134. (customer-facing yes)
  135. (single-screen yes)
  136. (not (repair ?))
  137. =>
  138. (assert (repair "[Native]
  139. A native app is designed to run on one specic mobile operating system, such as
  140. iOS, Android or Windows Phone. It is built using the operating system vendor’s
  141. technology and, typically, using development tools supplied by that vendor.")))
  142.  
  143. (defrule hybrid-mixed ""
  144. (or(or(poor-performance yes)(multi-os no))(native-function yes))
  145. (not (repair ?))
  146. =>
  147. (assert (repair "[Hybrid Mixed]
  148. A hybrid mixed app is similar to a hybrid web app but more code is written
  149. natively to take full advantage of device features and capabilities. Like
  150. hybrid web apps, hybrid mixed apps are primarily built with standard
  151. web technologies.")))
  152.  
  153. (defrule hybrid-web ""
  154. (branded yes)
  155. (not (repair ?))
  156. =>
  157. (assert (repair "[Hybrid Web]
  158. A hybrid web application combines the best attributes of native and mobile web
  159. apps. The vast majority of the app is built using mobile web standards – HTML5,
  160. CSS and JavaScript – that are either served from an application server or are
  161. distributed with the app.")))
  162.  
  163. (defrule packaged-hybrid ""
  164. (branded no)
  165. (not (repair ?))
  166. =>
  167. (assert (repair "[Packaged Hybrid]
  168. A packaged hybrid app consists of a native shell and a mobile web app very much
  169. like a hybrid web architecture. The dierence is that the native shell is maintained
  170. by a third-party vendor, further reducing the need for in-house maintenance work
  171. on the native code bases.")))
  172.  
  173. (defrule mobile-web-conclusions ""
  174. (customer-facing no)
  175. (sensor no)
  176. (appstore no)
  177. (not (repair ?))
  178. =>
  179. (assert (repair "[Mobile web]
  180. A mobile web app can be accessed from any device running a web browser
  181. regardless of its underlying operating system. Mobile web apps are built
  182. using standard Web technologies such as HTML5, JavaScript and CSS.")))
  183.  
  184. ;;;********************************
  185. ;;;* STARTUP AND CONCLUSION RULES *
  186. ;;;********************************
  187.  
  188. (defrule system-banner ""
  189. =>
  190. (printout t crlf crlf)
  191. (printout t "Mobile Architecture Expert System")
  192. (printout t crlf crlf))
  193.  
  194. (defrule print-repair ""
  195. (repair ?item)
  196. =>
  197. (printout t crlf crlf)
  198. (printout t "Suggested Architecture:")
  199. (printout t crlf crlf)
  200. (format t " %s%n%n%n" ?item))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement