Exemplo n.º 1
0
    def test_ptxOfMu(self):
        """docstring for test_ptxOfMu"""
        ans = optimMinPow2x2DTX.ptxOfMu(0.1, self.rate, self.linkBandwidth, self.noisepower[0], self.H[0,:,:]) # 59.16
        answer = 59.16385275
        np.testing.assert_almost_equal(ans, answer)
        
        ans = optimMinPow2x2DTX.ptxOfMu(0.1, self.rate, self.linkBandwidth, self.noisepower[0], self.Htrivial[0,:,:]) # 59.16
        answer = 511.5
        np.testing.assert_almost_equal(ans, answer)

        ans = optimMinPow2x2DTX.ptxOfMu(0.1, self.rate, self.linkBandwidth, self.noisepower[0], self.H1[0,:,:]) # 59.16
        answer = 0.15357658182477138
        np.testing.assert_almost_equal(ans, answer)
Exemplo n.º 2
0
    def test_optimPCDTX(self):
        # test for simple problem with known outcome
        H = np.array([[[1. - 1j, -1.], [-1., 1.]], [[1. - 1j, 1.], [-1., 1.]],
                      [[0.5, 1.j], [1., -1.j]]])
        for k in np.arange(3):
            H[k, :, :] = scipy.dot(H[k, :, :], H[k, :, :].conj().T)
        noisepower = np.ones(3)
        rate = 1
        linkBandwidth = 1
        p0 = 10
        m = 2
        pS = 5
        pMax = 10

        obj, solution, status = optimMinPow.optimizePCDTX(
            H, noisepower, rate, linkBandwidth, pMax, p0, m, pS, 0)
        answerObj = 13.9204261
        answerSol = np.array([0.32342002, 0.24371824, 0.27855287, 0.15430887])
        np.testing.assert_almost_equal(obj, answerObj)
        np.testing.assert_almost_equal(solution, answerSol)

        for k in np.arange(H.shape[0]):
            ptx = optimMinPow2x2DTX.ptxOfMu(solution[k], rate, linkBandwidth,
                                            noisepower[k], H[k, :, :])
            rate_test = solution[k] * np.real(
                utils.ergMIMOCapacityCDITCSIR(H[k, :, :], ptx))
            np.testing.assert_almost_equal(rate_test, rate)
Exemplo n.º 3
0
    def test_optimPCDTX_trivial(self):
        # test for simple problem with known outcome
        H = np.ones([3, 2, 2])
        for k in np.arange(3):
            H[k, :, :] = scipy.dot(H[k, :, :], H[k, :, :].conj().T)
        noisepower = np.ones(3)
        rate = 1
        linkBandwidth = 1
        p0 = 10
        m = 2
        pS = 5
        pMax = 10

        obj, solution, status = optimMinPow.optimizePCDTX(
            H, noisepower, rate, linkBandwidth, pMax, p0, m, pS, 0)
        answerObj = 17.000000115485285
        answerSol = np.array([0.33333334, 0.33333334, 0.33333334, 0.])
        np.testing.assert_almost_equal(obj, answerObj)
        np.testing.assert_almost_equal(solution, answerSol)

        for k in np.arange(H.shape[0]):
            ptx = optimMinPow2x2DTX.ptxOfMu(solution[k], rate, linkBandwidth,
                                            noisepower[k], H[k, :, :])
            rate_test = solution[k] * np.real(
                utils.ergMIMOCapacityCDITCSIR(H[k, :, :], ptx))
            np.testing.assert_almost_equal(rate_test, rate)
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
    def test_ptxOfMu(self):
        """docstring for test_ptxOfMu"""
        ans = optimMinPow2x2DTX.ptxOfMu(0.1, self.rate, self.linkBandwidth,
                                        self.noisepower[0],
                                        self.H[0, :, :])  # 59.16
        answer = 59.16385275
        np.testing.assert_almost_equal(ans, answer)

        ans = optimMinPow2x2DTX.ptxOfMu(0.1, self.rate, self.linkBandwidth,
                                        self.noisepower[0],
                                        self.Htrivial[0, :, :])  # 59.16
        answer = 511.5
        np.testing.assert_almost_equal(ans, answer)

        ans = optimMinPow2x2DTX.ptxOfMu(0.1, self.rate, self.linkBandwidth,
                                        self.noisepower[0],
                                        self.H1[0, :, :])  # 59.16
        answer = 0.15357658182477138
        np.testing.assert_almost_equal(ans, answer)
Exemplo n.º 6
0
    def test_optimPCDTX(self):
        # test for simple problem with known outcome
        H = np.array([[[1.-1j,-1.],[-1.,1.]],[[1.-1j,1.],[-1.,1.]],[[0.5,1.j],[1.,-1.j]]])
        for k in np.arange(3):
            H[k,:,:] = scipy.dot(H[k,:,:], H[k,:,:].conj().T)
        noisepower = np.ones(3)
        rate = 1
        linkBandwidth = 1
        p0 = 10
        m = 2
        pS = 5
        pMax = 10

        obj, solution, status = optimMinPow.optimizePCDTX(H, noisepower, rate, linkBandwidth, pMax, p0, m, pS, 0)
        answerObj = 13.9204261
        answerSol = np.array([ 0.32342002,  0.24371824,  0.27855287,  0.15430887])
        np.testing.assert_almost_equal(obj, answerObj)
        np.testing.assert_almost_equal(solution, answerSol)

        for k in np.arange(H.shape[0]):
            ptx = optimMinPow2x2DTX.ptxOfMu(solution[k], rate, linkBandwidth, noisepower[k], H[k,:,:])
            rate_test = solution[k]*np.real(utils.ergMIMOCapacityCDITCSIR(H[k,:,:], ptx))
            np.testing.assert_almost_equal(rate_test, rate)
Exemplo n.º 7
0
    def test_optimPCDTX_trivial(self):
        # test for simple problem with known outcome
        H = np.ones([3,2,2])
        for k in np.arange(3):
            H[k,:,:] = scipy.dot(H[k,:,:], H[k,:,:].conj().T)
        noisepower = np.ones(3)
        rate = 1
        linkBandwidth = 1
        p0 = 10
        m = 2
        pS = 5
        pMax = 10

        obj, solution, status = optimMinPow.optimizePCDTX(H, noisepower, rate, linkBandwidth, pMax, p0, m, pS, 0)
        answerObj = 17.000000115485285
        answerSol = np.array([ 0.33333334,  0.33333334,  0.33333334,  0.        ])
        np.testing.assert_almost_equal(obj, answerObj)
        np.testing.assert_almost_equal(solution, answerSol)

        for k in np.arange(H.shape[0]):
            ptx = optimMinPow2x2DTX.ptxOfMu(solution[k], rate, linkBandwidth, noisepower[k], H[k,:,:])
            rate_test = solution[k]*np.real(utils.ergMIMOCapacityCDITCSIR(H[k,:,:], ptx))
            np.testing.assert_almost_equal(rate_test, rate)
Exemplo n.º 8
0
    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)