petri_net 0.2.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +11 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +18 -0
- data/README.rdoc +5 -1
- data/Rakefile +7 -7
- data/lib/petri_net/edge.rb +13 -1
- data/lib/petri_net/net.rb +1 -1
- data/lib/petri_net/place.rb +2 -0
- data/lib/petri_net/transition.rb +4 -1
- data/lib/petri_net/version.rb +5 -0
- data/petri_net.gemspec +21 -0
- data/test/tc_petri_net.rb +2 -2
- data/test/tc_transition.rb +1 -1
- metadata +23 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05aa522c5e70ab46c5873a40cffe845f288ab674
|
4
|
+
data.tar.gz: aef6cc24ebb8ceeb44788a3cbf962f967bddd3d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0df2e5b3ca5598fc01e5835c6c79c3959df93d34b8620dd3734349842f4751718558ca10d0c8f00d106a646950b1a75ac65826f63a70cc3601d0564e321c435e
|
7
|
+
data.tar.gz: a64f758521a8a0a25b2343c41410330949d788b64e307de8725408865a8ac6f6bff5bd545eff7b226e96d7bc8d1209ee74509538e0eb353d7771e7112786f78e
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/README.rdoc
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
+
{<img src="https://travis-ci.org/cclausen/petri.png" />}[https://travis-ci.org/cclausen/petri]
|
2
|
+
|
3
|
+
{<img src="https://codeclimate.com/github/cclausen/petri.png" />}[https://codeclimate.com/github/cclausen/petri]
|
4
|
+
|
1
5
|
= PTNet: Petri-net Simulation in Ruby
|
2
6
|
===== based on the code by Brian D Nelson <bdnelson@wildcoder.com>
|
3
7
|
===== Christian Clausen cclausen@tzi.de
|
4
8
|
|
5
|
-
== Version 0.
|
9
|
+
== Version 0.6
|
6
10
|
I implemented most of the basics you need for playing with PetriNets but there are a lot things to add.
|
7
11
|
Next big step will be a stochastic analysis of the PetriNet.
|
8
12
|
|
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rake/testtask'
|
3
|
-
require 'hanna/rdoctask'
|
3
|
+
#require 'hanna/rdoctask'
|
4
4
|
require 'net/sftp'
|
5
5
|
require 'fileutils'
|
6
6
|
|
@@ -13,12 +13,12 @@ Rake::TestTask.new(:test) do |t|
|
|
13
13
|
t.ruby_opts = ['-rubygems'] if defined? Gem
|
14
14
|
end
|
15
15
|
|
16
|
-
Rake::RDocTask.new(:rdoc) do |rdoc|
|
17
|
-
rdoc.rdoc_files.include('LICENSE', 'CHANGELOG', 'README', 'lib/')
|
18
|
-
rdoc.title = "PetriNet Documentation"
|
19
|
-
rdoc.options << '--webcvs=http://svn.wildcoder.com/svn/petri/trunk/'
|
20
|
-
rdoc.rdoc_dir = 'doc' # rdoc output folder
|
21
|
-
end
|
16
|
+
#Rake::RDocTask.new(:rdoc) do |rdoc|
|
17
|
+
# rdoc.rdoc_files.include('LICENSE', 'CHANGELOG', 'README', 'lib/')
|
18
|
+
# rdoc.title = "PetriNet Documentation"
|
19
|
+
# rdoc.options << '--webcvs=http://svn.wildcoder.com/svn/petri/trunk/'
|
20
|
+
# rdoc.rdoc_dir = 'doc' # rdoc output folder
|
21
|
+
#end
|
22
22
|
|
23
23
|
desc 'Clean up unused files.'
|
24
24
|
task :clean => :clobber_rdoc do
|
data/lib/petri_net/edge.rb
CHANGED
@@ -5,6 +5,8 @@ class PetriNet::ReachabilityGraph::Edge < PetriNet::Base
|
|
5
5
|
attr_reader :id
|
6
6
|
# Graph this edge belongs to
|
7
7
|
attr_accessor :graph
|
8
|
+
# Probability of the relating transition
|
9
|
+
attr_accessor :probability
|
8
10
|
|
9
11
|
# Creates an edge for PetriNet::ReachabilityGraph
|
10
12
|
def initialize(options = {}, &block)
|
@@ -14,6 +16,7 @@ class PetriNet::ReachabilityGraph::Edge < PetriNet::Base
|
|
14
16
|
@source = options[:source]
|
15
17
|
@destination = options[:destination]
|
16
18
|
@label = (options[:label] or @name)
|
19
|
+
@probability = options[:probability]
|
17
20
|
|
18
21
|
yield self unless block.nil?
|
19
22
|
end
|
@@ -24,7 +27,7 @@ class PetriNet::ReachabilityGraph::Edge < PetriNet::Base
|
|
24
27
|
end
|
25
28
|
|
26
29
|
def to_gv
|
27
|
-
"\t#{@source.gv_id} -> #{@destination.gv_id};\n"
|
30
|
+
"\t#{@source.gv_id} -> #{@destination.gv_id}#{probability_to_gv};\n"
|
28
31
|
end
|
29
32
|
|
30
33
|
def ==(object)
|
@@ -35,4 +38,13 @@ class PetriNet::ReachabilityGraph::Edge < PetriNet::Base
|
|
35
38
|
"#{@id}: #{@name} #{@source.id} -> #{@destination} )"
|
36
39
|
end
|
37
40
|
|
41
|
+
private
|
42
|
+
def probability_to_gv
|
43
|
+
if @probability
|
44
|
+
" [ label = \"#{@probability.to_s}\" ] "
|
45
|
+
else
|
46
|
+
''
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
38
50
|
end
|
data/lib/petri_net/net.rb
CHANGED
@@ -305,7 +305,7 @@ class PetriNet::Net < PetriNet::Base
|
|
305
305
|
if @objects[tid].fire
|
306
306
|
current_node = PetriNet::ReachabilityGraph::Node.new(markings: get_markings)
|
307
307
|
current_node_id = @graph.add_node current_node
|
308
|
-
@graph.add_edge PetriNet::ReachabilityGraph::Edge.new(source: source, destination: current_node) unless current_node_id < 0
|
308
|
+
@graph.add_edge PetriNet::ReachabilityGraph::Edge.new(source: source, destination: current_node, probability: @objects[tid].probability) unless current_node_id < 0
|
309
309
|
reachability_helper get_markings, current_node unless (current_node_id < 0)
|
310
310
|
end
|
311
311
|
set_markings markings
|
data/lib/petri_net/place.rb
CHANGED
data/lib/petri_net/transition.rb
CHANGED
@@ -7,6 +7,8 @@ module PetriNet
|
|
7
7
|
attr_accessor :name
|
8
8
|
# Description
|
9
9
|
attr_accessor :description
|
10
|
+
# Probability of firing (this moment)
|
11
|
+
attr_accessor :probability
|
10
12
|
# List of input-arcs
|
11
13
|
attr_reader :inputs
|
12
14
|
# List of output-arcs
|
@@ -21,6 +23,7 @@ module PetriNet
|
|
21
23
|
@description = (options[:description] or "Transition #{@id}")
|
22
24
|
@inputs = Array.new
|
23
25
|
@outputs = Array.new
|
26
|
+
@probability = options[:probability]
|
24
27
|
|
25
28
|
yield self unless block == nil
|
26
29
|
end
|
@@ -54,7 +57,7 @@ module PetriNet
|
|
54
57
|
|
55
58
|
# GraphViz definition
|
56
59
|
def to_gv
|
57
|
-
"\t#{self.gv_id} [ label = \"#{@name}\" ];\n"
|
60
|
+
"\t#{self.gv_id} [ label = \"#{@name}#{@probability ? ' ' + @probability.to_s : ''}\" ];\n"
|
58
61
|
end
|
59
62
|
|
60
63
|
def ==(object)
|
data/petri_net.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/petri_net/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["cclausen"]
|
6
|
+
gem.email = ["\"cclausen@tzi.de\""]
|
7
|
+
gem.description = %q{A Petri net modeling gem}
|
8
|
+
gem.summary = %q{You can create Petri Nets and do some calculations with them like generating the Reachability Graph}
|
9
|
+
gem.homepage = "https://github.com/cclausen/petri"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "petri_net"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = PetriNet::VERSION
|
17
|
+
|
18
|
+
gem.license = 'MIT'
|
19
|
+
#gem.add_dependency "ruby-graphviz"
|
20
|
+
gem.add_development_dependency "net-sftp"
|
21
|
+
end
|
data/test/tc_petri_net.rb
CHANGED
data/test/tc_transition.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: petri_net
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cclausen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
11
|
+
date: 2014-01-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: net-sftp
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
description: A Petri net modeling gem
|
14
28
|
email:
|
15
29
|
- '"cclausen@tzi.de"'
|
@@ -18,7 +32,10 @@ extensions: []
|
|
18
32
|
extra_rdoc_files: []
|
19
33
|
files:
|
20
34
|
- .ruby-version
|
35
|
+
- .travis.yml
|
21
36
|
- CHANGELOG
|
37
|
+
- Gemfile
|
38
|
+
- Gemfile.lock
|
22
39
|
- LICENSE
|
23
40
|
- README.rdoc
|
24
41
|
- Rakefile
|
@@ -32,6 +49,8 @@ files:
|
|
32
49
|
- lib/petri_net/place.rb
|
33
50
|
- lib/petri_net/reachability_graph.rb
|
34
51
|
- lib/petri_net/transition.rb
|
52
|
+
- lib/petri_net/version.rb
|
53
|
+
- petri_net.gemspec
|
35
54
|
- test/create.rb
|
36
55
|
- test/tc_arc.rb
|
37
56
|
- test/tc_edge.rb
|
@@ -61,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
80
|
version: '0'
|
62
81
|
requirements: []
|
63
82
|
rubyforge_project:
|
64
|
-
rubygems_version: 2.
|
83
|
+
rubygems_version: 2.1.11
|
65
84
|
signing_key:
|
66
85
|
specification_version: 4
|
67
86
|
summary: You can create Petri Nets and do some calculations with them like generating
|