redshift 1.3.22 → 1.3.23

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/.bnsignore +27 -0
  2. data/RELEASE-NOTES +6 -0
  3. data/bench/aug17-ruby19.bench +86 -0
  4. data/bench/aug17.bench +86 -0
  5. data/bench/aug7.bench +86 -0
  6. data/bench/bench +4 -1
  7. data/bench/prof.html +0 -0
  8. data/ext/redshift/buffer/buffer.c +3 -1
  9. data/ext/redshift/dvector/dvector.c +236 -0
  10. data/ext/redshift/dvector/dvector.h +36 -0
  11. data/ext/redshift/dvector/dvector.rb +33 -0
  12. data/ext/redshift/dvector/extconf.rb +2 -0
  13. data/lib/redshift/redshift.rb +1 -1
  14. data/lib/redshift/target/c/component-gen.rb +17 -23
  15. data/lib/redshift/target/c/flow-gen.rb +2 -2
  16. data/lib/redshift/target/c/flow/algebraic.rb +1 -1
  17. data/lib/redshift/target/c/flow/delay.rb +1 -1
  18. data/lib/redshift/target/c/flow/derivative.rb +1 -1
  19. data/lib/redshift/target/c/flow/rk4.rb +1 -1
  20. data/lib/redshift/target/c/library.rb +5 -0
  21. data/lib/redshift/target/c/world-gen.rb +130 -127
  22. data/lib/redshift/util/isaac.rb +2 -2
  23. data/lib/redshift/util/random.rb +1 -1
  24. data/lib/redshift/world.rb +11 -6
  25. data/test/test_discrete.rb +1 -1
  26. data/test/test_discrete_isolated.rb +1 -1
  27. data/test/test_dvector.rb +110 -0
  28. data/test/test_flow.rb +1 -1
  29. data/test/test_flow_link.rb +1 -1
  30. data/test/test_flow_sub.rb +1 -1
  31. data/test/test_flow_trans.rb +3 -3
  32. data/test/test_inherit_event.rb +1 -1
  33. data/test/test_inherit_flow.rb +1 -1
  34. data/test/test_inherit_link.rb +1 -1
  35. data/test/test_inherit_state.rb +1 -1
  36. data/test/test_inherit_transition.rb +1 -1
  37. data/test/test_setup.rb +1 -1
  38. data/test/test_strict_continuity.rb +1 -1
  39. data/test/test_world.rb +4 -4
  40. metadata +22 -8
@@ -6,8 +6,8 @@ class ISAACGenerator < ISAAC
6
6
  def initialize(*seeds)
7
7
  super()
8
8
  if seeds.compact.empty?
9
- if defined?(Random::Sequence.random_seed)
10
- seeds = [Random::Sequence.random_seed]
9
+ if defined?(RandomDistribution::Sequence.random_seed)
10
+ seeds = [RandomDistribution::Sequence.random_seed]
11
11
  else
12
12
  seeds = [rand]
13
13
  end
@@ -1,4 +1,4 @@
1
- module Random
1
+ module RandomDistribution
2
2
 
3
3
  # Base class for sequences that sample different kinds of distributions.
4
4
  # The actual PRNG must be plugged in at initialization, or else ruby's
@@ -1,4 +1,5 @@
1
1
  require 'pstore'
2
+ require 'redshift/dvector/dvector'
2
3
 
3
4
  module RedShift
4
5
 
@@ -94,12 +95,16 @@ class World
94
95
  # Can override the options using assignments in the block.
95
96
  # Note that clock_start should not be assigned after the block.
96
97
  def initialize # :yields: world
