How to multiply two variables in cvx

Hello, I need to implement to multiply two variables in cvx. But the error ‘‘Disciplined convex programming error:Cannot perform the operation: {real affine} ./ {real affine}’’ exists. So I want to know how to solve the problem. The code is as follows.

close all;
clc;
d=[0.234;0.1759;0.1448;0.1467;0.1299;0.1567;0.295;0.551;0.2459;0.2162;0.2167;0.2125;0.2906;0.2214;0.1644;0.1792;0.2634;0.3187;0.4433;0.569;0.5879;0.8593;0.5094;0.3284];      
E=[-0.05 0 0 0 0 0 0 0.02 0.02 0.02 0.04 0.04 0.02 0.02 0.02 0.02 0.04 0.04 0.04 0.04 0.04 0 0 0 ; 
0 -0.05 0 0 0 0 0 0.02 0.02 0.02 0.04 0.04 0.02 0.02 0.02 0.02 0.04 0.04 0.04 0.04 0.04 0 0 0 ; 
0 0 -0.05 0 0 0 0 0.02 0.02 0.02 0.04 0.04 0.02 0.02 0.02 0.02 0.04 0.04 0.04 0.04 0.04 0 0 0 ; 
0 0 0 -0.05 0 0 0 0.02 0.02 0.02 0.04 0.04 0.02 0.02 0.02 0.02 0.04 0.04 0.04 0.04 0.04 0 0 0 ;
0 0 0 0 -0.05 0 0 0.02 0.02 0.02 0.04 0.04 0.02 0.02 0.02 0.02 0.04 0.04 0.04 0.04 0.04 0 0 0 ;
0 0 0 0 0 -0.05 0 0.02 0.02 0.02 0.04 0.04 0.02 0.02 0.02 0.02 0.04 0.04 0.04 0.04 0.04 0 0 0 ;
0 0 0 0 0 0 -0.05 0.02 0.02 0.02 0.04 0.04 0.02 0.02 0.02 0.02 0.04 0.04 0.04 0.04 0.04 0 0 0 ; 
0.02 0.02 0.02 0.02 0.02 0.02 0.02 -0.05 0 0 0 0 0 0 0.02 0.02 0.02 0.02 0.02 0.01 0.01 0.02 0.02 0.02 ; 
0.02 0.02 0.02 0.02 0.02 0.02 0.02 0 -0.05 0 0 0 0 0 0.02 0.02 0.02 0.02 0.02 0.01 0.01 0.02 0.02 0.02 ; 
0.02 0.02 0.02 0.02 0.02 0.02 0.02 0 0 -0.05 0 0 0 0 0.02 0.02 0.02 0.02 0.02 0.01 0.01 0.02 0.02 0.02 ; 
0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.02 0.02 0.02 -0.05 0 0.02 0.02 0.02 0.02 0 0 0 0 0 0.04 0.04 0.04 ; 
0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.02 0.02 0.02 0 -0.05 0.02 0.02 0.02 0.02 0 0 0 0 0 0.04 0.04 0.04 ;
0.02 0.02 0.02 0.02 0.02 0.02 0.02 0 0 0 0.02 0.02 -0.05 0 0 0 0.02 0.02 0.02 0.02 0.02 0.02 0.02 0.02 ; 
0.02 0.02 0.02 0.02 0.02 0.02 0.02 0 0 0 0.02 0.02 0 -0.05 0 0 0.02 0.02 0.02 0.02 0.02 0.02 0.02 0.02 ; 
0.02 0.02 0.02 0.02 0.02 0.02 0.02 0 0 0 0.02 0.02 0 0 -0.05 0 0.02 0.02 0.02 0.02 0.02 0.02 0.02 0.02 ;
0.02 0.02 0.02 0.02 0.02 0.02 0.02 0 0 0 0.02 0.02 0 0 0 -0.05 0.02 0.02 0.02 0.02 0.02 0.02 0.02 0.02 ;
0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.02 0.02 0.02 0 0 0.02 0.02 0.02 0.02 -0.05 0 0 0 0 0.04 0.04 0.04 ;
0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.02 0.02 0.02 0 0 0.02 0.02 0.02 0.02 0 -0.05 0 0 0 0.04 0.04 0.04 ;
0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.02 0.02 0.02 0 0 0.02 0.02 0.02 0.02 0 0 -0.05 0 0 0.04 0.04 0.04 ;
0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.02 0.02 0.02 0 0 0.02 0.02 0.02 0.02 0 0 0 -0.05 0 0.04 0.04 0.04 ;
0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.02 0.02 0.02 0 0 0.02 0.02 0.02 0.02 0 0 0 0 -0.05 0.04 0.04 0.04 ;
0 0 0 0 0 0 0 0.02 0.02 0.02 0.04 0.04 0.02 0.02 0.02 0.02 0.04 0.04 0.04 0.04 0.04 -0.05 0 0 ;
0 0 0 0 0 0 0 0.02 0.02 0.02 0.04 0.04 0.02 0.02 0.02 0.02 0.04 0.04 0.04 0.04 0.04 0 -0.05 0 ;
0 0 0 0 0 0 0 0.02 0.02 0.02 0.04 0.04 0.02 0.02 0.02 0.02 0.04 0.04 0.04 0.04 0.04 0 0 -0.05 ];
s_p=0.56;
cvx_begin
variable x1 x2
delta_pf=s_p*(1+x1);delta_pp=s_p;delta_pg=s_p*(1-x1);
delta_p=[delta_pg,delta_pg,delta_pg,delta_pg,delta_pg,delta_pg,delta_pg,delta_pp,delta_pp,delta_pp,delta_pf,delta_pf,delta_pp,delta_pp,delta_pp,...
delta_pp,delta_pf,delta_pf,delta_pf,delta_pf,delta_pf,delta_pg,delta_pg,delta_pg];
delta_d=(E*delta_p')'*diag(d)/s_p;
d_DR=d+delta_d';
minimize( max(d_DR)-min(d_DR) )
subject to
0<=x1<=1;
0<=x2<=1;
1.96<=delta_pf./nv_pos(delta_pg)<=5;
ones(1,24)*d==ones(1,24)*d_DR;
cvx_end

Is the error only arising from 1.96<=delta_pf./nv_pos(delta_pg)<=5; ?

I presume that is supposed to be inv_pos not nv_pos. Do you really mean 1.96<=delta_pf*nv_pos(delta_pg)<=5; If so, just multiply through, i.e., 1.95*delta_pg <= delta_pf <= 5*delta_pg .

if that is not what you want, you need to make clear what you do want.

Thank you, Mark. You are right. The error can be solved. But I meet a new problem. The running results of the code ‘‘Status: Infeasible Optimal value (cvx_optval): +Inf’’. I have no idea that the problem is the unreasonable data or the defective code. Thanks for your reply.

Follow the advice in https://yalmip.github.io/debugginginfeasible , all of which ewcept for section 1 also applies to CVX.

OK, I will try. Thanks for your advice.

Hello, I’m sorry that I can solve the infeasibility. I also noted that the error illustrates “sqlp stop: dual problem is suspected of being infeasible”. Also, I want to ask if the optimization problem aboveis convex. The reason is that real affine-real affine ?

real affine-real affine is real affine.

CVX wouldn’t have accepted your program if it weren’t convex.