Esempio n. 1
0
    def test_update_field(self):
        test = PheromoneField((7, 7, 5), G, True, 0.01, 0.1, 0.1, 2, 8)
        path = [
            (3, x) for x in range(7)
        ]
        test.updateField(path, 0, 3)
        test.field += test.diff_matrix

        self.assertEqual(np.count_nonzero(test.field), 35 * 2)
        self.assertEqual(list(test.field[3][0]), [1, 0, 0, 1, 0])
Esempio n. 2
0
    def test_update_field_diag(self):
        test = PheromoneField((7, 7, 5), G, True, 0.01, 0.1, 0.1, 2, 8)
        path = [
            (x, x) for x in range(7)
        ]
        test.updateField(path, 0, 0)
        test.field += test.diff_matrix

        test.plot()

        self.assertEqual(np.count_nonzero(test.field), 7 + 6 * 2 + 5 * 2)
Esempio n. 3
0
    def test_update_field_vee(self):
        test = PheromoneField((7, 7, 5), G, True, 0.01, 0.1, 0.1, 2, 8)
        path = [
            (x, x) for x in range(4)
        ]
        path.extend([
            (x, 6 - x) for x in range(4, 7)
        ])
        test.updateField(path, 0, 0)
        test.field += test.diff_matrix

        test.plot(cm='plasma')

        self.assertEqual(np.count_nonzero(test.field), 7 * 4 + 1)
Esempio n. 4
0
    def test_update_field_corner(self):
        test = PheromoneField((7, 7, 5), G, True, 0.01, 0.1, 0.1, 2, 8)
        path = [
            (3, 0), (3, 1), (3, 2), (3, 3), (4, 3), (5, 3), (6, 3)
        ]
        test.field += test.updateField(path, 0, 0)

        test.plot()

        self.assertEqual(np.count_nonzero(test.field), 7 + 6 * 2 + 5 * 2)
Esempio n. 5
0
 def test_plot(self):
     test = PheromoneField((7, 7, 5), G, True, 0.01, 0.1, 0.1, 2, 8)
     path = [
         (x, x) for x in range(7)
     ]
     test.updateField(path, 0, 0)