Beispiel #1
0
 def _load_fa(self, path=None):
   path_fa = (path if path else self.file_path) + ".fa"
   path_nfa = (path if path else self.file_path) + ".nfa"
   if osp.isfile(path_fa) and osp.isfile(path_nfa):
      self._fa_graph = FA(path_fa)
      self._nfa_graph = FA(path_nfa)
   else:
     self._fa_graph = TrivialFA(pure_block_states(self.initial_state), self.inputs, self.outputs)
     self._nfa_graph = TrivialFA(self.initial_state, self.inputs, self.outputs)
Beispiel #2
0
  def _set_data_from_graphs(self):
     self._name = self.connection_graph.name
     self._inputs = self.connection_graph.inputs
     self._outputs = self.connection_graph.outputs
     if "block_groups" in self._connection_graph.properties:
        self._block_groups = split_by_comma(self._connection_graph.properties["block_groups"])

     self._initial_state = str(dict((x, fa.INITIAL) for x in self._connection_graph.node))

     self._fa_graph = TrivialFA(pure_block_states(self.initial_state), self.inputs, self.outputs)
     self._nfa_graph = TrivialFA(self.initial_state, self.inputs, self.outputs)
Beispiel #3
0
 def _calc_fa(self):
   w = Workflow(self)
   G = self.fa_graph.G
   states_queue = set(G.nodes())
   while(states_queue):
     state = states_queue.pop()
     for n in range(len(self.inputs)):
       for inputs in combinations(self.inputs, n + 1):
         variants = []
         try:
           variants = w.work(state, set(inputs))
           print variants
         except SurplusWave:
           print "SurplusWave detected! Skip this inputs!"
           continue
         finally:
           for v in variants:
             new_state = pure_block_states(v.state)
             if not new_state in G.node:
               states_queue.add(new_state)
             G.add_edge(state, new_state, inputs=v.inputs, outputs=v.outputs)