redshift 1.3.24 → 1.3.30

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +49 -0
  3. data/RELEASE-NOTES +34 -3
  4. data/Rakefile +81 -0
  5. data/bench/bench +1 -1
  6. data/bench/formula.rb +2 -3
  7. data/examples/pid.rb +6 -6
  8. data/examples/robots/lib/shell-world.rb +1 -1
  9. data/examples/scheduler.rb +6 -1
  10. data/ext/redshift/dvector-float/dvector-float.c +184 -0
  11. data/ext/redshift/dvector-float/dvector-float.h +36 -0
  12. data/ext/redshift/dvector-float/dvector-float.rb +33 -0
  13. data/ext/redshift/dvector-float/extconf.rb +2 -0
  14. data/lib/redshift/redshift.rb +5 -5
  15. data/lib/redshift/target/c/component-gen.rb +1 -1
  16. data/lib/redshift/target/c/flow-gen.rb +1 -1
  17. data/lib/redshift/target/c/flow/delay.rb +1 -1
  18. data/lib/redshift/target/c/world-gen.rb +101 -101
  19. data/lib/redshift/util/isaac.rb +2 -2
  20. data/lib/redshift/util/tkar-driver.rb +1 -1
  21. data/test/test.rb +1 -1
  22. data/test/test_buffer.rb +2 -2
  23. data/test/test_connect.rb +2 -2
  24. data/test/test_connect_parallel.rb +2 -2
  25. data/test/test_connect_strict.rb +4 -5
  26. data/test/test_constant.rb +2 -4
  27. data/test/test_delay.rb +2 -2
  28. data/test/test_derivative.rb +2 -2
  29. data/test/test_discrete.rb +2 -4
  30. data/test/test_discrete_isolated.rb +2 -4
  31. data/test/test_dvector-float.rb +110 -0
  32. data/test/test_dvector.rb +15 -17
  33. data/test/test_exit.rb +2 -4
  34. data/test/test_flow.rb +2 -4
  35. data/test/test_flow_link.rb +2 -4
  36. data/test/test_flow_sub.rb +2 -4
  37. data/test/test_flow_trans.rb +23 -25
  38. data/test/test_inherit.rb +2 -4
  39. data/test/test_inherit_event.rb +2 -4
  40. data/test/test_inherit_flow.rb +2 -4
  41. data/test/test_inherit_link.rb +2 -4
  42. data/test/test_inherit_setup.rb +2 -4
  43. data/test/test_inherit_state.rb +2 -4
  44. data/test/test_inherit_transition.rb +2 -4
  45. data/test/test_numerics.rb +2 -4
  46. data/test/test_queue.rb +3 -3
  47. data/test/test_queue_alone.rb +2 -2
  48. data/test/test_reset.rb +2 -4
  49. data/test/test_setup.rb +2 -4
  50. data/test/test_strict_continuity.rb +2 -4
  51. data/test/test_strict_reset_error.rb +2 -4
  52. data/test/test_strictness_error.rb +2 -4
  53. data/test/test_sync.rb +2 -2
  54. data/test/test_world.rb +2 -4
  55. metadata +80 -106
  56. data/.bnsignore +0 -27
  57. data/.gitignore +0 -9
  58. data/README +0 -25
  59. data/TODO +0 -431
  60. data/bench/aug17-ruby19.bench +0 -86
  61. data/bench/aug17.bench +0 -86
  62. data/bench/aug7.bench +0 -86
  63. data/bench/prof.html +0 -0
  64. data/examples/robots/README +0 -49
  65. data/ext/redshift/util/isaac/extconf.rb +0 -2
  66. data/ext/redshift/util/isaac/isaac.c +0 -129
  67. data/ext/redshift/util/isaac/rand.c +0 -140
  68. data/ext/redshift/util/isaac/rand.h +0 -61
  69. data/rakefile +0 -50
