Beispiel #1
0
 def test_validation_parameters_false_9(self):
     """
     if not are_subarray_len_valid(p.degree_smoothness, l):
         return False
     """
     p = Parameters(1, "feldbaum_function", 2, [[1.5, 1], [0, -1]], [0, 1], [[-2, 1], [7.9]], [[1.4, 1], [0.1, 3]], [], [], [0,0], [1,1], min_f=0, max_f=1)
     f_type = "feldbaum_function"
     res = vld.validation_parameters(p, f_type)
     self.assertEqual(res, False)
Beispiel #2
0
 def test_validation_parameters_false_5(self):
     """
     if not type_valid(p.function_values, [int, float]):
         return False
     """
     p = Parameters(1, "feldbaum_function", 2, [[1, 1], [1, 1]], ['0', 1], [[1, 1], [1, 1]], [[1, 1], [1, 1]], [], [], [0,0], [1,1], min_f=0, max_f=1)
     f_type = "feldbaum_function"
     res = vld.validation_parameters(p, f_type)
     self.assertEqual(res, False)
Beispiel #3
0
 def test_validation_parameters_false_14(self):
     """
     if func_type not in ["method_min", "hyperbolic_potential", "exponential_potential"]:
         return False
     """
     p = Parameters(1, "exponential_potential", 2, [[1.5, 1], [0, -1]], [0, 1],
                    [[-2, 1], [7.9, 0]], [1.4, 1], [], [], [0,0], [1,1], min_f=0, max_f=1)
     f_type = "qwerty"
     res = vld.validation_parameters(p, f_type)
     self.assertEqual(res, False)
Beispiel #4
0
 def test_validation_parameters_false_11(self):
     """
     if not are_subarray_len_valid(p.coefficients_abruptness, l):
         return False
     """
     p = Parameters(1, "feldbaum_function", 2, [[1.5, 1], [0, -1]], [0, 1],
                    [[-2, 1], [7.9, 0]], [[1.4, 7], [0.1, 1.1, 0, 6]], [], [], [0,0], [1,1], min_f=0, max_f=1)
     f_type = "feldbaum_function"
     res = vld.validation_parameters(p, f_type)
     self.assertEqual(res, False)
Beispiel #5
0
 def test_validation_parameters_false_8(self):
     """
     l = len(p.coordinates[0])
     if not are_subarray_len_valid(p.coordinates, l):
         return False
     """
     p = Parameters(1, "feldbaum_function", 2, [[1.5, 1], [0, -1, 0]], [0, 1], [[1, 1], [1, 1]], [[1.4, 1], [0.1, 3]], [], [], [0,0], [1,1], min_f=0, max_f=1)
     f_type = "feldbaum_function"
     res = vld.validation_parameters(p, f_type)
     self.assertEqual(res, False)
Beispiel #6
0
 def test_validation_parameters_false_1(self):
     """
     n = p.number_extrema
     if n < 1:
         return False
     """
     p = Parameters(1, "feldbaum_function", 0, [], [0, 1], [], [], [], [], [0,0], [1,1], min_f=0, max_f=1)
     f_type = "feldbaum_function"
     res = vld.validation_parameters(p, f_type)
     self.assertEqual(res, False)
Beispiel #7
0
 def test_validation_parameters_false_12(self):
     """
     if (func_type == "hyperbolic_potential") or (func_type == "exponential_potential"):
         if not are_positive_elem_valid(p.function_values):
             return False
     """
     p = Parameters(1, "hyperbolic_potential_abs", 2, [[1.5, 1], [0, -1]], [0, -1],
                    [[-2, 1], [7.9, 0]], [[1.4, 7], [0.1, 1.1]], [], [], [0,0], [1,1], min_f=0, max_f=1)
     f_type = "hyperbolic_potential_abs"
     res = vld.validation_parameters(p, f_type)
     self.assertEqual(res, False)
Beispiel #8
0
 def test_validation_parameters_true(self):
     """
     if (func_type == "hyperbolic_potential") or (func_type == "exponential_potential"):
         ...
         if not type_valid(p.coefficients_abruptness, [int, float]):
             return False
     """
     p = Parameters(1, "exponential_potential", 2, [[1.5, 1], [0, -1]], [0, 1],
                    [[-2, 1], [7.9, 0]], [1.4, 1], [], [], [0,0], [1,1], min_f=0, max_f=1)
     f_type = "exponential_potential"
     res = vld.validation_parameters(p, f_type)
     self.assertEqual(res, True)
