예제 #1
0
    def _encode_local_automaton(self, local_automaton,
                                bound,
                                init_process_states,
                                model_states_to_encode):
        impl = self._get_sync_impl(bound, init_process_states, local_automaton)

        encoding_solver = GenericEncoder(self._logic,
                                         self._loc_spec_state_prefix, self._loc_counters_postfix,
                                         impl.state_types_by_process,
                                         self._underlying_solver)

        encoding_solver.encode_run_graph(impl, list((s,) for s in model_states_to_encode))
        return encoding_solver, impl
예제 #2
0
    def _encode_local_automaton(self, local_automaton, bound,
                                init_process_states, model_states_to_encode):
        impl = self._get_sync_impl(bound, init_process_states, local_automaton)

        encoding_solver = GenericEncoder(self._logic,
                                         self._loc_spec_state_prefix,
                                         self._loc_counters_postfix,
                                         impl.state_types_by_process,
                                         self._underlying_solver)

        encoding_solver.encode_run_graph(
            impl, list((s, ) for s in model_states_to_encode))
        return encoding_solver, impl
예제 #3
0
    def _encode_global_headers(self,
                               automaton,
                               automaton_index:int, max_size:int, nof_processes:int):

        sys_intern_funcs_postfix = self._get_glob_sys_intern_func_postfix(automaton_index)
        spec_state_type = self._get_glob_spec_state_type(automaton_index)

        par_impl = self._get_par_impl(automaton, max_size, nof_processes, sys_intern_funcs_postfix)

        encoding_solver = GenericEncoder(self._logic, spec_state_type, sys_intern_funcs_postfix,
                                         par_impl.state_types_by_process,
                                         self._underlying_solver)

        # encoding_solver.encode_sys_model_functions(par_impl)  # this is done in local encoder
        encoding_solver.encode_sys_aux_functions(par_impl)
        encoding_solver.encode_run_graph_headers(par_impl)
예제 #4
0
    def _encode_local_headers(self, max_size: int, init_process_states,
                              sync_automaton: Automaton):
        impl = self._get_sync_impl(max_size, init_process_states,
                                   sync_automaton)

        encoding_solver = GenericEncoder(self._logic,
                                         self._loc_spec_state_prefix,
                                         self._loc_counters_postfix,
                                         impl.state_types_by_process,
                                         self._underlying_solver)

        encoding_solver.encode_sys_model_functions(impl)
        encoding_solver.encode_sys_aux_functions(impl)
        encoding_solver.encode_run_graph_headers(impl)
예제 #5
0
    def _encode_local_headers(self, max_size:int, init_process_states, sync_automaton:Automaton):
        impl = self._get_sync_impl(max_size, init_process_states, sync_automaton)

        encoding_solver = GenericEncoder(self._logic,
                                         self._loc_spec_state_prefix, self._loc_counters_postfix,
                                         impl.state_types_by_process,
                                         self._underlying_solver)

        encoding_solver.encode_sys_model_functions(impl)
        encoding_solver.encode_sys_aux_functions(impl)
        encoding_solver.encode_run_graph_headers(impl)
예제 #6
0
    def _encode_global_automaton(self, automaton_index: int,
                                 nof_processes: int, automaton: Automaton,
                                 model_size: int, model_states_to_encode,
                                 already_encoded_model_states):

        sys_intern_funcs_postfix = self._get_glob_sys_intern_func_postfix(
            automaton_index)
        spec_state_type = self._get_glob_spec_state_type(automaton_index)

        par_impl = self._get_par_impl(automaton, model_size, nof_processes,
                                      sys_intern_funcs_postfix)

        encoding_solver = GenericEncoder(self._logic, spec_state_type,
                                         sys_intern_funcs_postfix,
                                         par_impl.state_types_by_process,
                                         self._underlying_solver)

        global_states_to_encode = self._get_global_states_to_encode(
            model_states_to_encode, already_encoded_model_states,
            nof_processes)
        # list(product(*(nof_processes * [model_states_to_encode])))
        encoding_solver.encode_run_graph(par_impl, global_states_to_encode)

        return encoding_solver, par_impl
예제 #7
0
    def _encode_global_automaton(self,
                                 automaton_index:int,
                                 nof_processes:int,
                                 automaton:Automaton,
                                 model_size:int,
                                 model_states_to_encode,
                                 already_encoded_model_states):

        sys_intern_funcs_postfix = self._get_glob_sys_intern_func_postfix(automaton_index)
        spec_state_type = self._get_glob_spec_state_type(automaton_index)

        par_impl = self._get_par_impl(automaton, model_size, nof_processes, sys_intern_funcs_postfix)

        encoding_solver = GenericEncoder(self._logic, spec_state_type, sys_intern_funcs_postfix,
                                         par_impl.state_types_by_process,
                                         self._underlying_solver)

        global_states_to_encode = self._get_global_states_to_encode(model_states_to_encode,
                                                                    already_encoded_model_states,
                                                                    nof_processes)
        # list(product(*(nof_processes * [model_states_to_encode])))
        encoding_solver.encode_run_graph(par_impl, global_states_to_encode)

        return encoding_solver, par_impl
예제 #8
0
    def _encode_global_headers(self, automaton, automaton_index: int,
                               max_size: int, nof_processes: int):

        sys_intern_funcs_postfix = self._get_glob_sys_intern_func_postfix(
            automaton_index)
        spec_state_type = self._get_glob_spec_state_type(automaton_index)

        par_impl = self._get_par_impl(automaton, max_size, nof_processes,
                                      sys_intern_funcs_postfix)

        encoding_solver = GenericEncoder(self._logic, spec_state_type,
                                         sys_intern_funcs_postfix,
                                         par_impl.state_types_by_process,
                                         self._underlying_solver)

        # encoding_solver.encode_sys_model_functions(par_impl)  # this is done in local encoder
        encoding_solver.encode_sys_aux_functions(par_impl)
        encoding_solver.encode_run_graph_headers(par_impl)
예제 #9
0
def search(automaton:Automaton,
           is_mealy:bool,
           input_signals, output_signals,
           sizes,
           underlying_solver:SolverInterface,
           logic):
    logger = logging.getLogger()

    logger.debug(automaton)
    logger.debug('search: automaton (dot) is:\n' + to_dot(automaton))

    spec_states_type = 'Q'
    sys_states_type = 'T'

    impl = SolitaryImpl(automaton, is_mealy, input_signals, output_signals, list(sizes)[-1], sys_states_type,
                        underlying_solver)

    encoding_solver = GenericEncoder(logic, spec_states_type, '', impl.state_types_by_process, underlying_solver)

    encoding_solver.encode_sys_model_functions(impl)  # TODO: emulator cannot advantage of knowing the current bound?
    encoding_solver.encode_sys_aux_functions(impl)
    encoding_solver.encode_run_graph_headers(impl)

    #: :type: EncodingSolver
    encoding_solver = encoding_solver
    last_size = 0
    for size in sizes:
        logger.info('searching a model of size {0}..'.format(size))

        cur_all_states = impl.states_by_process[0][:size]
        new_states = cur_all_states[last_size:]
        last_size = size

        encoding_solver.encode_run_graph(impl, list((s,) for s in new_states))

        encoding_solver.push()

        encoding_solver.encode_model_bound(cur_all_states, impl)

        model = encoding_solver.solve(impl)
        if model:
            return model

        encoding_solver.pop()

    return None