close all

numberOfUsers =3;

numberOfResources =3;

numberOfRRHs =3;

side =150;

G(:,:,1) = [1.2937 0.0630 0.6123

19.5208 17.0031 3.8738

3.1724 1.0392 2.8971 ];

G(:,:,2) = [ 0.9842 3.8887 1.2775

7.1651 8.1500 2.9065

31.6739 39.0287 34.5636];

G(:,:,3) =[ 12.5486 4.4018 7.0245

2.3316 10.9949 0.2540

1.4895 0.6239 1.4628];

thirdDimensionOnesTemp = [1 2 2 2 2 2 2 2 3]’;

rowsOnesTemp = [ 1 2 3 1 2 3 1 3 2]’;

coloumnsOnesTemp = [1 1 1 2 2 2 3 3 3]’;

sigma = 0.0024;

maxTotalPower =3;

cvx_begin gp

variable vars(9)

P = cvx(zeros(numberOfUsers,numberOfResources,numberOfRRHs));

for m = 1:9

P(rowsOnesTemp(m),coloumnsOnesTemp(m),thirdDimensionOnesTemp(m))= vars(m);

end

```
numSIRug = cvx(zeros(numberOfUsers,numberOfResources));
denumSIRug = cvx(zeros(numberOfUsers,numberOfResources));
numSIRu = cvx(zeros(1,numberOfUsers));
denumSIRu = cvx(zeros(1,numberOfUsers));
for u = 1:numberOfUsers
GsToBeIncludedNum = [];
for g = 1:numberOfResources
transmittingR = thirdDimensionOnesTemp(find(rowsOnesTemp==u & coloumnsOnesTemp == g));
if ~isempty(transmittingR)
numSIRug(u,g) = P(u,g,transmittingR)*G(u,g,transmittingR);
GsToBeIncludedNum = [GsToBeIncludedNum g];
end
end
numSIRu(u) = prod(numSIRug(u,GsToBeIncludedNum));
end
for g = 1: numberOfResources
urMatrixforThisG = P(:,g,:);
for u = 1:numberOfUsers
copy = urMatrixforThisG;
copy(u,:,:)=[];
denumSIRug(u,g) = 0;
for r = 1:numberOfRRHs
denumSIRug(u,g) = denumSIRug(u,g) + sum(copy(:,:,r))*G(u,g,r);
end
end
end
denumSIRug = denumSIRug + sigma;
for u = 1:numberOfUsers
GsToBeIncludedDenum = [];
for g = 1: numberOfResources
transmittingR = thirdDimensionOnesTemp(find(rowsOnesTemp==u & coloumnsOnesTemp == g));
if ~isempty(transmittingR)
GsToBeIncludedDenum = [GsToBeIncludedDenum g];
end
end
denumSIRu(u) = prod(denumSIRug(u,GsToBeIncludedDenum));
end
InvRatePerUser = denumSIRu./numSIRu;
totalInvRate = prod(InvRatePerUser);
miu = 2;
alpha = 2*ones(1,numberOfUsers);
minimize(totalInvRate + miu*(sum(vars)-maxTotalPower)+sum(alpha.*(InvRatePerUser-ones(1,numberOfUsers))))
```

cvx_end

Gives Unbounded result !