combine_EPN.mvc 18 KB

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