97
- self.curr_A = []; self.curr_P = []; self.curr_CR = []
98
- self.curr_S = []; self.next_S = []; self.curr_T = []
99
- self.active_E = []; self.prev_active_E = []
100
- self.awake = []; self.prev_awake = []
101
- self.strict_sleep = []; self.inert = []
102
- self.diff_list = []; self.queue_sleep = {}
98
+ dv_vars = %w{
99
+ curr_A curr_P curr_CR curr_S next_S curr_T
100
+ active_E prev_active_E awake prev_awake
101
+ strict_sleep inert diff_list
102
+ }
103
+ dv_vars.each do |var|
104
+ send "#{var}=", DVector[]
105
+ end
106
+
107
+ self.queue_sleep = {}
103
108
  @components = ComponentList.new \
104
109
  awake, prev_awake, curr_T, strict_sleep, inert # _not_ diff_list
105
110
 
@@ -578,7 +578,7 @@ class TestDiscrete < Test::Unit::TestCase
578
578
  testers = []
579
579
  ObjectSpace.each_object(Class) do |cl|
580
580
  if cl <= DiscreteTestComponent and
581
- cl.instance_methods.include? "assert_consistent"
581
+ cl.instance_methods.grep(/^assert_consistent$/).size > 0
582
582
  testers << @world.create(cl)
583
583
  end
584
584
  end
@@ -77,7 +77,7 @@ class TestDiscrete < Test::Unit::TestCase
77
77
  testers = []
78
78
  ObjectSpace.each_object(Class) do |cl|
79
79
  if cl <= DiscreteIsolatedTestComponent and
80
- cl.instance_methods.include? "assert_consistent"
80
+ cl.instance_methods.grep(/^assert_consistent$/).size > 0
81
81
  world = World.new
82
82
  world.time_step = 0.1
83
83
  testers << [world, world.create(cl)]
@@ -0,0 +1,110 @@
1
+ require 'redshift/dvector/dvector'
2
+ require 'test/unit'
3
+
4
+ DVector = RedShift::DVector
5
+
6
+ class TestDVector < Test::Unit::TestCase
7
+ def make_dvs n
8
+ assert_nothing_thrown do
9
+ n.times do
10
+ DVector.new
11
+ end
12
+ end
13
+ end
14
+
15
+ def test_gc
16
+ GC.start
17
+ n = ObjectSpace.each_object(DVector){}
18
+
19
+ assert_nothing_thrown do
20
+ make_dvs 100
21
+ end
22
+
23
+ GC.start
24
+ n2 = ObjectSpace.each_object(DVector){}
25
+
26
+ assert((0..n+1) === n2, "Not in #{0}..#{n+1}: #{n2}")
27
+ end
28
+
29
+ def test_gc_stress
30
+ GC.stress = true
31
+ assert_nothing_thrown do
32
+ make_dvs 10
33
+ end
34
+ ensure
35
+ GC.stress = false
36
+ end
37
+
38
+ def test_push_pop
39
+ dv = DVector.new
40
+ assert_nothing_thrown do
41
+ dv.push(1)
42
+ dv.push(2)
43
+ dv.push(3)
44
+ end
45
+ assert_equal(3, dv.pop)
46
+ assert_equal(2, dv.pop)
47
+ assert_equal(1, dv.pop)
48
+ assert_equal(nil, dv.pop)
49
+ end
50
+
51
+ def test_each
52
+ dv = DVector[1, 2, 3]
53
+ a = []
54
+ dv.each do |x|
55
+ a << x
56
+ end
57
+ assert_equal([1,2,3], a)
58
+ end
59
+
60
+ def test_to_a
61
+ dv = DVector[1, 2, 3]
62
+ assert_equal([1,2,3], dv.to_a)
63
+ end
64
+
65
+ def test_length
66
+ dv = DVector[1, 2, 3]
67
+ assert_equal(3, dv.length)
68
+ dv = DVector.new
69
+ assert_equal(0, dv.length)
70
+ end
71
+
72
+ def test_equal
73
+ dv1 = DVector[1, 2, 3]
74
+ dv2 = DVector[1, 2, 3, 4]
75
+ assert_equal(false, dv1 == dv2)
76
+ assert_equal(false, dv1 == [1,2,3])
77
+ assert_equal(false, dv1 == 123)
78
+ assert_equal(true, dv1 == dv1)
79
+ assert_equal(true, DVector.new == DVector.new)
80
+ assert_equal(true, DVector[1] == DVector[1.0])
81
+ end
82
+
83
+ def test_eql
84
+ dv1 = DVector[1, 2, 3]
85
+ dv2 = DVector[1, 2, 3, 4]
86
+ assert_equal(false, dv1.eql?(dv2))
87
+ assert_equal(false, dv1.eql?([1,2,3]))
88
+ assert_equal(false, dv1.eql?(123))
89
+ assert_equal(true, dv1.eql?(dv1))
90
+ assert_equal(true, DVector.new.eql?(DVector.new))
91
+ assert_equal(false, DVector[1].eql?(DVector[1.0]))
92
+ end
93
+
94
+ def test_hash
95
+ h = {}
96
+ h[DVector[1,2,3]] = true
97
+ assert_equal(true, h[DVector[1,2,3]])
98
+ assert_equal(nil, h[DVector[1,2,3,4]])
99
+ end
100
+
101
+ def test_dup
102
+ DVector[1,2,3] == DVector[1,2,3].dup
103
+ end
104
+
105
+ def test_marshal
106
+ dv = DVector[1, 2, 3]
107
+ dv2 = Marshal.load(Marshal.dump(dv))
108
+ assert_equal(dv.to_a, dv2.to_a)
109
+ end
110
+ end
data/test/test_flow.rb CHANGED
@@ -206,7 +206,7 @@ class TestFlow < Test::Unit::TestCase
206
206
  testers = []
