baturaysaglam / RIS-MISO-Deep-Reinforcement-Learning

Joint Transmit Beamforming and Phase Shifts Design with Deep Reinforcement Learning
MIT License
139 stars 39 forks source link

Unit modulus constraint of RIS #7

Closed wzy385389 closed 1 year ago

wzy385389 commented 1 year ago

hi, i debugg the code and have a problem. i observed variable values in the environment.py, and found that diagonal elements of Phi ("Phi" denotes RIS matrix) dissatisfy with unit modulus constraint, i.e., |Phi(n,n)|^2 is not equal to 1. This seems to mean that the "Normalize the phase matrix" part in DDPG.py doesn't guarantee that |Phi(n,n)|^2 = 1. If you have any suggestions, please do not hesitate to advise, thank you!

baturaysaglam commented 1 year ago

hello. what values do you get typically?

wzy385389 commented 1 year ago

For example, the values of Psi are represented as follows : Psi = diag[ 0.2381 - 0.0633j, -0.0620 + 0.4077j, -0.1322-0.1541j, -0.2746-0.0817j ].

baturaysaglam commented 1 year ago

I created a tensor from this array: Phi = torch.tensor([0.2381 - 0.0633j, -0.0620 + 0.4077j, -0.1322-0.1541j, -0.2746-0.0817j])

Then, run the code to compute the phase: torch.sum(torch.abs(Phi_imag)).reshape(-1, 1) * np.sqrt(2)

I've got: tensor([[1.]], device='cuda:0', grad_fn=<MulBackward0>)

Everything works fine. I multiply the norm with np.sqrt(2)because I separately normalize the real and imaginary parts. So, it would be best if you multiplied it with np.sqrt(2).

yangliang011 commented 1 year ago

I created a tensor from this array: Phi = torch.tensor([0.2381 - 0.0633j, -0.0620 + 0.4077j, -0.1322-0.1541j, -0.2746-0.0817j])

Then, run the code to compute the phase: torch.sum(torch.abs(Phi_imag)).reshape(-1, 1) * np.sqrt(2)

I've got: tensor([[1.]], device='cuda:0', grad_fn=<MulBackward0>)

Everything works fine. I multiply the norm with np.sqrt(2)because I separately normalize the real and imaginary parts. So, it would be best if you multiplied it with np.sqrt(2).

I'm sorry, you didn't say that the sum of the squares of the real and imaginary parts of each original reflector is equal to 1