@@ -1,8 +1,8 @@
1
- require 'redshift/util/isaac/isaac.so'
1
+ require 'isaac'
2
2
 
3
3
  # Adaptor class to use ISAAC with redshift/util/random distributions.
4
4
  # See test/test_flow_trans.rb for an example.
5
- class ISAACGenerator < ISAAC
5
+ class ISAACGenerator < PRNG::ISAAC
6
6
  def initialize(*seeds)
7
7
  super()
8
8
  if seeds.compact.empty?
@@ -2,7 +2,7 @@
2
2
  # Depends on:
3
3
  # gem install tkar
4
4
  # See also:
5
- # http://tkar.rubyforge.org
5
+ # https://github.com/vjoel/tkar
6
6
  class TkarDriver
7
7
  # +dragger+ is a callable object that takes (id, x, y) and should
8
8
  # move object id to (x,y)
data/test/test.rb CHANGED
@@ -37,7 +37,7 @@ tests.sort!
37
37
  #end
38
38
 
39
39
  require 'rbconfig'
40
- ruby = Config::CONFIG["RUBY_INSTALL_NAME"]
40
+ ruby = RbConfig::CONFIG["RUBY_INSTALL_NAME"]
41
41
 
42
42
  pending = tests.dup
43
43
  failed = []
data/test/test_buffer.rb CHANGED
@@ -7,9 +7,9 @@ RedShift.with_library do |library|
7
7
  library.define_buffer
8
8
  end
9
9
 
10
- require 'test/unit'
10
+ require 'minitest/autorun'
11
11
 
12
- class TestBuffer < Test::Unit::TestCase
12
+ class TestBuffer < Minitest::Test
13
13
 
14
14
  class T < Component
15
15
  RedShift.with_library do
data/test/test_connect.rb CHANGED
@@ -26,9 +26,9 @@ end
26
26
 
27
27
  #-----#
28
28
 
29
- require 'test/unit'
29
+ require 'minitest/autorun'
30
30
 
31
- class TestConnect < Test::Unit::TestCase
31
+ class TestConnect < Minitest::Test
32
32
 
33
33
  def setup
34
34
  @world = World.new
@@ -20,9 +20,9 @@ end
20
20
 
21
21
  #-----#
22
22
 
23
- require 'test/unit'
23
+ require 'minitest/autorun'
24
24
 
25
- class TestConnect < Test::Unit::TestCase
25
+ class TestConnect < Minitest::Test
26
26
 
27
27
  def setup
28
28
  @world = World.new
@@ -56,9 +56,9 @@ end
56
56
 
57
57
  #-----#
58
58
 
59
- require 'test/unit'
59
+ require 'minitest/autorun'
60
60
 
61
- class TestConnectStrict < Test::Unit::TestCase
61
+ class TestConnectStrict < Minitest::Test
62
62
 
63
63
  def setup
64
64
  @world = SCWorld.new
@@ -114,9 +114,8 @@ class TestConnectStrict < Test::Unit::TestCase
114
114
  a.x = a.k = 12.34
115
115
  end
116
116
  @b.port(:y) << a.port(:x)
117
- assert_nothing_raised do
118
- @b.port(:y) << a.port(:k)
119
- end
117
+ #assert_nothing_raised
118
+ @b.port(:y) << a.port(:k)
120
119
  end
121
120
 
122
121
  # One check per step, despite the Dummy
@@ -1,5 +1,3 @@
1
- #!/usr/bin/env ruby
2
-
3
1
  require 'redshift'
4
2
 
5
3
  include RedShift
@@ -41,9 +39,9 @@ end
41
39
 
42
40
  #-----#
43
41
 
44
- require 'test/unit'
42
+ require 'minitest/autorun'
45
43
 
46
- class TestConstant < Test::Unit::TestCase
44
+ class TestConstant < Minitest::Test
47
45
 
48
46
  def setup
49
47
  @world = World.new