207
207
  ObjectSpace.each_object(Class) do |cl|
208
208
  if cl <= FlowTestComponent and
209
- cl.instance_methods.include? "assert_consistent"
209
+ cl.instance_methods.grep(/^assert_consistent$/).size > 0
210
210
  testers << @world.create(cl)
211
211
  end
212
212
  end
@@ -260,7 +260,7 @@ class TestFlow < Test::Unit::TestCase
260
260
  testers = []
261
261
  ObjectSpace.each_object(Class) do |cl|
262
262
  if cl <= FlowTestComponent and
263
- cl.instance_methods.include? "assert_consistent"
263
+ cl.instance_methods.grep(/^assert_consistent$/).size > 0
264
264
  testers << @world.create(cl)
265
265
  end
266
266
  end
@@ -72,7 +72,7 @@ class TestFlow < Test::Unit::TestCase
72
72
  testers = []
73
73
  ObjectSpace.each_object(Class) do |cl|
74
74
  if cl <= FlowTestComponent and
75
- cl.instance_methods.include? "assert_consistent"
75
+ cl.instance_methods.grep(/^assert_consistent$/).size > 0
76
76
  testers << @world.create(cl)
77
77
  end
78
78
  end
@@ -53,12 +53,12 @@ class Flow_Transition < FlowTestComponent
53
53
  setup do
54
54
  self.x = 0
55
55
  @alarm_time = 0
