# Simple power control in communication systems via GP.

    % Boyd, Kim, Vandenberghe, and Hassibi, "A Tutorial on Geometric Programming"
    % Written for CVX by Almir Mutapcic 02/08/06
    % (a figure is generated)
    %
    % Solves the power control problem in communication systems, where
    % we want to minimize the total transmitter power for n transmitters,
    % subject to minimum SINR level, and lower and upper bounds on powers.
    % This results in a GP:
    %
    %   minimize   sum(P)
    %       s.t.   Pmin <= P <= Pmax
    %              SINR >= SINR_min
    %
    % where variables are transmitter powers P.
    % Numerical data for the specific examples was made up.

    % problem constants
    n = 5;                 % number of transmitters and receivers
    sigma = 0.5*ones(n,1); % noise power at the receiver i
    Pmin = 0.1*ones(n,1);  % minimum power at the transmitter i
    Pmax = 5*ones(n,1);    % maximum power at the transmitter i
    SINR_min = 2;          % threshold SINR for each receiver

    % path gain matrix
    G = [1.0  0.1  0.2  0.1  0.0
         0.1  1.0  0.1  0.1  0.0
         0.2  0.1  2.0  0.2  0.2
         0.1  0.1  0.2  1.0  0.1
         0.0  0.0  0.2  0.1  1.0];

    % variables are power levels
    cvx_begin gp
      variable P(n)

      % objective function is the total transmitter power
      minimize( sum(P) )
      subject to

        % formulate the inverse SINR at each receiver using vectorize features
        Gdiag = diag(G);          % the main diagonal of G matrix
        Gtilde = G - diag(Gdiag); % G matrix without the main diagonal
        % inverse SINR
        inverseSINR = (sigma + Gtilde*P)./(Gdiag.*P);

        % constraints are power limits and minimum SINR level
        P >= Pmin;
        P <= Pmax;
        inverseSINR <= (1/SINR_min);
    cvx_end

    fprintf(1,'\nThe minimum total transmitter power is %3.2f.\n',cvx_optval);
    disp('Optimal power levels are: '), P

    Calling SeDuMi: 520 variables (10 free), 300 equality constraints
    ------------------------------------------------------------------------
    SeDuMi 1.1 by AdvOL, 2005 and Jos F. Sturm, 1998, 2001-2003.
    Alg = 2: xz-corrector, Adaptive Step-Differentiation, theta = 0.250, beta = 0.500
    Split 10 free variables
    eqs m = 300, order n = 231, dim = 831, blocks = 21
    nnz(A) = 1016 + 0, nnz(ADA) = 4130, nnz(L) = 2286
     it :     b*y       gap    delta  rate   t/tP*  t/tD*   feas cg cg  prec
      0 :            4.88E-001 0.000
      1 :  5.70E+000 1.79E-001 0.000 0.3674 0.9000 0.9000   2.26  1  1  2.4E+000
      2 :  5.14E+000 5.22E-002 0.000 0.2915 0.9000 0.9000   1.71  1  1  5.3E-001
      3 :  3.82E+000 1.48E-002 0.000 0.2841 0.9000 0.9000   1.24  1  1  1.4E-001
      4 :  3.18E+000 4.58E-003 0.000 0.3089 0.9000 0.9000   1.20  1  1  4.2E-002
      5 :  3.04E+000 1.54E-003 0.000 0.3370 0.9000 0.9000   1.30  1  1  1.2E-002
      6 :  2.96E+000 9.15E-004 0.000 0.5923 0.9000 0.9000   1.32  1  1  6.7E-003
      7 :  2.87E+000 2.52E-004 0.000 0.2757 0.9000 0.9000   1.13  1  1  1.8E-003
      8 :  2.84E+000 1.79E-005 0.000 0.0710 0.9900 0.9900   1.09  1  1  1.2E-004
      9 :  2.83E+000 4.65E-007 0.000 0.0260 0.9900 0.9900   1.08  1  1  2.9E-006
     10 :  2.83E+000 8.86E-008 0.000 0.1908 0.9000 0.9000   1.01  1  2  5.5E-007
     11 :  2.83E+000 8.36E-009 0.189 0.0943 0.9900 0.9900   1.00  2  3  5.2E-008
     12 :  2.83E+000 1.41E-010 0.000 0.0169 0.9000 0.0000   1.00  4  7  1.8E-008
     13 :  2.83E+000 2.66E-011 0.000 0.1884 0.9089 0.9000   1.00 11 12  3.5E-009

    iter seconds digits       c*x               b*y
     13      0.2   Inf  2.8338047822e+000  2.8338050242e+000
    |Ax-b| =  1.3e-008, [Ay-c]_+ =  2.5E-009, |x|= 2.8e+001, |y|= 6.4e+000

    Detailed timing (sec)
       Pre          IPM          Post
    0.000E+000    1.903E-001    0.000E+000
    Max-norms: ||b||=4.380570e+000, ||c|| = 2.202759e+000,
    Cholesky |add|=0, |skip| = 0, ||L.L|| = 19.5702.
    ------------------------------------------------------------------------
    Status: Solved
    Optimal value (cvx_optval): +17.0101

    The minimum total transmitter power is 17.01.
    Optimal power levels are:

    P =

        3.6613
        3.1633
        2.9882
        4.1666
        3.0291