'Test SOCP representable problems.'

def test_soc(self):

    if (ELEMENTAL in installed_solvers()):
        x = Variable(2, 2)
        prob = Problem(Minimize(huber(x)[(0, 0)]), [(x == [[0.5, (-1.5)], [4, 0]])])
        prob.solve(verbose=False, solver=ELEMENTAL)
        self.assertAlmostEqual(prob.value, 0.25)
        x = Variable(3)
        prob = Problem(Maximize(pnorm(x, 0.5)), [(x == [1.1, 2, 0.1])])
        prob.solve(verbose=False, solver=ELEMENTAL)
        self.assertAlmostEqual(prob.value, 7.724231543909264, places=3)
        x = Variable()
        prob = Problem(Minimize(power(x, 1.34)), [(x == 7.45)])
        prob.solve(solver=ELEMENTAL, verbose=False)
        self.assertAlmostEqual(prob.value, 14.746515290825071, places=3)
        x = Variable(2, 2)
        expr = inv_pos(x)
        prob = Problem(Minimize(expr[(1, 0)]), [(x == [[1, 2], [3, 4]])])
        prob.solve(solver=ELEMENTAL, verbose=False)
        self.assertAlmostEqual(prob.value, 0.5)
        x = Variable(2, 2)
        expr = sqrt(x)
        constr = [(x == [[2, 4], [16, 1]])]
        prob = Problem(Maximize(expr[(0, 0)]), constr)
        prob.solve(solver=ELEMENTAL, verbose=False)
        x = Variable(2, 3)
        expr = mixed_norm(x, 1, 1)
        constr = [(x == [[1, 2], [3, 4], [5, 6]])]
        prob = Problem(Minimize(expr), constr)
        prob.solve(solver=ELEMENTAL, verbose=False)
        self.assertAlmostEqual(prob.value, 21)
