HELP!Optimal value (cvx_optval): NaN

Why does cvx optimization fail, but still outputs the result,

clc;clear all;close all
kappa=0.6;
eta=0.6;
K=3;
T=1;
pd=10^(-5);
pe=10^(-4);
b=10^(-8);
dertak=b/K;
dgk=1;
gk=dgk^(-3);
dhk=7;
hk=dhk^(-3);
g_k=dertak/gk
 etaEE=0;
 
 
 
 Pmax=1;


%***********************************************************************

%***********************************************************************
%*****************************cvx****************************************
 cvx_begin 
         variables  T1 T2 L p_bl p_sj;
          R1=(-rel_entr(T1*g_k,T1*g_k+p_bl*hk))/g_k;
          R2=kappa*(-rel_entr(T2,T2+L));
         R=(R1+R2);
         Power=(p_sj+3*(p_sj-p_bl)*hk*eta-pe*T1-pd*T);
         maximize R-etaEE*Power
         subject to  
         T1>0;
         T2>0;
         T1<1;
         T1+T2==1; 
         p_bl>=0;
         p_sj>=0;
         L>=0;
         3*p_sj<=T1*Pmax;
         eta*3*hk*(p_sj-p_bl)>=L*g_k*K+pd*T+pe*T1;
  cvx_end 

Status: Failed
Optimal value (cvx_optval): NaN

L =

2.4560e+04

T1 =

0.9986

If Status is Failed, all variable values are meaningless.

However, with CVXQUAD and its exponential.m replacement installed CVXQUAD: How to use CVXQUAD's Pade Approximant instead of CVX's unreliable Successive Approximation for GP mode, log, exp, entr, rel_entr, kl_div, log_det, det_rootn, exponential cone. CVXQUAD's Quantum (Matrix) Entropy & Matrix Log related functions, this problem is solved to optimality, as I did with 3 different solvers. Unfortunately, the optimal objective value differed significantly among the 3. I suggest you try to improve the scaling in your model.

Thank you very much. I found the optimal solution under this parameter by modifying the parameters. What I want to know is whether I can use a loop. For example, a loop at Pmax, [1: 0.1: 2], to output the optimization amount I need at different pmax at one time.
What should I do if CCVX can

You can have

for Pmax=1:.01:2
  cvx_begin
  <your code from aboive>
  cvx_end
end

So you will be calling CVX 101 times, and solving 101 separate optimization problems.

Thank you very much for your reply, but in this way, I cannot record the value of the optimization value under each Pmax. For example, I want to use the Plot function in matlab to draw the horizontal axis as Pmax and the vertical axis as etaEE. Graph, in this way, I can’t seem to draw the desired curve

In other words, how do I record these values, when Pmax changes, the corresponding changes in T1, p_bl, p_sj, etc.

