Esempio n. 1
0
    def test_mip_print(self):
        """Test to string methods for Bool/Int vars.
        """
        self.assertEqual(repr(self.x_bool), "Bool(1, 1, 'x')")
        self.assertEqual(repr(self.B_int), "Int(2, 3, 'B')")

        x = Bool()
        B = Int(2, 3)

        self.assertEqual(repr(x), "Bool(1, 1)")
        self.assertEqual(repr(B), "Int(2, 3)")
Esempio n. 2
0
    def test_partial_optimize_special_var(self):
        x, y = Bool(1), Int(1)

        # Solve the (simple) two-stage problem by "combining" the two stages (i.e., by solving a single linear program)
        p1 = Problem(Minimize(x+y), [x+y >= 3, y >= 4, x >= 5])
        p1.solve()

        # Solve the two-stage problem via partial_optimize
        p2 = Problem(Minimize(y), [x+y >= 3, y >= 4])
        g = cvxpy.partial_optimize(p2, [y], [x])
        p3 = Problem(Minimize(x+g), [x >= 5])
        p3.solve()
        self.assertAlmostEqual(p1.value, p3.value)
Esempio n. 3
0
 def setUp(self):
     self.x_bool = Bool(name='x')
     self.y_int = Int()
     self.A_bool = Bool(3, 2)
     self.B_int = Int(2, 3, name='B')
Esempio n. 4
0
 def setUp(self):
     self.x_bool = Bool()
     self.y_int = Int()
     self.A_bool = Bool(3, 2)
     self.B_int = Int(2, 3)