# Using the mosek and sedumi to solve the same problem,but the results are diffrent

the sedumi’s status is “solved”,but the mosek shows that it is failed.It is a trajectory optimazation problem.
The code is as follows:

clear all;
close all;

% constants and vehicle parameters
g0 = 9.807; % Earth gravity, m/s^2
g_plan = [0; 0;-3.711]; % Other planet gravity, m/s^2
tv_max = 25; % maximum TVC angle
Isp = 255; % specific impulse, s
m_d = 1500; % drymass, kg
m_f = 500; % fuel mass, kg
m_t = m_f + m_d; % total mass, kg
Ft = 22000; % thrust
rho2 = Ft; % thrust, Newtons
rho1 = 0.15 * Ft; % lowest throttleability, Newtons
% initial and final conditions – dynamics [x y z]
r_0 = [-2000; 1500; 2000]; % position vector, m
v_0 = [50; 70; -75]; % velocity vector, m/s
r_N =[0; 0; 0]; % terminal position, m
v_N =[0; 0; 0]; % terminal velocity, m
% other timing and constraint garbage
t_f = 100; % final time horizon (not necessarily optimal)
dt = 1; % period of calculation
N = 1+(t_f/dt); % calculation steps
a = 1/(Isp*g0); % alpha used in mass calculations
gs = 4; % glides slope constraint

% the discretized problem 4
% maximize the terminal mass
cvx_solver SEDUMI
cvx_begin
variables u(3,N) z(1,N) s(1,N) r(3,N) v(3,N)
minimize(-z(N)) % objective function
subject to % constraints and dynamics
r(:,1) == r_0; % position IC
v(:,1) == v_0; % velocity IC
r(:,N) == r_N; % position TC
v(:,N) == v_N; % velocity TC
z(1) == log(m_t); % mass IC

r(3,:) >= 0;							% plz don't crash into the ground
%u(2,:) >= s.*cos(degtorad(tv_max));		% thrust vector control constraint
%r(1,:) <= r(2,:)/tan(degtorad(gs));		% glide slope
z(:) >= 0;

for  k = 1:N-1
r(:,k+1) == r(:,k) + ((dt/2)*(v(:,k) + v(:,k+1))) +(((dt^2)/12)*(u(:,k+1) - u(:,k)));
v(:,k+1) == v(:,k) + ((dt/2)*(u(:,k) + u(:,k+1))) +(g_plan*dt);
z(1,k+1) == z(1,k) - (((a*dt)/2)*(s(1,k) + s(1,k+1)));
end

for k=1:N
norm(u(:,k)) <= s(1,k);
z_0 = m_t - (a*rho2*dt*(k-1));
m_1 = rho1/z_0;
m_2 = rho2/z_0;
z1 = log(m_t-(a*rho1*dt*(k-1)));
z0 = log(z_0);
z(1,k) >= z0;
z(1,k) <= z1;
s(1,k) <= m_2*(1 - (z(1,k) - z0));
s(1,k) >= m_1*(1 - (z(1,k) - z0) + (((z(1,k) - z0)^2)/2));
end

cvx_end

This is a trajectory optimazation problem.When I want to add a obstacle to the constraints to limit the trajectory,it is always infeasible.Even though I set the size of the obstacle to 0,the result is also infeasible.

Please provide log output for both optimizers.

## Calling SeDuMi 1.3.4: 1906 variables, 992 equality constraints For improved efficiency, SeDuMi is solving the dual problem.

