several_petrinets.mvc 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. import models/SimpleClassDiagrams as SCD
  2. include "primitives.alh"
  3. include "modelling.alh"
  4. SCD PetriNets{
  5. SimpleAttribute Natural {
  6. constraint =
  7. $
  8. String function constraint_Natural(model : Element, name : String):
  9. Element self
  10. self = model["model"][name]
  11. if (is_physical_int(self)):
  12. if (integer_gte(self, 0)):
  13. return "OK"!
  14. else:
  15. return ("Natural does not have a positive or zero value at " + name)!
  16. else:
  17. return ("Natural has no integer value at " + name)!
  18. $
  19. }
  20. Class Place{
  21. tokens : Natural
  22. }
  23. Class Transition{}
  24. Association P2T (Place, Transition) {
  25. weight : Natural
  26. }
  27. Association T2P (Transition, Place) {
  28. weight : Natural
  29. }
  30. }
  31. PetriNets valid_petrinet {
  32. Place p1 {
  33. tokens = 1
  34. }
  35. Place p2 {
  36. tokens = 3
  37. }
  38. Transition t1 {}
  39. P2T (p1, t1) {
  40. weight = 1
  41. }
  42. T2P (t1, p2) {
  43. weight = 2
  44. }
  45. }
  46. PetriNets invalid_petrinet_1 {
  47. Place p1 {
  48. tokens = -1
  49. }
  50. Place p2 {
  51. tokens = 3
  52. }
  53. Transition t1 {}
  54. P2T (p1, t1) {
  55. weight = 1
  56. }
  57. T2P (t1, p2) {
  58. weight = 2
  59. }
  60. }
  61. PetriNets invalid_petrinet_2 {
  62. Place p1 {
  63. tokens = 1
  64. }
  65. Place p2 {
  66. tokens = 3
  67. }
  68. Transition t1 {}
  69. P2T p2t(p1, t1) {
  70. weight = -1
  71. }
  72. T2P (t1, p2) {
  73. weight = 2
  74. }
  75. }
  76. PetriNets invalid_petrinet_3 {
  77. Place p1 {
  78. tokens = 1
  79. }
  80. Place p2 {
  81. tokens = 3
  82. }
  83. Transition t1 {}
  84. P2T wrong_p2t (p1, p2) {
  85. weight = 1
  86. }
  87. T2P (t1, p2) {
  88. weight = 2
  89. }
  90. }
  91. PetriNets invalid_petrinet_4 {
  92. Place p1 {
  93. tokens = 1
  94. }
  95. Place p2 {
  96. tokens = 3
  97. }
  98. Transition t1 {}
  99. P2T (p1, t1) {
  100. weight = 1
  101. }
  102. T2P wrong_t2p(p1, p2) {
  103. weight = 2
  104. }
  105. }
  106. PetriNets invalid_petrinet_5 {
  107. Place p1 {}
  108. Place p2 {
  109. tokens = 3
  110. }
  111. Transition t1 {}
  112. P2T (p1, t1) {
  113. weight = 1
  114. }
  115. T2P (t1, p2) {
  116. weight = 2
  117. }
  118. }
  119. PetriNets invalid_petrinet_6 {
  120. Place p1 {
  121. tokens = 1
  122. }
  123. Place p2 {
  124. tokens = 3
  125. }
  126. Transition t1 {}
  127. P2T p2t (p1, t1) {}
  128. T2P (t1, p2) {
  129. weight = 2
  130. }
  131. }
  132. PetriNets invalid_petrinet_7 {
  133. Place p1 {
  134. tokens = "abc"
  135. }
  136. Place p2 {
  137. tokens = 3
  138. }
  139. Transition t1 {}
  140. P2T (p1, t1) {
  141. weight = 1
  142. }
  143. T2P (t1, p2) {
  144. weight = 2
  145. }
  146. }
  147. export PetriNets to models/PetriNets
  148. export valid_petrinet to models/valid_petrinet
  149. export invalid_petrinet_1 to models/invalid_petrinet_1
  150. export invalid_petrinet_2 to models/invalid_petrinet_2
  151. export invalid_petrinet_3 to models/invalid_petrinet_3
  152. export invalid_petrinet_4 to models/invalid_petrinet_4
  153. export invalid_petrinet_5 to models/invalid_petrinet_5
  154. export invalid_petrinet_6 to models/invalid_petrinet_6
  155. export invalid_petrinet_7 to models/invalid_petrinet_7