示例#1
0
 def detect_cycles(self):
     "Detect the cycles in the current states of the model"
     return util.detect_cycles(data=self.fp())
示例#2
0
if __name__ == '__main__':

    text = """
    A  =  B =  C = False
    D  = True
    
    5: A* = C and (not B)
    10: B* = A
    15: C* = D
    20: D* = B 
    """

    model = BoolModel(mode='async', text=text)

    model.initialize()

    print '>>>', model.first

    model.iterate(steps=2)

    print model.fp()
    model.report_cycles()
    model.save_states(fname='states.txt')

    # detect cycles from a list of states
    states = ['S1', 'S2', 'S1', 'S2', 'S1', 'S2']
    print
    print 'States %s -> Detect cycles %s' % (states,
                                             util.detect_cycles(states))