Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.95 KB | None | 0 0
  1. (defglobal ?*nod-gen* = 0)
  2. (defglobal ?*f* = 1)
  3.  
  4. ;(deffacts Aeropuerto MT P6 T1 T1 P6 T2 P2 maletas M1 12 F P3 M2 18 F P5 M3 20 P1 R M4 14 P6 R)
  5. ;(deffacts mapa F P2 F)
  6. ;(deffacts mapa P2 P4 P2)
  7. ;(deffacts mapa P4 P3 P4)
  8. ;(deffacts mapa P3 P1 P3)
  9. ;(deffacts mapa P1 P5 P1)
  10. ;(deffacts mapa F P1 F)
  11. ;(deffacts mapa P5 R P5)
  12. ;(deffacts mapa P5 P7 P5)
  13. ;(deffacts mapa P7 P8 P7)
  14. ;(deffacts mapa P8 P6 P8)
  15. ;(deffacts mapa P6 R P6)
  16.  
  17.  
  18.  
  19. ;(deffacts cargas T1 0 15 T2 16 23)
  20.  
  21. (defrule enganchar
  22. (declare (salience 20))
  23. ?f <- (Aeropuerto MT ?p ?vagon carros $?anon3 ?vagon ?pos $?anon1 ?maleta ?pmal $?anon2 nivel ?n)
  24. (cargas $? vagon ?vagon ?pmin ?pmax $?)
  25. (test (eq ?p ?pos))
  26. ;(test (and(> ?pmal ?pmin)(< ?pmal ?pmax)))
  27. =>
  28. ;(retract ?f)
  29. (assert (Aeropuerto MT ?p ?vagon carros $?anon3 ?vagon ?pos $?anon1 ?maleta ?pmal $?anon2 nivel (+ ?n 1)))
  30. )
  31. (defrule mover
  32. (declare (salience 10))
  33. ?f <- (Aeropuerto MT ?p ?y carros $?z1 ?y ?p $?z2 ?maleta ?peso ?ori ?dest $?z3 nivel ?n)
  34. (mapa $? ?p ?pos2 $?)
  35. =>
  36. (assert(Aeropuerto MT ?pos2 ?y carros $?z1 ?y ?pos2 $?z2 ?maleta ?peso ?ori ?dest $?z3 nivel (+ ?n 1)))
  37. (bind ?*nod-gen* (+ ?*nod-gen* 1))
  38. )
  39.  
  40.  
  41.  
  42.  
  43. (defrule cargar
  44. (declare(salience 100))
  45. (Aeropuerto MT ?p ?y carros $?z1 ?y ?p $?z2 ?m ?pmal ?ori ?dest $?z3 nivel ?n)
  46. (cargas $? vagon ?vagon ?pmin ?pmax $?)
  47. ;(test (and(> ?pmal ?pmin)(< ?pmal ?pmax)))
  48. (test (eq ?p ?ori))
  49. =>
  50. (assert (Aeropuerto MT ?p ?y ?m ?pmal ?ori ?dest carros $?z1 ?y ?p $?z2 $?z3 nivel (+ ?n 1)))
  51.  
  52. (bind ?*nod-gen* (+ ?*nod-gen* 1))
  53. )
  54.  
  55. (defrule descargar
  56. (declare (salience 100))
  57. (Aeropuerto MT ?p ?y carros $?z1 ?m ?pmal ?ori ?dest $?z2 ?y ?p $?z3 nivel ?n)
  58. (test (eq ?p ?dest))
  59. =>
  60. (assert(Aeropuerto MT ?p ?y carros $?z1 $?z2 ?y ?p $?z3 nivel (+ ?n 1)))
  61.  
  62. (bind ?*nod-gen* (+ ?*nod-gen* 1))
  63. )
  64.  
  65.  
  66.  
  67.  
  68.  
  69. (defrule objetivo
  70. (declare (salience 100))
  71. ?f<-(Aeropuerto MT $?x maletas nivel ?n)
  72.  
  73. =>
  74. (printout t "SOLUCION ENCONTRADA EN EL NIVEL " ?n crlf)
  75. (printout t "NUMERO DE NODOS EXPANDIDOS O REGLAS DISPARADAS " ?*nod-gen* crlf)
  76. (printout t "HECHO OBJETIVO " ?f crlf)
  77.  
  78. (halt)
  79. )
  80.  
  81.  
  82. (deffunction inicio ()
  83. (reset)
  84. (printout t "Profundidad Maxima:= " )
  85. (bind ?prof (read))
  86. (printout t "Tipo de Busqueda " crlf " 1.- Anchura" crlf " 2.- Profundidad" crlf )
  87. (bind ?a (read))
  88. (if (= ?a 1)
  89. then (set-strategy breadth)
  90. else (set-strategy depth))
  91. (printout t " Ejecuta run para poner en marcha el programa " crlf)
  92. (assert (Aeropuerto MT P6 T1 carros T1 P6 T2 P2 maletas M1 12 F P3 M2 18 F P5 M3 20 P1 R M4 14 P6 R nivel 0))
  93. (assert (mapa F P2 F))
  94. (assert (mapa P2 P4 P2))
  95. (assert (mapa P4 P3 P4))
  96. (assert (mapa P1 F P1))
  97. (assert (mapa P1 P5 P1))
  98. (assert (mapa P5 P7 P5))
  99. (assert (mapa P7 P8 P7))
  100. (assert (mapa P8 P6 P8))
  101. (assert (mapa R P6 R))
  102. (assert (mapa R P5 R))
  103. (assert (cargas vagon T1 0 15 vagon T2 16 23))
  104. (assert (profundidad-maxima ?prof))
  105.  
  106. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement