pione 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (304) hide show
  1. data/.gitignore +2 -0
  2. data/.s3cfg +42 -0
  3. data/.travis.yml +18 -4
  4. data/.yardopts +1 -0
  5. data/Gemfile +3 -0
  6. data/History.txt +14 -0
  7. data/Procfile +7 -0
  8. data/Rakefile +25 -0
  9. data/bin/pione-interactive +6 -0
  10. data/bin/{pione-compiler → pione-notification-listener} +1 -1
  11. data/bin/{pione-broker → pione-task-worker-broker} +1 -1
  12. data/doc/man/pione-list-param.md +36 -0
  13. data/example/ActionError/ActionError.pione +9 -0
  14. data/example/ActionError/pione-package.json +15 -0
  15. data/example/CountChar/CountChar.pione +1 -1
  16. data/example/ScoreAggregation/ScoreAggregation.pione +1 -1
  17. data/example/Touch/pione-package.json +15 -0
  18. data/lib/pione.rb +12 -0
  19. data/lib/pione/agent.rb +3 -3
  20. data/lib/pione/agent/basic-agent.rb +10 -4
  21. data/lib/pione/agent/input-generator.rb +3 -3
  22. data/lib/pione/agent/{process-manager.rb → job-manager.rb} +10 -7
  23. data/lib/pione/agent/job-terminator.rb +2 -2
  24. data/lib/pione/agent/logger.rb +3 -3
  25. data/lib/pione/agent/messenger.rb +20 -9
  26. data/lib/pione/agent/notification-listener.rb +88 -0
  27. data/lib/pione/agent/task-worker-broker.rb +84 -0
  28. data/lib/pione/agent/task-worker.rb +3 -2
  29. data/lib/pione/agent/tuple-space-client.rb +1 -0
  30. data/lib/pione/agent/tuple-space-provider.rb +17 -35
  31. data/lib/pione/command.rb +33 -15
  32. data/lib/pione/command/action.rb +105 -0
  33. data/lib/pione/command/basic-command.rb +34 -376
  34. data/lib/pione/command/command-exception.rb +12 -11
  35. data/lib/pione/command/common.rb +198 -0
  36. data/lib/pione/command/option.rb +159 -204
  37. data/lib/pione/command/pione-action-exec.rb +85 -0
  38. data/lib/pione/command/pione-action-list.rb +43 -19
  39. data/lib/pione/command/pione-action-print.rb +79 -0
  40. data/lib/pione/command/pione-action.rb +8 -67
  41. data/lib/pione/command/pione-clean.rb +88 -68
  42. data/lib/pione/command/pione-client.rb +475 -332
  43. data/lib/pione/command/pione-command.rb +14 -31
  44. data/lib/pione/command/pione-compile.rb +90 -0
  45. data/lib/pione/command/pione-config-get.rb +53 -0
  46. data/lib/pione/command/pione-config-list.rb +64 -0
  47. data/lib/pione/command/pione-config-set.rb +59 -0
  48. data/lib/pione/command/pione-config-unset.rb +50 -0
  49. data/lib/pione/command/pione-config.rb +61 -0
  50. data/lib/pione/command/pione-diagnosis-notification.rb +235 -0
  51. data/lib/pione/command/pione-diagnosis.rb +21 -0
  52. data/lib/pione/command/pione-interactive.rb +188 -0
  53. data/lib/pione/command/pione-lang-check-syntax.rb +163 -0
  54. data/lib/pione/command/pione-lang-interactive.rb +146 -0
  55. data/lib/pione/command/pione-lang.rb +22 -0
  56. data/lib/pione/command/pione-log-format.rb +163 -0
  57. data/lib/pione/command/pione-log-list-id.rb +48 -0
  58. data/lib/pione/command/pione-log.rb +19 -101
  59. data/lib/pione/command/pione-notification-listener.rb +95 -0
  60. data/lib/pione/command/pione-package-add.rb +137 -0
  61. data/lib/pione/command/pione-package-build.rb +122 -0
  62. data/lib/pione/command/pione-package-show.rb +96 -0
  63. data/lib/pione/command/pione-package-update.rb +59 -0
  64. data/lib/pione/command/pione-package.rb +11 -139
  65. data/lib/pione/command/pione-task-worker-broker.rb +88 -0
  66. data/lib/pione/command/pione-task-worker.rb +148 -98
  67. data/lib/pione/command/pione-tuple-space-provider.rb +62 -54
  68. data/lib/pione/command/pione-tuple-space-viewer.rb +105 -83
  69. data/lib/pione/command/pione-val.rb +39 -39
  70. data/lib/pione/command/spawner.rb +34 -27
  71. data/lib/pione/front.rb +4 -2
  72. data/lib/pione/front/basic-front.rb +86 -23
  73. data/lib/pione/front/client-front.rb +2 -2
  74. data/lib/pione/front/diagnosis-notification-front.rb +40 -0
  75. data/lib/pione/front/front-exception.rb +7 -1
  76. data/lib/pione/front/notification-listener-front.rb +36 -0
  77. data/lib/pione/front/notification-recipient-interface.rb +19 -0
  78. data/lib/pione/front/relay-front.rb +4 -4
  79. data/lib/pione/front/task-worker-broker-front.rb +19 -0
  80. data/lib/pione/front/task-worker-front.rb +2 -2
  81. data/lib/pione/front/tuple-space-provider-front.rb +3 -2
  82. data/lib/pione/global.rb +3 -1
  83. data/lib/pione/global/client-variable.rb +1 -1
  84. data/lib/pione/global/config.rb +63 -7
  85. data/lib/pione/global/diagnosis-variable.rb +26 -0
  86. data/lib/pione/global/item.rb +28 -5
  87. data/lib/pione/global/log-variable.rb +6 -5
  88. data/lib/pione/global/network-variable.rb +75 -4
  89. data/lib/pione/global/path-variable.rb +1 -1
  90. data/lib/pione/global/system-variable.rb +12 -12
  91. data/lib/pione/global/task-worker-broker-variable.rb +43 -0
  92. data/lib/pione/global/tuple-space-notifier-variable.rb +3 -55
  93. data/lib/pione/lang/boolean.rb +4 -0
  94. data/lib/pione/lang/data-expr.rb +1 -1
  95. data/lib/pione/lang/integer.rb +1 -1
  96. data/lib/pione/lang/string.rb +4 -0
  97. data/lib/pione/lang/type.rb +1 -1
  98. data/lib/pione/location.rb +1 -0
  99. data/lib/pione/location/data-location.rb +41 -13
  100. data/lib/pione/location/dropbox-location.rb +175 -56
  101. data/lib/pione/location/ftp-location.rb +4 -1
  102. data/lib/pione/location/http-location.rb +5 -3
  103. data/lib/pione/location/https-location.rb +4 -2
  104. data/lib/pione/location/local-location.rb +6 -3
  105. data/lib/pione/location/location-exception.rb +12 -0
  106. data/lib/pione/location/notification-scheme.rb +46 -0
  107. data/lib/pione/log.rb +8 -7
  108. data/lib/pione/log/debug.rb +9 -9
  109. data/lib/pione/log/domain-log.rb +6 -1
  110. data/lib/pione/log/message-log-receiver.rb +32 -0
  111. data/lib/pione/log/system-log.rb +62 -141
  112. data/lib/pione/model.rb +7 -0
  113. data/lib/pione/model/notification-listener-model.rb +29 -0
  114. data/lib/pione/model/task-worker-broker-model.rb +129 -0
  115. data/lib/pione/notification.rb +13 -0
  116. data/lib/pione/notification/address.rb +104 -0
  117. data/lib/pione/notification/exception.rb +10 -0
  118. data/lib/pione/notification/message.rb +109 -0
  119. data/lib/pione/notification/receiver.rb +90 -0
  120. data/lib/pione/notification/recipient.rb +68 -0
  121. data/lib/pione/notification/task-worker-broker-recipient.rb +85 -0
  122. data/lib/pione/notification/transmitter.rb +84 -0
  123. data/lib/pione/pnml.rb +35 -0
  124. data/lib/pione/pnml/annotation-extractor.rb +47 -0
  125. data/lib/pione/pnml/compiler.rb +176 -0
  126. data/lib/pione/pnml/input-merge-complement.rb +78 -0
  127. data/lib/pione/pnml/input-parallelization-complement.rb +75 -0
  128. data/lib/pione/pnml/input-reduction.rb +80 -0
  129. data/lib/pione/pnml/invalid-arc-elimination.rb +41 -0
  130. data/lib/pione/pnml/io-expansion.rb +88 -0
  131. data/lib/pione/pnml/isolated-element-elimination.rb +32 -0
  132. data/lib/pione/pnml/net-rewriter.rb +44 -0
  133. data/lib/pione/pnml/output-decomposition-complement.rb +77 -0
  134. data/lib/pione/pnml/output-reduction.rb +86 -0
  135. data/lib/pione/pnml/output-synchronization-complement.rb +77 -0
  136. data/lib/pione/pnml/pione-model.rb +417 -0
  137. data/lib/pione/pnml/pnml-exception.rb +23 -0
  138. data/lib/pione/pnml/pnml-model.rb +368 -0
  139. data/lib/pione/pnml/reader.rb +51 -0
  140. data/lib/pione/rule-engine/action-handler.rb +8 -6
  141. data/lib/pione/rule-engine/basic-handler.rb +5 -5
  142. data/lib/pione/rule-engine/engine-exception.rb +7 -6
  143. data/lib/pione/rule-engine/flow-handler.rb +27 -18
  144. data/lib/pione/system.rb +3 -1
  145. data/lib/pione/system/domain-dump.rb +34 -0
  146. data/lib/pione/system/file-cache.rb +92 -13
  147. data/lib/pione/system/init.rb +3 -0
  148. data/lib/pione/system/normalizer.rb +40 -0
  149. data/lib/pione/system/status.rb +5 -5
  150. data/lib/pione/system/system-exception.rb +14 -1
  151. data/lib/pione/task-worker-broker.rb +7 -0
  152. data/lib/pione/task-worker-broker/basic-provider.rb +20 -0
  153. data/lib/pione/task-worker-broker/easy-provider.rb +65 -0
  154. data/lib/pione/test-helper.rb +27 -0
  155. data/lib/pione/test-helper/command-helper.rb +9 -101
  156. data/lib/pione/tuple-space/basic-tuple.rb +1 -1
  157. data/lib/pione/tuple-space/tuple-definition.yml +4 -6
  158. data/lib/pione/tuple-space/tuple-space-interface.rb +3 -45
  159. data/lib/pione/tuple-space/tuple-space-server.rb +45 -0
  160. data/lib/pione/util.rb +1 -2
  161. data/lib/pione/util/boolean-value.rb +62 -0
  162. data/lib/pione/util/completion.rb +111 -0
  163. data/lib/pione/util/evaluatable.rb +13 -27
  164. data/lib/pione/util/package-parameters-list.rb +15 -27
  165. data/lib/pione/util/zip.rb +8 -3
  166. data/lib/pione/version.rb +1 -1
  167. data/lib/rootage.rb +20 -0
  168. data/lib/rootage/action.rb +114 -0
  169. data/lib/rootage/argument.rb +46 -0
  170. data/lib/rootage/command.rb +218 -0
  171. data/lib/rootage/core.rb +532 -0
  172. data/lib/rootage/exception.rb +107 -0
  173. data/lib/rootage/help.rb +148 -0
  174. data/lib/rootage/help.txt.erb +31 -0
  175. data/lib/rootage/log.rb +226 -0
  176. data/lib/rootage/normalizer.rb +184 -0
  177. data/lib/rootage/option.rb +152 -0
  178. data/lib/rootage/scenario-test-result.erb +39 -0
  179. data/lib/rootage/scenario.rb +362 -0
  180. data/lib/rootage/test-helper.rb +115 -0
  181. data/man/pione-list-param.1 +44 -0
  182. data/misc/clock.rb +9 -0
  183. data/misc/machine-info.sh +21 -0
  184. data/misc/pione-completion.bash +238 -0
  185. data/misc/pione-completion.erb +53 -0
  186. data/misc/pione-completion.zsh +238 -0
  187. data/misc/pione.god +22 -0
  188. data/misc/ui.xml +23 -0
  189. data/pione.gemspec +3 -1
  190. data/test/agent/spec_basic-agent.rb +1 -1
  191. data/test/agent/spec_input-generator.rb +2 -2
  192. data/test/agent/spec_messenger.rb +6 -9
  193. data/test/agent/spec_notification-listener.rb +80 -0
  194. data/test/agent/{spec_broker.rb → spec_task-worker-broker.rb} +13 -10
  195. data/test/agent/spec_tuple-space-provider.rb +10 -6
  196. data/test/command/command-behavior.rb +3 -11
  197. data/test/command/data/pione-list-param/AdvancedParameters.pione +12 -0
  198. data/test/command/data/pione-list-param/BasicParameters.pione +12 -0
  199. data/test/command/spec_pione-action-exec.rb +16 -0
  200. data/test/command/spec_pione-action-list.rb +15 -10
  201. data/test/command/spec_pione-action-print.rb +14 -0
  202. data/test/command/spec_pione-action.rb +6 -19
  203. data/test/command/spec_pione-clean.rb +29 -46
  204. data/test/command/spec_pione-client.rb +29 -36
  205. data/test/command/spec_pione-command.rb +6 -6
  206. data/test/command/{spec_pione-compiler.rb → spec_pione-compile.rb} +11 -13
  207. data/test/command/spec_pione-config-get.rb +47 -0
  208. data/test/command/spec_pione-config-list.rb +42 -0
  209. data/test/command/spec_pione-config-set.rb +38 -0
  210. data/test/command/spec_pione-config-unset.rb +44 -0
  211. data/test/command/spec_pione-config.rb +11 -0
  212. data/test/command/spec_pione-diagnosis-notification.rb +23 -0
  213. data/test/command/spec_pione-diagnosis.rb +11 -0
  214. data/test/command/spec_pione-lang-check-syntax.rb +12 -0
  215. data/test/command/spec_pione-lang.rb +11 -0
  216. data/test/command/spec_pione-log-format.rb +29 -0
  217. data/test/command/spec_pione-log-list-id.rb +17 -0
  218. data/test/command/spec_pione-log.rb +6 -20
  219. data/test/command/spec_pione-package-add.rb +55 -0
  220. data/test/command/spec_pione-package-build.rb +57 -0
  221. data/test/command/spec_pione-package-show.rb +72 -0
  222. data/test/command/{spec_pione-update-package-info.rb → spec_pione-package-update.rb} +12 -13
  223. data/test/command/spec_pione-package.rb +4 -104
  224. data/test/command/spec_pione-val.rb +10 -7
  225. data/test/global/spec_config.rb +50 -0
  226. data/test/global/spec_item.rb +1 -1
  227. data/test/literate-action/data/HelloWorld.md +1 -1
  228. data/test/location/location-behavior.rb +1 -1
  229. data/test/location/spec_dropbox-location.rb +39 -0
  230. data/test/location/spec_notification-scheme.rb +37 -0
  231. data/test/log/spec_debug.rb +5 -4
  232. data/test/log/spec_message-log-receiver.rb +13 -0
  233. data/test/log/spec_message-log.rb +6 -9
  234. data/test/log/spec_system-log.rb +5 -3
  235. data/test/notification/spec_address.rb +229 -0
  236. data/test/notification/spec_message.rb +30 -0
  237. data/test/notification/spec_receiver.rb +36 -0
  238. data/test/notification/spec_transmitter.rb +37 -0
  239. data/test/pnml/data/ConditionalBranchIf.pnml +270 -0
  240. data/test/pnml/data/ConditionalBranchIfElse.pnml +309 -0
  241. data/test/pnml/data/IOExpansionComplex.pnml +363 -0
  242. data/test/pnml/data/IOExpansionSimple.pnml +140 -0
  243. data/test/pnml/data/InputMergeComplementComplex.pnml +381 -0
  244. data/test/pnml/data/InputMergeComplementSimple.pnml +248 -0
  245. data/test/pnml/data/InputParallelizationComplementComplex.pnml +433 -0
  246. data/test/pnml/data/InputParallelizationComplementSimple.pnml +288 -0
  247. data/test/pnml/data/InputReductionComplex.pnml +192 -0
  248. data/test/pnml/data/InputReductionLong.pnml +344 -0
  249. data/test/pnml/data/InputReductionSimple.pnml +140 -0
  250. data/test/pnml/data/IsolatedElementElimination.pnml +171 -0
  251. data/test/pnml/data/OutputDecompositionComplementComplex.pnml +381 -0
  252. data/test/pnml/data/OutputDecompositionComplementSimple.pnml +242 -0
  253. data/test/pnml/data/OutputReductionComplex.pnml +186 -0
  254. data/test/pnml/data/OutputReductionLong.pnml +344 -0
  255. data/test/pnml/data/OutputReductionSimple.pnml +140 -0
  256. data/test/pnml/data/OutputSynchronizationComplementComplex.pnml +498 -0
  257. data/test/pnml/data/OutputSynchronizationComplementSimple.pnml +347 -0
  258. data/test/pnml/data/SampleNet.pnml +238 -0
  259. data/test/pnml/spec_input-merge-complement.rb +40 -0
  260. data/test/pnml/spec_input-parallelization-complement.rb +50 -0
  261. data/test/pnml/spec_input-reduction.rb +113 -0
  262. data/test/pnml/spec_invalid-arc-elimination.rb +33 -0
  263. data/test/pnml/spec_io-expansion.rb +126 -0
  264. data/test/pnml/spec_isolated-element-elimination.rb +25 -0
  265. data/test/pnml/spec_output-decomposition-complement.rb +40 -0
  266. data/test/pnml/spec_output-reduction.rb +114 -0
  267. data/test/pnml/spec_output-synchronization-complement.rb +62 -0
  268. data/test/pnml/spec_pione-element.rb +144 -0
  269. data/test/pnml/spec_pnml-element.rb +373 -0
  270. data/test/pnml/spec_reader.rb +16 -0
  271. data/test/rootage/spec_argument.rb +18 -0
  272. data/test/rootage/spec_command.rb +239 -0
  273. data/test/rootage/spec_core.rb +198 -0
  274. data/test/rootage/spec_scenario.rb +149 -0
  275. data/test/system/{spec_domain-info.rb → spec_domain-dump.rb} +6 -6
  276. data/test/system/spec_file-cache.rb +6 -9
  277. data/test/tuple-space/spec_finished-tuple.rb +1 -1
  278. data/test/util/{spec_package-parameters-list_1.pione → data/package-parameters-list/Param1.pione} +0 -0
  279. data/test/util/{spec_package-parameters-list_2.pione → data/package-parameters-list/Param2.pione} +0 -0
  280. data/test/util/{spec_package-parameters-list_3.pione → data/package-parameters-list/Param3.pione} +0 -0
  281. data/test/util/{spec_package-parameters-list_4.pione → data/package-parameters-list/Param4.pione} +0 -0
  282. data/test/util/spec_boolean-value.rb +32 -0
  283. data/test/util/spec_completion.rb +22 -0
  284. data/test/util/spec_package-parameters-list.rb +39 -52
  285. data/test/util/spec_zip.rb +28 -1
  286. metadata +288 -47
  287. data/bin/pione-tuple-space-receiver +0 -5
  288. data/lib/pione/agent/broker.rb +0 -304
  289. data/lib/pione/agent/tuple-space-receiver.rb +0 -137
  290. data/lib/pione/command/pione-broker.rb +0 -104
  291. data/lib/pione/command/pione-compiler.rb +0 -57
  292. data/lib/pione/command/pione-relay-account-db.rb +0 -141
  293. data/lib/pione/command/pione-relay-client-db.rb +0 -118
  294. data/lib/pione/command/pione-relay.rb +0 -59
  295. data/lib/pione/command/pione-syntax-checker.rb +0 -214
  296. data/lib/pione/command/pione-tuple-space-receiver.rb +0 -111
  297. data/lib/pione/command/pione-update-package-info.rb +0 -53
  298. data/lib/pione/front/broker-front.rb +0 -22
  299. data/lib/pione/front/tuple-space-receiver-front.rb +0 -11
  300. data/lib/pione/global/broker-variable.rb +0 -33
  301. data/lib/pione/system/domain-info.rb +0 -25
  302. data/lib/pione/util/pnml-compiler.rb +0 -168
  303. data/test/agent/spec_tuple-space-receiver.rb +0 -47
  304. data/test/util/spec_pnml-compiler.rb +0 -32
@@ -0,0 +1,40 @@
1
+ require 'pione/test-helper'
2
+
3
+ TestHelper.scope do |this|
4
+ this::DIR = Location[__FILE__].dirname + "data"
5
+ this::SIMPLE = this::DIR + "InputMergeComplementSimple.pnml"
6
+ this::COMPLEX = this::DIR + "InputMergeComplementComplex.pnml"
7
+
8
+ describe Pione::PNML::InputMergeComplement do
9
+ it "should name by `input merge` in simple case" do
10
+ net = PNML::Reader.read(this::SIMPLE)
11
+
12
+ # transition
13
+ transition_A = net.find_transition_by_name("A")
14
+ place = net.find_all_places_by_target_id(transition_A.id).first
15
+
16
+ # apply "input merge complement" rule
17
+ PNML::NetRewriter.new{|rules| rules << PNML::InputMergeComplement}.rewrite(net)
18
+
19
+ # test
20
+ place.name.should == "<'i1' or 'i2' or 'i3'"
21
+ end
22
+
23
+ it "should name by `input merge` in complex case" do
24
+ net = PNML::Reader.read(this::COMPLEX)
25
+
26
+ # transition
27
+ transition_A = net.find_transition_by_name("A")
28
+ transition_B = net.find_transition_by_name("B")
29
+ place_LA = net.find_all_places_by_target_id(transition_A.id).first
30
+ place_LB = net.find_all_places_by_target_id(transition_B.id).first
31
+
32
+ # apply "input merge complement" rule
33
+ PNML::NetRewriter.new{|rules| rules << PNML::InputMergeComplement}.rewrite(net)
34
+
35
+ # test
36
+ place_LA.name.should == "<'i1' or 'i2' or 'i3'"
37
+ place_LB.name.should == "<'i2' or 'i3' or 'i4'"
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,50 @@
1
+ require 'pione/test-helper'
2
+
3
+ TestHelper.scope do |this|
4
+ this::DIR = Location[__FILE__].dirname + "data"
5
+ this::SIMPLE = this::DIR + "InputParallelizationComplementSimple.pnml"
6
+ this::COMPLEX = this::DIR + "InputParallelizationComplementComplex.pnml"
7
+
8
+ describe Pione::PNML::InputParallelizationComplement do
9
+ it "should name by `input parallelization` in simple case" do
10
+ net = PNML::Reader.read(this::SIMPLE)
11
+
12
+ # elements
13
+ transition_A = net.find_transition_by_name("A")
14
+ transition_B = net.find_transition_by_name("B")
15
+ transition_C = net.find_transition_by_name("C")
16
+ place_LA = net.find_all_places_by_target_id(transition_A.id).first
17
+ place_LB = net.find_all_places_by_target_id(transition_B.id).first
18
+ place_LC = net.find_all_places_by_target_id(transition_C.id).first
19
+
20
+ # apply "input parallelization complement" rule
21
+ PNML::NetRewriter.new{|rules| rules << PNML::InputParallelizationComplement}.rewrite(net)
22
+
23
+ # test
24
+ place_LA.name.should == "'i1'"
25
+ place_LB.name.should == "'i1'"
26
+ place_LC.name.should == "'i1'"
27
+ end
28
+
29
+ it "should name by `input parallelization` in complex case" do
30
+ net = PNML::Reader.read(this::COMPLEX)
31
+
32
+ # elements
33
+ transition_A = net.find_transition_by_name("A")
34
+ transition_B = net.find_transition_by_name("B")
35
+ transition_C = net.find_transition_by_name("C")
36
+ places_LA = net.find_all_places_by_target_id(transition_A.id)
37
+ places_LB = net.find_all_places_by_target_id(transition_B.id)
38
+ places_LC = net.find_all_places_by_target_id(transition_C.id)
39
+
40
+ # apply "input parallelization complement" rule
41
+ PNML::NetRewriter.new{|rules| rules << PNML::InputParallelizationComplement}.rewrite(net)
42
+
43
+ # test
44
+ places_LA.map{|place| place.name}.sort.should == ["'i1'", "'i2'"]
45
+ places_LB.map{|place| place.name}.sort.should == ["'i1'", "'i2'"]
46
+ places_LC.map{|place| place.name}.sort.should == ["'i1'", "'i2'"]
47
+ end
48
+ end
49
+ end
50
+
@@ -0,0 +1,113 @@
1
+ require 'pione/test-helper'
2
+
3
+ TestHelper.scope do |this|
4
+ this::DIR = Location[__FILE__].dirname + "data"
5
+ this::SIMPLE = this::DIR + "InputReductionSimple.pnml"
6
+ this::COMPLEX = this::DIR + "InputReductionComplex.pnml"
7
+ this::LONG = this::DIR + "InputReductionLong.pnml"
8
+
9
+ describe Pione::PNML::InputReduction do
10
+ it "should reduce nodes by `input reduction` in simple case" do
11
+ net = PNML::Reader.read(this::SIMPLE)
12
+
13
+ # save net elements
14
+ transition_A = net.transitions.find {|transition| transition.name == "A"}
15
+ place_i1 = net.find_place_by_name("<'i1'")
16
+ place_o1 = net.find_place_by_name(">'o1'")
17
+ arc_A_o1 = net.find_arc(transition_A.id, place_o1.id)
18
+
19
+ # apply input reduction
20
+ PNML::NetRewriter.new{|rules| rules << PNML::InputReduction}.rewrite(net)
21
+
22
+ # test transitions
23
+ net.transitions.size.should == 1
24
+ net.transitions.should.include transition_A
25
+
26
+ # test places
27
+ net.places.size.should == 2
28
+ net.places.should.include place_i1
29
+ net.places.should.include place_o1
30
+
31
+ # test arcs
32
+ net.arcs.size.should == 2
33
+ net.find_arc(place_i1.id, transition_A.id).should.kind_of PNML::Arc
34
+ net.find_arc(transition_A.id, place_o1.id).should == arc_A_o1
35
+ end
36
+
37
+ it "should reduce nodes by `input reduction` in complex case" do
38
+ net = PNML::Reader.read(this::COMPLEX)
39
+
40
+ # save net elements
41
+ transition_A = net.find_transition_by_name("A")
42
+ place_i1 = net.find_place_by_name("<'i1'")
43
+ place_i2 = net.find_place_by_name("<'i2'")
44
+ place_i3 = net.find_place_by_name("<'i3'")
45
+ place_o1 = net.find_place_by_name(">'o1'")
46
+
47
+ # apply output reduction
48
+ PNML::NetRewriter.new{|rules| rules << PNML::InputReduction}.rewrite(net)
49
+
50
+ # test transitions
51
+ net.transitions.size.should == 1
52
+ net.transitions.first.should == transition_A
53
+
54
+ # test places
55
+ net.places.size.should == 4
56
+ net.places.should.include place_i1
57
+ net.places.should.include place_i2
58
+ net.places.should.include place_i3
59
+ net.places.should.include place_o1
60
+
61
+ # test arcs
62
+ net.arcs.size.should == 4
63
+ net.find_arc(place_i1.id, transition_A.id).should.not.nil
64
+ net.find_arc(place_i2.id, transition_A.id).should.not.nil
65
+ net.find_arc(place_i3.id, transition_A.id).should.not.nil
66
+ net.find_arc(transition_A.id, place_o1.id).should.not.nil
67
+ end
68
+
69
+ it "should reduce nodes by `input reduction` in long case" do
70
+ net = PNML::Reader.read(this::LONG)
71
+
72
+ # save net elements
73
+ transition_A = net.transitions.find {|transition| transition.name == "A"}
74
+ place_i1 = net.find_place_by_name("<'i1'")
75
+ place_o1 = net.find_place_by_name(">'o1'")
76
+ arc_A_o1 = net.find_arc(transition_A.id, place_o1.id)
77
+
78
+ # apply input reduction
79
+ PNML::NetRewriter.new{|rules| rules << PNML::InputReduction}.rewrite(net)
80
+
81
+ # test transitions
82
+ net.transitions.size.should == 1
83
+ net.transitions.should.include transition_A
84
+
85
+ # test places
86
+ net.places.size.should == 2
87
+ net.places.should.include place_i1
88
+ net.places.should.include place_o1
89
+
90
+ # test arcs
91
+ net.arcs.size.should == 2
92
+ net.find_arc(place_i1.id, transition_A.id).should.kind_of PNML::Arc
93
+ net.find_arc(transition_A.id, place_o1.id).should == arc_A_o1
94
+ end
95
+
96
+ it "should not reduce any nodes if there aren't output reducible nodes" do
97
+ net = PNML::Reader.read(this::DIR + "OutputReductionSimple.pnml")
98
+
99
+ # save net elements
100
+ places = net.places.clone
101
+ transitions = net.transitions.clone
102
+ arcs = net.arcs.clone
103
+
104
+ # apply input reduction
105
+ PNML::NetRewriter.new{|rules| rules << PNML::InputReduction}.rewrite(net)
106
+
107
+ # test
108
+ net.places.should == places
109
+ net.transitions.should == transitions
110
+ net.arcs.should == arcs
111
+ end
112
+ end
113
+ end
@@ -0,0 +1,33 @@
1
+ require 'pione/test-helper'
2
+
3
+ describe Pione::PNML::InvalidArcElimination do
4
+ it "should eliminate invalid arcs" do
5
+ net = PNML::Net.new
6
+
7
+ # place and transition
8
+ place = PNML::Place.new(net, net.generate_id)
9
+ net.places << place
10
+ transition = PNML::Transition.new(net, net.generate_id)
11
+ net.transitions << transition
12
+
13
+ # valid arc
14
+ valid_arc = PNML::Arc.new(net, net.generate_id, place.id, transition.id)
15
+ net.arcs << valid_arc
16
+
17
+ # invalid arcs
18
+ net.arcs << PNML::Arc.new(net, net.generate_id, net.generate_id, net.generate_id)
19
+ net.arcs << PNML::Arc.new(net, net.generate_id, place.id, net.generate_id)
20
+ net.arcs << PNML::Arc.new(net, net.generate_id, net.generate_id, place.id)
21
+ net.arcs << PNML::Arc.new(net, net.generate_id, transition.id, net.generate_id)
22
+ net.arcs << PNML::Arc.new(net, net.generate_id, net.generate_id, transition.id)
23
+ net.arcs << PNML::Arc.new(net, net.generate_id, place.id, place.id)
24
+ net.arcs << PNML::Arc.new(net, net.generate_id, transition.id, transition.id)
25
+
26
+ # apply "invalid arc elimination" rule
27
+ PNML::NetRewriter.new{|rules| rules << PNML::InvalidArcElimination}.rewrite(net)
28
+
29
+ # test
30
+ net.arcs.size.should == 1
31
+ net.arcs.should.include valid_arc
32
+ end
33
+ end
@@ -0,0 +1,126 @@
1
+ require 'pione/test-helper'
2
+
3
+ TestHelper.scope do |this|
4
+ this::DIR = Location[__FILE__].dirname + "data"
5
+ this::SIMPLE = this::DIR + "IOExpansionSimple.pnml"
6
+ this::COMPLEX = this::DIR + "IOExpansionComplex.pnml"
7
+
8
+ describe Pione::PNML::IOExpansion do
9
+ it "should expand in simple case" do
10
+ net = PNML::Reader.read(this::SIMPLE)
11
+
12
+ # save elements
13
+ transition_A = net.find_transition_by_name("A")
14
+ transition_B = net.find_transition_by_name("B")
15
+ place_i1 = net.find_place_by_name("'i1'")
16
+ place_p1 = net.find_place_by_name("'p1'")
17
+ place_o1 = net.find_place_by_name(">'o1'")
18
+ arc_A_p1 = net.find_arc(transition_A.id, place_p1.id)
19
+ arc_p1_B = net.find_arc(place_p1.id, transition_B.id)
20
+
21
+ # apply "input/output expansion"
22
+ PNML::NetRewriter.new{|rules| rules << PNML::IOExpansion}.rewrite(net)
23
+
24
+ # new elements
25
+ places_p1= net.find_all_places_by_name("'p1'")
26
+ places_p1.delete place_p1
27
+ place_p1_expanded = places_p1.first
28
+ accommodation = net.find_transition_by_source_id(place_p1.id)
29
+
30
+ # test transitions
31
+ net.transitions.size.should == 3
32
+ net.transitions.should.include accommodation
33
+
34
+ # test places
35
+ net.places.size.should == 4
36
+ net.places.should.include place_p1
37
+ net.places.should.include place_p1_expanded
38
+
39
+ # test arcs
40
+ net.arcs.size.should == 6
41
+ net.find_arc(place_p1.id, accommodation.id).should.not.nil
42
+ net.find_arc(accommodation.id, place_p1_expanded.id).should.not.nil
43
+ net.find_arc(place_p1_expanded.id, transition_B.id).should.not.nil
44
+ net.arcs.should.include arc_A_p1
45
+ net.arcs.should.not.include arc_p1_B
46
+ end
47
+
48
+ it "should expand in complex case" do
49
+ net = PNML::Reader.read(this::COMPLEX)
50
+
51
+ # save elements
52
+ transition_A = net.find_transition_by_name("A")
53
+ transition_B = net.find_transition_by_name("B")
54
+ transition_C = net.find_transition_by_name("C")
55
+ transition_D = net.find_transition_by_name("D")
56
+ transition_E = net.find_transition_by_name("E")
57
+ place_p1 = net.find_place_by_name("'p1'")
58
+ place_p2 = net.find_place_by_name("'p2'")
59
+ arc_A_p1 = net.find_arc(transition_A.id, place_p1.id)
60
+ arc_B_p1 = net.find_arc(transition_B.id, place_p1.id)
61
+ arc_p1_C = net.find_arc(place_p1.id, transition_C.id)
62
+ arc_p1_D = net.find_arc(place_p1.id, transition_D.id)
63
+ arc_p1_E = net.find_arc(place_p1.id, transition_E.id)
64
+ arc_A_p2 = net.find_arc(transition_A.id, place_p2.id)
65
+ arc_B_p2 = net.find_arc(transition_B.id, place_p2.id)
66
+ arc_p2_C = net.find_arc(place_p2.id, transition_C.id)
67
+ arc_p2_D = net.find_arc(place_p2.id, transition_D.id)
68
+ arc_p2_E = net.find_arc(place_p2.id, transition_E.id)
69
+
70
+ # apply "input/output expansion"
71
+ PNML::NetRewriter.new{|rules| rules << PNML::IOExpansion}.rewrite(net)
72
+
73
+ # test the net
74
+ net.should.valid
75
+
76
+ # new elements
77
+ places_p1 = net.find_all_places_by_name("'p1'")
78
+ places_p1.delete place_p1
79
+ place_p1_expanded = places_p1.first
80
+ places_p2 = net.find_all_places_by_name("'p2'")
81
+ places_p2.delete place_p2
82
+ place_p2_expanded = places_p2.first
83
+ accommodation_p1 = net.find_transition_by_source_id(place_p1.id)
84
+ accommodation_p2 = net.find_transition_by_source_id(place_p2.id)
85
+
86
+ # test transitions
87
+ net.transitions.size.should == 7
88
+ net.transitions.should.include accommodation_p1
89
+ net.transitions.should.include accommodation_p2
90
+
91
+ # test places
92
+ net.places.size.should == 9
93
+ net.places.should.include place_p1
94
+ net.places.should.include place_p1_expanded
95
+ net.places.should.include place_p2
96
+ net.places.should.include place_p2_expanded
97
+
98
+ # test arcs
99
+ net.arcs.size.should == 19
100
+ net.find_arc(place_p1.id, accommodation_p1.id).should.not.nil
101
+ net.find_arc(accommodation_p1.id, place_p1_expanded.id).should.not.nil
102
+ net.find_arc(place_p1_expanded.id, transition_C.id).should.not.nil
103
+ net.find_arc(place_p1_expanded.id, transition_D.id).should.not.nil
104
+ net.find_arc(place_p1_expanded.id, transition_E.id).should.not.nil
105
+ net.find_arc(place_p2.id, accommodation_p2.id).size.should.not.nil
106
+ net.find_arc(accommodation_p2.id, place_p2_expanded.id).should.not.nil
107
+ net.find_arc(place_p2_expanded.id, transition_C.id).should.not.nil
108
+ net.find_arc(place_p2_expanded.id, transition_D.id).should.not.nil
109
+ net.find_arc(place_p2_expanded.id, transition_E.id).should.not.nil
110
+ net.arcs.should.include arc_A_p1
111
+ net.arcs.should.include arc_B_p1
112
+ net.arcs.should.include arc_A_p2
113
+ net.arcs.should.include arc_B_p2
114
+ net.arcs.should.not.include arc_p1_C
115
+ net.arcs.should.not.include arc_p1_D
116
+ net.arcs.should.not.include arc_p1_E
117
+ net.arcs.should.not.include arc_p2_C
118
+ net.arcs.should.not.include arc_p2_D
119
+ net.arcs.should.not.include arc_p2_E
120
+ net.find_arc(place_p1.id, accommodation_p2.id).should.nil
121
+ net.find_arc(place_p2.id, accommodation_p1.id).should.nil
122
+ net.find_arc(accommodation_p1.id, place_p2_expanded).should.nil
123
+ net.find_arc(accommodation_p2.id, place_p1_expanded).should.nil
124
+ end
125
+ end
126
+ end
@@ -0,0 +1,25 @@
1
+ require 'pione/test-helper'
2
+
3
+ TestHelper.scope do |this|
4
+ this::DOC = Location[__FILE__].dirname + "data" + "IsolatedElementElimination.pnml"
5
+
6
+ describe Pione::PNML::IsolatedElementElimination do
7
+ it "should elminate floating elements" do
8
+ net = PNML::Reader.read(this::DOC)
9
+
10
+ # apply floating element elimination
11
+ PNML::NetRewriter.new{|rules| rules << PNML::IsolatedElementElimination}.rewrite(net)
12
+
13
+ # test
14
+ net.find_transition_by_name("A").should.not.nil
15
+ net.find_transition_by_name("B").should.nil
16
+ net.find_transition_by_name("C").should.nil
17
+ net.find_place_by_name("<'i1'").should.not.nil
18
+ net.find_place_by_name("'i2'").should.nil
19
+ net.find_place_by_name("'i3'").should.nil
20
+ net.find_place_by_name("'i4'").should.nil
21
+ net.find_place_by_name("'i5'").should.nil
22
+ net.find_place_by_name(">'o1'").should.not.nil
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,40 @@
1
+ require 'pione/test-helper'
2
+
3
+ TestHelper.scope do |this|
4
+ this::DIR = Location[__FILE__].dirname + "data"
5
+ this::SIMPLE = this::DIR + "OutputDecompositionComplementSimple.pnml"
6
+ this::COMPLEX = this::DIR + "OutputDecompositionComplementComplex.pnml"
7
+
8
+ describe Pione::PNML::OutputDecompositionComplement do
9
+ it "should complement the name of source place in simple case" do
10
+ net = PNML::Reader.read(this::SIMPLE)
11
+
12
+ # elements
13
+ transition_A = net.find_transition_by_name("A")
14
+ place_RA = net.find_all_places_by_source_id(transition_A.id).first
15
+
16
+ # apply "output decomposition complement" rule
17
+ PNML::NetRewriter.new{|rules| rules << PNML::OutputDecompositionComplement}.rewrite(net)
18
+
19
+ # test
20
+ place_RA.name.should == ">'o1' or 'o2' or 'o3'"
21
+ end
22
+
23
+ it "should complement the name of source place in complex case" do
24
+ net = PNML::Reader.read(this::COMPLEX)
25
+
26
+ # elements
27
+ transition_A = net.find_transition_by_name("A")
28
+ transition_B = net.find_transition_by_name("B")
29
+ place_RA = net.find_all_places_by_source_id(transition_A.id).first
30
+ place_RB = net.find_all_places_by_source_id(transition_B.id).first
31
+
32
+ # apply "output decomposition complement" rule
33
+ PNML::NetRewriter.new{|rules| rules << PNML::OutputDecompositionComplement}.rewrite(net)
34
+
35
+ # test
36
+ place_RA.name.should == ">'o1' or 'o2' or 'o3'"
37
+ place_RB.name.should == ">'o2' or 'o3' or 'o4'"
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,114 @@
1
+ require 'pione/test-helper'
2
+
3
+ TestHelper.scope do |this|
4
+ this::DIR = Location[__FILE__].dirname + "data"
5
+ this::SIMPLE = this::DIR + "OutputReductionSimple.pnml"
6
+ this::COMPLEX = this::DIR + "OutputReductionComplex.pnml"
7
+ this::LONG = this::DIR + "OutputReductionLong.pnml"
8
+
9
+ describe Pione::PNML::OutputReduction do
10
+ it "should reduce nodes by `output reduction` in simple case" do
11
+ net = PNML::Reader.read(this::SIMPLE)
12
+
13
+ # save elements
14
+ transition_A = net.find_transition_by_name("A")
15
+ place_i1 = net.find_place_by_name("<'i1'")
16
+ place_o1 = net.find_place_by_name(">'o1'")
17
+ arc_i1_A = net.find_arc(place_i1.id, transition_A.id)
18
+
19
+ # apply output reduction
20
+ PNML::NetRewriter.new{|rules| rules << PNML::OutputReduction}.rewrite(net)
21
+
22
+ # test transitions
23
+ net.transitions.size.should == 1
24
+ net.transitions.first.should == transition_A
25
+
26
+ # test places
27
+ net.places.size.should == 2
28
+ net.places.should.include place_i1
29
+ net.places.should.include place_o1
30
+
31
+ # test arcs
32
+ net.arcs.size.should == 2
33
+ net.find_arc(place_i1.id, transition_A.id).should == arc_i1_A
34
+ net.find_arc(transition_A.id, place_o1.id).should.kind_of PNML::Arc
35
+ end
36
+
37
+ it "should reduce nodes by `output reduction` in complex case" do
38
+ net = PNML::Reader.read(this::COMPLEX)
39
+
40
+ # save net elements
41
+ transition_A = net.transitions.find {|transition| transition.name == "A"}
42
+ place_i1 = net.find_place_by_name("<'i1'")
43
+ place_o1 = net.find_place_by_name(">'o1'")
44
+ place_o2 = net.find_place_by_name(">'o2'")
45
+ place_o3 = net.find_place_by_name(">'o3'")
46
+ arc_i1_A = net.find_arc(place_i1.id, transition_A.id)
47
+
48
+ # apply output reduction
49
+ PNML::NetRewriter.new{|rules| rules << PNML::OutputReduction}.rewrite(net)
50
+
51
+ # test transitions
52
+ net.transitions.size.should == 1
53
+ net.transitions.first.should == transition_A
54
+
55
+ # test places
56
+ net.places.size.should == 4
57
+ net.places.should.include place_i1
58
+ net.places.should.include place_o1
59
+ net.places.should.include place_o2
60
+ net.places.should.include place_o3
61
+
62
+ # test arcs
63
+ net.arcs.size.should == 4
64
+ net.find_arc(place_i1.id, transition_A.id).should == arc_i1_A
65
+ net.find_arc(transition_A.id, place_o1.id).should.kind_of PNML::Arc
66
+ net.find_arc(transition_A.id, place_o2.id).should.kind_of PNML::Arc
67
+ net.find_arc(transition_A.id, place_o3.id).should.kind_of PNML::Arc
68
+ end
69
+
70
+ it "should reduce nodes by `output reduction` in long case" do
71
+ net = PNML::Reader.read(this::LONG)
72
+
73
+ # save elements
74
+ transition_A = net.transitions.find {|transition| transition.name == "A"}
75
+ place_i1 = net.find_place_by_name("<'i1'")
76
+ place_o1 = net.find_place_by_name(">'o1'")
77
+ arc_i1_A = net.find_arc(place_i1.id, transition_A.id)
78
+
79
+ # apply output reduction
80
+ PNML::NetRewriter.new{|rules| rules << PNML::OutputReduction}.rewrite(net)
81
+
82
+ # test transitions
83
+ net.transitions.size.should == 1
84
+ net.transitions.first.should == transition_A
85
+
86
+ # test places
87
+ net.places.size.should == 2
88
+ net.places.should.include place_i1
89
+ net.places.should.include place_o1
90
+
91
+ # test arcs
92
+ net.arcs.size.should == 2
93
+ net.find_arc(place_i1.id, transition_A.id).should == arc_i1_A
94
+ net.find_arc(transition_A.id, place_o1.id).should.kind_of PNML::Arc
95
+ end
96
+
97
+ it "should not reduce any nodes if there aren't output reducible nodes" do
98
+ net = PNML::Reader.read(this::DIR + "InputReductionSimple.pnml")
99
+
100
+ # save net elements
101
+ places = net.places.clone
102
+ transitions = net.transitions.clone
103
+ arcs = net.arcs.clone
104
+
105
+ # apply output reduction
106
+ PNML::NetRewriter.new{|rules| rules << PNML::OutputReduction}.rewrite(net)
107
+
108
+ # test
109
+ net.places.should == places
110
+ net.transitions.should == transitions
111
+ net.arcs.should == arcs
112
+ end
113
+ end
114
+ end