Esempio n. 1
0
class Test_Storage(object):
    def setup_method(self):
        self.x0 = np.array(1)
        self.f0 = 0

        minres = OptimizeResult()
        minres.x = self.x0
        minres.fun = self.f0

        self.storage = Storage(minres)

    def test_higher_f_rejected(self):
        new_minres = OptimizeResult()
        new_minres.x = self.x0 + 1
        new_minres.fun = self.f0 + 1

        ret = self.storage.update(new_minres)
        minres = self.storage.get_lowest()
        assert_equal(self.x0, minres.x)
        assert_equal(self.f0, minres.fun)
        assert_(not ret)

    def test_lower_f_accepted(self):
        new_minres = OptimizeResult()
        new_minres.x = self.x0 + 1
        new_minres.fun = self.f0 - 1

        ret = self.storage.update(new_minres)
        minres = self.storage.get_lowest()
        assert_(self.x0 != minres.x)
        assert_(self.f0 != minres.fun)
        assert_(ret)
Esempio n. 2
0
class Test_Storage(object):
    def setup_method(self):
        self.x0 = np.array(1)
        self.f0 = 0

        minres = OptimizeResult()
        minres.x = self.x0
        minres.fun = self.f0

        self.storage = Storage(minres)

    def test_higher_f_rejected(self):
        new_minres = OptimizeResult()
        new_minres.x = self.x0 + 1
        new_minres.fun = self.f0 + 1

        ret = self.storage.update(new_minres)
        minres = self.storage.get_lowest()
        assert_equal(self.x0, minres.x)
        assert_equal(self.f0, minres.fun)
        assert_(not ret)

    def test_lower_f_accepted(self):
        new_minres = OptimizeResult()
        new_minres.x = self.x0 + 1
        new_minres.fun = self.f0 - 1

        ret = self.storage.update(new_minres)
        minres = self.storage.get_lowest()
        assert_(self.x0 != minres.x)
        assert_(self.f0 != minres.fun)
        assert_(ret)
Esempio n. 3
0
class Test_Storage(TestCase):
    def setUp(self):
        self.x0 = np.array(1)
        self.f0 = 0
        self.storage = Storage(self.x0, self.f0)

    def test_higher_f_rejected(self):
        ret = self.storage.update(self.x0 + 1, self.f0 + 1)
        x, f = self.storage.get_lowest()
        assert_equal(self.x0, x)
        assert_equal(self.f0, f)
        assert_(not ret)

    def test_lower_f_accepted(self):
        ret = self.storage.update(self.x0 + 1, self.f0 - 1)
        x, f = self.storage.get_lowest()
        assert_(self.x0 != x)
        assert_(self.f0 != f)
        assert_(ret)
class Test_Storage(TestCase):
    def setUp(self):
        self.x0 = np.array(1)
        self.f0 = 0
        self.storage = Storage(self.x0, self.f0)

    def test_higher_f_rejected(self):
        ret = self.storage.update(self.x0 + 1, self.f0 + 1)
        x, f = self.storage.get_lowest()
        self.assertEqual(self.x0, x)
        self.assertEqual(self.f0, f)
        self.assertFalse(ret)

    def test_lower_f_accepted(self):
        ret = self.storage.update(self.x0 + 1, self.f0 - 1)
        x, f = self.storage.get_lowest()
        self.assertNotEqual(self.x0, x)
        self.assertNotEqual(self.f0, f)
        self.assertTrue(ret)
Esempio n. 5
0
class Test_Storage(TestCase):
    def setUp(self):
        self.x0 = np.array(1)
        self.f0 = 0
        self.storage = Storage(self.x0, self.f0)

    def test_higher_f_rejected(self):
        ret = self.storage.update(self.x0 + 1, self.f0 + 1)
        x, f = self.storage.get_lowest()
        self.assertEqual(self.x0, x)
        self.assertEqual(self.f0, f)
        self.assertFalse(ret)

    def test_lower_f_accepted(self):
        ret = self.storage.update(self.x0 + 1, self.f0 - 1)
        x, f = self.storage.get_lowest()
        self.assertNotEqual(self.x0, x)
        self.assertNotEqual(self.f0, f)
        self.assertTrue(ret)
Esempio n. 6
0
class Test_Storage(TestCase):
    def setUp(self):
        self.x0 = np.array(1)
        self.f0 = 0
        self.storage = Storage(self.x0, self.f0)

    def test_higher_f_rejected(self):
        ret = self.storage.update(self.x0 + 1, self.f0 + 1)
        x, f = self.storage.get_lowest()
        assert_equal(self.x0, x)
        assert_equal(self.f0, f)
        assert_(not ret)

    def test_lower_f_accepted(self):
        ret = self.storage.update(self.x0 + 1, self.f0 - 1)
        x, f = self.storage.get_lowest()
        assert_(self.x0 != x)
        assert_(self.f0 != f)
        assert_(ret)