several_petrinets.mvc 2.8 KB

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