pn_simulate.mvc 4.4 KB

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