SeDuMi 1.3.4 by AdvOL, 2005-2008 and Jos F. Sturm, 1998-2003.
Alg = 2: xz-corrector, Adaptive Step-Differentiation, theta = 0.250, beta = 0.500
eqs m = 992, order n = 1214, dim = 1908, blocks = 204
nnz(A) = 4072 + 298, nnz(ADA) = 8526, nnz(L) = 10685
Handling 3 + 1 dense columns.
it : by gap delta rate t/tP t/tD* feas cg cg prec
0 : 7.61E+01 0.000
1 : -1.77E+03 2.19E+01 0.000 0.2880 0.9000 0.9000 1.60 1 1 7.8E+00
2 : -3.34E+02 1.20E+01 0.000 0.5465 0.9000 0.9000 4.36 1 1 1.5E+00
3 : -3.48E+01 8.18E+00 0.000 0.6833 0.9000 0.9000 5.57 1 1 3.3E-01
4 : 9.98E+00 5.69E+00 0.000 0.6959 0.9000 0.9000 6.01 1 1 7.9E-02
5 : 8.37E+00 3.79E+00 0.000 0.6660 0.9000 0.9000 4.22 1 1 2.8E-02
6 : 8.19E+00 2.43E+00 0.000 0.6416 0.9000 0.9000 2.42 1 1 1.4E-02
7 : 8.14E+00 1.61E+00 0.000 0.6610 0.9000 0.9000 2.15 1 1 7.2E-03
8 : 8.08E+00 1.06E+00 0.000 0.6599 0.9000 0.9000 2.06 1 1 3.7E-03
9 : 8.03E+00 6.54E-01 0.000 0.6165 0.9000 0.9000 1.87 1 1 1.8E-03
10 : 8.00E+00 4.73E-01 0.000 0.7231 0.9000 0.9000 1.60 1 1 1.2E-03
11 : 7.96E+00 4.00E-01 0.000 0.8458 0.9000 0.9000 0.96 1 1 1.2E-03
12 : 7.68E+00 1.60E-01 0.000 0.4011 0.9064 0.9000 1.19 1 1 4.0E-04
13 : 7.68E+00 3.57E-02 0.000 0.2226 0.9000 0.0000 1.10 1 1 2.0E-04
14 : 7.68E+00 1.15E-08 0.000 0.0000 0.9000 0.0000 1.19 1 1 7.1E-05
15 : 7.60E+00 3.98E-09 0.220 0.3461 0.9179 0.9000 1.19 1 1 2.3E-05
16 : 7.58E+00 1.96E-09 0.186 0.4924 0.9528 0.9000 1.16 1 1 1.1E-05
17 : 7.57E+00 1.38E-09 0.391 0.7030 0.9268 0.9000 0.96 1 2 7.8E-06
18 : 7.56E+00 9.89E-10 0.243 0.7187 0.9000 0.9078 0.64 1 2 6.0E-06
19 : 7.55E+00 6.63E-10 0.076 0.6702 0.9000 0.9197 0.34 2 2 4.6E-06
20 : 7.55E+00 3.72E-10 0.000 0.5614 0.9000 0.9088 0.13 2 2 3.4E-06
21 : 7.54E+00 1.43E-10 0.000 0.3853 0.9193 0.9000 -0.23 2 2 3.0E-06
22 : 7.54E+00 6.15E-11 0.000 0.4288 0.9339 0.9000 -0.62 2 2 2.7E-06
23 : 7.51E+00 3.70E-11 0.000 0.6015 0.9000 0.8863 -0.39 2 2 2.2E-06
24 : 7.48E+00 2.04E-11 0.000 0.5524 0.9000 0.5976 0.19 2 2 1.4E-06
25 : 7.43E+00 5.88E-12 0.000 0.2876 0.9000 0.9000 0.67 2 2 4.4E-07
26 : 7.42E+00 2.52E-12 0.000 0.4282 0.9116 0.9000 0.98 2 2 1.8E-07
27 : 7.41E+00 1.34E-12 0.000 0.5332 0.9282 0.9000 1.01 3 3 8.6E-08
28 : 7.41E+00 7.42E-13 0.000 0.5527 0.9252 0.9000 1.02 3 3 4.4E-08
29 : 7.41E+00 3.63E-13 0.000 0.4901 0.8053 0.9000 1.02 3 3 2.1E-08
30 : 7.41E+00 1.53E-13 0.000 0.4223 0.4874 0.9000 1.01 3 3 9.8E-09

iter seconds digits cx by
30 2.2 Inf 7.4072441793e+00 7.4074807445e+00
|Ax-b| = 2.0e-08, [Ay-c]_+ = 5.8E-05, |x|= 1.4e+01, |y|= 1.7e+04

## Detailed timing (sec) Pre IPM Post 2.100E-01 1.102E+00 4.399E-02 Max-norms: ||b||=1, ||c|| = 2.356113e+04, Cholesky |add|=0, |skip| = 0, ||L.L|| = 9083.67.

Status: Solved
Optimal value (cvx_optval): -7.40748

## Calling Mosek 9.1.9: 1906 variables, 992 equality constraints For improved efficiency, Mosek is solving the dual problem.

MOSEK Version 9.1.9 (Build date: 2019-11-21 11:34:40)
Platform: Windows/64-X86

Problem
Name :
Objective sense : min
Type : CONIC (conic optimization problem)
Constraints : 992
Cones : 202
Scalar variables : 1906
Matrix variables : 0
Integer variables : 0

Optimizer started.
Presolve started.
Linear dependency checker started.
Linear dependency checker terminated.
Eliminator started.
Freed constraints in eliminator : 488
Eliminator terminated.
Eliminator started.
Freed constraints in eliminator : 0
Eliminator terminated.
Eliminator - tries : 2 time : 0.00
Lin. dep. - tries : 1 time : 0.01
Lin. dep. - number : 0
Presolve terminated. Time: 0.09
Problem
Name :
Objective sense : min
Type : CONIC (conic optimization problem)
Constraints : 992
Cones : 202
Scalar variables : 1906
Matrix variables : 0
Integer variables : 0