i = 1`
for Pmax=1:.01:2
  cvx_begin
  <your code from above>
  cvx_end
optimal_objective(i) = cvx_optval;
optimal_T1(i) = T1;
<etc.>
i = i+1
end

Thank you for your answer, then next, can I use the plot instruction to draw the corresponding graph, for example, plot (Pmax, T1)

At that point, you are outside CVX, and can use plot or any other MATLAB tools in accordance with MATLAB capabilities.

Thank you so much, you help me too much

Can I use CVXQUAD to solve a formula like this. For example, log (1 + x / c), where c is a constant and x is the optimized value

Yes. That is a concave expression which CVX will accept, if used in accordance with its DCP rules.

However, to get CVXUQAD’s Pade appproximant to be invoked for this, it must be refromulated per CVXQUAD: How to use CVXQUAD's Pade Approximant instead of CVX's unreliable Successive Approximation for GP mode, log, exp, entr, rel_entr, kl_div, log_det, det_rootn, exponential cone. CVXQUAD's Quantum (Matrix) Entropy & Matrix Log related functions

image
According to the illustration, can I think it can be transformed into this?
Replace log(1+x/c) with -rel_entr(1,(x+c)/c) or -rel_entr(1,1+x/c)

That should work. Remember to install the exponential.m replacement as per the link.

Okay, thank you. happy New Year!

Dear sir ,
I have a problem when i run my script to check feasability, so i have in all matrix -inv(R1tilde) and -inv(R2)

Do you know how i can solve this problem to obtain a faisability

The title of paper is : Optimal State feedback integral control using Network-based Measurements

%% Paper HONGBO LI
% Title : OPTIMAL STATE FEEDBACK INTEGRAL CONTROL USING NETWORK-Based
% Measurements
%% G_SFIC Controller design procedure
%% Define Plant :
clear all
close all
clc
format long
warning(‘off’,‘YALMIP:strict’)
%% ------------------------------------------------------------------------
Ts=0.1;
LMI=[];
F=[1.0000 0.0046;
0 1.9e-5];
G=[0.7326; 7.6794];
H=[0.020;0.001];
C=[1 0];
% ------------------ Calcul size ----------------
nF=size(F,1)
mG=size(G,2)
nC=size(C,1)
%% ------------------------------------------------------------------------
Fb=[F zeros(nF,mG);C eye(nC,mG)];
Gb=[G;zeros(1,1)];
Hb=[H;zeros(1,1)];
% ------------------ Calcul size ----------------
nFb=size(Fb,1)
mGb=size(Gb,2)
nCb=size(C,1)
%% ------------------------------------------------------------------------
Z=zeros(nFb);
I=eye(nFb);
Ftilde=[Fb Z Z Z;I Z Z Z;Z I Z Z;Z Z I Z];
Gtilde=[Gb;zeros(3,1);zeros(3,1);zeros(3,1)];
Htilde=[Hb;zeros(3,1);zeros(3,1);zeros(3,1)];
Etilde0=[I Z Z Z];
Etilde1=[Z I Z Z];
Etilde2=[Z Z I Z];
Etilde3=[Z Z Z I];

%% -----------------------------------------------------------------------------
% LMI TOOLBOX
nFtilde=size(Ftilde,1);
dimp=nFtilde;
dimq=nFtilde;
II=eye(nFtilde);
ZZ=zeros(nFtilde);
lamda=1.12;

%% ********************* YALMIP ***************************
cvx_begin sdp
variable P0(dimp,dimp) symmetric
variable P1(dimp,dimp) symmetric
variable P2(dimp,dimp) symmetric
variable P3(dimp,dimp) symmetric

variable Q0(dimp,dimp) symmetric
variable Q1(dimp,dimp) symmetric
variable Q2(dimp,dimp) symmetric
variable Q3(dimp,dimp) symmetric

variable R1(3,3) symmetric
variable R2(1,1) symmetric
variable Lbare(1,3)
variable Z(nFtilde,1)

PI0=Ftilde+GtildeLbareEtilde0;
PI1=Ftilde+GtildeLbareEtilde1;
PI2=Ftilde+GtildeLbareEtilde2;
PI3=Ftilde+GtildeLbareEtilde3;

P0 > 0;
P1 > 0;
P2 > 0;
P3 > 0;

Q0 > 0;
Q1 > 0;
Q2 > 0;
Q3 > 0;

R1 > 0;
R2 > 0;

% |R1 0|
% R1bare = | |
% |0 0|

R1bare=[ R1 zeros(3);
zeros(3) zeros(3)];

% |R1bare 0|
% R1tilde = | |
% |0 0|
R1tilde=[R1bare zeros(6,6);
zeros(6,6) zeros(6,6)];

%% STEP 1

% Solve LMI 32

% |-P(i)       *        *      *   |
% |PI(i)    -Q(i+1)     *      *   |<0    with i ==> Omega 4
% |I           0        0    -R1^(-1)|      Omega4 = {}
% |LE(i)       0        0    -R2^(-1)| 

% Pour i=0
[ -P0 PI0’ II’ (LbareEtilde0)’;
PI0 -Q1 ZZ zeros(nFtilde,1);
II zeros(nFtilde) -(R1tilde) zeros(nFtilde,1);
Lbare
Etilde0 zeros(1,nFtilde) zeros(1,nFtilde) -(R2)]<0;

% Pour i=1
[ -P1 PI1’ II’ (LbareEtilde1)’;
PI1 -Q2 ZZ zeros(nFtilde,1);
II zeros(nFtilde) -(R1tilde) zeros(nFtilde,1);
Lbare
Etilde1 zeros(1,nFtilde) zeros(1,nFtilde) -(R2)]<0;

% Solve LMI equation 33

% |-P(i)       *        *      *   |
% |PI(i)    -Q(j)     *      *   |<0       with i ==> Omega 3
% |I           0        0    -R1^-1|            j ==> Omega 4
% |LE(i)       0        0    -R2^-1| 

[     -P0               PI0'                       II'              (Lbare*Etilde0)';
       PI0             -Q0                         ZZ                zeros(nFtilde,1);   
       II          zeros(nFtilde)               -(R1tilde)           zeros(nFtilde,1);
   Lbare*Etilde0   zeros(1,nFtilde)          zeros(1,nFtilde)           -(R2)]<0;

[    -P1               PI1'                       II'                (Lbare*Etilde1)';
      PI1              -Q0                         ZZ                 zeros(nFtilde,1);   
      II          zeros(nFtilde)            -(R1tilde)               zeros(nFtilde,1);
  Lbare*Etilde1   zeros(1,nFtilde)          zeros(1,nFtilde)             -(R2)]<0;

[    -P2               PI2'                       II'               (Lbare*Etilde2)';
      PI2              -Q0                        ZZ                 zeros(nFtilde,1);   
      II          zeros(nFtilde)            -(R1tilde)               zeros(nFtilde,1);
  Lbare*Etilde2   zeros(1,nFtilde)          zeros(1,nFtilde)           -(R2)]<0;

[    -P3               PI3'                      II'               (Lbare*Etilde3)';
      PI3              -Q0                       ZZ                 zeros(nFtilde,1);   
      II          zeros(nFtilde)           -(R1tilde)               zeros(nFtilde,1);
  Lbare*Etilde3   zeros(1,nFtilde)          zeros(1,nFtilde)           -(R2)]<0;

% -------------------------------------------------------------------------

[     -P0              PI0'                  II'                   (Lbare*Etilde0)';
       PI0              -Q1                  ZZ                    zeros(nFtilde,1);   
       II           zeros(nFtilde)         -(R1tilde)               zeros(nFtilde,1);
   Lbare*Etilde0   zeros(1,nFtilde)      zeros(1,nFtilde)              -(R2)]<0;

[    -P1               PI1'                II'               (Lbare*Etilde1)';
      PI1               -Q1                 ZZ                zeros(nFtilde,1);   
      II           zeros(nFtilde)      -(R1tilde)              zeros(nFtilde,1);
  Lbare*Etilde1   zeros(1,nFtilde)     zeros(1,nFtilde)           -(R2)]<0;


[    -P2                PI2'                   II'             (Lbare*Etilde2)';
      PI2               -Q1                   ZZ                zeros(nFtilde,1);   
      II          zeros(nFtilde)        -(R1tilde)            zeros(nFtilde,1);
  Lbare*Etilde2   zeros(1,nFtilde)    zeros(1,nFtilde)           -(R2)]<0;

[    -P3                PI3'                  II'          (Lbare*Etilde3)';
      PI3              -Q1                   ZZ            zeros(nFtilde,1);   
      II          zeros(nFtilde)         -(R1tilde)        zeros(nFtilde,1);
  Lbare*Etilde3   zeros(1,nFtilde)      zeros(1,nFtilde)        -(R2)]<0;

%---------------------------------------------------------------------
[ -P0 PI0’ II’ (LbareEtilde0)’;
PI0 -Q2 ZZ zeros(nFtilde,1);
II zeros(nFtilde) -(R1tilde) zeros(nFtilde,1);
Lbare
Etilde0 zeros(1,nFtilde) zeros(1,nFtilde) -(R2)]<0;

[    -P1               PI1'                II'           (Lbare*Etilde1)';
      PI1               -Q2                 ZZ            zeros(nFtilde,1);   
      II            zeros(nFtilde)      -(R1tilde)        zeros(nFtilde,1);
  Lbare*Etilde1   zeros(1,nFtilde)    zeros(1,nFtilde)           -(R2)]<0;


[    -P2               PI2'                  II'             (Lbare*Etilde2)';
      PI2              -Q2                    ZZ              zeros(nFtilde,1);   
      II           zeros(nFtilde)         -(R1tilde)          zeros(nFtilde,1);
  Lbare*Etilde2   zeros(1,nFtilde)    zeros(1,nFtilde)           -(R2)]<0;

[    -P3               PI3'                II'             (Lbare*Etilde3)';
      PI3               -Q2                 ZZ              zeros(nFtilde,1);   
      II           zeros(nFtilde)      -(R1tilde)           zeros(nFtilde,1);
  Lbare*Etilde3   zeros(1,nFtilde)    zeros(1,nFtilde)           -(R2)]<0;

% ---------------------------------------------
[ -P0 PI0’ II’ (LbareEtilde0)’;
PI0 -Q3 ZZ zeros(nFtilde,1);
II zeros(nFtilde) -(R1tilde) zeros(nFtilde,1);
Lbare
Etilde0 zeros(1,nFtilde) zeros(1,nFtilde) -(R2)]<0;

[    -P1          PI1'                     II'                (Lbare*Etilde1)';
      PI1          -Q3                      ZZ                 zeros(nFtilde,1);   
      II          zeros(nFtilde)      -(R1tilde)               zeros(nFtilde,1);
  Lbare*Etilde1   zeros(1,nFtilde)    zeros(1,nFtilde)             -(R2)]<0;


[    -P2          PI2'                   II'              (Lbare*Etilde2)';
      PI2          -Q3                     ZZ              zeros(nFtilde,1);   
      II          zeros(nFtilde)      -(R1tilde)           zeros(nFtilde,1);
  Lbare*Etilde2   zeros(1,nFtilde)    zeros(1,nFtilde)           -(R2)]<0;

[    -P3             PI3'                 II'             (Lbare*Etilde3)';
      PI3             -Q3                  ZZ               zeros(nFtilde,1);   
      II            zeros(nFtilde)      -(R1tilde)          zeros(nFtilde,1);
  Lbare*Etilde3   zeros(1,nFtilde)     zeros(1,nFtilde)         -(R2)]<0;

% Solve LMI 36

% |Pi    I|
% |       |>0    with i ==> Omega 3
% |I    Qi| 

[P0 II;II Q0]>=0;
[P1 II;II Q1]>=0;
[P2 II;II Q2]>=0;
[P3 II;II Q3]>=0;

% Solve LMI 37

% z’(0)P_I z(0)<Lamda
[lamda Z’;Z P0]>0;
[lamda Z’;Z P1]>0;
[lamda Z’;Z P2]>0;
[lamda Z’;Z P3]>0;

cvx_end

Try following the advice in https://yalmip.github.io/debugginginfeasible/ , which for the most part applies to CVX as well as to YALMIP.