log_sum_exp( {mixed concave/constant} )

Hi,

I am doing an Information Theoretic optimization. Here’s my code (inside a loop), and here’s the error I get.

Specially this

“Illegal operation: log_sum_exp( {mixed concave/constant} ).”

is bothering me. What is it?

Any help would be appreciated.

(Everything is converted to log format, for finite precision limitations. Otherwise, I get NaN.)

function [I_min_general, P_min_general]=i_min_general_cvx(q,D,epsilon,n,C_n_4,Cnk)


cvx_clear

cvx_begin 

variables P(n+1,n+1,n+1)


P <= 0

I=log(0);
prob=log(0);
P_sum=log(0);

for n0=0:n
    n1=n-n0;

    P_sum=log(0);

    for n00=0:n0
        n01=n0-n00;
        for n10=0:n1
            n11= n1-n10;


            P_sum = log_sum_exp ([P_sum , Cnk(n0+1,n00+2)+Cnk(n1+1,n10+2)+P(n00+1,n01+1,n10+1)]);

            %% calculating I
            p_x= log(q)*(n00+n01) + log(1-q)*(n10+n11);
            p_joint=p_x + P(n00+1,n01+1,n10+1);

            p_x_hat=log(0);
            for a=0:n00+n10
                for b=0:n01+n11
                    p_x_hat= log_sum_exp([p_x_hat ,(Cnk(n00+n10+1,a+2)+Cnk(n01+n11+1,b+2)+ (log(q)*(a+b)+log(1-q)*(n-a-b)) + P(a+1,b+1,n00+n10-a+1))]);
                end
            end

            p_x
            p_joint
            p_x_hat


            entrp_log = p_joint + log(p_joint - p_x - p_x_hat)

            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            %% Here is the problem
            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

            I= log_sum_exp([I , C_n_4(n+1,n00+2,n01+2,n10+2)+ entrp_log]);

            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

            %% calculating tail probability
            if((n01+n10)/n>D)
                prob= log_sum_exp ([prob , C_n_4(n+1,n00+2,n01+2,n10+2) + p_joint]);
            end

        end
    end
    P_sum==log(1);
end

I=I-log(n);

prob<=log(epsilon)

minimize(I)

cvx_end


I_min_general=cvx_optval;
P_min_general=P;

cvx_status


cvx_clear

end

p_x_hat =

  -Inf


p_x =

   -1.3863

 
p_joint =
 
    cvx real affine expression (scalar)
 
 
p_x_hat =
 
    cvx convex expression (scalar)
 
 
entrp_log =
 
    cvx concave expression (scalar)
 
Error using cvx/log_sum_exp (line 90)
Disciplined convex programming error:
    Illegal operation: log_sum_exp( {mixed
    concave/constant} ).

Error in i_min_general_cvx (line 49)
            I= log_sum_exp([I ,
            C_n_4(n+1,n00+2,n01+2,n10+2)+
            entrp_log]);

Error in R_n_q_d_e (line 26)
        [I_min_general(d,e),
        P_min_general]=i_min_general_cvx(q,D(d),epsilon(e),n,C_n_4,Cnk);
        
Error in run2_calculate (line 34)
        [I_min_iid(i_n,i_q,:,:) ,
        I_min_general(i_n,i_q,:,:)]=R_n_q_d_e(n(i_n),q(i_q),d,epsilon,C_n_4,Cnk);

FAQ: Why doesn’t CVX accept my problem? [READ THIS FIRST]