def get_start_values(self):
     if len(self.__start_values_filepath) == 0:
         default_values = SolversDescriptions.get_default_parameters_values(self.__solver_name)
         return SolversDescriptions.get_start_parameters_values(self.__solver_name,
                                                                self.__handled_parameters_indexes,
                                                                default_values)
     else:
         read_values = self.__read_start_parameters()
         return SolversDescriptions.get_start_parameters_values(self.__solver_name,
                                                                self.__handled_parameters_indexes,
                                                                read_values)
 def __init__(self,
              solver_file_path,
              cnf_file_path,
              reports_folder_path,
              threads_number,
              handled_parameters_indexes,
              # количество = количеству обрабатываемых активных параметров (лишних значений нет)
              start_parameters_values,
              max_delta,
              max_hamming_distance,
              min_hamming_distance=1):
     self.__solver_name = FileModule.get_file_name(solver_file_path)
     self.__solver_file_path = solver_file_path
     self.__cnf_file_path = cnf_file_path
     self.__reports_folder_path = reports_folder_path
     self.__handled_parameters_indexes = handled_parameters_indexes
     # start_parameters_values это массив, элементы которого могут быть:
     # bool значением для параметра типа BOOL
     # кортежем из 2-х double для параметра типа RANGE
     self.__start_parameters_values = start_parameters_values
     self.__last_parameters_values_tuple = list()
     self.__parameters_templates = SolversDescriptions.get_handled_parameters_template(self.__solver_name,
                                                                                       threads_number,
                                                                                       handled_parameters_indexes)
     parameters_classes = self.__create_parameters_classes()
     self.__max_delta = max_delta
     self.__values_factory = ParametersValuesFactory(parameters_classes,
                                                     max_delta,
                                                     max_hamming_distance,
                                                     min_hamming_distance)
Exemple #3
0
 def __request_general_input_data(self):
     solver_name = input('Choose index of minisat subtype: \n'
                         '    1) minisat_core\n'
                         '    2) minisat_simp\n'
                         '    3) pmcsat\n'
                         '    4) glucored+march_release\n'
                         '    5) glucan_static\n'
                         '    6) mipisat\n'
                         '    7) minisat_ClauseSplit\n'
     )
     if (solver_name == '1') or (solver_name == 'minisat_core'):
         solver_name = 'minisat_core'
     elif (solver_name == '2') or (solver_name == 'minisat_simp'):
         solver_name = 'minisat_simp'
     elif (solver_name == '3') or (solver_name == 'pmcsat'):
         solver_name = 'pmcsat'
     elif (solver_name == '4') or (solver_name == 'glucored+march_release'):
         solver_name = 'glucored+march_release'
     elif (solver_name == '5') or (solver_name == 'glucan_static'):
         solver_name = 'glucan_static'
     elif (solver_name == '6') or (solver_name == 'mipisat'):
         solver_name = 'mipisat'
     elif (solver_name == '7') or (solver_name == 'minisat_ClauseSplit'):
         solver_name = 'minisat_ClauseSplit'
     else:
         print('Error: Invalid minisat subtype.')
         exit()
     if not FileModule.solver_exist(solver_name):
         print('Error: Solver file does not exist.')
         exit()
     # general ---------------
     self.__solver_file_path = FileModule.get_solver_file_path(solver_name)
     self.__cnf_file_path = FileModule.get_cnf_file_path()
     if len(self.__cnf_file_path) == 0:
         print('Error: Multiple cnf files in cnf folder.')
         exit()
     self.__root_experiments_path = Config.Filepaths.RESULTS_FOLDER
     start_file_name = input('Input start values file name: ')
     self.__start_parameters_values_file_path = Config.Filepaths.START_VALUES_FOLDER + '/' + start_file_name
     if not FileModule.file_exist(self.__start_parameters_values_file_path):
         print('File does not exist.')
         exit()
     self.__max_threads_number = Config.Defaults.USED_CORES_NUMBER
     parameters_templates = SolversDescriptions.get_parameters_template(solver_name, self.__max_threads_number)
     print('Choose handled parameters indexes (or just push ENTER for choose all):')
     for index, parameter in enumerate(parameters_templates):
         print('    ' + str(index) + ') ' + str(parameter))
     handled_indexes_string = input('(separated by commas): ')
     handled_indexes_string = handled_indexes_string.replace(' ', '')
     if len(handled_indexes_string) == 0:
         self.__handled_parameters_indexes = range(len(parameters_templates))
     else:
         self.__handled_parameters_indexes = list()
         for index_string in handled_indexes_string.split(','):
             self.__handled_parameters_indexes.append(int(index_string))
     self.__experiment_name = input('Input experiment name (optional): ')
