pn_simulate.mvc 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. import models/RAM_PetriNets_Runtime_Runtime as RAM_PN_R
  2. include "primitives.alh"
  3. include "modelling.alh"
  4. RAM_PN_R s {
  5. Composite schedule {
  6. {Contains} Failure failure {}
  7. {Contains} Success success {}
  8. {Contains} Atomic mark {
  9. LHS {
  10. Pre_PetriNets_Runtime/Transition {
  11. label = "1"
  12. }
  13. }
  14. NAC {
  15. Pre_PetriNets_Runtime/Transition mark_nac_t {
  16. label = "1"
  17. }
  18. Pre_PetriNets_Runtime/Place mark_nac_p{
  19. label = "10"
  20. }
  21. Pre_PetriNets_Runtime/P2T (mark_nac_p, mark_nac_t){
  22. label = "11"
  23. }
  24. constraint = $
  25. Boolean function constraint(host_model : Element, mapping : Element):
  26. Integer tokens
  27. Integer weight
  28. tokens = read_attribute(host_model, mapping["10"], "tokens")
  29. weight = read_attribute(host_model, mapping["11"], "weight")
  30. return (tokens < weight)!
  31. $
  32. }
  33. RHS {
  34. Post_PetriNets_Runtime/Transition {
  35. label = "1"
  36. value_executing = $
  37. Boolean function value(host_model : Element, name : String, mapping : Element):
  38. return True!
  39. $
  40. }
  41. }
  42. }
  43. {Contains} ForAll consume {
  44. LHS {
  45. Pre_PetriNets_Runtime/Transition lhs_consume_t{
  46. label = "0"
  47. constraint_executing = $
  48. Boolean function constraint(value : Boolean):
  49. return value!
  50. $
  51. }
  52. Pre_PetriNets_Runtime/Place lhs_consume_p{
  53. label = "1"
  54. }
  55. Pre_PetriNets_Runtime/P2T lhs_consume_p2t(lhs_consume_p, lhs_consume_t){
  56. label = "2"
  57. }
  58. }
  59. RHS {
  60. Post_PetriNets_Runtime/Transition rhs_consume_t {
  61. label = "0"
  62. }
  63. Post_PetriNets_Runtime/Place rhs_consume_p {
  64. label = "1"
  65. value_tokens = $
  66. Integer function value(host_model : Element, name : String, mapping : Element):
  67. return integer_subtraction(read_attribute(host_model, name, "tokens"), read_attribute(host_model, mapping["2"], "weight"))!
  68. $
  69. }
  70. Post_PetriNets_Runtime/P2T (rhs_consume_p, rhs_consume_t){
  71. label = "2"
  72. }
  73. }
  74. }
  75. {Contains} ForAll produce {
  76. LHS {
  77. Pre_PetriNets_Runtime/Transition lhs_produce_t{
  78. label = "0"
  79. constraint_executing = $
  80. Boolean function constraint(value : Boolean):
  81. return value!
  82. $
  83. }
  84. Pre_PetriNets_Runtime/Place lhs_produce_p{
  85. label = "1"
  86. }
  87. Pre_PetriNets_Runtime/T2P (lhs_produce_t, lhs_produce_p){
  88. label = "2"
  89. }
  90. }
  91. RHS {
  92. Post_PetriNets_Runtime/Transition rhs_produce_t{
  93. label = "0"
  94. }
  95. Post_PetriNets_Runtime/Place rhs_produce_p{
  96. label = "1"
  97. value_tokens = $
  98. Integer function value(host_model : Element, name : String, mapping : Element):
  99. return integer_addition(read_attribute(host_model, name, "tokens"), read_attribute(host_model, mapping["2"], "weight"))!
  100. $
  101. }
  102. Post_PetriNets_Runtime/T2P (rhs_produce_t, rhs_produce_p){
  103. label = "2"
  104. }
  105. }
  106. }
  107. {Contains} Atomic unmark_transition {
  108. LHS {
  109. Pre_PetriNets_Runtime/Transition {
  110. label = "0"
  111. constraint_executing = $
  112. Boolean function constraint(value : Boolean):
  113. return value!
  114. $
  115. }
  116. }
  117. RHS {
  118. Post_PetriNets_Runtime/Transition {
  119. label = "0"
  120. value_executing = $
  121. Boolean function value(host_model : Element, name : String, mapping : Element):
  122. return False!
  123. $
  124. }
  125. }
  126. }
  127. }
  128. OnSuccess (mark, consume) {}
  129. OnFailure (mark, failure) {}
  130. OnSuccess (consume, produce) {}
  131. OnFailure (consume, produce) {}
  132. OnSuccess (produce, unmark_transition) {}
  133. OnFailure (produce, unmark_transition) {}
  134. OnSuccess (unmark_transition, success) {}
  135. OnFailure (unmark_transition, failure) {}
  136. Initial (schedule, mark) {}
  137. }
  138. export s to models/pn_simulate