data/test/test_delay.rb CHANGED
@@ -102,9 +102,9 @@ class StateChanger < Component
102
102
  end
103
103
  end
104
104
 
105
- require 'test/unit'
105
+ require 'minitest/autorun'
106
106
 
107
- class TestDelay < Test::Unit::TestCase
107
+ class TestDelay < Minitest::Test
108
108
 
109
109
  def setup
110
110
  @world = World.new
@@ -27,9 +27,9 @@ class DerivativeTestComponent < Component
27
27
  end
28
28
  end
29
29
 
30
- require 'test/unit'
30
+ require 'minitest/autorun'
31
31
 
32
- class TestDerivative < Test::Unit::TestCase
32
+ class TestDerivative < Minitest::Test
33
33
 
34
34
  def setup
35
35
  @world = World.new
@@ -1,5 +1,3 @@
1
- #!/usr/bin/env ruby
2
-
3
1
  require 'redshift'
4
2
 
5
3
  include RedShift
@@ -561,9 +559,9 @@ test guard phases
561
559
 
562
560
  #-----#
563
561
 
564
- require 'test/unit'
562
+ require 'minitest/autorun'
565
563
 
566
- class TestDiscrete < Test::Unit::TestCase
564
+ class TestDiscrete < Minitest::Test
567
565
 
568
566
  def setup
569
567
  @world = World.new
@@ -1,5 +1,3 @@
1
- #!/usr/bin/env ruby
2
-
3
1
  require 'redshift'
4
2
 
5
3
  include RedShift
@@ -60,9 +58,9 @@ end
60
58
 
61
59
  #-----#
62
60
 
63
- require 'test/unit'
61
+ require 'minitest/autorun'
64
62
 
65
- class TestDiscrete < Test::Unit::TestCase
63
+ class TestDiscrete < Minitest::Test
66
64
 
67
65
  def setup
68
66
  @world = World.new
