'Test a problem with mul_elemwise by a scalar.'

def test_mul_elemwise(self):

    import numpy as np
    T = 10
    J = 20
    rvec = np.random.randn(T, J)
    dy = np.random.randn((2 * T), 1)
    theta = Variable(J)
    delta = 0.001
    loglambda = (rvec * theta)
    a = mul_elemwise(dy[0:T], loglambda)
    b1 = exp(loglambda)
    b2 = mul_elemwise(delta, b1)
    cost = ((- a) + b1)
    cost = ((- a) + b2)
    prob = Problem(Minimize(sum_entries(cost)))
    prob.solve(solver=s.SCS)
    obj = Minimize(sum_entries(mul_elemwise(2, self.x)))
    prob = Problem(obj, [(self.x == 2)])
    result = prob.solve()
    self.assertAlmostEqual(result, 8)
