combine_EPN.mvc 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  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 merge_P2T {
  74. LHS {
  75. Pre_Encapsulated_PetriNet/Place pre_p2t_1 {
  76. label = "1"
  77. }
  78. Pre_Encapsulated_PetriNet/Port pre_p2t_2 {
  79. label = "2"
  80. constraint_selected = $
  81. Boolean function constraint(value : Boolean):
  82. return value!
  83. $
  84. }
  85. Pre_Encapsulated_PetriNet/PortPlace (pre_p2t_2, pre_p2t_1){
  86. label = "3"
  87. }
  88. Pre_Encapsulated_PetriNet/Place pre_p2t_4 {
  89. label = "4"
  90. }
  91. Pre_Encapsulated_PetriNet/Port pre_p2t_5 {
  92. label = "5"
  93. constraint_selected = $
  94. Boolean function constraint(value : Boolean):
  95. return bool_not(value)!
  96. $
  97. }
  98. Pre_Encapsulated_PetriNet/PortPlace (pre_p2t_5, pre_p2t_4){
  99. label = "6"
  100. }
  101. Pre_Encapsulated_PetriNet/Transition pre_p2t_7 {
  102. label = "7"
  103. }
  104. Pre_Encapsulated_PetriNet/P2T (pre_p2t_4, pre_p2t_7) {
  105. label = "8"
  106. }
  107. constraint = $
  108. Boolean function constraint(model : Element, mapping : Element):
  109. return value_eq(read_attribute(model, mapping["2"], "name"), read_attribute(model, mapping["5"], "name"))!
  110. $
  111. }
  112. RHS {
  113. Post_Encapsulated_PetriNet/Place post_p2t_1 {
  114. label = "1"
  115. }
  116. Post_Encapsulated_PetriNet/Port post_p2t_2 {
  117. label = "2"
  118. }
  119. Post_Encapsulated_PetriNet/PortPlace (post_p2t_2, post_p2t_1){
  120. label = "3"
  121. }
  122. Post_Encapsulated_PetriNet/Place post_p2t_4 {
  123. label = "4"
  124. }
  125. Post_Encapsulated_PetriNet/Port post_p2t_5 {
  126. label = "5"
  127. }
  128. Post_Encapsulated_PetriNet/PortPlace (post_p2t_5, post_p2t_4){
  129. label = "6"
  130. }
  131. Post_Encapsulated_PetriNet/Transition post_p2t_7 {
  132. label = "7"
  133. }
  134. Post_Encapsulated_PetriNet/P2T (post_p2t_4, post_p2t_7) {
  135. label = "8"
  136. }
  137. Post_Encapsulated_PetriNet/P2T (post_p2t_1, post_p2t_7) {
  138. label = "9"
  139. }
  140. }
  141. }
  142. {Contains} ForAll merge_T2P {
  143. LHS {
  144. Pre_Encapsulated_PetriNet/Place pre_t2p_1 {
  145. label = "1"
  146. }
  147. Pre_Encapsulated_PetriNet/Port pre_t2p_2 {
  148. label = "2"
  149. constraint_selected = $
  150. Boolean function constraint(value : Boolean):
  151. return value!
  152. $
  153. }
  154. Pre_Encapsulated_PetriNet/PortPlace (pre_t2p_2, pre_t2p_1){
  155. label = "3"
  156. }
  157. Pre_Encapsulated_PetriNet/Place pre_t2p_4 {
  158. label = "4"
  159. }
  160. Pre_Encapsulated_PetriNet/Port pre_t2p_5 {
  161. label = "5"
  162. constraint_selected = $
  163. Boolean function constraint(value : Boolean):
  164. return bool_not(value)!
  165. $
  166. }
  167. Pre_Encapsulated_PetriNet/PortPlace (pre_t2p_5, pre_t2p_4){
  168. label = "6"
  169. }
  170. Pre_Encapsulated_PetriNet/Transition pre_t2p_7 {
  171. label = "7"
  172. }
  173. Pre_Encapsulated_PetriNet/T2P (pre_t2p_7, pre_t2p_4) {
  174. label = "8"
  175. }
  176. constraint = $
  177. Boolean function constraint(model : Element, mapping : Element):
  178. return value_eq(read_attribute(model, mapping["2"], "name"), read_attribute(model, mapping["5"], "name"))!
  179. $
  180. }
  181. RHS {
  182. Post_Encapsulated_PetriNet/Place post_t2p_1 {
  183. label = "1"
  184. }
  185. Post_Encapsulated_PetriNet/Port post_t2p_2 {
  186. label = "2"
  187. }
  188. Post_Encapsulated_PetriNet/PortPlace (post_t2p_2, post_t2p_1){
  189. label = "3"
  190. }
  191. Post_Encapsulated_PetriNet/Place post_t2p_4 {
  192. label = "4"
  193. }
  194. Post_Encapsulated_PetriNet/Port post_t2p_5 {
  195. label = "5"
  196. }
  197. Post_Encapsulated_PetriNet/PortPlace (post_t2p_5, post_t2p_4){
  198. label = "6"
  199. }
  200. Post_Encapsulated_PetriNet/Transition post_t2p_7 {
  201. label = "7"
  202. }
  203. Post_Encapsulated_PetriNet/T2P (post_t2p_7, post_t2p_4) {
  204. label = "8"
  205. }
  206. Post_Encapsulated_PetriNet/T2P (post_t2p_7, post_t2p_1) {
  207. label = "9"
  208. }
  209. }
  210. }
  211. {Contains} ForAll remove_old {
  212. LHS {
  213. Pre_Encapsulated_PetriNet/Place pre_rem_1 {
  214. label = "1"
  215. }
  216. Pre_Encapsulated_PetriNet/Port pre_rem_2 {
  217. label = "2"
  218. constraint_selected = $
  219. Boolean function constraint(value : Boolean):
  220. return bool_not(value)!
  221. $
  222. }
  223. Pre_Encapsulated_PetriNet/PortPlace (pre_rem_2, pre_rem_1){
  224. label = "3"
  225. }
  226. }
  227. RHS {
  228. }
  229. }
  230. {Contains} ForAll copy_transitions {
  231. LHS {
  232. Pre_Encapsulated_PetriNet/Transition {
  233. label = "0"
  234. }
  235. }
  236. RHS {
  237. Post_Encapsulated_PetriNet/Transition ct1 {
  238. label = "0"
  239. }
  240. Post_PetriNet/Transition ct2 {
  241. label = "1"
  242. value_name = $
  243. Integer function value(model : Element, name : String, mapping : Element):
  244. return read_attribute(model, mapping["0"], "name")!
  245. $
  246. }
  247. Post_EPN2PN_transition_link (ct1, ct2){
  248. label = "2"
  249. }
  250. }
  251. }
  252. {Contains} ForAll copy_places {
  253. LHS {
  254. Pre_Encapsulated_PetriNet/Place {
  255. label = "0"
  256. }
  257. }
  258. RHS {
  259. Post_Encapsulated_PetriNet/Place cp1 {
  260. label = "0"
  261. }
  262. Post_PetriNet/Place cp2 {
  263. label = "1"
  264. value_tokens = $
  265. Integer function value(model : Element, name : String, mapping : Element):
  266. return read_attribute(model, mapping["0"], "tokens")!
  267. $
  268. value_name = $
  269. Integer function value(model : Element, name : String, mapping : Element):
  270. return read_attribute(model, mapping["0"], "name")!
  271. $
  272. }
  273. Post_EPN2PN_place_link (cp1, cp2){
  274. label = "2"
  275. }
  276. }
  277. }
  278. {Contains} ForAll copy_P2T {
  279. LHS {
  280. Pre_Encapsulated_PetriNet/Place cp2t_p{
  281. label = "0"
  282. }
  283. Pre_Encapsulated_PetriNet/Transition cp2t_t{
  284. label = "1"
  285. }
  286. Pre_Encapsulated_PetriNet/P2T (cp2t_p, cp2t_t){
  287. label = "2"
  288. }
  289. Pre_PetriNet/Place cp2t_p2{
  290. label = "3"
  291. }
  292. Pre_PetriNet/Transition cp2t_t2{
  293. label = "4"
  294. }
  295. Pre_EPN2PN_place_link (cp2t_p, cp2t_p2){
  296. label = "5"
  297. }
  298. Pre_EPN2PN_transition_link (cp2t_t, cp2t_t2){
  299. label = "6"
  300. }
  301. }
  302. RHS {
  303. Post_Encapsulated_PetriNet/Place rhs_cp2t_p{
  304. label = "0"
  305. }
  306. Post_Encapsulated_PetriNet/Transition rhs_cp2t_t{
  307. label = "1"
  308. }
  309. Post_Encapsulated_PetriNet/P2T rhs_cp2t_p2t (rhs_cp2t_p, rhs_cp2t_t){
  310. label = "2"
  311. }
  312. Post_PetriNet/Place rhs_cp2t_p2 {
  313. label = "3"
  314. }
  315. Post_PetriNet/Transition rhs_cp2t_t2 {
  316. label = "4"
  317. }
  318. Post_EPN2PN_place_link (rhs_cp2t_p, rhs_cp2t_p2){
  319. label = "5"
  320. }
  321. Post_EPN2PN_transition_link (rhs_cp2t_t, rhs_cp2t_t2){
  322. label = "6"
  323. }
  324. Post_PetriNet/P2T rhs_cp2t_p2t2(rhs_cp2t_p2, rhs_cp2t_t2) {
  325. label = "7"
  326. value_weight = $
  327. Integer function value(host_model : Element, name : String, mapping : Element):
  328. return 1!
  329. $
  330. }
  331. }
  332. }
  333. {Contains} ForAll copy_T2P {
  334. LHS {
  335. Pre_Encapsulated_PetriNet/Place ct2p_p{
  336. label = "0"
  337. }
  338. Pre_Encapsulated_PetriNet/Transition ct2p_t{
  339. label = "1"
  340. }
  341. Pre_Encapsulated_PetriNet/T2P (ct2p_t, ct2p_p){
  342. label = "2"
  343. }
  344. Pre_PetriNet/Place ct2p_p2{
  345. label = "3"
  346. }
  347. Pre_PetriNet/Transition ct2p_t2{
  348. label = "4"
  349. }
  350. Pre_EPN2PN_place_link (ct2p_p, ct2p_p2){
  351. label = "5"
  352. }
  353. Pre_EPN2PN_transition_link (ct2p_t, ct2p_t2){
  354. label = "6"
  355. }
  356. }
  357. RHS {
  358. Post_Encapsulated_PetriNet/Place rhs_ct2p_p{
  359. label = "0"
  360. }
  361. Post_Encapsulated_PetriNet/Transition rhs_ct2p_t{
  362. label = "1"
  363. }
  364. Post_Encapsulated_PetriNet/T2P (rhs_ct2p_t, rhs_ct2p_p){
  365. label = "2"
  366. }
  367. Post_PetriNet/Place rhs_ct2p_p2 {
  368. label = "3"
  369. }
  370. Post_PetriNet/Transition rhs_ct2p_t2 {
  371. label = "4"
  372. }
  373. Post_EPN2PN_place_link (rhs_ct2p_p, rhs_ct2p_p2){
  374. label = "5"
  375. }
  376. Post_EPN2PN_transition_link (rhs_ct2p_t, rhs_ct2p_t2){
  377. label = "6"
  378. }
  379. Post_PetriNet/T2P (rhs_ct2p_t2, rhs_ct2p_p2) {
  380. label = "7"
  381. value_weight = $
  382. Integer function value(host_model : Element, name : String, mapping : Element):
  383. return 1!
  384. $
  385. }
  386. }
  387. }
  388. }
  389. Initial (schedule, unselect_all) {}
  390. OnSuccess (unselect_all, select) {}
  391. OnFailure (unselect_all, select) {}
  392. OnSuccess (select, select) {}
  393. OnFailure (select, merge_P2T) {}
  394. OnSuccess (merge_P2T, merge_T2P) {}
  395. OnFailure (merge_P2T, merge_T2P) {}
  396. OnSuccess (merge_T2P, remove_old) {}
  397. OnFailure (merge_T2P, remove_old) {}
  398. OnSuccess (remove_old, copy_places) {}
  399. OnFailure (remove_old, copy_places) {}
  400. OnSuccess (copy_places, copy_transitions) {}
  401. OnSuccess (copy_transitions, copy_P2T) {}
  402. OnSuccess (copy_P2T, copy_T2P) {}
  403. OnSuccess (copy_T2P, success) {}
  404. OnFailure (copy_places, copy_transitions) {}
  405. OnFailure (copy_transitions, copy_P2T) {}
  406. OnFailure (copy_P2T, copy_T2P) {}
  407. OnFailure (copy_T2P, success) {}
  408. }