@@ -0,0 +1,110 @@
1
+ require 'redshift/dvector-float/dvector-float'
2
+ require 'minitest/autorun'
3
+
4
+ DVectorFloat = RedShift::DVectorFloat
5
+
6
+ class TestDVectorFloat < Minitest::Test
7
+ def make_dvs n
8
+ #assert_nothing_thrown do
9
+ n.times do
10
+ DVectorFloat.new
11
+ end
12
+ end
13
+
14
+ def test_gc
15
+ GC.start
16
+ n = ObjectSpace.each_object(DVectorFloat){}
17
+
18
+ #assert_nothing_thrown
19
+ make_dvs 100
20
+
21
+ GC.start
22
+ n2 = ObjectSpace.each_object(DVectorFloat){}
23
+
24
+ assert((0..n+1) === n2, "Not in #{0}..#{n+1}: #{n2}")
25
+ end
26
+
27
+ def test_gc_stress
28
+ GC.stress = true
29
+ #assert_nothing_thrown
30
+ make_dvs 10
31
+ ensure
32
+ GC.stress = false
33
+ end
34
+
35
+ def test_push_pop
36
+ dv = DVectorFloat.new
37
+ #assert_nothing_thrown
38
+ dv.push(1)
39
+ dv.push(2.567)
40
+ dv.push(3)
41
+
42
+ assert_equal(3, dv.pop)
43
+ assert_in_delta(2.567, dv.pop, 0.01)
44
+ assert_equal(1, dv.pop)
45
+ assert_equal(nil, dv.pop)
46
+ end
47
+
48
+ def test_each
49
+ dv = DVectorFloat[1, 2.567, 3]
50
+ a = []
51
+ dv.each do |x|
52
+ a << x
53
+ end
54
+ [1,2.567,3].zip a do |x,y|
55
+ assert_in_delta(x, y, 0.01)
56
+ end
57
+ end
58
+
59
+ def test_to_a
60
+ dv = DVectorFloat[1, 2.567, 3]
61
+ [1,2.567,3].zip dv.to_a do |x,y|
62
+ assert_in_delta(x, y, 0.01)
63
+ end
64
+ end
65
+
66
+ def test_length
67
+ dv = DVectorFloat[1, 2.567, 3]
68
+ assert_equal(3, dv.length)
69
+ dv = DVectorFloat.new
70
+ assert_equal(0, dv.length)
71
+ end
72
+
73
+ def test_equal
74
+ dv1 = DVectorFloat[1, 2.567, 3]
75
+ dv2 = DVectorFloat[1, 2.567, 3, 4]
76
+ assert_equal(false, dv1 == dv2)
77
+ assert_equal(false, dv1 == [1,2.567,3])
78
+ assert_equal(false, dv1 == 123)
79
+ assert_equal(true, dv1 == dv1)
80
+ assert_equal(true, DVectorFloat.new == DVectorFloat.new)
81
+ assert_equal(true, DVectorFloat[1] == DVectorFloat[1.0])
82
+ end
83
+
84
+ def test_eql
85
+ dv1 = DVectorFloat[1, 2.567, 3]
86
+ dv2 = DVectorFloat[1, 2.567, 3, 4]
87
+ assert_equal(false, dv1.eql?(dv2))
88
+ assert_equal(false, dv1.eql?([1,2.567,3]))
89
+ assert_equal(false, dv1.eql?(123))
90
+ assert_equal(true, dv1.eql?(dv1))
91
+ assert_equal(true, DVectorFloat.new.eql?(DVectorFloat.new))
92
+ end
93
+
94
+ def test_hash
95
+ h = {}
96
+ h[DVectorFloat[1,2.567,3]] = true
97
+ assert_equal(true, h[DVectorFloat[1,2.567,3]])
98
+ assert_equal(nil, h[DVectorFloat[1,2.567,3,4]])
99
+ end
100
+
101
+ def test_dup
102
+ DVectorFloat[1,2.567,3] == DVectorFloat[1,2.567,3].dup
103
+ end
104
+
105
+ def test_marshal
106
+ dv = DVectorFloat[1, 2.567, 3]
107
+ dv2 = Marshal.load(Marshal.dump(dv))
108
+ assert_equal(dv.to_a, dv2.to_a)
109
+ end
110
+ end
data/test/test_dvector.rb CHANGED
@@ -1,14 +1,13 @@
1
1
  require 'redshift/dvector/dvector'
2
- require 'test/unit'
2
+ require 'minitest/autorun'
3
3
 
4
4
  DVector = RedShift::DVector
5
5
 
6
- class TestDVector < Test::Unit::TestCase
6
+ class TestDVector < Minitest::Test
7
7
  def make_dvs n
8
- assert_nothing_thrown do
9
- n.times do
10
- DVector.new
11
- end
8
+ #assert_nothing_thrown
9
+ n.times do
10
+ DVector.new
12
11
  end
13
12
  end
14
13
 
@@ -16,9 +15,8 @@ class TestDVector < Test::Unit::TestCase
16
15
  GC.start
17
16
  n = ObjectSpace.each_object(DVector){}
18
17
 
19
- assert_nothing_thrown do
20
- make_dvs 100
21
- end
18
+ #assert_nothing_thrown
19
+ make_dvs 100
22
20
 
23
21
  GC.start
24
22
  n2 = ObjectSpace.each_object(DVector){}
@@ -28,20 +26,20 @@ class TestDVector < Test::Unit::TestCase
28
26
 
29
27
  def test_gc_stress
30
28
  GC.stress = true
31
- assert_nothing_thrown do
32
- make_dvs 10
33
- end
29
+ #assert_nothing_thrown
30
+ make_dvs 10
31
+
34
32
  ensure
35
33
  GC.stress = false
36
34
  end
37
35
 
38
36
  def test_push_pop
39
37
  dv = DVector.new
