'Test a basic LP with Gurobi.'

def test_gurobi(self):

    if (GUROBI in installed_solvers()):
        prob = Problem(Minimize(norm(self.x, 1)), [(self.x == 0)])
        prob.solve(solver=GUROBI)
        self.assertItemsAlmostEqual(self.x.value, [0, 0])
        objective = Minimize((((-4) * self.x[0]) - (5 * self.x[1])))
        constraints = [(((2 * self.x[0]) + self.x[1]) <= 3), ((self.x[0] + (2 * self.x[1])) <= 3), (self.x[0] >= 0), (self.x[1] >= 0)]
        prob = Problem(objective, constraints)
        prob.solve(solver=GUROBI)
        self.assertAlmostEqual(prob.value, (-9))
        self.assertItemsAlmostEqual(self.x.value, [1, 1])
        objective = Minimize(self.x[0])
        constraints = [(self.x[0] >= (-100)), (self.x[0] <= (-10)), (self.x[1] == 1)]
        prob = Problem(objective, constraints)
        prob.solve(solver=GUROBI)
        self.assertItemsAlmostEqual(self.x.value, [(-100), 1])
        bool_var = Bool()
        int_var = Int()
        prob = Problem(Minimize(norm(self.x, 1)), [(self.x == bool_var), (bool_var == 0)])
        prob.solve(solver=GUROBI)
        self.assertAlmostEqual(prob.value, 0)
        self.assertAlmostEqual(bool_var.value, 0)
        self.assertItemsAlmostEqual(self.x.value, [0, 0])
        objective = Minimize((((-4) * self.x[0]) - (5 * self.x[1])))
        constraints = [(((2 * self.x[0]) + self.x[1]) <= int_var), ((self.x[0] + (2 * self.x[1])) <= (3 * bool_var)), (self.x[0] >= 0), (self.x[1] >= 0), (int_var == (3 * bool_var)), (int_var == 3)]
        prob = Problem(objective, constraints)
        prob.solve(solver=GUROBI)
        self.assertAlmostEqual(prob.value, (-9))
        self.assertAlmostEqual(int_var.value, 3)
        self.assertAlmostEqual(bool_var.value, 1)
        self.assertItemsAlmostEqual(self.x.value, [1, 1])
    else:
        with self.assertRaises(Exception) as cm:
            prob = Problem(Minimize(norm(self.x, 1)), [(self.x == 0)])
            prob.solve(solver=GUROBI)
        self.assertEqual(str(cm.exception), ('The    solver    %s    is    not    installed.' % GUROBI))
