def test_iwf_cap(self): # Test that the requested capacity comes out systemBandwidth = 12. systemTime = 0.1 targetLoad = 1e2 for i in range(10): H = utils.rayleighChannel(2, 2) eigvls, eigvects = scipy.linalg.eig(np.dot(H, H.conj().T)) if i is 0: eigvals = eigvls else: eigvals = np.append(eigvals, eigvls) eigvals = np.real(eigvals) # clear numberical imaginary parts subcarriers = 1. timeslots = 1. channelBandwidth = systemBandwidth / subcarriers transmissionTime = systemTime / timeslots noiseIfPowerPerChannel = np.ones( 20) * 1e-10 * systemBandwidth / subcarriers powerlvls, waterlvl, cap = iwf.inversewaterfill( eigvals, targetLoad, noiseIfPowerPerChannel, channelBandwidth, transmissionTime) np.testing.assert_almost_equal(targetLoad, cap)
def test_optimPCDTXrandomChannel(self): # test for simple problem with known outcome users = 22 n_tx = 2 n_rx = 2 H = np.empty([users, n_tx, n_rx], dtype=complex) # very important to make it complex! for k in np.arange(users): H[k, :, :] = 10e-7 * utils.rayleighChannel(n_tx, n_rx) H[k, :, :] = scipy.dot(H[k, :, :], H[k, :, :].conj().T) noisepower = np.ones(users) * 4e-14 rate = 1.2e7 / users # bps linkBandwidth = 1e7 p0 = 100 m = 2.4 pS = 50 pMax = 40 obj, solution, status = optimMinPow.optimizePCDTX( H, noisepower, rate, linkBandwidth, pMax, p0, m, pS, 0) # Test that all calls were correct and their order. What goes in must come out. for k in np.arange(users): ptx = optimMinPow2x2DTX.ptxOfMu( solution[k], rate, linkBandwidth, noisepower[k], H[k, :, :]) # power as a function of the MIMO link rate_test = solution[k] * np.real( utils.ergMIMOCapacityCDITCSIR( H[k, :, :], ptx / noisepower[k])) * linkBandwidth # bps np.testing.assert_almost_equal(rate_test, rate)
def test_iwf_cap(self): # Test that the requested capacity comes out systemBandwidth = 12. systemTime = 0.1 targetLoad = 1e2 for i in range(10): H = utils.rayleighChannel(2,2) eigvls, eigvects = scipy.linalg.eig(np.dot(H,H.conj().T)) if i is 0: eigvals = eigvls else: eigvals = np.append(eigvals,eigvls) eigvals = np.real(eigvals) # clear numberical imaginary parts subcarriers = 1. timeslots = 1. channelBandwidth = systemBandwidth / subcarriers transmissionTime = systemTime / timeslots noiseIfPowerPerChannel = np.ones(20) * 1e-10*systemBandwidth/subcarriers powerlvls, waterlvl, cap = iwf.inversewaterfill(eigvals, targetLoad, noiseIfPowerPerChannel, channelBandwidth, transmissionTime) np.testing.assert_almost_equal(targetLoad, cap)
def test_optimPCDTXrandomChannel(self): # test for simple problem with known outcome users = 22 n_tx = 2 n_rx = 2 H = np.empty([users, n_tx, n_rx],dtype=complex) # very important to make it complex! for k in np.arange(users): H[k,:,:] = 10e-7*utils.rayleighChannel(n_tx,n_rx) H[k,:,:] = scipy.dot(H[k,:,:], H[k,:,:].conj().T) noisepower = np.ones(users) * 4e-14 rate = 1.2e7/users # bps linkBandwidth = 1e7 p0 = 100 m = 2.4 pS = 50 pMax = 40 obj, solution, status = optimMinPow.optimizePCDTX(H, noisepower, rate, linkBandwidth, pMax, p0, m, pS, 0) # Test that all calls were correct and their order. What goes in must come out. for k in np.arange(users): ptx = optimMinPow2x2DTX.ptxOfMu(solution[k], rate, linkBandwidth, noisepower[k], H[k,:,:]) # power as a function of the MIMO link rate_test = solution[k]*np.real(utils.ergMIMOCapacityCDITCSIR(H[k,:,:], ptx/noisepower[k]))*linkBandwidth # bps np.testing.assert_almost_equal(rate_test, rate)
def capacity(channelBandwidth, transmissionTime, powerlvls, channelValues, noiseIfPowerPerChannel): """Returns the Shannon capacity over multiple channels.""" return channelBandwidth * transmissionTime * sum(log2(1.0 + powerlvls * channelValues / (noiseIfPowerPerChannel))) if __name__ == "__main__": systemBandwidth = 1.0 systemTime = 1.0 targetLoad = 1e2 channelStateAvg = 1e-5 from utils import utils for i in range(10): H = utils.rayleighChannel(2, 2) import scipy.linalg eigvls, eigvects = linalg.eig(dot(H, H.conj().T)) if i is 0: eigvals = eigvls else: eigvals = append(eigvals, eigvls) eigvals = real(eigvals) # clear numberical imaginary parts # DEBUG # eigvals = array([6,6,4,6,4,6])*0.1 subcarriers = 1.0 timeslots = 1.0 channelBandwidth = systemBandwidth / subcarriers
def capacity(channelBandwidth, transmissionTime, powerlvls, channelValues, noiseIfPowerPerChannel): """Returns the Shannon capacity over multiple channels.""" return channelBandwidth * transmissionTime * sum( log2(1. + powerlvls * channelValues / (noiseIfPowerPerChannel))) if __name__ == '__main__': systemBandwidth = 1. systemTime = 1. targetLoad = 1e2 channelStateAvg = 1e-5 from utils import utils for i in range(10): H = utils.rayleighChannel(2, 2) import scipy.linalg eigvls, eigvects = linalg.eig(dot(H, H.conj().T)) if i is 0: eigvals = eigvls else: eigvals = append(eigvals, eigvls) eigvals = real(eigvals) # clear numberical imaginary parts # DEBUG # eigvals = array([6,6,4,6,4,6])*0.1 subcarriers = 1. timeslots = 1. channelBandwidth = systemBandwidth / subcarriers transmissionTime = systemTime / timeslots