combine_EPN.mvc 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  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 unselect_all {
  9. LHS {
  10. Pre_Encapsulated_PetriNet/Port pre_ua_1 {
  11. label = "1"
  12. }
  13. }
  14. RHS {
  15. Post_Encapsulated_PetriNet/Port post_ua_1 {
  16. label = "1"
  17. value_selected = $
  18. Boolean function value(model : Element, name : String, mapping : Element):
  19. return False!
  20. $
  21. }
  22. }
  23. }
  24. {Contains} Atomic select {
  25. LHS {
  26. Pre_Encapsulated_PetriNet/Place pre_s_1 {
  27. label = "1"
  28. }
  29. Pre_Encapsulated_PetriNet/Port pre_s_0 {
  30. label = "0"
  31. constraint_selected = $
  32. Boolean function constraint(value : Boolean):
  33. return bool_not(value)!
  34. $
  35. }
  36. Pre_Encapsulated_PetriNet/PortPlace (pre_s_0, pre_s_1){
  37. label = "2"
  38. }
  39. }
  40. NAC {
  41. Pre_Encapsulated_PetriNet/Port nac_s_0 {
  42. label = "0"
  43. }
  44. Pre_Encapsulated_PetriNet/Port nac_s_3 {
  45. label = "3"
  46. constraint_selected = $
  47. Boolean function constraint(value : Boolean):
  48. return value!
  49. $
  50. }
  51. constraint = $
  52. Boolean function constraint(model : Element, mapping : Element):
  53. return value_eq(read_attribute(model, mapping["0"], "name"), read_attribute(model, mapping["3"], "name"))!
  54. $
  55. }
  56. RHS {
  57. Post_Encapsulated_PetriNet/Place post_s_1 {
  58. label = "1"
  59. }
  60. Post_Encapsulated_PetriNet/Port post_s_0 {
  61. label = "0"
  62. value_selected = $
  63. Boolean function value(model : Element, name : String, mapping : Element):
  64. return True!
  65. $
  66. }
  67. Post_Encapsulated_PetriNet/PortPlace (post_s_0, post_s_1){
  68. label = "2"
  69. }
  70. }
  71. }
  72. {Contains} ForAll link {
  73. LHS {
  74. Pre_Encapsulated_PetriNet/Port pre_link_1 {
  75. label = "1"
  76. constraint_selected = $
  77. Boolean function constraint(value : Boolean):
  78. return value!
  79. $
  80. constraint = $
  81. Boolean function constraint(model : Element, name : String):
  82. return (read_nr_out(allOutgoingAssociationInstances(model, name, "Encapsulated_PetriNet/Related")) == 0)!
  83. $
  84. }
  85. Pre_Encapsulated_PetriNet/Port pre_link_2 {
  86. label = "2"
  87. constraint_selected = $
  88. Boolean function constraint(value : Boolean):
  89. return bool_not(value)!
  90. $
  91. }
  92. Pre_Encapsulated_PetriNet/Place pre_link_4 {
  93. label = "4"
  94. }
  95. Pre_Encapsulated_PetriNet/Place pre_link_5 {
  96. label = "5"
  97. }
  98. Pre_Encapsulated_PetriNet/PortPlace (pre_link_1, pre_link_4) {
  99. label = "6"
  100. }
  101. Pre_Encapsulated_PetriNet/PortPlace (pre_link_2, pre_link_5) {
  102. label = "7"
  103. }
  104. constraint = $
  105. Boolean function constraint(model : Element, mapping : Element):
  106. return value_eq(read_attribute(model, mapping["1"], "name"), read_attribute(model, mapping["2"], "name"))!
  107. $
  108. }
  109. RHS {
  110. Post_Encapsulated_PetriNet/Port post_link_1 {
  111. label = "1"
  112. }
  113. Post_Encapsulated_PetriNet/Port post_link_2 {
  114. label = "2"
  115. }
  116. Post_Encapsulated_PetriNet/Related (post_link_1, post_link_2) {
  117. label = "3"
  118. }
  119. Post_Encapsulated_PetriNet/Place post_link_4 {
  120. label = "4"
  121. value_tokens = $
  122. Integer function value(model : Element, name : String, mapping : Element):
  123. Integer tokens_4
  124. Integer tokens_5
  125. tokens_4 = read_attribute(model, mapping["4"], "tokens")
  126. tokens_5 = read_attribute(model, mapping["5"], "tokens")
  127. if (bool_or(tokens_4 > 0, tokens_5 > 0)):
  128. return 1!
  129. else:
  130. return 0!
  131. $
  132. }
  133. Post_Encapsulated_PetriNet/Place post_link_5 {
  134. label = "5"
  135. }
  136. Post_Encapsulated_PetriNet/PortPlace (post_link_1, post_link_4) {
  137. label = "6"
  138. }
  139. Post_Encapsulated_PetriNet/PortPlace (post_link_2, post_link_5) {
  140. label = "7"
  141. }
  142. }
  143. }
  144. {Contains} ForAll merge_P2T {
  145. LHS {
  146. Pre_Encapsulated_PetriNet/Place pre_p2t_1 {
  147. label = "1"
  148. }
  149. Pre_Encapsulated_PetriNet/Port pre_p2t_2 {
  150. label = "2"
  151. constraint_selected = $
  152. Boolean function constraint(value : Boolean):
  153. return value!
  154. $
  155. }
  156. Pre_Encapsulated_PetriNet/PortPlace (pre_p2t_2, pre_p2t_1){
  157. label = "3"
  158. }
  159. Pre_Encapsulated_PetriNet/Place pre_p2t_4 {
  160. label = "4"
  161. }
  162. Pre_Encapsulated_PetriNet/Port pre_p2t_5 {
  163. label = "5"
  164. constraint_selected = $
  165. Boolean function constraint(value : Boolean):
  166. return bool_not(value)!
  167. $
  168. }
  169. Pre_Encapsulated_PetriNet/PortPlace (pre_p2t_5, pre_p2t_4){
  170. label = "6"
  171. }
  172. Pre_Encapsulated_PetriNet/Transition pre_p2t_7 {
  173. label = "7"
  174. }
  175. Pre_Encapsulated_PetriNet/P2T (pre_p2t_4, pre_p2t_7) {
  176. label = "8"
  177. }
  178. Pre_Encapsulated_PetriNet/Related (pre_p2t_2, pre_p2t_5) {
  179. label = "10"
  180. }
  181. }
  182. RHS {
  183. Post_Encapsulated_PetriNet/Place post_p2t_1 {
  184. label = "1"
  185. }
  186. Post_Encapsulated_PetriNet/Port post_p2t_2 {
  187. label = "2"
  188. }
  189. Post_Encapsulated_PetriNet/PortPlace (post_p2t_2, post_p2t_1){
  190. label = "3"
  191. }
  192. Post_Encapsulated_PetriNet/Place post_p2t_4 {
  193. label = "4"
  194. }
  195. Post_Encapsulated_PetriNet/Port post_p2t_5 {
  196. label = "5"
  197. }
  198. Post_Encapsulated_PetriNet/PortPlace (post_p2t_5, post_p2t_4){
  199. label = "6"
  200. }
  201. Post_Encapsulated_PetriNet/Transition post_p2t_7 {
  202. label = "7"
  203. }
  204. Post_Encapsulated_PetriNet/P2T (post_p2t_4, post_p2t_7) {
  205. label = "8"
  206. }
  207. Post_Encapsulated_PetriNet/P2T (post_p2t_1, post_p2t_7) {
  208. label = "9"
  209. }
  210. Post_Encapsulated_PetriNet/Related (post_p2t_2, post_p2t_5) {
  211. label = "10"
  212. }
  213. }
  214. }
  215. {Contains} ForAll merge_T2P {
  216. LHS {
  217. Pre_Encapsulated_PetriNet/Place pre_t2p_1 {
  218. label = "1"
  219. }
  220. Pre_Encapsulated_PetriNet/Port pre_t2p_2 {
  221. label = "2"
  222. constraint_selected = $
  223. Boolean function constraint(value : Boolean):
  224. return value!
  225. $
  226. }
  227. Pre_Encapsulated_PetriNet/PortPlace (pre_t2p_2, pre_t2p_1){
  228. label = "3"
  229. }
  230. Pre_Encapsulated_PetriNet/Place pre_t2p_4 {
  231. label = "4"
  232. }
  233. Pre_Encapsulated_PetriNet/Port pre_t2p_5 {
  234. label = "5"
  235. constraint_selected = $
  236. Boolean function constraint(value : Boolean):
  237. return bool_not(value)!
  238. $
  239. }
  240. Pre_Encapsulated_PetriNet/PortPlace (pre_t2p_5, pre_t2p_4){
  241. label = "6"
  242. }
  243. Pre_Encapsulated_PetriNet/Transition pre_t2p_7 {
  244. label = "7"
  245. }
  246. Pre_Encapsulated_PetriNet/T2P (pre_t2p_7, pre_t2p_4) {
  247. label = "8"
  248. }
  249. Pre_Encapsulated_PetriNet/Related (pre_t2p_2, pre_t2p_5) {
  250. label = "10"
  251. }
  252. }
  253. RHS {
  254. Post_Encapsulated_PetriNet/Place post_t2p_1 {
  255. label = "1"
  256. }
  257. Post_Encapsulated_PetriNet/Port post_t2p_2 {
  258. label = "2"
  259. }
  260. Post_Encapsulated_PetriNet/PortPlace (post_t2p_2, post_t2p_1){
  261. label = "3"
  262. }
  263. Post_Encapsulated_PetriNet/Place post_t2p_4 {
  264. label = "4"
  265. }
  266. Post_Encapsulated_PetriNet/Port post_t2p_5 {
  267. label = "5"
  268. }
  269. Post_Encapsulated_PetriNet/PortPlace (post_t2p_5, post_t2p_4){
  270. label = "6"
  271. }
  272. Post_Encapsulated_PetriNet/Transition post_t2p_7 {
  273. label = "7"
  274. }
  275. Post_Encapsulated_PetriNet/T2P (post_t2p_7, post_t2p_4) {
  276. label = "8"
  277. }
  278. Post_Encapsulated_PetriNet/T2P (post_t2p_7, post_t2p_1) {
  279. label = "9"
  280. }
  281. Post_Encapsulated_PetriNet/Related (post_t2p_2, post_t2p_5) {
  282. label = "10"
  283. }
  284. }
  285. }
  286. {Contains} ForAll remove_old {
  287. LHS {
  288. Pre_Encapsulated_PetriNet/Place pre_rem_1 {
  289. label = "1"
  290. }
  291. Pre_Encapsulated_PetriNet/Port pre_rem_2 {
  292. label = "2"
  293. constraint_selected = $
  294. Boolean function constraint(value : Boolean):
  295. return bool_not(value)!
  296. $
  297. }
  298. Pre_Encapsulated_PetriNet/PortPlace (pre_rem_2, pre_rem_1){
  299. label = "3"
  300. }
  301. }
  302. RHS {
  303. }
  304. }
  305. {Contains} ForAll copy_transitions {
  306. LHS {
  307. Pre_Encapsulated_PetriNet/Transition {
  308. label = "0"
  309. }
  310. }
  311. RHS {
  312. Post_Encapsulated_PetriNet/Transition ct1 {
  313. label = "0"
  314. }
  315. Post_PetriNet/Transition ct2 {
  316. label = "1"
  317. value_name = $
  318. Integer function value(model : Element, name : String, mapping : Element):
  319. return read_attribute(model, mapping["0"], "name")!
  320. $
  321. }
  322. Post_EPN2PN_transition_link (ct1, ct2){
  323. label = "2"
  324. }
  325. }
  326. }
  327. {Contains} ForAll copy_places {
  328. LHS {
  329. Pre_Encapsulated_PetriNet/Place {
  330. label = "0"
  331. }
  332. }
  333. RHS {
  334. Post_Encapsulated_PetriNet/Place cp1 {
  335. label = "0"
  336. }
  337. Post_PetriNet/Place cp2 {
  338. label = "1"
  339. value_tokens = $
  340. Integer function value(model : Element, name : String, mapping : Element):
  341. return read_attribute(model, mapping["0"], "tokens")!
  342. $
  343. value_name = $
  344. Integer function value(model : Element, name : String, mapping : Element):
  345. return read_attribute(model, mapping["0"], "name")!
  346. $
  347. }
  348. Post_EPN2PN_place_link (cp1, cp2){
  349. label = "2"
  350. }
  351. }
  352. }
  353. {Contains} ForAll copy_P2T {
  354. LHS {
  355. Pre_Encapsulated_PetriNet/Place cp2t_p{
  356. label = "0"
  357. }
  358. Pre_Encapsulated_PetriNet/Transition cp2t_t{
  359. label = "1"
  360. }
  361. Pre_Encapsulated_PetriNet/P2T (cp2t_p, cp2t_t){
  362. label = "2"
  363. }
  364. Pre_PetriNet/Place cp2t_p2{
  365. label = "3"
  366. }
  367. Pre_PetriNet/Transition cp2t_t2{
  368. label = "4"
  369. }
  370. Pre_EPN2PN_place_link (cp2t_p, cp2t_p2){
  371. label = "5"
  372. }
  373. Pre_EPN2PN_transition_link (cp2t_t, cp2t_t2){
  374. label = "6"
  375. }
  376. }
  377. RHS {
  378. Post_Encapsulated_PetriNet/Place rhs_cp2t_p{
  379. label = "0"
  380. }
  381. Post_Encapsulated_PetriNet/Transition rhs_cp2t_t{
  382. label = "1"
  383. }
  384. Post_Encapsulated_PetriNet/P2T rhs_cp2t_p2t (rhs_cp2t_p, rhs_cp2t_t){
  385. label = "2"
  386. }
  387. Post_PetriNet/Place rhs_cp2t_p2 {
  388. label = "3"
  389. }
  390. Post_PetriNet/Transition rhs_cp2t_t2 {
  391. label = "4"
  392. }
  393. Post_EPN2PN_place_link (rhs_cp2t_p, rhs_cp2t_p2){
  394. label = "5"
  395. }
  396. Post_EPN2PN_transition_link (rhs_cp2t_t, rhs_cp2t_t2){
  397. label = "6"
  398. }
  399. Post_PetriNet/P2T rhs_cp2t_p2t2(rhs_cp2t_p2, rhs_cp2t_t2) {
  400. label = "7"
  401. value_weight = $
  402. Integer function value(host_model : Element, name : String, mapping : Element):
  403. return 1!
  404. $
  405. }
  406. }
  407. }
  408. {Contains} ForAll copy_T2P {
  409. LHS {
  410. Pre_Encapsulated_PetriNet/Place ct2p_p{
  411. label = "0"
  412. }
  413. Pre_Encapsulated_PetriNet/Transition ct2p_t{
  414. label = "1"
  415. }
  416. Pre_Encapsulated_PetriNet/T2P (ct2p_t, ct2p_p){
  417. label = "2"
  418. }
  419. Pre_PetriNet/Place ct2p_p2{
  420. label = "3"
  421. }
  422. Pre_PetriNet/Transition ct2p_t2{
  423. label = "4"
  424. }
  425. Pre_EPN2PN_place_link (ct2p_p, ct2p_p2){
  426. label = "5"
  427. }
  428. Pre_EPN2PN_transition_link (ct2p_t, ct2p_t2){
  429. label = "6"
  430. }
  431. }
  432. RHS {
  433. Post_Encapsulated_PetriNet/Place rhs_ct2p_p{
  434. label = "0"
  435. }
  436. Post_Encapsulated_PetriNet/Transition rhs_ct2p_t{
  437. label = "1"
  438. }
  439. Post_Encapsulated_PetriNet/T2P (rhs_ct2p_t, rhs_ct2p_p){
  440. label = "2"
  441. }
  442. Post_PetriNet/Place rhs_ct2p_p2 {
  443. label = "3"
  444. }
  445. Post_PetriNet/Transition rhs_ct2p_t2 {
  446. label = "4"
  447. }
  448. Post_EPN2PN_place_link (rhs_ct2p_p, rhs_ct2p_p2){
  449. label = "5"
  450. }
  451. Post_EPN2PN_transition_link (rhs_ct2p_t, rhs_ct2p_t2){
  452. label = "6"
  453. }
  454. Post_PetriNet/T2P (rhs_ct2p_t2, rhs_ct2p_p2) {
  455. label = "7"
  456. value_weight = $
  457. Integer function value(host_model : Element, name : String, mapping : Element):
  458. return 1!
  459. $
  460. }
  461. }
  462. }
  463. }
  464. Initial (schedule, unselect_all) {}
  465. OnSuccess (unselect_all, select) {}
  466. OnFailure (unselect_all, select) {}
  467. OnSuccess (select, link) {}
  468. OnFailure (select, merge_P2T) {}
  469. OnSuccess (link, select) {}
  470. OnFailure (link, select) {}
  471. OnSuccess (merge_P2T, merge_T2P) {}
  472. OnFailure (merge_P2T, merge_T2P) {}
  473. OnSuccess (merge_T2P, remove_old) {}
  474. OnFailure (merge_T2P, remove_old) {}
  475. OnSuccess (remove_old, copy_places) {}
  476. OnFailure (remove_old, copy_places) {}
  477. OnSuccess (copy_places, copy_transitions) {}
  478. OnSuccess (copy_transitions, copy_P2T) {}
  479. OnSuccess (copy_P2T, copy_T2P) {}
  480. OnSuccess (copy_T2P, success) {}
  481. OnFailure (copy_places, copy_transitions) {}
  482. OnFailure (copy_transitions, copy_P2T) {}
  483. OnFailure (copy_P2T, copy_T2P) {}
  484. OnFailure (copy_T2P, success) {}
  485. }