Exemple #4
0
 def main_dialog(self):
     greeting_text = 'ParametersTester'
     print(greeting_text)
     FileModule.init_folders()
     solver_name = UI.__request_solver_name()
     timeout = UI.__request_solving_timeout()
     handled_parameters = UI.__request_handled_parameters(solver_name, Config.Defaults.USED_CORES_NUMBER)
     active_parameters_values = UI.__request_parameters_values(SolversDescriptions.get_active_parameters_indexes(solver_name, handled_parameters))
         #len(SolversDescriptions.get_active(solver_name, handled_parameters)))
     UI.__run_solver(solver_name, timeout, handled_parameters, active_parameters_values)
Exemple #5
0
 def __request_handled_parameters(solver_name, threads_number):
     parameters_templates = SolversDescriptions.get_parameters_template(solver_name, threads_number)
     print('Choose handled parameters indexes (or just push ENTER for choose all):')
     for index, parameter in enumerate(parameters_templates):
         print('    ' + str(index) + ') ' + str(parameter))
     handled_indexes_string = input('(separated by commas): ')
     handled_indexes_string = handled_indexes_string.replace(' ', '')
     if len(handled_indexes_string) == 0:
         return range(len(parameters_templates))
     else:
         handled_parameters_indexes = list()
         for index_string in handled_indexes_string.split(','):
             handled_parameters_indexes.append(int(index_string))
         return handled_parameters_indexes
 def __create_output_file_name(self, parameters_values):
     result_file_name = ''
     handled_params_index = 0
     handled_params_indexes_number = len(self.__handled_parameters_indexes)
     param_index = -1
     full_templates = SolversDescriptions.get_parameters_template(self.__solver_name, 1)
     for system_parameter_template in full_templates:
         param_index += 1
         if handled_params_index >= handled_params_indexes_number:
             break
         if param_index == self.__handled_parameters_indexes[handled_params_index]:
             for concrete_parameter_template in system_parameter_template[1]:
                 if concrete_parameter_template[0] == 'BOOL':
                     if parameters_values[handled_params_index]:
                         result_file_name += str(param_index) + '-' + concrete_parameter_template[1] + '__'
                     else:
                         result_file_name += str(param_index) + '-' + concrete_parameter_template[2] + '__'
                 elif concrete_parameter_template[0] == 'RANGE':
                     result_file_name += str(param_index) + '-' \
                         + str(parameters_values[handled_params_index]) + '__'
             handled_params_index += 1
     return result_file_name[:len(result_file_name)-2]
 def __init__(self,
              solver_file_path,
              cnf_file_path,
              reports_folder_path,
              threads_number,
              handled_parameters_indexes,
              start_parameters_values,
              max_delta):
     self.__solver_name = FileModule.get_file_name(solver_file_path)
     self.__solver_file_path = solver_file_path
     self.__cnf_file_path = cnf_file_path
     self.__reports_folder_path = reports_folder_path
     self.__handled_parameters_indexes = handled_parameters_indexes
     self.__start_parameters_values = start_parameters_values
     self.__max_delta = max_delta
     self.__last_parameters_values_tuple = list()
     self.__parameters_templates = SolversDescriptions.get_handled_parameters_template(self.__solver_name,
                                                                                       threads_number,
                                                                                       handled_parameters_indexes)
     parameters_classes = self.__create_parameters_classes()
     self.__values_factory = RandomParametersValuesFactory(parameters_classes)
     self.__stop = False
 def __init__(
     self,
     solver_file_path,
     reports_folder_path,
     threads_number,
     handled_parameters_indexes,
     # количество = количеству обрабатываемых активных параметров (лишних значений нет)
     start_parameters_values,
 ):
     self.__solver_name = FileModule.get_file_name(solver_file_path)
     self.__solver_file_path = solver_file_path
     self.__next_cnf_index = 0
     self.__current_cnf = ""
     self.__cnf_files_paths = FileModule.get_cnf_file_path()
     self.__reports_folder_path = reports_folder_path
     self.__handled_parameters_indexes = handled_parameters_indexes
     # start_parameters_values это массив, элементы которого могут быть:
     # bool значением для параметра типа BOOL
     # double значением для параметра типа RANGE
     self.__start_parameters_values = start_parameters_values
     self.__parameters_templates = SolversDescriptions.get_handled_parameters_template(
         self.__solver_name, threads_number, handled_parameters_indexes
     )