def test_bisect_variable(self): b = Box([x, y, z]) (b1, b2) = b.bisect(x) self.assertEqual(b1[x].ub(), 0) self.assertEqual(b2[x].lb(), 0)
def test_index(self): b = Box([x, y, z]) self.assertEqual(b.index(x), 0)
def test_bisect_int(self): b = Box([x, y, z]) (b1, b2) = b.bisect(0) self.assertEqual(b1[0].ub(), 0) self.assertEqual(b2[0].lb(), 0)
def test_get_set_item_variable(self): b = Box([x, y, z]) b[x] = Interval(3, 4) self.assertEqual(b[x], Interval(3, 4))
def test_get_set_item_int(self): b = Box([x, y, z]) self.assertEqual(b.variable(0), x) b[0] = Interval(3, 4) self.assertEqual(b[0], Interval(3, 4))
def test_string(self): b = Box([x]) self.assertEqual(str(b), "x : [ ENTIRE ]") self.assertEqual(repr(b), '<Box "x : [ ENTIRE ]">')
def test_size_empty_set_empty(self): b = Box([x, y, z]) self.assertEqual(b.size(), 3) self.assertFalse(b.empty()) b.set_empty() self.assertTrue(b.empty())
def test_copy_constructor(self): b1 = Box([x, y, z]) b2 = Box([x, y, z]) self.assertEqual(b1, b2) b2.set_empty() self.assertNotEqual(b1, b2)
def test_add(self): b = Box([x]) b.Add(y) b.Add(z, 2, 5) self.assertEqual(b[y], Interval()) self.assertEqual(b[z], Interval(2, 5))
def test_minimize2(self): b = Box([x]) result = Minimize(objective, constraint, 0.00001, b) self.assertTrue(result) self.assertAlmostEqual(b[x].mid(), -1.5, places=2)