# ValueError: Incompatible dimensions (2, 5) (2, 5)

import cvxpy as cp
import numpy as np

n_users = 5
n_base_stations = 2
P_max = 10 # Maximum transmission power
Gamma_th = 5 # Interference threshold
eta = np.array([1, 2, 3, 4, 5]) # Weighting factors for each user
g = np.random.randn(n_base_stations, n_users) + 1j * np.random.randn(n_base_stations, n_users) # Channel matrix
r = np.array([2, 1, 3, 2, 1]) # Vector of rate requirements for each user

# Optimization variables

w = cp.Variable((n_base_stations, n_users), complex=True)

# Customized satisfaction level (rate in this case)

satisfaction = r / cp.log(1 + cp.abs(g @ w) ** 2)

# Objective function

obj = cp.sum(eta * satisfaction)

# Constraints

constraints = []
for j in range(n_base_stations):
constraints.append(cp.sum(cp.square(cp.abs(w[j]))) <= P_max)

for i in range(n_users):
interference_sum = cp.sum([cp.square(cp.abs(cp.sum(g[j, i] * w[j, u] for j in range(n_base_stations)))) for u in range(n_users) if u != i])
constraints.append(interference_sum <= Gamma_th)

# Optimization problem

prob = cp.Problem(cp.Maximize(obj), constraints)

prob.solve()

print(“Optimal beamforming solution:\n”, w.value)

hello friends iam solving a second order cone optimisation problem and i get this error: raise
ValueError: Incompatible dimensions (2, 5) (2, 5)

The question seems to be unrelated to PyTorch so I would recommend posting it into a `cvxpy`-specific discussion board as you would find the experts there.