40
- assert_nothing_thrown do
41
- dv.push(1)
42
- dv.push(2)
43
- dv.push(3)
44
- end
38
+ #assert_nothing_thrown
39
+ dv.push(1)
40
+ dv.push(2)
41
+ dv.push(3)
42
+
45
43
  assert_equal(3, dv.pop)
46
44
  assert_equal(2, dv.pop)
47
45
  assert_equal(1, dv.pop)
data/test/test_exit.rb CHANGED
@@ -1,5 +1,3 @@
1
- #!/usr/bin/env ruby
2
-
3
1
  require 'redshift'
4
2
 
5
3
  include RedShift
@@ -33,9 +31,9 @@ end
33
31
 
34
32
  #-----#
35
33
 
36
- require 'test/unit'
34
+ require 'minitest/autorun'
37
35
 
38
- class TestExit < Test::Unit::TestCase
36
+ class TestExit < Minitest::Test
39
37
 
40
38
  def setup
41
39
  @world = World.new
data/test/test_flow.rb CHANGED
@@ -1,5 +1,3 @@
1
- #!/usr/bin/env ruby
2
-
3
1
  require 'redshift'
4
2
 
5
3
  include RedShift
@@ -188,9 +186,9 @@ end
188
186
 
189
187
  #-----#
190
188
 
191
- require 'test/unit'
189
+ require 'minitest/autorun'
192
190
 
193
- class TestFlow < Test::Unit::TestCase
191
+ class TestFlow < Minitest::Test
194
192
 
195
193
  def setup
196
194
  @world = World.new
@@ -1,5 +1,3 @@
1
- #!/usr/bin/env ruby
2
-
3
1
  require 'redshift'
4
2
 
5
3
  include RedShift
@@ -242,9 +240,9 @@ end
242
240
 
243
241
  #-----#
244
242
 
245
- require 'test/unit'
243
+ require 'minitest/autorun'
246
244
 
247
- class TestFlow < Test::Unit::TestCase
245
+ class TestFlow < Minitest::Test
248
246
 
249
247
  def setup
250
248
  @world = World.new
@@ -1,5 +1,3 @@
1
- #!/usr/bin/env ruby
2
-
3
1
  require 'redshift'
4
2
 
5
3
  include RedShift
@@ -54,9 +52,9 @@ end
54
52
 
55
53
  #-----#
56
54
 
57
- require 'test/unit'
55
+ require 'minitest/autorun'
58
56
 
59
- class TestFlow < Test::Unit::TestCase
57
+ class TestFlow < Minitest::Test
60
58
 
61
59
  def setup
62
60
  @world = World.new
@@ -1,5 +1,3 @@
1
- #!/usr/bin/env ruby
2
-
3
1
  require 'redshift'
4
2
  require 'redshift/util/random'
5
3
  require 'redshift/util/isaac'
@@ -21,7 +19,7 @@ class Flow_Transition_Alg_To_Other < FlowTestComponent
21
19
  alg "x=42"
22
20
  end
23
21
  transition A => B
24
-
22
+
25
23
  def assert_consistent test
26
24
  if state == B
27
25
  test.assert_equal(42, x)
@@ -33,23 +31,23 @@ end
33
31
 
34
32
  class Flow_Transition < FlowTestComponent
35
33
  state :Alg, :Diff, :Euler, :Empty, :Switch
36
-
34
+
37
35
  flow Alg, Diff, Euler, Empty do
38
36
  diff "t' = 1"
39
37
  end
40
-
38
+
41
39
  flow Alg do
42
40
  alg "x = 10*t"
43
41
  end
44
-
42
+
45
43
  flow Diff do
46
44
  diff "x' = 10"
47
45
  end
48
-
46
+
49
47
  flow Euler do
50
48
  euler "x' = 10"
51
49
  end
52
-
50
+
53
51
  setup do
54
52
  self.x = 0
55
53
  @alarm_time = 0