56
- @alarm_seq = Random::Exponential.new(
56
+ @alarm_seq = RandomDistribution::Exponential.new(
57
57
  :generator => ISAACGenerator,
58
58
  :seed => 614822716,
59
59
  :mean => 0.5
60
60
  )
61
- @state_seq = Random::Discrete.new(
61
+ @state_seq = RandomDistribution::Discrete.new(
62
62
  :generator => ISAACGenerator,
63
63
  :seed => 3871653669, ## doesn't make sense to re-seed the same global gen
64
64
  :distrib =>
@@ -249,7 +249,7 @@ class TestFlow < Test::Unit::TestCase
249
249
  testers = []
250
250
  ObjectSpace.each_object(Class) do |cl|
251
251
  if cl <= FlowTestComponent and
252
- cl.instance_methods.include? "assert_consistent"
252
+ cl.instance_methods.grep(/^assert_consistent$/).size > 0
253
253
  testers << @world.create(cl)
254
254
  end
255
255
  end
@@ -60,7 +60,7 @@ class TestInheritEvent < Test::Unit::TestCase
60
60
  testers = []
61
61
  ObjectSpace.each_object(Class) do |cl|
62
62
  if cl <= EventTestComponent and
63
- cl.instance_methods.include? "assert_consistent"
63
+ cl.instance_methods.grep(/^assert_consistent$/).size > 0
64
64
  testers << @world.create(cl)
65
65
  end
66
66
  end
@@ -127,7 +127,7 @@ class TestInheritFlow < Test::Unit::TestCase
127
127
  testers = []
128
128
  ObjectSpace.each_object(Class) do |cl|
129
129
  if cl <= FlowTestComponent and
130
- cl.instance_methods.include? "assert_consistent"
130
+ cl.instance_methods.grep(/^assert_consistent$/).size > 0
131
131
  testers << @world.create(cl)
132
132
  end
133
133
  end
@@ -53,7 +53,7 @@ class TestInheritLink < Test::Unit::TestCase
53
53
  testers = []
54
54
  ObjectSpace.each_object(Class) do |cl|
55
55
  if cl <= LinkTestComponent and
56
- cl.instance_methods.include? "assert_consistent"
56
+ cl.instance_methods.grep(/^assert_consistent$/).size > 0
57
57
  testers << @world.create(cl)
58
58
  end
59
59
  end
@@ -52,7 +52,7 @@ class TestInheritState < Test::Unit::TestCase
52
52
  testers = []
53
53
  ObjectSpace.each_object(Class) do |cl|
54
54
  if cl <= StateTestComponent and
55
- cl.instance_methods.include? "assert_consistent"
55
+ cl.instance_methods.grep(/^assert_consistent$/).size > 0
56
56
  testers << @world.create(cl)
57
57
  end
58
58
  end
@@ -148,7 +148,7 @@ class TestInheritTrans < Test::Unit::TestCase
148
148
  testers = []
149
149
  ObjectSpace.each_object(Class) do |cl|
150
150
  if cl <= TransTestComponent and
151
- cl.instance_methods.include? "assert_consistent"
151
+ cl.instance_methods.grep(/^assert_consistent$/).size > 0
152
152
  testers << @world.create(cl)
153
153
  end
154
154
  end
data/test/test_setup.rb CHANGED
@@ -107,7 +107,7 @@ class TestSetup < Test::Unit::TestCase
107
107
  testers = []
108
108
  ObjectSpace.each_object(Class) do |cl|
109
109
  if cl <= SetupTestComponent and
110
- cl.instance_methods.include? "assert_consistent"
110
+ cl.instance_methods.grep(/^assert_consistent$/).size > 0
111
111
  testers << @world.create(cl) { |tester| tester.x = 1 }
112
112
  end
113
113
  end
@@ -364,7 +364,7 @@ class TestStrictContinuity < Test::Unit::TestCase
364
364
  testers = []
365
365
  ObjectSpace.each_object(Class) do |cl|
366
366
  if cl <= TestComponent and
367
- cl.instance_methods.include? "assert_consistent"
367
+ cl.instance_methods.grep(/^assert_consistent$/).size > 0
368
368
  testers << @world.create(cl)
369
369
  end
370
370
  end
data/test/test_world.rb CHANGED
@@ -94,7 +94,7 @@ end
94
94
  # test create and remove
95
95
 
96
96
  puts "World#remove TEST DISABLED **************************"
97
- if false && World.instance_methods.include?("remove")
97
+ if false && World.instance_methods.grep(/^remove$/).size > 0
98
98
  class World_3 < World
99
99
  setup do @x = create(Component) end
100
100
  def run
@@ -292,9 +292,9 @@ class TestWorld < Test::Unit::TestCase
292
292
  def test_world
293
293
  testers = []
294
294
  ObjectSpace.each_object(Class) do |cl|
295
- if cl <= World and ## cl.instance_methods.grep /\Aassert_consistent/
296
- (cl.instance_methods.include? "assert_consistent_before" or
297
- cl.instance_methods.include? "assert_consistent_after")
295
+ if cl <= World and
296
+ cl.instance_methods.grep(
297
+ /^assert_consistent_(?:before|after)$/).size > 0
298
298
  testers << cl.new
299
299
  end
300
300
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redshift
3
3
  version: !ruby/object:Gem::Version
4
- hash: 55
4
+ hash: 53
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 3
9
- - 22
10
- version: 1.3.22
9
+ - 23
10
+ version: 1.3.23
11
11
  platform: ruby
12
12
  authors:
13
13
  - Joel VanderWerf
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-11 00:00:00 -07:00
18
+ date: 2010-08-17 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -26,10 +26,12 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- hash: 3
29
+ hash: 81
30
30
  segments:
31
31
  - 0
32
- version: "0"
32
+ - 16
33
+ - 7
34
+ version: 0.16.7
33
35
  type: :runtime
34
36
  version_requirements: *id001
35
37
  - !ruby/object:Gem::Dependency
@@ -40,10 +42,11 @@ dependencies:
40
42
  requirements:
41
43
  - - ">="
42
44
  - !ruby/object:Gem::Version
43
- hash: 3
45
+ hash: 117
44
46
  segments:
45
47
  - 0
46
- version: "0"
48
+ - 63
49
+ version: "0.63"
47
50
  type: :runtime
48
51
  version_requirements: *id002
49
52
  - !ruby/object:Gem::Dependency
@@ -70,17 +73,22 @@ executables: []
70
73
 
71
74
  extensions:
72
75
  - ext/redshift/buffer/extconf.rb
76
+ - ext/redshift/dvector/extconf.rb
73
77
  - ext/redshift/util/isaac/extconf.rb
74
78
  extra_rdoc_files:
75
79
  - README
76
80
  - RELEASE-NOTES
77
81
  files:
82
+ - .bnsignore
78
83
  - .gitignore
79
84
  - README
80
85
  - RELEASE-NOTES
81
86
  - TODO
82
87
  - bench/alg-state.rb
83
88
  - bench/algebraic.rb
89
+ - bench/aug17-ruby19.bench
90
+ - bench/aug17.bench
91
+ - bench/aug7.bench
84
92
  - bench/bench
85
93
  - bench/bench.rb
86
94
  - bench/connect.rb
@@ -92,6 +100,7 @@ files:
92
100
  - bench/half-strict.rb
93
101
  - bench/inertness.rb
94
102
  - bench/linked-flows.rb
103
+ - bench/prof.html
95
104
  - bench/queues.rb
96
105
  - bench/run
97
106
  - bench/simple.rb
@@ -143,6 +152,10 @@ files:
143
152
  - ext/redshift/buffer/buffer.h
144
153
  - ext/redshift/buffer/dir.rb
145
154
  - ext/redshift/buffer/extconf.rb
155
+ - ext/redshift/dvector/dvector.c
156
+ - ext/redshift/dvector/dvector.h
157
+ - ext/redshift/dvector/dvector.rb
158
+ - ext/redshift/dvector/extconf.rb
146
159
  - ext/redshift/util/isaac/extconf.rb
147
160
  - ext/redshift/util/isaac/isaac.c
148
161
  - ext/redshift/util/isaac/rand.c
@@ -196,6 +209,7 @@ files:
196
209
  - test/test_derivative.rb
197
210
  - test/test_discrete.rb
198
211
  - test/test_discrete_isolated.rb
212
+ - test/test_dvector.rb
199
213
  - test/test_exit.rb
200
214
  - test/test_flow.rb
201
215
  - test/test_flow_link.rb