@@ -91,32 +91,32 @@ function IndexCache(sys::AbstractSystem)
91
91
92
92
for (i, (inps, disc_sys)) in enumerate (zip (inputs, syss))
93
93
i == continuous_id && continue
94
- disc_buffers[i - 1 ] = Dict {Any, Set{BasicSymbolic}} ()
94
+ disc_buffers[i] = Dict {Any, Set{BasicSymbolic}} ()
95
95
96
96
for inp in inps
97
97
inp = unwrap (inp)
98
98
is_parameter (sys, inp) ||
99
99
error (" Discrete subsystem $i input $inp is not a parameter" )
100
- disc_clocks[inp] = i - 1
101
- disc_clocks[default_toterm (inp)] = i - 1
100
+ disc_clocks[inp] = i
101
+ disc_clocks[default_toterm (inp)] = i
102
102
if hasname (inp) && (! istree (inp) || operation (inp) != = getindex)
103
- disc_clocks[getname (inp)] = i - 1
104
- disc_clocks[default_toterm (inp)] = i - 1
103
+ disc_clocks[getname (inp)] = i
104
+ disc_clocks[default_toterm (inp)] = i
105
105
end
106
- insert_by_type! (disc_buffers[i - 1 ], inp)
106
+ insert_by_type! (disc_buffers[i], inp)
107
107
end
108
108
109
109
for sym in unknowns (disc_sys)
110
110
sym = unwrap (sym)
111
111
is_parameter (sys, sym) ||
112
112
error (" Discrete subsystem $i unknown $sym is not a parameter" )
113
- disc_clocks[sym] = i - 1
114
- disc_clocks[default_toterm (sym)] = i - 1
113
+ disc_clocks[sym] = i
114
+ disc_clocks[default_toterm (sym)] = i
115
115
if hasname (sym) && (! istree (sym) || operation (sym) != = getindex)
116
- disc_clocks[getname (sym)] = i - 1
117
- disc_clocks[getname (default_toterm (sym))] = i - 1
116
+ disc_clocks[getname (sym)] = i
117
+ disc_clocks[getname (default_toterm (sym))] = i
118
118
end
119
- insert_by_type! (disc_buffers[i - 1 ], sym)
119
+ insert_by_type! (disc_buffers[i], sym)
120
120
end
121
121
t = get_iv (sys)
122
122
for eq in observed (disc_sys)
@@ -127,12 +127,12 @@ function IndexCache(sys::AbstractSystem)
127
127
if istree (sym) && operation (sym) == Shift (t, 1 )
128
128
sym = only (arguments (sym))
129
129
end
130
- disc_clocks[sym] = i - 1
131
- disc_clocks[sym] = i - 1
132
- disc_clocks[default_toterm (sym)] = i - 1
130
+ disc_clocks[sym] = i
131
+ disc_clocks[sym] = i
132
+ disc_clocks[default_toterm (sym)] = i
133
133
if hasname (sym) && (! istree (sym) || operation (sym) != = getindex)
134
- disc_clocks[getname (sym)] = i - 1
135
- disc_clocks[getname (default_toterm (sym))] = i - 1
134
+ disc_clocks[getname (sym)] = i
135
+ disc_clocks[getname (default_toterm (sym))] = i
136
136
end
137
137
end
138
138
end
@@ -154,7 +154,7 @@ function IndexCache(sys::AbstractSystem)
154
154
end
155
155
156
156
affs = vcat (affects (continuous_events (sys)), affects (discrete_events (sys)))
157
- user_affect_clock = maximum (values (disc_clocks); init = 1 )
157
+ user_affect_clock = maximum (values (disc_clocks); init = 0 ) + 1
158
158
for affect in affs
159
159
if affect isa Equation
160
160
is_parameter (sys, affect. lhs) || continue
0 commit comments