Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I want to solve this problem using CVXPY but I don't know why I get the following error message:

DCPError: Problem does not follow DCP rules.

I guess my constraints are not DCP. Is there any way to model this in DCP?

n_k = [10000, 20000]
request_rate = [15, 10]
p_k_1 = np.random.rand(n_k[0])
p_k_2 = np.random.rand(n_k[1])
#params
p_k_param_1 = cvx.Parameter(1, n_k[0], sign="positive")
p_k_param_1 = np.array(p_k_1)
p_k_param_2 = cvx.Parameter(1, n_k[1], sign="positive")
p_k_param_2 = np.array(p_k_2)
request_rate_param = cvx.Parameter(2, sign="positive")
request_rate_param = np.array(request_rate)
#varibales
c_k = cvx.Variable(2)
T_k = cvx.Variable(2)
constraints = [ cvx.sum_entries(c_k) <= 10000,
               c_k >= 0,
               c_k[0]==cvx.sum_entries(1-cvx.exp(-request_rate_param[0]*T_k[0]*p_k_param_1)),
               c_k[1]==cvx.sum_entries(1-cvx.exp((-request_rate_param[1]*T_k[1])*p_k_param_2))]
h_k_1 = request_rate_param[0] * cvx.sum_entries((p_k_param_1 * (1-cvx.exp(-request_rate_param[0]*T_k[0]*p_k_param_1))))
h_k_2 = request_rate_param[1]* cvx.sum_entries(p_k_param_2 * (1-cvx.exp(-request_rate_param[1]*T_k[1]*p_k_param_2)))
obj = cvx.Maximize(cvx.log(h_k_1) + cvx.log(h_k_2))
prob = cvx.Problem(obj, constraints)
prob.solve(verbose=True)
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.