combine_EPN.mvc 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. include "primitives.alh"
  2. include "modelling.alh"
  3. include "object_operations.alh"
  4. A B {
  5. Composite schedule {
  6. {Contains} Success success {}
  7. {Contains} Failure failure {}
  8. {Contains} ForAll link {
  9. LHS {
  10. Pre_Architecture/Group pre_l_0{
  11. label = "0"
  12. }
  13. Pre_Architecture/Port pre_l_1{
  14. label = "1"
  15. }
  16. Pre_Architecture/Contains pre_l_10 (pre_l_0, pre_l_1){
  17. label = "10"
  18. }
  19. Pre_Encapsulated_PetriNet/Port pre_l_2{
  20. label = "2"
  21. }
  22. Pre_Architecture/Group pre_l_3{
  23. label = "3"
  24. }
  25. Pre_Architecture/Port pre_l_4{
  26. label = "4"
  27. }
  28. Pre_Architecture/Contains pre_l_11 (pre_l_3, pre_l_4){
  29. label = "11"
  30. }
  31. Pre_Encapsulated_PetriNet/Port pre_l_5{
  32. label = "5"
  33. }
  34. Pre_Architecture/Connects (pre_l_1, pre_l_4){
  35. label = "6"
  36. }
  37. constraint = $
  38. Boolean function constraint(model : Element, mapping : Element):
  39. String name_0
  40. String name_1
  41. String name_2
  42. String name_3
  43. String name_4
  44. String name_5
  45. name_0 = read_attribute(model, mapping["0"], "name")
  46. name_1 = read_attribute(model, mapping["1"], "name")
  47. name_2 = read_attribute(model, mapping["2"], "name")
  48. name_3 = read_attribute(model, mapping["3"], "name")
  49. name_4 = read_attribute(model, mapping["4"], "name")
  50. name_5 = read_attribute(model, mapping["5"], "name")
  51. if bool_not((name_0 + "/") + name_1 == name_2):
  52. return False!
  53. if bool_not((name_3 + "/") + name_4 == name_5):
  54. return False!
  55. return True!
  56. $
  57. }
  58. RHS {
  59. Post_Architecture/Group post_l_0{
  60. label = "0"
  61. }
  62. Post_Architecture/Port post_l_1{
  63. label = "1"
  64. }
  65. Post_Architecture/Contains post_l_10 (post_l_0, post_l_1){
  66. label = "10"
  67. }
  68. Post_Encapsulated_PetriNet/Port post_l_2{
  69. label = "2"
  70. }
  71. Post_Architecture/Group post_l_3{
  72. label = "3"
  73. }
  74. Post_Architecture/Port post_l_4{
  75. label = "4"
  76. }
  77. Post_Architecture/Contains post_l_11 (post_l_3, post_l_4){
  78. label = "11"
  79. }
  80. Post_Encapsulated_PetriNet/Port post_l_5{
  81. label = "5"
  82. }
  83. Post_Architecture/Connects (post_l_1, post_l_4){
  84. label = "6"
  85. }
  86. Post_Encapsulated_PetriNet/Related (post_l_2, post_l_5){
  87. label = "7"
  88. }
  89. }
  90. }
  91. {Contains} ForAll remove_old {
  92. LHS {
  93. Pre_Encapsulated_PetriNet/Port pre_ro_0 {
  94. label = "0"
  95. }
  96. Pre_Encapsulated_PetriNet/Port pre_ro_1 {
  97. label = "1"
  98. }
  99. Pre_Encapsulated_PetriNet/Place pre_ro_2 {
  100. label = "2"
  101. }
  102. Pre_Encapsulated_PetriNet/Related (pre_ro_0, pre_ro_1) {
  103. label = "3"
  104. }
  105. Pre_Encapsulated_PetriNet/PortPlace (pre_ro_1, pre_ro_2) {
  106. label = "4"
  107. }
  108. }
  109. RHS {
  110. Post_Encapsulated_PetriNet/Port {
  111. label = "0"
  112. }
  113. }
  114. }
  115. {Contains} ForAll merge_P2T {
  116. LHS {
  117. Pre_Encapsulated_PetriNet/Place pre_p2t_1 {
  118. label = "1"
  119. }
  120. Pre_Encapsulated_PetriNet/Port pre_p2t_2 {
  121. label = "2"
  122. }
  123. Pre_Encapsulated_PetriNet/PortPlace (pre_p2t_2, pre_p2t_1){
  124. label = "3"
  125. }
  126. Pre_Encapsulated_PetriNet/Place pre_p2t_4 {
  127. label = "4"
  128. }
  129. Pre_Encapsulated_PetriNet/Port pre_p2t_5 {
  130. label = "5"
  131. }
  132. Pre_Encapsulated_PetriNet/PortPlace (pre_p2t_5, pre_p2t_4){
  133. label = "6"
  134. }
  135. Pre_Encapsulated_PetriNet/Transition pre_p2t_7 {
  136. label = "7"
  137. }
  138. Pre_Encapsulated_PetriNet/P2T (pre_p2t_4, pre_p2t_7) {
  139. label = "8"
  140. }
  141. Pre_Encapsulated_PetriNet/Related (pre_p2t_2, pre_p2t_5) {
  142. label = "10"
  143. }
  144. }
  145. RHS {
  146. Post_Encapsulated_PetriNet/Place post_p2t_1 {
  147. label = "1"
  148. }
  149. Post_Encapsulated_PetriNet/Port post_p2t_2 {
  150. label = "2"
  151. }
  152. Post_Encapsulated_PetriNet/PortPlace (post_p2t_2, post_p2t_1){
  153. label = "3"
  154. }
  155. Post_Encapsulated_PetriNet/Place post_p2t_4 {
  156. label = "4"
  157. }
  158. Post_Encapsulated_PetriNet/Port post_p2t_5 {
  159. label = "5"
  160. }
  161. Post_Encapsulated_PetriNet/PortPlace (post_p2t_5, post_p2t_4){
  162. label = "6"
  163. }
  164. Post_Encapsulated_PetriNet/Transition post_p2t_7 {
  165. label = "7"
  166. }
  167. Post_Encapsulated_PetriNet/P2T (post_p2t_4, post_p2t_7) {
  168. label = "8"
  169. }
  170. Post_Encapsulated_PetriNet/P2T (post_p2t_1, post_p2t_7) {
  171. label = "9"
  172. }
  173. Post_Encapsulated_PetriNet/Related (post_p2t_2, post_p2t_5) {
  174. label = "10"
  175. }
  176. }
  177. }
  178. {Contains} ForAll merge_T2P {
  179. LHS {
  180. Pre_Encapsulated_PetriNet/Place pre_t2p_1 {
  181. label = "1"
  182. }
  183. Pre_Encapsulated_PetriNet/Port pre_t2p_2 {
  184. label = "2"
  185. }
  186. Pre_Encapsulated_PetriNet/PortPlace (pre_t2p_2, pre_t2p_1){
  187. label = "3"
  188. }
  189. Pre_Encapsulated_PetriNet/Place pre_t2p_4 {
  190. label = "4"
  191. }
  192. Pre_Encapsulated_PetriNet/Port pre_t2p_5 {
  193. label = "5"
  194. }
  195. Pre_Encapsulated_PetriNet/PortPlace (pre_t2p_5, pre_t2p_4){
  196. label = "6"
  197. }
  198. Pre_Encapsulated_PetriNet/Transition pre_t2p_7 {
  199. label = "7"
  200. }
  201. Pre_Encapsulated_PetriNet/T2P (pre_t2p_7, pre_t2p_4) {
  202. label = "8"
  203. }
  204. Pre_Encapsulated_PetriNet/Related (pre_t2p_2, pre_t2p_5) {
  205. label = "10"
  206. }
  207. }
  208. RHS {
  209. Post_Encapsulated_PetriNet/Place post_t2p_1 {
  210. label = "1"
  211. }
  212. Post_Encapsulated_PetriNet/Port post_t2p_2 {
  213. label = "2"
  214. }
  215. Post_Encapsulated_PetriNet/PortPlace (post_t2p_2, post_t2p_1){
  216. label = "3"
  217. }
  218. Post_Encapsulated_PetriNet/Place post_t2p_4 {
  219. label = "4"
  220. }
  221. Post_Encapsulated_PetriNet/Port post_t2p_5 {
  222. label = "5"
  223. }
  224. Post_Encapsulated_PetriNet/PortPlace (post_t2p_5, post_t2p_4){
  225. label = "6"
  226. }
  227. Post_Encapsulated_PetriNet/Transition post_t2p_7 {
  228. label = "7"
  229. }
  230. Post_Encapsulated_PetriNet/T2P (post_t2p_7, post_t2p_4) {
  231. label = "8"
  232. }
  233. Post_Encapsulated_PetriNet/T2P (post_t2p_7, post_t2p_1) {
  234. label = "9"
  235. }
  236. Post_Encapsulated_PetriNet/Related (post_t2p_2, post_t2p_5) {
  237. label = "10"
  238. }
  239. }
  240. }
  241. {Contains} ForAll copy_transitions {
  242. LHS {
  243. Pre_Encapsulated_PetriNet/Transition {
  244. label = "0"
  245. }
  246. }
  247. RHS {
  248. Post_Encapsulated_PetriNet/Transition ct1 {
  249. label = "0"
  250. }
  251. Post_PetriNet/Transition ct2 {
  252. label = "1"
  253. value_name = $
  254. Integer function value(model : Element, name : String, mapping : Element):
  255. return read_attribute(model, mapping["0"], "name")!
  256. $
  257. }
  258. Post_EPN2PN_transition_link (ct1, ct2){
  259. label = "2"
  260. }
  261. }
  262. }
  263. {Contains} ForAll copy_places {
  264. LHS {
  265. Pre_Encapsulated_PetriNet/Place {
  266. label = "0"
  267. }
  268. }
  269. RHS {
  270. Post_Encapsulated_PetriNet/Place cp1 {
  271. label = "0"
  272. }
  273. Post_PetriNet/Place cp2 {
  274. label = "1"
  275. value_tokens = $
  276. Integer function value(model : Element, name : String, mapping : Element):
  277. return read_attribute(model, mapping["0"], "tokens")!
  278. $
  279. value_name = $
  280. Integer function value(model : Element, name : String, mapping : Element):
  281. return read_attribute(model, mapping["0"], "name")!
  282. $
  283. }
  284. Post_EPN2PN_place_link (cp1, cp2){
  285. label = "2"
  286. }
  287. }
  288. }
  289. {Contains} ForAll copy_P2T {
  290. LHS {
  291. Pre_Encapsulated_PetriNet/Place cp2t_p{
  292. label = "0"
  293. }
  294. Pre_Encapsulated_PetriNet/Transition cp2t_t{
  295. label = "1"
  296. }
  297. Pre_Encapsulated_PetriNet/P2T (cp2t_p, cp2t_t){
  298. label = "2"
  299. }
  300. Pre_PetriNet/Place cp2t_p2{
  301. label = "3"
  302. }
  303. Pre_PetriNet/Transition cp2t_t2{
  304. label = "4"
  305. }
  306. Pre_EPN2PN_place_link (cp2t_p, cp2t_p2){
  307. label = "5"
  308. }
  309. Pre_EPN2PN_transition_link (cp2t_t, cp2t_t2){
  310. label = "6"
  311. }
  312. }
  313. RHS {
  314. Post_Encapsulated_PetriNet/Place rhs_cp2t_p{
  315. label = "0"
  316. }
  317. Post_Encapsulated_PetriNet/Transition rhs_cp2t_t{
  318. label = "1"
  319. }
  320. Post_Encapsulated_PetriNet/P2T rhs_cp2t_p2t (rhs_cp2t_p, rhs_cp2t_t){
  321. label = "2"
  322. }
  323. Post_PetriNet/Place rhs_cp2t_p2 {
  324. label = "3"
  325. }
  326. Post_PetriNet/Transition rhs_cp2t_t2 {
  327. label = "4"
  328. }
  329. Post_EPN2PN_place_link (rhs_cp2t_p, rhs_cp2t_p2){
  330. label = "5"
  331. }
  332. Post_EPN2PN_transition_link (rhs_cp2t_t, rhs_cp2t_t2){
  333. label = "6"
  334. }
  335. Post_PetriNet/P2T rhs_cp2t_p2t2(rhs_cp2t_p2, rhs_cp2t_t2) {
  336. label = "7"
  337. value_weight = $
  338. Integer function value(host_model : Element, name : String, mapping : Element):
  339. return 1!
  340. $
  341. }
  342. }
  343. }
  344. {Contains} ForAll copy_T2P {
  345. LHS {
  346. Pre_Encapsulated_PetriNet/Place ct2p_p{
  347. label = "0"
  348. }
  349. Pre_Encapsulated_PetriNet/Transition ct2p_t{
  350. label = "1"
  351. }
  352. Pre_Encapsulated_PetriNet/T2P (ct2p_t, ct2p_p){
  353. label = "2"
  354. }
  355. Pre_PetriNet/Place ct2p_p2{
  356. label = "3"
  357. }
  358. Pre_PetriNet/Transition ct2p_t2{
  359. label = "4"
  360. }
  361. Pre_EPN2PN_place_link (ct2p_p, ct2p_p2){
  362. label = "5"
  363. }
  364. Pre_EPN2PN_transition_link (ct2p_t, ct2p_t2){
  365. label = "6"
  366. }
  367. }
  368. RHS {
  369. Post_Encapsulated_PetriNet/Place rhs_ct2p_p{
  370. label = "0"
  371. }
  372. Post_Encapsulated_PetriNet/Transition rhs_ct2p_t{
  373. label = "1"
  374. }
  375. Post_Encapsulated_PetriNet/T2P (rhs_ct2p_t, rhs_ct2p_p){
  376. label = "2"
  377. }
  378. Post_PetriNet/Place rhs_ct2p_p2 {
  379. label = "3"
  380. }
  381. Post_PetriNet/Transition rhs_ct2p_t2 {
  382. label = "4"
  383. }
  384. Post_EPN2PN_place_link (rhs_ct2p_p, rhs_ct2p_p2){
  385. label = "5"
  386. }
  387. Post_EPN2PN_transition_link (rhs_ct2p_t, rhs_ct2p_t2){
  388. label = "6"
  389. }
  390. Post_PetriNet/T2P (rhs_ct2p_t2, rhs_ct2p_p2) {
  391. label = "7"
  392. value_weight = $
  393. Integer function value(host_model : Element, name : String, mapping : Element):
  394. return 1!
  395. $
  396. }
  397. }
  398. }
  399. }
  400. Initial (schedule, link) {}
  401. OnSuccess (link, merge_P2T) {}
  402. OnFailure (link, merge_P2T) {}
  403. OnSuccess (merge_P2T, merge_T2P) {}
  404. OnFailure (merge_P2T, merge_T2P) {}
  405. OnSuccess (merge_T2P, remove_old) {}
  406. OnFailure (merge_T2P, remove_old) {}
  407. OnSuccess (remove_old, copy_places) {}
  408. OnFailure (remove_old, copy_places) {}
  409. OnSuccess (copy_places, copy_transitions) {}
  410. OnSuccess (copy_transitions, copy_P2T) {}
  411. OnSuccess (copy_P2T, copy_T2P) {}
  412. OnSuccess (copy_T2P, success) {}
  413. OnFailure (copy_places, copy_transitions) {}
  414. OnFailure (copy_transitions, copy_P2T) {}
  415. OnFailure (copy_P2T, copy_T2P) {}
  416. OnFailure (copy_T2P, success) {}
  417. }