Optimizer - solved problem : the primal
Optimizer - Constraints : 504
Optimizer - Cones : 202
Optimizer - Scalar variables : 1311 conic : 809
Optimizer - Semi-definite variables: 0 scalarized : 0
Factor - setup time : 0.01 dense det. time : 0.00
Factor - ML order time : 0.00 GP order time : 0.00
Factor - nonzeros before factor : 1.35e+04 after factor : 2.67e+04
Factor - dense dim. : 2 flops : 2.49e+06
ITE PFEAS DFEAS GFEAS PRSTATUS POBJ DOBJ MU TIME
0 1.7e+00 2.4e+04 1.0e+03 0.00e+00 -1.032777860e+03 0.000000000e+00 1.0e+00 0.20
1 3.2e-01 4.5e+03 4.5e+02 -1.00e+00 -1.036959720e+03 -6.387957779e-04 1.9e-01 0.48
2 9.7e-02 1.3e+03 2.5e+02 -1.00e+00 -1.048924906e+03 -3.882052241e-03 5.7e-02 0.48
3 7.8e-02 1.1e+03 2.2e+02 -9.95e-01 -1.050416320e+03 1.397981637e-02 4.6e-02 0.50
4 4.8e-02 6.6e+02 1.7e+02 -9.79e-01 -1.036644431e+03 1.872036706e-01 2.8e-02 0.50
5 3.5e-02 4.8e+02 1.3e+02 -7.90e-01 -9.505220878e+02 8.076225259e-01 2.0e-02 0.52
6 1.1e-02 1.5e+02 4.9e+01 -6.10e-01 -6.446605300e+02 3.016550369e+00 6.3e-03 0.53
7 1.2e-03 1.6e+01 3.3e+00 9.02e-02 -1.170991256e+02 6.363453013e+00 6.9e-04 0.55
8 4.6e-04 6.4e+00 7.6e-01 1.00e+00 -3.985720016e+01 6.790133635e+00 2.7e-04 0.56
9 3.5e-04 4.8e+00 5.0e-01 1.02e+00 -2.826941834e+01 6.895800953e+00 2.0e-04 0.58
10 1.4e-04 1.9e+00 1.1e-01 1.03e+00 -6.220624394e+00 7.058448164e+00 8.0e-05 0.59
11 7.9e-05 1.1e+00 5.0e-02 1.01e+00 -5.406627684e-01 7.113581075e+00 4.6e-05 0.61
12 1.1e-05 1.6e-01 2.6e-03 1.02e+00 6.082904906e+00 7.166758350e+00 6.7e-06 0.63
13 6.6e-07 9.1e-03 3.4e-05 1.00e+00 7.110830786e+00 7.172588520e+00 3.9e-07 0.64
14 1.0e-07 1.4e-03 2.0e-06 1.00e+00 7.196521245e+00 7.205995913e+00 6.0e-08 0.66
15 6.4e-08 5.9e-04 5.5e-07 1.00e+00 7.324410430e+00 7.328370831e+00 2.5e-08 0.67
16 6.4e-08 5.9e-04 5.5e-07 1.00e+00 7.324410430e+00 7.328370831e+00 2.5e-08 0.69
17 6.3e-08 5.9e-04 5.5e-07 1.00e+00 7.324438820e+00 7.328385199e+00 2.5e-08 0.70
18 6.3e-08 5.9e-04 5.5e-07 1.00e+00 7.324438820e+00 7.328385199e+00 2.5e-08 0.72
Optimizer terminated. Time: 0.86

Interior-point solution summary
Problem status : UNKNOWN
Solution status : UNKNOWN
Primal. obj: 7.3244388202e+00 nrm: 1e+00 Viol. con: 3e-04 var: 1e-04 cones: 0e+00
Dual. obj: 7.3283851993e+00 nrm: 2e+03 Viol. con: 0e+00 var: 8e-02 cones: 0e+00
Optimizer summary
Optimizer - time: 0.86
Interior-point - iterations : 19 time: 0.73
Basis identification - time: 0.00
Primal - iterations : 0 time: 0.00
Dual - iterations : 0 time: 0.00
Clean primal - iterations : 0 time: 0.00
Clean dual - iterations : 0 time: 0.00
Simplex - time: 0.00
Primal simplex - iterations : 0 time: 0.00
Dual simplex - iterations : 0 time: 0.00
Mixed integer - relaxations: 0 time: 0.00

Status: Failed
Optimal value (cvx_optval): NaN

I cannot say from the log output why Mosek cannot solve your problem. It might be if you use a newer version of Mosek v9 that you can solve the problem.

You are also welcome to dump the problem to disk using the instructions at

email it to support@mosek.com for an inspection.

Thank you for taking the time to read it.I will try to email it to support@mosek.com for an inspection.

1 Like