redshift 1.3.24 → 1.3.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +49 -0
- data/RELEASE-NOTES +34 -3
- data/Rakefile +81 -0
- data/bench/bench +1 -1
- data/bench/formula.rb +2 -3
- data/examples/pid.rb +6 -6
- data/examples/robots/lib/shell-world.rb +1 -1
- data/examples/scheduler.rb +6 -1
- data/ext/redshift/dvector-float/dvector-float.c +184 -0
- data/ext/redshift/dvector-float/dvector-float.h +36 -0
- data/ext/redshift/dvector-float/dvector-float.rb +33 -0
- data/ext/redshift/dvector-float/extconf.rb +2 -0
- data/lib/redshift/redshift.rb +5 -5
- data/lib/redshift/target/c/component-gen.rb +1 -1
- data/lib/redshift/target/c/flow-gen.rb +1 -1
- data/lib/redshift/target/c/flow/delay.rb +1 -1
- data/lib/redshift/target/c/world-gen.rb +101 -101
- data/lib/redshift/util/isaac.rb +2 -2
- data/lib/redshift/util/tkar-driver.rb +1 -1
- data/test/test.rb +1 -1
- data/test/test_buffer.rb +2 -2
- data/test/test_connect.rb +2 -2
- data/test/test_connect_parallel.rb +2 -2
- data/test/test_connect_strict.rb +4 -5
- data/test/test_constant.rb +2 -4
- data/test/test_delay.rb +2 -2
- data/test/test_derivative.rb +2 -2
- data/test/test_discrete.rb +2 -4
- data/test/test_discrete_isolated.rb +2 -4
- data/test/test_dvector-float.rb +110 -0
- data/test/test_dvector.rb +15 -17
- data/test/test_exit.rb +2 -4
- data/test/test_flow.rb +2 -4
- data/test/test_flow_link.rb +2 -4
- data/test/test_flow_sub.rb +2 -4
- data/test/test_flow_trans.rb +23 -25
- data/test/test_inherit.rb +2 -4
- data/test/test_inherit_event.rb +2 -4
- data/test/test_inherit_flow.rb +2 -4
- data/test/test_inherit_link.rb +2 -4
- data/test/test_inherit_setup.rb +2 -4
- data/test/test_inherit_state.rb +2 -4
- data/test/test_inherit_transition.rb +2 -4
- data/test/test_numerics.rb +2 -4
- data/test/test_queue.rb +3 -3
- data/test/test_queue_alone.rb +2 -2
- data/test/test_reset.rb +2 -4
- data/test/test_setup.rb +2 -4
- data/test/test_strict_continuity.rb +2 -4
- data/test/test_strict_reset_error.rb +2 -4
- data/test/test_strictness_error.rb +2 -4
- data/test/test_sync.rb +2 -2
- data/test/test_world.rb +2 -4
- metadata +80 -106
- data/.bnsignore +0 -27
- data/.gitignore +0 -9
- data/README +0 -25
- data/TODO +0 -431
- data/bench/aug17-ruby19.bench +0 -86
- data/bench/aug17.bench +0 -86
- data/bench/aug7.bench +0 -86
- data/bench/prof.html +0 -0
- data/examples/robots/README +0 -49
- data/ext/redshift/util/isaac/extconf.rb +0 -2
- data/ext/redshift/util/isaac/isaac.c +0 -129
- data/ext/redshift/util/isaac/rand.c +0 -140
- data/ext/redshift/util/isaac/rand.h +0 -61
- data/rakefile +0 -50
data/lib/redshift/util/isaac.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require '
|
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?
|
data/test/test.rb
CHANGED
data/test/test_buffer.rb
CHANGED
data/test/test_connect.rb
CHANGED
data/test/test_connect_strict.rb
CHANGED
@@ -56,9 +56,9 @@ end
|
|
56
56
|
|
57
57
|
#-----#
|
58
58
|
|
59
|
-
require '
|
59
|
+
require 'minitest/autorun'
|
60
60
|
|
61
|
-
class TestConnectStrict < Test
|
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
|
118
|
-
|
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
|
data/test/test_constant.rb
CHANGED
@@ -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 '
|
42
|
+
require 'minitest/autorun'
|
45
43
|
|
46
|
-
class TestConstant < Test
|
44
|
+
class TestConstant < Minitest::Test
|
47
45
|
|
48
46
|
def setup
|
49
47
|
@world = World.new
|
data/test/test_delay.rb
CHANGED
data/test/test_derivative.rb
CHANGED
data/test/test_discrete.rb
CHANGED
@@ -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 '
|
562
|
+
require 'minitest/autorun'
|
565
563
|
|
566
|
-
class TestDiscrete < Test
|
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 '
|
61
|
+
require 'minitest/autorun'
|
64
62
|
|
65
|
-
class TestDiscrete < Test
|
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 '
|
2
|
+
require 'minitest/autorun'
|
3
3
|
|
4
4
|
DVector = RedShift::DVector
|
5
5
|
|
6
|
-
class TestDVector < Test
|
6
|
+
class TestDVector < Minitest::Test
|
7
7
|
def make_dvs n
|
8
|
-
assert_nothing_thrown
|
9
|
-
|
10
|
-
|
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
|
20
|
-
|
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
|
32
|
-
|
33
|
-
|
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
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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 '
|
34
|
+
require 'minitest/autorun'
|
37
35
|
|
38
|
-
class TestExit < Test
|
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 '
|
189
|
+
require 'minitest/autorun'
|
192
190
|
|
193
|
-
class TestFlow < Test
|
191
|
+
class TestFlow < Minitest::Test
|
194
192
|
|
195
193
|
def setup
|
196
194
|
@world = World.new
|
data/test/test_flow_link.rb
CHANGED
@@ -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 '
|
243
|
+
require 'minitest/autorun'
|
246
244
|
|
247
|
-
class TestFlow < Test
|
245
|
+
class TestFlow < Minitest::Test
|
248
246
|
|
249
247
|
def setup
|
250
248
|
@world = World.new
|
data/test/test_flow_sub.rb
CHANGED
@@ -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 '
|
55
|
+
require 'minitest/autorun'
|
58
56
|
|
59
|
-
class TestFlow < Test
|
57
|
+
class TestFlow < Minitest::Test
|
60
58
|
|
61
59
|
def setup
|
62
60
|
@world = World.new
|
data/test/test_flow_trans.rb
CHANGED
@@ -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 '
|
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 }
|