compilation problem

126 views
Skip to first unread message

José Ferreira de Rezende

unread,
Mar 3, 2023, 10:27:19 AM3/3/23
to mosek
Hi guys,

I'm using mosek-10.0.37 on Linux with cvxpy. 

I'm running the  code below and I'm having a issue when I increase the value of K (after 40). The cvxpy gives the  warnings below and Mosek takes a long time in the reduction and consumes a lot of memory before crashing. Please, could you give some advice to solve this problem?

cvxpy UserWarning:  Constraint #2 (and #3) contains too many subexpressions. Consider vectorizing your CVXPY code to speed up compilation. 

Regards, Jose
========
import numpy as np
import cvxpy as cp

K = 5

e_gp = {(0, 0): 0.01, (0, 1): 0.01, (0, 2): 0.01, (0, 3): 0.01, (0, 4): 0.01, (1, 0): 0.01, (1, 1): 0.01, (1, 2): 0.01, (1, 3): 0.01, (1, 4): 0.01, (2, 0): 0.01, (2, 1): 0.01, (2, 2): 0.01, (2, 3): 0.01, (2, 4): 0.01, (3, 0): 0.01, (3, 1): 0.01, (3, 2): 0.01, (3, 3): 0.01, (3, 4): 0.01, (4, 0): 0.01, (4, 1): 0.01, (4, 2): 0.01, (4, 3): 0.01, (4, 4): 0.01}
f_gp = {(0, 0): 0.0022083736662195513, (0, 1): 1.6361300004264737e-07, (0, 2): 6.673065375868695e-07, (0, 3): 1.8216969961107378e-05, (0, 4): 7.747569454751729e-06, (1, 0): 0.0007991844189121604, (1, 1): 0.0958477227950784, (1, 2): 0.0006366120217946077, (1, 3): 0.005370938447086471, (1, 4): 0.0007190951574825933, (2, 0): 0.0001461922258284424, (2, 1): 8.781670998829123e-06, (2, 2): 0.013922894884250001, (2, 3): 0.0007882566113873586, (2, 4): 5.609072687532707e-05, (3, 0): 1.6647180495599578e-05, (3, 1): 9.701212848634301e-06, (3, 2): 8.415947875397424e-05, (3, 3): 0.002340059870467834, (3, 4): 6.260839608528006e-06, (4, 0): 0.002396438491055845, (4, 1): 2.777751959882801e-05, (4, 2): 0.00011551904109760868, (4, 3): 0.0005849270607107239, (4, 4): 0.013415428308115004}
r_gp = {0: 3.9230406757174874e-05, 1: 0.04336223814165744, 2: 0.0009650237242044663, 3: 5.605495010604486e-05, 4: 0.0008930969228883886}

sinr_t = cp.Variable(pos=True)

p = cp.Variable(shape=(K,), pos=True)
p_min = 1e-10 * np.ones(K)
p_max = 1.0 * np.ones(K)

t_e, t_f, t_r = [], [], []
for k in range(K):
    t_e.append(cp.sum(cp.hstack(e_gp[(k,kp)]*p[kp] for kp in range(K) if k != kp)))
    t_f.append(cp.sum(cp.hstack(f_gp[(k,kp)]*p[kp] for kp in range(K))))
    t_r.append(r_gp[k])
   
objective = cp.Maximize(sinr_t)
S = (cp.hstack(t_e)+cp.hstack(t_f)+cp.hstack(t_r))/p
constraints = [p >= p_min, p <= p_max, S <= 1/sinr_t]
problem = cp.Problem(objective, constraints)
sol = problem.solve(solver=cp.MOSEK, gp=True, verbose=False)


Michal Adamaszek

unread,
Mar 4, 2023, 5:31:54 AM3/4/23
to mosek
If cvxpy produces these warnings and even worse crashes while processing the problem then I suggest reporting it to https://github.com/cvxpy/cvxpy

There does not seem to be any Mosek issue here.

It looks like you should be able to organize your data structures such that you can express your problem using ordinary linear algebra. For example the t_f part looks like "F@p" for a matrix F defined by f_gp and similarly the other bits.

Michal

Reply all
Reply to author
Forward
0 new messages