Inclusion of Expressions Causes Infeasibility

Hi, I have a working CVX program given by:

function [output] = RunCVXMissions
for cnt = 1:9
    output(cnt) = RunCVX(50,cnt);
end
end

function [output] = RunCVX(varargin)
if nargin == 1
    kv = varargin{1};
elseif nargin > 1
    kv = varargin{1};
    mission = varargin{2};
else
    kv = 50;
end
%% CVX PREP + REF TRAJ
% Constants
Re = 6378e3; % Radius of Earth in m.
g = 9.81;   % Acceleration due to gravity in m/s^2.
kQ = 1.65e-4*sqrt(g*Re)^(3.15); % Heat transfer constant.
rho0 = 1.225; % Density of air in kg/m^3;
hs = 7200; % Reference altitude in m.
Omega = 7.2921150e-5; % Rotational rate of Earth.

% Initial and terminal states (note that these may not necessarily be in
% the cvx program.
if nargin < 2
    xi = [100e3+Re;-0.1278*pi/180;51.5074*pi/180;7450;-0.5*pi/180;-90*pi/180;0]./[Re;1;1;sqrt(Re*g);1;1;1];
    xf = [15e3+Re;-74.0060*pi/180;40.7128*pi/180;0;0*pi/180;0;0]./[Re;1;1;sqrt(Re*g);1;1;1];
else
    missionic = [[100e3+Re;0*pi/180;0*pi/180;7450;0*pi/180;0*pi/180;0],...
        [100e3+Re;0*pi/180;0*pi/180;7450;0*pi/180;0*pi/180;0],...
        [100e3+Re;0*pi/180;0*pi/180;7450;0*pi/180;0*pi/180;0],...
        [100e3+Re;0*pi/180;0*pi/180;7450;0*pi/180;0*pi/180;0],...
        [100e3+Re;0*pi/180;0*pi/180;7450;0*pi/180;0*pi/180;0],...
        [100e3+Re;0*pi/180;0*pi/180;7450;0*pi/180;0*pi/180;0],...
        [100e3+Re;0*pi/180;0*pi/180;7450;0*pi/180;0*pi/180;0],...
        [100e3+Re;0*pi/180;0*pi/180;7450;0*pi/180;0*pi/180;0],...
        [100e3+Re;0*pi/180;0*pi/180;7450;0*pi/180;45*pi/180;0]...
        ]./[Re;1;1;sqrt(Re*g);1;1;1];
    missiontc = [[0;0;0;0;0;0;0],...
        [0;0*pi/180;65*pi/180;0;0;0;0],...
        [0;30*pi/180;50*pi/180;0;0;0;0],...
        [0;45*pi/180;35*pi/180;0;0;0;0],...
        [0;0;0;0;0;0;0],...
        [0e3+Re;45*pi/180;45*pi/180;2500;-25*pi/180;0;0],...
        [0e3+Re;45*pi/180;45*pi/180;2500;-25*pi/180;0;0],...
        [5e3+Re;45*pi/180;45*pi/180;2500;-25*pi/180;0;0],...
        [0;0;0;0;0;0;0]...
        ]./[Re;1;1;sqrt(Re*g);1;1;1];
    xi = missionic(:,mission);
    xf = missiontc(:,mission);
end
% Control Matrix.
B  = [zeros(6,1);1];

% Virtual control scale.
la = 10^8;

% Trust region and Convergence condition.
de = [10000/Re; 20*pi/180; 40*pi/180; 10000/sqrt(Re/g); 40*pi/180; 60*pi/180; 20*pi/180];
zi = [500/Re; 2*pi/180; 2*pi/180; 15/sqrt(Re/g); 2*pi/180; 2*pi/180; 5*pi/180];

% Time parameters
ti = 0;    % Initial time in s.
tf = 900; % Final time in s.
N  = 150;  % Time segments.

% Scaled time parameters.
tin = ti/sqrt(Re/g);
tfn = tf/sqrt(Re/g);
dtn = (tfn-tin)/(N-1);
t = linspace(ti,tf,N+1);

% Vehicle parameters.
m = 104305; % Mass in KG.
Ar = 391.22; % Surface area in m^2.

% Reference trajectory.
rx(:,1) = xi;
rx(:,2:tf*N) = zeros(7,tf*(N)-1);
u(:,1) = 0*pi/180;
for i = 1:tf*N
    rx(:,i+1) = rx(:,i) + dtn/tf*StateFunction(rx(:,i)) + B*u(:,i);
    u(:,i+1) = u(:,i);
end
rxtmp = zeros(7,N);
for i = 1:N
    rxtmp(:,i) = rx(:,i*tf);
end
rx = [rxtmp,rxtmp(:,end)];
% Outputs.
output.rx = rx;
output.parameters.initialstate = xi;
output.parameters.terminalstate = xf;
output.t = t;

% Constraints
sigmadotmax = 10*pi/180;
Qdmax = 1500;
qmax = 18000;
nmax = 2.5*g;
sigmamax = 90*pi/180;

% CVX Setup
xdim = size(rx,1);
udim = 1;

%% CVX
rxs(:,:,1) = rx;
for k = 1:kv
    pause
    cvx_begin
    % Variables
    variables u(udim,N) ep(xdim,N) x(xdim,N+1)
%     expressions al CL CD
    x(:,1) == xi;
    switch nargin
        case 2
            % Time parameters
            ti = 0;    % Initial time in s.
            tf = 915; % Final time in s.
            % Scaled time parameters.
            tin = ti/sqrt(Re/g);
            tfn = tf/sqrt(Re/g);
            dtn = (tfn-tin)/(N-1);
            t = linspace(ti,tf,N+1);
            switch mission
                case 1
                    minimize(la*norm(ep,1))
                case 2
                    minimize(la*norm(ep,1))
                    x(2,N+1) == xf(2); % Longitude
                    x(3,N+1) == xf(3); % Latitude.
                case 3
                    minimize(la*norm(ep,1))
                    x(2,N+1) == xf(2); % Longitude
                    x(3,N+1) == xf(3); % Latitude.
                case 4
                    minimize(la*norm(ep,1))
                    x(2,N+1) == xf(2); % Longitude
                    x(3,N+1) == xf(3); % Latitude.
                case 5
                    minimize(-x(2,N+1)*180/pi*1e3 + la*norm(ep,1))
                case 6
                    minimize((-rel_entr(1,kQ) - 0.5*rel_entr(1,rho0) - (x(1,i)*Re-Re)/(2*hs)+3.15*(-rel_entr(1,rx(4,i))+(1/rx(4,i))*(x(4,i)-rx(4,i)))) + la*norm(ep,1))
                    x(2,N+1) == xf(2); % Longitude
                    x(3,N+1) == xf(3); % Latitude.
                case 7
                    minimize(-x(4,N+1)*1e3 + la*norm(ep,1))
                    x(2,N+1) == xf(2); % Longitude
                    x(3,N+1) == xf(3); % Latitude.
                case 8
                    minimize(la*norm(ep,1))
                    x(1,N+1) == xf(1); % Length from centre of Earth.
                    x(2,N+1) == xf(2); % Longitude
                    x(3,N+1) == xf(3); % Latitude.
                    x(5,N+1) == xf(5); % Flight path angle.
                    x(6,N+1) == xf(6); % Heading angle.
                case 9
                    minimize(la*norm(ep,1))
                    x(2,N+1) == xf(2); % Longitude
                    x(3,N+1) == xf(3); % Latitude.
            end
        otherwise
            minimize(la*norm(ep,1))
            x(2,N+1) == xf(2); % Longitude
            x(3,N+1) == xf(3); % Latitude.
    end
    % Path constraints.
    for i = 1:N+1
        x(1,i) <= xi(1);
        x(1,i) >= (500+Re)/Re;
        x(4,i) <= 10000/sqrt(g*Re);
        x(4,i) >= 500/sqrt(g*Re);
        x(7,i) <= sigmamax;
        x(7,i) >= -sigmamax;
    end
    % Control constraints.
    for i = 1:N
        u(:,i) <= sigmadotmax;
        u(:,i) >= -sigmadotmax;
    end
    % Dynamic Constraints.
    for i = 1:N
        % Heating Rate.
        -rel_entr(1,kQ) - 0.5*rel_entr(1,rho0) - (x(1,i)*Re-Re)/(2*hs)+3.15*(-rel_entr(1,rx(4,i))+(1/rx(4,i))*(x(4,i)-rx(4,i))) <= Qdmax;
        % Dynamic pressure.
        -rel_entr(1,0.5*g*Re) -rel_entr(1,rho0) - (x(1,i)*Re-Re)/(hs) + 2*(-rel_entr(1,rx(4,i))+(1/rx(4,i))*(x(4,i)-rx(4,i))) <= qmax;
%         Normal force.
%         al = 0.002638.*x(4,i) + 21.11;
%         CL = -0.041065 + 0.016292*al + 0.0002602*pow_pos(al,2);
%         CD = 0.0009497*pow_pos(al,2) - 0.0183*al + 0.1713;
%         -0.5*rel_entr(1,CL^2+CD^2)-rel_entr(1,Re*rho0*Ar/2*m) - (x(1,i)*Re-Re)/(hs) + 2*(-rel_entr(1,rx(4,i))+(1/rx(4,i))*(x(4,i)-rx(4,i))) <= nmax;
    end
    % Trust region.
    if k > 1
        for i = 1:N
            abs(x(:,i)-rx(:,i)) <= de;
        end
    end
    % Equations of motion.
    for i = 1:N
        x(:,i+1) == x(:,i) + dtn*(Afunc(rx(:,i))*x(:,i) + B*u(:,i) + C(rx(:,i)) + ep(:,i));
    end
    cvx_end
    if k > 1
        rxs(:,:,k) = rx;
        if all(abs(x-rx) < zi)
            if nargin >= 2
                fprintf('Convergence of mission %.0f achieved.\n',mission)
            else
                fprintf('Convergence of condition reached.\n')
            end
            break
        end
    end
    rx = x;
    if strcmp(cvx_status,'Failed') || strcmp(cvx_status,'Infeasible')
        if nargin >= 2
            fprintf('Optimisation of mission %.0f failed.\n',mission)
        else
            fprintf('Optimisation failed.\n')
        end
        break
    end
    if all(max(max(abs(x(:,i)-rx(:,i)))) <= zi) && ~strcmp(cvx_status,'Inaccurate/Solved')
        if nargin >= 2
            fprintf('Convergence of mission %.0f achieved.\n',mission)
        else
            fprintf('Convergence of condition reached.\n')
        end
        break
    end
end
% Vector length fix.
u(:,end+1) = u(:,end);
ep(:,end+1) = ep(:,end);
% Outputs.
output.status = cvx_status;
output.rx = rxs;
output.cost = la*norm(ep,1);
output.x = x;
output.u = u;
output.ep = ep;
output.constraints.heatingrate = Qdmax;
output.constraints.dynamicpressure = qmax;
output.constraints.normalforce = nmax;
output.convex.cputtime = cvx_cputime;
output.convex.optval = cvx_optval;
end

function [output] = C(x)
output = StateFunction(x)-Afunc(x)*x;
end

function A = Afunc(x)
%AF
%    A = AF(X)

%    This function was generated by the Symbolic Math Toolbox version 8.7.
%    04-May-2021 15:25:15

x1 = x(1);
x2 = x(2);
x3 = x(3);
x4 = x(4);
x5 = x(5);
x6 = x(6);
x7 = x(7);

vn = x4*sqrt(9.81*6378e3);
alph = 40*(vn>4570) + (40-0.20705*((vn-4570)^2/(340^2)))*(vn<=4570);

t2 = cos(x3);
t3 = cos(x5);
t4 = cos(x6);
t5 = cos(x7);
t6 = sin(x3);
t7 = sin(x5);
t8 = sin(x6);
t9 = sin(x7);
t10 = tan(x3);
t11 = tan(x5);
t12 = alph.^2;
t13 = x4.^2;
t14 = 1.0./x1;
t17 = 1.0./x4;
t27 = x1.*8.858333333333333e+2;
t30 = alph.*3.66e-2;
t36 = x4.*4.652944151110821;
t39 = x4.*9.468741347510521;
t15 = t14.^2;
t16 = t14.^3;
t18 = 1.0./t13;
t19 = t2.*t3;
t20 = t2.*t7;
t21 = 1.0./t2;
t22 = 1.0./t3;
t24 = -t13;
t25 = t3.*t4.*t6;
t26 = t4.*t6.*t7;
t29 = -t27;
t37 = -t36;
t40 = -t39;
t42 = t12.*7.53e-4;
t23 = t22.^2;
t28 = -t25;
t31 = t14+t24;
t32 = t19+t26;
t34 = t29+8.858333333333333e+2;
t38 = exp(t37);
t41 = exp(t40);
t33 = t20+t28;
t35 = exp(t34);
t43 = t38.*2.664e-1;
t44 = t41.*(2.7e+1./1.0e+2);
t45 = t2.*t32.*x1.*3.457184248754628e-3;
t46 = t30+t43-1.177e-1;
t47 = t42+t44+4.42e-2;
et1 = t17.*(t2.*t8.*1.175956504085866e-1+t3.*t14.*x4.*2.0-t5.*t13.*t35.*t38.*1.85139711293432e+3+t5.*t35.*t46.*x4.*2.987222127180242e+3);
et2 = -t18.*(t45+t2.*t8.*x4.*1.175956504085866e-1+t3.*t14.*(t13-t14)+t5.*t13.*t35.*t46.*1.493611063590121e+3);
et3 = t17.*(t6.*1.175956504085866e-1-t2.*t4.*t11.*1.175956504085866e-1-t9.*t13.*t22.*t35.*t38.*1.85139711293432e+3+t3.*t8.*t10.*t14.*x4.*2.0+t9.*t22.*t35.*t46.*x4.*2.987222127180242e+3);
et4 = -t18.*(x4.*(t6-t2.*t4.*t11).*1.175956504085866e-1+t3.*t8.*t10.*t13.*t14+t9.*t13.*t22.*t35.*t46.*1.493611063590121e+3+t2.*t6.*t8.*t22.*x1.*3.457184248754628e-3);
mt1 = [0.0,-t3.*t8.*t15.*t21.*x4,-t3.*t4.*t15.*x4,t7.*t16.*2.0+t2.*t33.*3.457184248754628e-3+t13.*t35.*t47.*1.323090467163582e+6];
mt2 = [t17.*(t3.*t16+t2.*t32.*3.457184248754628e-3-t3.*t15.*(t13-t14)-t5.*t13.*t35.*t46.*1.323090467163582e+6),-t17.*(t2.*t6.*t8.*t22.*(-3.457184248754628e-3)+t3.*t8.*t10.*t13.*t15+t9.*t13.*t22.*t35.*t46.*1.323090467163582e+6),0.0];
mt3 = [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,t3.*t6.*t8.*t14.*t21.^2.*x4,0.0,t2.*x1.*(t6.*t7+t4.*t19).*(-3.457184248754628e-3)-t6.*t33.*x1.*3.457184248754628e-3];
mt4 = [-t17.*(t2.*x1.*(t3.*t6-t4.*t20).*3.457184248754628e-3+t6.*t8.*x4.*1.175956504085866e-1+t6.*t32.*x1.*3.457184248754628e-3)];
mt5 = [t17.*(x4.*(t2+t4.*t6.*t11).*1.175956504085866e-1-t6.^2.*t8.*t22.*x1.*3.457184248754628e-3+t8.*1.0./t21.^2.*t22.*x1.*3.457184248754628e-3+t3.*t8.*t13.*t14.*(t10.^2+1.0)),0.0,t7,t3.*t8.*t14.*t21,t3.*t4.*t14];
mt6 = [t13.*t35.*t41.*3.818506545427035e+3-t35.*t47.*x4.*2.987222127180242e+3,et1+et2,et3+et4,0.0,t3.*x4,-t7.*t8.*t14.*t21.*x4,-t4.*t7.*t14.*x4,t45-t3.*t15,-t17.*(t2.*t33.*x1.*3.457184248754628e-3+t7.*t14.*(t13-t14))];
mt7 = [-t17.*(t2.*t4.*x4.*(t11.^2+1.0).*1.175956504085866e-1+t7.*t8.*t10.*t13.*t14-t6.*t8.*t20.*t23.*x1.*3.457184248754628e-3-t7.*t9.*t13.*t23.*t35.*t46.*1.493611063590121e+3),0.0,0.0,t3.*t4.*t14.*t21.*x4,-t3.*t8.*t14.*x4,t6.*t8.*t19.*x1.*3.457184248754628e-3];
mt8 = [t17.*(t2.*t4.*x4.*1.175956504085866e-1-t6.*t8.*t20.*x1.*3.457184248754628e-3),t17.*(t2.*t8.*t11.*x4.*1.175956504085866e-1+t3.*t4.*t10.*t13.*t14+t2.*t4.*t6.*t22.*x1.*3.457184248754628e-3),0.0,0.0,0.0,0.0,0.0];
mt9 = [t9.*t35.*t46.*x4.*(-1.493611063590121e+3),t5.*t22.*t35.*t46.*x4.*1.493611063590121e+3,0.0];
A = reshape([mt1,mt2,mt3,mt4,mt5,mt6,mt7,mt8,mt9],7,7);
end

function f = StateFunction(x)
%% Input parameters
% radius from centre of Earth = x(1);
% longitude = x(2);
% latitude = x(3);
% velocity = x(4);
% flight path angle = x(5);
% heading angle = x(6);
% bank angle = x(7);
% Constants
g = 9.81;
Re = 6378e3;
rho0 = 1.225;
hs = 7200;
m = 104305;
Ar = 391.22;
% Calculations
vn = x(4)*sqrt(g*Re);
h = x(1)*Re-Re;
rho = rho0*exp(-h/hs);
omega = 7.2921150e-5/sqrt(g/Re);
Mach = vn/340;
alph = 40*(vn>4570) + ((40-0.20705*(vn-4570)^2)/(340^2))*(vn<=4570);
CL = -0.041065 + 0.016292*alph + 0.00026024*alph^2;
CD = 0.080505 - 0.03026*CL + 0.86495*CL^2;
L = (0.5*Re*rho*x(4)^2*Ar*CL)/(m*g);
D = (0.5*Re*rho*x(4)^2*Ar*CD)/(m*g);

%% Rates.
% Bollino
% rd = x(4)*sin(x(5));
% ld = (x(4)*cos(x(5))*sin(x(6)))/(x(1)*cos(x(3)));
% ad = (x(4)*cos(x(5))*cos(x(6)))/(x(1));
% vd = -D -(sin(x(5))/x(1)^2)+((omega^2*x(1)*cos(x(3)))*(sin(x(5))*cos(x(3))-cos(x(5))*sin(x(3))*cos(x(6))));
% gd = (1/x(4))*(L*cos(x(7))+(x(4)^2-(1/x(1)))*((cos(x(5)))/x(1))+(2*omega*x(4)*cos(x(3))*sin(x(6)))+omega^2*x(1)*cos(x(3))*(cos(x(5))*cos(x(3))+sin(x(5))*cos(x(6))*sin(x(3))));
% pd = (1/x(4))*((L*sin(x(7))/cos(x(5)))+(x(4)^2/x(1))*(cos(x(5))*sin(x(6))*tan(x(3)))-2*omega*x(4)*(tan(x(5))*cos(x(6))*cos(x(3))-sin(x(3)))+((omega^2*x(1))/(cos(x(5))))*(sin(x(6))*sin(x(3))*cos(x(3))));
% sd = 0;
% Pei et al.
rd = x(4)*sin(x(5));
ld = (x(4)*cos(x(5))*sin(x(6)))/(x(1)*cos(x(3)));
ad = (x(4)*cos(x(5))*cos(x(6)))/(x(1));
vd = -D -(sin(x(5))/x(1)^2);
gd = (1/x(4))*(L*cos(x(7)))+((x(4)^2-(1/x(1)))*(cos(x(5))))/(x(1)*x(4));
pd = (1/x(4))*((L*sin(x(7))/cos(x(5)))+(x(4)^2/x(1))*(cos(x(5))*sin(x(6))*tan(x(3))));
sd = 0;
f = [rd;ld;ad;vd;gd;pd;sd];
end

I’m finding that if I uncomment the expressions and include the alpha, CL and CD calculations the previously solvable optimization problems produce NaN’s, can anybody tell me what is happening?

1 Like

You haven’t told us why the NaN 's occurred? What do the solver and CVX output show? Did the solver (numerically) fail (was CVX’s Successive Approximation method used? Was CVXQUAD invoked? Was Mosek 9.x used?)? Did the solver complete, but with the result of (primal) infeasible?

1 Like

Here is the output of the ninth mission optimization:

Calling SDPT3 4.0: 5401 variables, 2552 equality constraints
------------------------------------------------------------

 num. of constraints = 2552
 dim. of sdp    var  = 600,   num. of sdp  blk  = 300
 dim. of socp   var  = 2100,   num. of socp blk  = 1050
 dim. of linear var  = 1956
 dim. of free   var  = 445 *** convert ublk to lblk
*******************************************************************
   SDPT3: Infeasible path-following algorithms
*******************************************************************
 version  predcorr  gam  expon  scale_data
   HKM      1      0.000   1        0    
it pstep dstep pinfeas dinfeas  gap      prim-obj      dual-obj    cputime
-------------------------------------------------------------------
 0|0.000|0.000|2.2e+04|8.9e+02|6.0e+19|-5.746600e+04  0.000000e+00| 0:0:00| spchol  1  2 
 1|0.000|0.000|2.2e+04|8.9e+02|1.2e+19| 9.749953e+10  3.952484e+08| 0:0:00| spchol  2  2 
 2|0.000|0.000|2.2e+04|8.9e+02|2.4e+18| 3.899792e+11 -5.155837e+09| 0:0:00| spchol  2  2 
 3|0.000|0.000|2.2e+04|8.9e+02|4.8e+17| 7.949392e+11 -2.676334e+10| 0:0:00| spchol  1  2 
 4|0.001|0.010|2.2e+04|8.8e+02|9.6e+16| 9.982715e+11 -3.599445e+11| 0:0:00| spchol  1  2 
 5|0.016|0.002|2.1e+04|8.8e+02|2.0e+16| 1.774144e+12 -4.639021e+11| 0:0:00| spchol  2  2 
 6|0.100|0.640|1.9e+04|3.2e+02|3.2e+15| 1.889875e+12 -1.683070e+12| 0:0:00| spchol  2  2 
 7|0.820|0.246|3.5e+03|2.4e+02|1.3e+15| 1.674043e+13 -1.848547e+12| 0:0:00| spchol  1  2 
 8|0.526|0.539|1.6e+03|1.1e+02|5.8e+14| 2.430628e+13 -1.728396e+12| 0:0:00| spchol  1  1 
 9|0.730|0.646|4.4e+02|3.9e+01|2.3e+14| 2.840779e+13 -1.234167e+12| 0:0:00| spchol  1  1 
10|0.590|0.706|1.8e+02|1.1e+01|9.4e+13| 2.333913e+13 -6.344812e+11| 0:0:00| spchol  1  1 
11|0.432|0.225|1.0e+02|8.9e+00|6.8e+13| 1.793840e+13 -5.830635e+11| 0:0:00| spchol  1  1 
12|0.622|0.392|3.9e+01|5.4e+00|4.0e+13| 1.213790e+13 -5.112581e+11| 0:0:00| spchol  1  1 
13|0.595|0.358|1.6e+01|3.5e+00|2.4e+13| 7.906331e+12 -4.647865e+11| 0:0:00| spchol  1  1 
14|0.656|0.371|5.4e+00|2.2e+00|1.4e+13| 4.845832e+12 -4.308377e+11| 0:0:00| spchol  1  1 
15|0.609|0.308|2.1e+00|1.5e+00|9.4e+12| 2.996241e+12 -4.166436e+11| 0:0:00| spchol  1  1 
16|0.398|0.309|1.3e+00|1.0e+00|7.1e+12| 2.327436e+12 -4.168065e+11| 0:0:00| spchol  1  1 
17|0.498|0.415|6.4e-01|6.1e-01|4.8e+12| 1.626933e+12 -4.033767e+11| 0:0:00| spchol  1  1 
18|0.765|0.214|1.5e-01|4.8e-01|3.0e+12| 7.773393e+11 -3.815630e+11| 0:0:00| spchol  1  1 
19|0.691|0.327|4.6e-02|3.2e-01|1.9e+12| 4.386975e+11 -3.335974e+11| 0:0:00| spchol  1  1 
20|0.636|0.293|1.7e-02|2.3e-01|1.4e+12| 2.778609e+11 -2.894367e+11| 0:0:01| spchol  1  1 
21|0.636|0.409|6.2e-03|1.3e-01|8.3e+11| 1.431139e+11 -2.030212e+11| 0:0:01| spchol  1  1 
22|0.596|0.260|2.5e-03|9.9e-02|6.1e+11| 8.378954e+10 -1.650308e+11| 0:0:01| spchol  1  1 
23|0.843|0.470|3.9e-04|5.3e-02|3.4e+11| 2.282933e+10 -9.529404e+10| 0:0:01| spchol  1  1 
24|0.464|0.132|2.1e-04|4.6e-02|3.3e+11| 2.199239e+10 -8.695771e+10| 0:0:01| spchol  1  1 
25|0.429|0.135|1.2e-04|4.0e-02|3.3e+11| 2.333478e+10 -8.055446e+10| 0:0:01| spchol  1  1 
26|0.535|0.149|5.6e-05|3.4e-02|3.3e+11| 2.436284e+10 -7.453852e+10| 0:0:01| spchol  1  1 
27|0.669|0.174|1.8e-05|2.8e-02|3.2e+11| 2.494512e+10 -6.865166e+10| 0:0:01| spchol  1  1 
28|0.860|0.206|2.6e-06|2.2e-02|3.0e+11| 2.480760e+10 -6.283133e+10| 0:0:01| spchol  1  1 
29|0.968|0.250|8.3e-08|1.7e-02|2.7e+11| 2.333549e+10 -5.667310e+10| 0:0:01| spchol  1  1 
30|1.000|0.279|8.4e-11|1.2e-02|2.3e+11| 2.043793e+10 -5.020162e+10| 0:0:01| spchol  1  1 
31|1.000|0.298|1.2e-11|8.4e-03|1.9e+11| 1.660115e+10 -4.334825e+10| 0:0:01| spchol  1  1 
32|1.000|0.320|9.6e-11|5.7e-03|1.4e+11| 1.201330e+10 -3.575746e+10| 0:0:01| spchol  1  1 
33|1.000|0.360|2.1e-10|3.7e-03|1.0e+11| 7.191971e+09 -2.711533e+10| 0:0:01| spchol  1  1 
34|1.000|0.401|3.2e-10|2.2e-03|6.7e+10| 3.542755e+09 -1.854064e+10| 0:0:01| spchol  1  1 
35|1.000|0.460|3.9e-10|1.2e-03|4.0e+10| 1.360497e+09 -1.099851e+10| 0:0:01| spchol  1  1 
36|1.000|0.337|4.7e-10|7.8e-04|3.0e+10| 8.627189e+08 -7.710027e+09| 0:0:01| spchol  2  2 
37|1.000|0.409|3.3e-10|4.6e-04|2.0e+10| 4.545136e+08 -4.782827e+09| 0:0:01| spchol  2  2 
38|1.000|0.346|2.6e-10|3.0e-04|1.4e+10| 3.057781e+08 -3.232311e+09| 0:0:01| spchol  2  1 
39|1.000|0.192|2.7e-10|2.4e-04|1.3e+10| 3.839704e+08 -2.701045e+09| 0:0:01| spchol  1  2 
40|1.000|0.405|3.8e-10|1.5e-04|8.8e+09| 2.354784e+08 -1.694570e+09| 0:0:01| spchol  2  2 
41|1.000|0.327|3.4e-10|9.8e-05|6.6e+09| 1.773459e+08 -1.180172e+09| 0:0:01| spchol  2  2 
42|1.000|0.321|3.9e-10|6.6e-05|5.0e+09| 1.435964e+08 -8.235358e+08| 0:0:01| spchol  2  2 
43|1.000|0.338|4.2e-10|4.4e-05|3.7e+09| 1.163813e+08 -5.530979e+08| 0:0:01| spchol  2  2 
44|1.000|0.259|3.8e-10|3.3e-05|3.1e+09| 1.128542e+08 -4.149142e+08| 0:0:01| spchol  2  2 
45|1.000|0.193|3.1e-10|2.6e-05|2.8e+09| 1.338391e+08 -3.464067e+08| 0:0:01| spchol  2  2 
46|1.000|0.440|5.0e-10|1.5e-05|1.8e+09| 9.706002e+07 -1.901421e+08| 0:0:01| spchol  2  2 
47|1.000|0.122|3.1e-10|1.3e-05|1.8e+09| 1.358490e+08 -1.746594e+08| 0:0:01| spchol  2  2 
48|1.000|0.369|2.5e-10|8.2e-06|1.3e+09| 1.110314e+08 -1.164034e+08| 0:0:01| spchol  2  2 
49|1.000|0.339|8.9e-10|5.4e-06|9.7e+08| 9.415343e+07 -7.246959e+07| 0:0:01| spchol  2  2 
50|1.000|0.246|2.8e-10|4.1e-06|8.4e+08| 9.479004e+07 -5.170158e+07| 0:0:01| spchol  2  2 
51|1.000|0.285|4.2e-10|2.9e-06|6.9e+08| 9.108735e+07 -3.165566e+07| 0:0:01| spchol  2  2 
52|1.000|0.309|5.3e-10|2.0e-06|5.4e+08| 8.494052e+07 -1.275167e+07| 0:0:01| spchol  2  2 
53|1.000|0.321|4.9e-10|1.4e-06|4.2e+08| 7.917985e+07  4.066808e+06| 0:0:01| spchol  2  2 
54|1.000|0.314|4.2e-10|9.4e-07|3.3e+08| 7.534301e+07  1.730938e+07| 0:0:01| spchol  2  2 
55|1.000|0.319|5.2e-10|6.4e-07|2.5e+08| 7.236995e+07  2.816344e+07| 0:0:01| spchol  2  2 
56|1.000|0.316|3.9e-10|4.4e-07|1.9e+08| 7.026390e+07  3.664027e+07| 0:0:01| spchol  3  2 
57|1.000|0.234|4.1e-10|3.3e-07|1.7e+08| 7.084593e+07  4.068757e+07| 0:0:01| spchol  3  3 
58|1.000|0.283|4.3e-10|2.4e-07|1.4e+08| 7.016550e+07  4.477002e+07| 0:0:01| spchol  3  3 
59|1.000|0.298|4.8e-10|1.7e-07|1.1e+08| 6.908715e+07  4.839523e+07| 0:0:01| spchol  3  3 
60|1.000|0.279|4.2e-10|1.2e-07|9.4e+07| 6.853762e+07  5.103361e+07| 0:0:01| spchol  3  3 
61|1.000|0.278|4.6e-10|8.7e-08|7.9e+07| 6.810155e+07  5.313094e+07| 0:0:01| spchol  3  3 
62|1.000|0.281|5.4e-10|6.3e-08|6.5e+07| 6.765017e+07  5.486759e+07| 0:0:01| spchol  4  3 
63|1.000|0.265|5.9e-10|4.6e-08|5.6e+07| 6.747349e+07  5.611520e+07| 0:0:02| spchol  3  3 
64|1.000|0.280|8.1e-10|3.3e-08|4.7e+07| 6.710972e+07  5.723388e+07| 0:0:02| spchol  4  4 
65|1.000|0.267|1.1e-09|2.4e-08|4.1e+07| 6.689767e+07  5.807248e+07| 0:0:02| spchol  4  4 
66|1.000|0.287|1.7e-09|1.7e-08|3.4e+07| 6.642859e+07  5.890021e+07| 0:0:02| spchol  4  4 
67|1.000|0.271|2.0e-09|1.3e-08|3.0e+07| 6.618638e+07  5.953553e+07| 0:0:02| spchol  5  4 
68|1.000|0.301|4.1e-09|8.8e-09|2.4e+07| 6.538547e+07  6.024939e+07| 0:0:02| spchol  5  4 
69|1.000|0.281|4.7e-09|6.4e-09|2.1e+07| 6.505203e+07  6.080938e+07| 0:0:02| spchol  5  4 
70|1.000|0.306|6.6e-09|4.4e-09|1.7e+07| 6.446583e+07  6.140282e+07| 0:0:02| spchol  5  4 
71|1.000|0.297|7.0e-09|3.1e-09|1.4e+07| 6.431142e+07  6.190747e+07| 0:0:02| spchol  5  5 
72|1.000|0.303|8.0e-09|2.2e-09|1.1e+07| 6.417928e+07  6.236297e+07| 0:0:02| spchol  5  5 
73|1.000|0.321|9.0e-09|1.5e-09|8.9e+06| 6.394332e+07  6.280048e+07| 0:0:02| spchol  6  6 
74|1.000|0.323|1.0e-08|9.9e-10|6.9e+06| 6.387491e+07  6.317418e+07| 0:0:02| spchol  7  7 
75|1.000|0.290|1.2e-08|7.1e-10|5.7e+06| 6.395268e+07  6.342957e+07| 0:0:02| spchol  7  7 
76|1.000|0.323|1.5e-08|4.8e-10|4.4e+06| 6.362706e+07  6.367323e+07| 0:0:02| spchol  8  9 
77|1.000|0.244|1.3e-08|3.6e-10|3.9e+06| 6.426974e+07  6.379396e+07| 0:0:02| spchol  9 11 
78|1.000|0.353|2.7e-08|2.3e-10|2.9e+06| 6.430288e+07  6.396999e+07| 0:0:02| spchol 10 10 
79|1.000|0.246|2.6e-08|1.8e-10|2.6e+06| 6.429572e+07  6.404860e+07| 0:0:02| spchol 16 13 
80|1.000|0.357|5.7e-08|1.1e-10|1.9e+06| 6.468491e+07  6.416360e+07| 0:0:02| spchol 22 30 
81|1.000|0.227|1.0e-07|8.8e-11|1.7e+06| 6.490857e+07  6.420714e+07| 0:0:02| spchol 26 23 
82|1.000|0.263|9.8e-08|6.5e-11|1.5e+06| 6.483750e+07  6.424603e+07| 0:0:02| spchol 
  warning: symqmr failed: 0.3 
  switch to LU factor. splu 17 ^24 
83|0.349|0.137|4.0e-07|5.6e-11|1.6e+06| 6.080348e+07  6.423687e+07| 0:0:02| splu 25 ^17 
84|0.004|0.004|6.1e-07|5.6e-11|1.7e+06| 6.035782e+07  6.423702e+07| 0:0:02| splu 14 ^13 
85|0.022|0.021|6.2e-07|5.4e-11|1.8e+06| 6.062591e+07  6.423110e+07| 0:0:02| splu 20 ^ 6 
86|0.001|0.001|6.4e-07|5.4e-11|2.0e+06| 6.049688e+07  6.423219e+07| 0:0:02| splu 28 ^13 
87|0.153|0.003|5.5e-07|5.4e-11|2.3e+06| 6.098440e+07  6.423140e+07| 0:0:02| splu 13 ^16 
88|0.037|0.026|3.5e-06|5.3e-11|2.5e+06| 5.980788e+07  6.422044e+07| 0:0:03| splu 30 ^11 
89|0.066|0.156|3.3e-06|4.4e-11|2.5e+06| 6.005186e+07  6.415447e+07| 0:0:03| splu 29 ^ 6 
90|0.691|0.025|1.1e-06|4.3e-11|3.1e+06| 5.919569e+07  6.414397e+07| 0:0:03| splu 30 ^ 6 
91|0.077|0.036|1.9e-06|4.2e-11|3.4e+06| 6.705201e+07  6.412764e+07| 0:0:03| splu 15  30 
92|0.004|0.004|2.0e-06|4.2e-11|3.7e+06| 6.763467e+07  6.412737e+07| 0:0:03| splu 12 ^12 
93|0.247|0.026|1.5e-06|4.1e-11|4.1e+06| 6.637439e+07  6.411625e+07| 0:0:03| splu 30 ^18 
94|0.004|0.002|1.6e-06|4.0e-11|4.5e+06| 6.677449e+07  6.411400e+07| 0:0:03| splu 12 ^17 
95|0.033|0.013|1.7e-06|4.0e-11|4.9e+06| 6.701622e+07  6.409981e+07| 0:0:03| splu 12 ^ 4 
96|0.003|0.004|1.7e-06|4.0e-11|5.4e+06| 6.698288e+07  6.409491e+07| 0:0:03| splu 30 ^ 4 
97|0.013|0.005|1.7e-06|4.0e-11|5.9e+06| 6.694546e+07  6.408757e+07| 0:0:03| splu 30  13 
98|0.131|0.007|1.4e-06|3.9e-11|6.6e+06| 6.669933e+07  6.408038e+07| 0:0:03| splu 12 ^15 
99|0.009|0.024|1.5e-06|3.8e-11|7.1e+06| 6.737842e+07  6.405382e+07| 0:0:04| splu 15 ^18 
100|0.147|0.142|1.3e-06|3.3e-11|7.3e+06| 6.766474e+07  6.387643e+07| 0:0:04|
  sqlp stop: maximum number of iterations reached
-------------------------------------------------------------------
 number of iterations   = 100
 primal objective value =  6.48375049e+07
 dual   objective value =  6.42460269e+07
 gap := trace(XZ)       = 1.49e+06
 relative gap           = 1.16e-02
 actual relative gap    = 4.58e-03
 rel. primal infeas (scaled problem)   = 9.75e-08
 rel. dual     "        "       "      = 6.45e-11
 rel. primal infeas (unscaled problem) = 0.00e+00
 rel. dual     "        "       "      = 0.00e+00
 norm(X), norm(y), norm(Z) = 5.3e+13, 2.9e+12, 2.9e+12
 norm(A), norm(b), norm(C) = 1.2e+04, 2.2e+05, 1.4e+08
 Total CPU time (secs)  = 3.64  
 CPU time per iteration = 0.04  
 termination code       = -6
 DIMACS: 1.2e-06  0.0e+00  9.1e-11  0.0e+00  4.6e-03  1.2e-02
-------------------------------------------------------------------
 
------------------------------------------------------------
Status: Failed
Optimal value (cvx_optval): NaN
1 Like

As you can see, the solver failed due to hitting max # of iterations. Perhaps a different solver, such as Mosek or SeDuMi, might succeed. Did you look at the input data for the problem instance which failed? The objective values look quite large. maybe your input data became wild. if you are feeding the results from one problem into the next, perhaps the whole process is unstable. I was trying to warn you about this, but maybe I wasn’t explicit enough. When you do hokey things, you may not have a robust procedure. Non-convex solvers are more sophisticated than your own linearizations.

1 Like

I reset my PC and I believe the default solver was employed. Do you know how to change the default solver?

1 Like

cvx_solver , and cvx_save_prefs to save across MATLAB sessions.

I believe you would benefit from carefully reading the entire CVX User’s Guide. Perhaps slow down a bit and get a solid foundation, and things will go better.

Also read Why isn't CVX accepting my model? READ THIS FIRST!

1 Like

Thank you Mark, I will do.

1 Like