Beispiel #9
0
 def test_validation_parameters_false_10(self):
     """
     if func_type == "method_min":
         for i in range(n):
             if not type_valid(p.coefficients_abruptness[i], [int, float]):
                 return False
     """
     p = Parameters(1, "feldbaum_function", 2, [[1.5, 1], [0, -1]], [0, 1],
                    [[-2, 1], [7.9, 0]], [[1.4, '6'], [0.1, 'dfg']], [], [], [0,0], [1,1], min_f=0, max_f=1)
     f_type = "feldbaum_function"
     res = vld.validation_parameters(p, f_type)
     self.assertEqual(res, False)
Beispiel #10
0
 def test_validation_parameters_false_7(self):
     """
     for i in range(n):
         if not type_valid(p.coordinates[i], [int, float]):
             return False  # выход
         if not type_valid(p.degree_smoothness[i], [int, float]):
             return False 
     """
     p = Parameters(1, "feldbaum_function", 2, [[1.5, 1], ['0', 'h']], [0, 1], [[1, 1], [1, 1]], [[1.4, 1], [0.1, 3]], [], [], [0,0], [1,1], min_f=0, max_f=1)
     f_type = "feldbaum_function"
     res = vld.validation_parameters(p, f_type)
     self.assertEqual(res, False)
Beispiel #11
0
 def test_validation_parameters_false_4(self):
     """
     ok = (n == len(p.coordinates)) and \  # истино 
      (n == len(p.function_values)) and \  # истино 
      (n == len(p.degree_smoothness)) and \  # истино 
      (n == len(p.coefficients_abruptness))  # ложно
     if not ok:
         return False
     """
     p = Parameters(1, "feldbaum_function", 2, [[1, 1], [1, 1]], [0, 1], [0, 0], [1, 1, 1], [], [], [0,0], [1,1], min_f=0, max_f=1)
     f_type = "feldbaum_function"
     res = vld.validation_parameters(p, f_type)
     self.assertEqual(res, False)
Beispiel #12
0
    def read_parameters_function(self):
        # TODO: добавить комментарии
        self.idx_func, er = parser_field.parse_number(self.ui.idx_func.value(),
                                                      self.ui.idx_func_label)
        if er != "":
            self.display_error_message(er)
            return
        number_extrema, er = parser_field.parse_number(
            self.ui.number_extrema.value(), self.ui.number_extrema_label)
        if er != "":
            self.display_error_message(er)
            return
        coordinates, er = parser_field.parse_coordinates(
            self.ui.coordinates.text())
        if er != "":
            self.display_error_message(er)
            return
        function_values, er = parser_field.parse_field(
            self.ui.function_values.text(),
            self.ui.function_values_label.text())
        if er != "":
            self.display_error_message(er)
            return
        degree_smoothness, er = parser_field.parse_field(
            self.ui.degree_smoothness.text(),
            self.ui.degree_smoothness_label.text())
        if er != "":
            self.display_error_message(er)
            return
        coefficients, er = parser_field.parse_field(
            self.ui.coefficients_abruptness_function.text(),
            self.ui.coefficients_abruptness_function_label.text())
        if er != "":
            self.display_error_message(er)
            return
        func_type = self.read_type()
        constraints_high, er = parser_field.parse_field(
            self.ui.constraints_high.text(),
            self.ui.constraints_x1_label.text())
        if er != "":
            self.display_error_message(er)
            return
        constraints_down, er = parser_field.parse_field(
            self.ui.constraints_down.text(),
            self.ui.constraints_x2_label.text())
        if er != "":
            self.display_error_message(er)
            return
        global_min, er = parser_field.parse_field(
            self.ui.min_func_coord.text(), self.ui.min_label.text())
        if er != "":
            self.display_error_message(er)
            return
        global_max, er = parser_field.parse_field(
            self.ui.max_func_coord.text(), self.ui.max_label.text())
        if er != "":
            self.display_error_message(er)
            return

        if len(global_min) != len(global_max) or len(global_min) != len(
                coordinates[0]):
            error = "Поля координат глобального минимума или максимума заполенны некорректно!"
            self.display_error_message(error)
            return None
        if func_type != "":
            p = Parameters(self.idx_func,
                           func_type,
                           number_extrema,
                           coordinates,
                           function_values,
                           degree_smoothness,
                           coefficients,
                           constraints_high,
                           constraints_down,
                           global_min,
                           global_max,
                           min_f=self.ui.min_func.value(),
                           max_f=self.ui.max_func.value())
            ok = validation.validation_parameters(p, func_type)
            if not ok:
                error = "Одно или несколько полей заполнены некорректно!"
                self.display_error_message(error)
                return None
            else:
                return p