189
189
#print "Transitions:"
190
190
#print self.transitions
192
def checkInvariant(self, state):
193
for t_idx in self.invariants.keys():
194
cur_inv = self.invariants[t_idx][state.locs[t_idx]]
195
if cur_inv != '' and not eval(cur_inv, self.constants, state):
192
# def checkInvariant(self, a):
194
# for t_idx in self.invariants.keys():
195
# cur_inv = self.invariants[t_idx][state.locs[t_idx]]
196
# if cur_inv != '' and not eval(cur_inv, self.constants, state):
200
201
def normalize(self, state, w):
202
for c in self.clocks:
203
state[c] = min(w+state[c], 12)
203
for c,_ in self.clocks:
204
state[c] = min([w+state[c], 12])
207
208
#TODO: We dont need to update if no changes has been made
209
for c in self.clocks:
210
state[c] = state[c] - min
210
for c,_ in self.clocks:
211
state[c] = state[c] - m
214
215
def trans_successors(self, state, trans_info=False):
215
216
#Take an active transition
217
218
for (target_idx, guard, update, sync, debug_info, lowerVal, higherVal) in self.transitions[t_idx][state.locs[t_idx]]:
222
#Find min and max delay for each clocks
224
for c,_ in self.clocks:
221
w = self.pwlist.getW(state)
224
#Find min and max delay for each clocks
226
for c,_ in self.clocks:
229
continue #No lower guard set, is enabled from now
230
print "guard: ", guard
231
continue #No lower guard set, is enabled from now
232
print "guard: ", guard
231
233
if guard > start:
236
for c,_ in self.clocks:
238
for c,_ in self.clocks:
241
continue #No lower guard set, is enabled from now
243
print "guard: ", guard
244
print guard, end, guard < end
243
continue #No lower guard set, is enabled from now
245
print "guard: ", guard
246
print guard, end, guard < end
249
#Check if the guard can be satisfied
251
#Check if the guard can be satisfied
252
if start > end or w > end:
255
#Calculate discrete update
252
257
a.locs[t_idx] = target_idx
258
#Calculate successor states
260
yield self.normalize(a, w) # We only need to normalize if we had a open higher guard
261
else: #yield many states
262
for i in range(start, end+1): #dont need infin as max is mc+1
263
yield self.normalize(a,i) #not clever as we use normalize to calculate the state
256
265
# #Check the guard using the values
257
266
# if guard == None or self.satesfyguard(state, lowerVal, higherVal):
321
330
def successors(self, state):
322
331
for a in self.trans_successors(state):
323
if self.checkInvariant(a):
332
#if self.checkInvariant(a):
325
334
#for a in self.delay_successors_1step(state):
326
335
# if self.checkInvariant(a):