Example #1
0
    def test_should_update_with_one_point_work_properly(self) -> None:
        point = IdealPoint(3)

        vector = [2.2, -1.5, 3.5]
        point.update(vector)

        self.assertEqual(vector, point.point)
Example #2
0
    def test_should_update_with_two_solutions_work_properly(self) -> None:
        point = IdealPoint(2)

        vector1 = [0.0, 1.0]
        vector2 = [1.0, 0.0]

        point.update(vector1)
        point.update(vector2)

        self.assertEqual([0.0, 0.0], point.point)
Example #3
0
class Tschebycheff(AggregativeFunction):
    def __init__(self, dimension: int):
        self.ideal_point = IdealPoint(dimension)

    def compute(self, vector: [], weight_vector: []) -> float:
        max_fun = -1.0e+30

        for i in range(len(vector)):
            diff = abs(vector[i] - self.ideal_point.point[i])

            if weight_vector[i] == 0:
                feval = 0.0001 * diff
            else:
                feval = diff * weight_vector[i]

            if feval > max_fun:
                max_fun = feval

        return max_fun

    def update(self, vector: []) -> None:
        self.ideal_point.update(vector)
Example #4
0
    def test_should_update_with_three_solutions_work_properly(self) -> None:
        point = IdealPoint(3)

        point.update([3.0, 1.0, 2.0])
        point.update([0.2, 4.0, 5.5])
        point.update([5.0, 6.0, 1.5])

        self.assertEqual([0.2, 1.0, 1.5], point.point)
Example #5
0
 def __init__(self, dimension: int):
     self.ideal_point = IdealPoint(dimension)
Example #6
0
    def test_should_constructor_create_a_correctly_initialized_point(
            self) -> None:
        point = IdealPoint(2)

        self.assertEqual(2, len(point.point))
        self.assertEqual(2 * [float("inf")], point.point)