@@ -73,7 +71,7 @@ class Flow_Transition < FlowTestComponent
73
71
  puts " alarm seed = #{@alarm_seq.generator.seeds rescue @alarm_seq.generator.seed}"
74
72
  puts " state seed = #{@state_seq.generator.seeds rescue @state_seq.generator.seed}"
75
73
  end
76
-
74
+
77
75
  transition Enter => Switch,
78
76
  Alg => Switch, Diff => Switch,
79
77
  Euler => Switch, Empty => Switch do
@@ -91,7 +89,7 @@ class Flow_Transition < FlowTestComponent
91
89
  end
92
90
  }
93
91
  end
94
-
92
+
95
93
  transition Switch => Alg do
96
94
  guard { @current == Alg }
97
95
  end
@@ -104,7 +102,7 @@ class Flow_Transition < FlowTestComponent
104
102
  transition Switch => Empty do
105
103
  guard { @current == Empty }
106
104
  end
107
-
105
+
108
106
  transition Empty => Empty do
109
107
  guard { t > (@last_empty_t || 0) }
110
108
  action {
@@ -112,7 +110,7 @@ class Flow_Transition < FlowTestComponent
112
110
  self.x = 10 * t # manually update x
113
111
  }
114
112
  end
115
-
113
+
116
114
  def assert_consistent test
117
115
  # In the alg case, calling the accessor invokes the update method. We want
118
116
  # to test that alg flows work even if the update method isn't called.
@@ -124,7 +122,7 @@ class Flow_Transition < FlowTestComponent
124
122
  "in #{state.name} after #{t} sec,\n")
125
123
  end
126
124
  end
127
-
125
+
128
126
  def finish test
129
127
  # puts "At finish: t = #{t}, alarm_time = #{@alarm_time}"
130
128
  end
@@ -193,9 +191,9 @@ class Flow_AlgebraicAction < FlowTestComponent
193
191
  constant :k
194
192
  link :other => self
195
193
  flow {alg " x = other.y + k "}
196
-
194
+
197
195
  @@first = true
198
-
196
+
199
197
  setup do
200
198
  self.other = self
201
199
  if @@first
@@ -203,21 +201,21 @@ class Flow_AlgebraicAction < FlowTestComponent
203
201
  @other = create(Flow_AlgebraicAction) {|c| c.y = 5}
204
202
  end
205
203
  end
206
-
204
+
207
205
  transition Enter => Exit do
208
206
  action do
209
207
  next unless @other
210
-
208
+
211
209
  @x_values = []
212
210
  @x_values << x
213
211
  other.y = 1
214
212
  @x_values << x
215
213
  other.y = 2
216
214
  @x_values << x
217
-
215
+
218
216
  self.other = @other
219
217
  @x_values << x
220
-
218
+
221
219
  self.k = 10
222
220
  @x_values << x
223
221
  end
@@ -231,20 +229,20 @@ end
231
229
 
232
230
  #-----#
233
231
 
234
- require 'test/unit'
232
+ require 'minitest/autorun'
233
+
234
+ class TestFlow < Minitest::Test
235
235
 
236
- class TestFlow < Test::Unit::TestCase
237
-
238
236
  def setup
239
237
  @world = World.new
240
238
  @world.time_step = 0.01
241
239
  @world.zeno_limit = 100
242
240
  end
243
-
241
+
244
242
  def teardown
245
243
  @world = nil
246
244
  end
247
-
245
+
248
246
  def test_flow
249
247
  testers = []
250
248
  ObjectSpace.each_object(Class) do |cl|
@@ -253,7 +251,7 @@ class TestFlow < Test::Unit::TestCase
253
251
  testers << @world.create(cl)
254
252
  end
255
253
  end
256
-
254
+
257
255
  testers.each { |t| t.assert_consistent self }
258
256
  @world.run 1000 do
259
257
  testers.each { |t| t.assert_consistent self }