Should I scale my variables?Status: Infeasible Optimal value (cvx_optval): +Inf

I want to solve this similar problem (redo the paper)


also include the constraints:
image
where
image

And my code is divided into 2 parts. One is the parameter define and the second is the CVX programmer. I used the mosek solver.
The code is:
parameter part:
%%%%%%%%%%%%%%%%%%%%%%UAV attributes%%%%%%%%%%%%%%%%%%%%%%%
DELTA = 0.012; %profile drag coefficient
rou = 1.225; %air density
s = 0.05;%rotor solidity
A = 0.503;% rotor disc area
OMG = 300; %blade angular velocity
R = 0.4;% rotor radius
kamma = 0.1;%incremental correction factor
W = 20; %aircraft weight in Newton
d0 = 0.6;%Fuselag drag ratio
Utip = 120;%Tip speed of rotor blade
v_0 = 4.03;% mean rotor induced velocity in hover
P0 = DELTA/8srouAOMG^3R^3;
Pi = (1+kamma)W^1.5/ (sqrt(2rou
A));
Pc = 5;
%%scenario
Length = 1200;
start=[Length/2,Length/2];
number = 10;
nodeNum = number;
M = 1000;
%ground nodes cordinates
x = [847 1157 888 1140 600 332 41 381 35 117];
y = [226 535 588 851 1034 919 906 776 458 224];
w_n = zeros(10,2);
w_n(:,1) = x’;
w_n(:,2) = y’;
%initial input
q_m_0 = zeros(M+1,2);
q_m_0(1,:slight_smile: = start;
q_m_0(M+1,:slight_smile: = start;
%%path discretization and initial trajectory
a = zeros(1,number+1);
b = zeros(1,number+1);
for i = 1:(number+1) %%if M is changed ,these should be all changed.
if i==1
a(i) = (w_n(i,2)-start(2))/(w_n(i,1)-start(1));
b(i) = (w_n(i,1)*start(2)-w_n(i,2)*start(1))/(w_n(i,1)-start(1));
x_temp = start(1):(w_n(i,1)-start(1)+1)/91:w_n(i,1);
y_temp = a(i)*x_temp+b(i);
q_m_0(2:90,1)=x_temp(2:90);
q_m_0(2:90,2)=y_temp(2:90);
q_m_0(91,1)=w_n(1,1);
q_m_0(91,2)=w_n(1,2);
else
if i==(number+1)
a(i) = (w_n(i-1,2)-start(2))/(w_n(i-1,1)-start(1));
b(i) = (w_n(i-1,1)start(2)-w_n(i-1,2)start(1))/(w_n(i-1,1)-start(1));
if start(1)>w_n(i-1,1)
x_temp = w_n(i-1,1):(start(1)-w_n(i-1,1)+1)/101:start(1);
y_temp = a(i)x_temp+b(i);
else
x_temp = start(1):(w_n(i-1,1)-start(1)+1)/101:w_n(i-1,1);
x_temp = fliplr(x_temp);
y_temp = a(i)x_temp+b(i);
end
q_m_0(91+90
(i-2)+1:91+90
(i-2)+99,1)=x_temp(2:100);
q_m_0(91+90
(i-2)+1:91+90
(i-2)+99,2)=y_temp(2:100);

    else
    a(i) = (w_n(i,2)-w_n(i-1,2))/(w_n(i,1)-w_n(i-1,1));
    b(i) = (w_n(i,1)*w_n(i-1,2)-w_n(i,2)*w_n(i-1,1))/(w_n(i,1)-w_n(i-1,1)); 
       if w_n(i,1)>w_n(i-1,1)
       x_temp = w_n(i-1,1):(w_n(i,1)-w_n(i-1,1)+1)/91:w_n(i,1);
       y_temp = a(i)*x_temp+b(i);
       else
       x_temp = w_n(i,1):(w_n(i-1,1)-w_n(i,1)+1)/91:w_n(i-1,1);
       x_temp = fliplr(x_temp);
       y_temp = a(i)*x_temp+b(i);    
       end
    q_m_0(91+90*(i-2)+1:91+90*(i-2)+90-1,1)=x_temp(2:90);
    q_m_0(91+90*(i-2)+1:91+90*(i-2)+90-1,2)=y_temp(2:90);
    q_m_0(91+90*(i-2)+90,1)=w_n(i,1);
    q_m_0(91+90*(i-2)+90,2)=w_n(i,2);
    end
end  

end
%% cal distance qm+1 - qm
DIS = zeros(M,1);
for k=1:M
DIS(k) = cal(q_m_0(k,:),q_m_0(k+1,:));
end
max_DIS = max(DIS);
%% Tm
SNR_db = 52.5; %%db
SNR = 10^5.25;
B = 10^6; %bandwidth
H = 100;%flying altitude 100m
Q = 1010^6;% required throughput
T_temp = zeros(M,1);
arfa = 2.3/2;
for i=1:number
for j=1:M
distance = cal(q_m_0(j,:),w_n(i,:));
T_temp(j) = B
log2(1+(SNR/(H^2+distance^2)^arfa));
end
sum_T = sum(T_temp);
T_m(i) = Qnumber/sum_T;
end
Tm_temp = max(T_m);
tao_mn_temp = Tm_temp/number;
Tm_0 = Tm_temp
ones(M,1);
tao_mn_0 = tao_mn_tempones(M,number);
%%ym_0, Amn_0
y_m_0 = zeros(M,1);
Amn_0 = zeros(M,number);
for i=1:M
y_m_0(i) = sqrt(sqrt(Tm_0(i)^4+0.25
(DIS(i)/v_0)^4)-0.5*(DIS(i)/v_0)^2);
end
for i=1:number
for j=1:M
distance = cal(q_m_0(j,:),w_n(i,:));
Amn_0(j,i) = tao_mn_0(j,i)Blog2(1+(SNR/(H^2+distance^2)^arfa));
end
end

%% save
filename = ‘data.mat’;
save(filename,“DELTA”,“rou”,“s”,“A”,“OMG”,“R”,“kamma”,“W”,“d0”,“Utip”,“v_0”,“number”,“M”,“start”,“w_n”,“q_m_0”,“DIS”,“SNR”,“B”,“H”,“Q”,“arfa”,“Tm_0”,“tao_mn_0”,“Amn_0”,“y_m_0”,“Pc”,“Pi”,“P0”)

CVX part:
load(“data.mat”);
Qn = Qones(1,number);
cvx_clear
cvx_begin
cvx_precision high
cvx_solver mosek
variables qm(M+1,2) Tm(M,1) tao_mn(M,number) ym(M,1) Amn(M,number) temp1(M,1)
expression Rmn(M,number)
expression beta_mn(M,number)
expression Dm(M,1)
for i=1:M
Dm(i) = norm(qm(i+1,:)-qm(i,:));
end
for i=1:number
for j=1:M
Rmn(j,i) = log(1+SNR/(H^2+(cal(q_m_0(j,:),w_n(i,:)))^2)^arfa)/log(2);
beta_mn(j,i) = SNR
arfa/((H^2+(norm(q_m_0(j,:)-w_n(i,:)))^2)((H^2+(norm(q_m_0(j,:)-w_n(i,:)))^2)^arfa+SNR)log(2));
end
end
for i=1:M
geo_mean([temp1(i),Tm(i),Tm(i)]) >= norm(qm(i+1,:)-qm(i,:));
end
expression ratio1(M,1)
for i=1:M
ratio1(i) = quad_over_lin((qm(i+1,:)-qm(i,:)),Tm(i));
end
expression ratio2(M,number)
for i=1:M
for j=1:number
ratio2(i,j) = quad_over_lin(Amn(i,j),tao_mn(i,j));
end
end
expression ratio3(M,1)
for i=1:M
ratio3(i) = square_pos(quad_over_lin(Tm(i),ym(i)));
end
minimize(P0
sum(Tm+3
ratio1/(Utip^2))+Pisum(ym)+0.5d0rousAsum(temp1)+Pcsum(sum(tao_mn)))
subject to
sum(pow_pos(Amn_0,2)+2
Amn_0.(Amn-Amn_0)) >= Qn;
for i=1:M
ratio3(i) <= pow_pos(y_m_0(i),2)+2
y_m_0(i).(ym(i)-y_m_0(i))-square_pos(norm(q_m_0(i+1,:)-q_m_0(i,:))/(v_0))+(2/square(v_0))(q_m_0(i+1,:)-q_m_0(i,:))(qm(i+1,:)-qm(i,:))’;
end
for i=1:number
for j=1:M
ratio2(i)/B <= Rmn(j,i)-beta_mn(j,i)
(square_pos(norm(qm(j,:)-w_n(i,:)))-square_pos(norm(q_m_0(j,:)-w_n(i,:))));
end
end
ym >= 0;
for i=1:M
Dm(i) <= min(30,Tm(i)*30);
end
qm(1,:slight_smile: == q_m_0(1,:);
qm(M+1,:slight_smile: == q_m_0(M+1,:);
sum(tao_mn,2) <= Tm;
tao_mn >= 0;
Tm >= 0;
cvx_end

the output is:
Calling Mosek 9.1.9: 165010 variables, 79012 equality constraints

MOSEK Version 9.1.9 (Build date: 2019-11-21 11:34:40)
Copyright © MOSEK ApS, Denmark. WWW: mosek.com
Platform: Windows/64-X86

MOSEK warning 52: A numerically large lower bound value 4.4e+11 is specified for constraint ‘’ (15000).
MOSEK warning 53: A numerically large upper bound value 4.4e+11 is specified for constraint ‘’ (15000).
MOSEK warning 52: A numerically large lower bound value 6.0e+11 is specified for constraint ‘’ (15001).
MOSEK warning 53: A numerically large upper bound value 6.0e+11 is specified for constraint ‘’ (15001).
MOSEK warning 52: A numerically large lower bound value 7.0e+11 is specified for constraint ‘’ (15002).
MOSEK warning 53: A numerically large upper bound value 7.0e+11 is specified for constraint ‘’ (15002).
MOSEK warning 52: A numerically large lower bound value 4.4e+11 is specified for constraint ‘’ (15003).
MOSEK warning 53: A numerically large upper bound value 4.4e+11 is specified for constraint ‘’ (15003).
MOSEK warning 52: A numerically large lower bound value 5.1e+11 is specified for constraint ‘’ (15004).
MOSEK warning 53: A numerically large upper bound value 5.1e+11 is specified for constraint ‘’ (15004).
MOSEK warning 52: A numerically large lower bound value 8.6e+11 is specified for constraint ‘’ (15005).
MOSEK warning 53: A numerically large upper bound value 8.6e+11 is specified for constraint ‘’ (15005).
MOSEK warning 52: A numerically large lower bound value 6.1e+11 is specified for constraint ‘’ (15006).
MOSEK warning 53: A numerically large upper bound value 6.1e+11 is specified for constraint ‘’ (15006).
MOSEK warning 52: A numerically large lower bound value 6.3e+11 is specified for constraint ‘’ (15007).
MOSEK warning 53: A numerically large upper bound value 6.3e+11 is specified for constraint ‘’ (15007).
MOSEK warning 52: A numerically large lower bound value 6.1e+11 is specified for constraint ‘’ (15008).
MOSEK warning 53: A numerically large upper bound value 6.1e+11 is specified for constraint ‘’ (15008).
MOSEK warning 52: A numerically large lower bound value 5.6e+11 is specified for constraint ‘’ (15009).
MOSEK warning 53: A numerically large upper bound value 5.6e+11 is specified for constraint ‘’ (15009).
Problem
Name :
Objective sense : min
Type : CONIC (conic optimization problem)
Constraints : 79012
Cones : 38000
Scalar variables : 165010
Matrix variables : 0
Integer variables : 0

Optimizer started.
Presolve started.
Linear dependency checker started.
Linear dependency checker terminated.
Eliminator started.
Freed constraints in eliminator : 25834
Eliminator terminated.
Eliminator started.
Freed constraints in eliminator : 0
Eliminator terminated.
Eliminator - tries : 2 time : 0.00
Lin. dep. - tries : 1 time : 0.03
Lin. dep. - number : 0
Presolve terminated. Time: 0.16
Problem
Name :
Objective sense : min
Type : CONIC (conic optimization problem)
Constraints : 79012
Cones : 38000
Scalar variables : 165010
Matrix variables : 0
Integer variables : 0

Optimizer - threads : 14
Optimizer - solved problem : the dual
Optimizer - Constraints : 49174
Optimizer - Cones : 38000
Optimizer - Scalar variables : 139166 conic : 114990
Optimizer - Semi-definite variables: 0 scalarized : 0
Factor - setup time : 0.08 dense det. time : 0.00
Factor - ML order time : 0.00 GP order time : 0.00
Factor - nonzeros before factor : 2.03e+05 after factor : 3.81e+05
Factor - dense dim. : 30 flops : 8.74e+06
ITE PFEAS DFEAS GFEAS PRSTATUS POBJ DOBJ MU TIME
0 8.7e+07 1.2e+02 1.1e+07 0.00e+00 9.242625000e+00 -1.106878650e+07 1.0e+00 0.28
1 5.0e+07 7.1e+01 8.4e+06 -1.00e+00 1.061673977e+05 -1.096248291e+07 5.7e-01 0.34
2 3.7e+07 5.3e+01 7.2e+06 -1.00e+00 2.119426723e+05 -1.085644535e+07 4.2e-01 0.38
3 1.3e+07 1.8e+01 4.2e+06 -1.00e+00 1.030082382e+06 -1.003712089e+07 1.5e-01 0.41
4 6.7e+06 9.6e+00 3.1e+06 -1.00e+00 2.348298477e+06 -8.717609500e+06 7.7e-02 0.47
5 3.5e+06 5.1e+00 2.2e+06 -1.00e+00 5.051236995e+06 -6.012432788e+06 4.1e-02 0.50
6 1.4e+06 2.0e+00 1.4e+06 -9.99e-01 1.556692048e+07 4.511647933e+06 1.6e-02 0.53
7 5.2e+05 7.5e-01 8.6e+05 -9.97e-01 4.636580892e+07 3.533392686e+07 6.0e-03 0.58
8 2.2e+05 3.1e-01 5.5e+05 -9.93e-01 1.125353280e+08 1.015613564e+08 2.5e-03 0.61
9 1.5e+05 2.2e-01 4.6e+05 -9.81e-01 1.533999689e+08 1.424763681e+08 1.8e-03 0.66
10 5.7e+04 8.2e-02 2.7e+05 -9.71e-01 3.427658383e+08 3.321304533e+08 6.6e-04 0.69
11 4.1e+04 5.9e-02 2.3e+05 -9.14e-01 3.948748518e+08 3.844105506e+08 4.7e-04 0.72
12 2.2e+04 3.2e-02 1.6e+05 -8.88e-01 5.105261472e+08 5.005002280e+08 2.5e-04 0.75
13 1.5e+04 2.1e-02 1.2e+05 -8.27e-01 5.851093017e+08 5.754342795e+08 1.7e-04 0.80
14 6.4e+03 9.2e-03 7.3e+04 -7.82e-01 7.528527788e+08 7.441887879e+08 7.4e-05 0.83
15 3.9e+03 5.6e-03 5.1e+04 -6.51e-01 8.171682328e+08 8.092490088e+08 4.5e-05 0.86
16 1.9e+03 2.7e-03 2.8e+04 -5.49e-01 8.649203147e+08 8.584186783e+08 2.1e-05 0.89
17 8.0e+02 1.2e-03 1.3e+04 -3.31e-01 8.081733771e+08 8.035453525e+08 9.3e-06 0.94
18 6.5e+02 9.4e-04 1.0e+04 -1.56e-02 7.628800862e+08 7.586885004e+08 7.5e-06 0.97
19 2.4e+02 3.5e-04 3.4e+03 5.78e-02 5.584622981e+08 5.561739553e+08 2.8e-06 1.02
20 1.4e+02 2.0e-04 1.7e+03 4.10e-01 4.508238140e+08 4.492920514e+08 1.6e-06 1.05
21 8.7e+01 1.3e-04 9.9e+02 4.39e-01 3.862606554e+08 3.851158127e+08 1.0e-06 1.08
22 5.3e+01 7.6e-05 6.3e+02 2.93e-01 3.840698953e+08 3.831151283e+08 6.1e-07 1.13
23 3.6e+01 5.2e-05 5.7e+02 -3.48e-01 5.513132641e+08 5.502142424e+08 4.2e-07 1.16
24 2.4e+01 3.5e-05 4.6e+02 -6.10e-01 7.246259226e+08 7.235251172e+08 2.8e-07 1.20
25 1.1e+01 1.6e-05 3.1e+02 -7.61e-01 1.308292365e+09 1.307251055e+09 1.3e-07 1.23
26 6.8e+00 9.8e-06 2.4e+02 -9.09e-01 1.940084604e+09 1.939108064e+09 7.9e-08 1.27
27 2.0e+00 2.9e-06 1.2e+02 -9.52e-01 5.746784648e+09 5.746062490e+09 2.3e-08 1.31
28 7.4e-01 1.1e-06 7.5e+01 -9.93e-01 1.454882874e+10 1.454854395e+10 8.5e-09 1.34
29 3.9e-01 9.3e-07 5.5e+01 -9.99e-01 2.773902549e+10 2.773931386e+10 4.5e-09 1.39
30 2.3e-01 5.5e-07 4.3e+01 -1.00e+00 4.665282908e+10 4.665396385e+10 2.7e-09 1.48
31 7.1e-02 1.7e-07 2.4e+01 -1.00e+00 1.512005839e+11 1.512064439e+11 8.2e-10 1.59
32 2.1e-02 4.8e-08 1.3e+01 -1.00e+00 5.136659914e+11 5.136884179e+11 2.4e-10 1.70
33 8.2e-03 1.9e-08 8.2e+00 -1.00e+00 1.399652525e+12 1.399713139e+12 9.4e-11 1.81
34 3.2e-03 8.0e-09 5.2e+00 -1.00e+00 3.342111787e+12 3.342268694e+12 3.7e-11 1.92
35 1.2e-03 3.5e-09 3.2e+00 -1.00e+00 9.515369111e+12 9.515785436e+12 1.4e-11 2.02
36 8.1e-04 1.8e-09 2.6e+00 -1.00e+00 1.431416742e+13 1.431480939e+13 9.3e-12 2.14
37 5.2e-04 1.4e-09 2.1e+00 -1.00e+00 2.211182304e+13 2.211283400e+13 6.0e-12 2.25
38 1.4e-04 2.0e-10 1.1e+00 -1.00e+00 8.148813606e+13 8.149197376e+13 1.6e-12 2.36
Optimizer terminated. Time: 2.41

Interior-point solution summary
Problem status : PRIMAL_INFEASIBLE
Solution status : PRIMAL_INFEASIBLE_CER
Dual. obj: 1.5674379481e+03 nrm: 2e+05 Viol. con: 0e+00 var: 2e-11 cones: 8e-13
Optimizer summary
Optimizer - time: 2.41
Interior-point - iterations : 38 time: 2.41
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: Infeasible
Optimal value (cvx_optval): +Inf

About the mosek warning, should I scale my variables firstly or should I reduce the for loop?

1 Like

Never use cvx_precision high with Mosek. And you shouldn’t use it with any other solver either. Stick with the default.

Re-scale the variables as best you can (all non-zero input values to be within a small number of orders of magnitude of one), certainly well enough to make the Mosek warnings go away.

Then try running it again. If it is still reported by CVX as infeasible (CVX accounts for whether it provided the dual problem to the solver), follow the advice (except for section 1) in https://yalmip.github.io/debugginginfeasible .

Thank you Mark. For the precision I will keep with default. For re-scaling variables, the simplest way is to divide all the inputs by an equal constant so that the range of variation of the inputs is reduced? But how about one is 10 the other one is 10^6, which means the difference is large? Sorry for that, I am a starter in data processing.
Also thanks for your share of the link~

Different scaling can be applied to different variables, provided you make corresponding adjustments in your formulation.

10^6 is kind of a big number, although maybe not large enough to trigger a Mosek warning. If you divide 10 and 10^6 by 10^3, you get 10^(-2 ) and 10^3, which is fairly balanced. B = 10^6 is crying out for re-scaling.

BTW, without comment on the paper you are using, many papers are riddled with badly scaled input data, even for the solved examples; and special tricks or kludges might have been required to get any solution. The problems might not all have even been solved to optimality, or even primal feasibility, even if no indication of that is given in the paper. Some authors hide the shenanigans; others aren’t even aware, and the referees and editors are none the wiser.

Thanks for your reply. I got it and I will try scaling first step by step.

Hi, Mark I have rescaled my inputs and the result is still infeasible. Now I am following the link you shared. What is the meaning of getting rid of objective function when debugging infeasible and unbounded? Does it mean I should just minimize the multiple variables instead of objective function?

Currently I just remove the objective and click run the cvx programme

Yes, remove the objective function (minimize statement). That eliminates the possibility of bad scaling of the objective function coupling into the constraints and causing numerical difficulties.

Thank you Mark! I think the previous result was infeasible is because the variable qm is unbounded and I add the constraints of qm. Then, I used 2 different solvers to test. The first one is mosek, the result is still infeasible and the second is Gurobi, the status is Inaccurate/Solved. So, does it mean that I should use the gurobi solver and add my objective function back?

It probably means your formulation is still not wonderful. You should work on improving it.

So my next work should be to improve my constraints and keep removing my minimum statement until the status is accurate in gurobi solver?

I don’t have the magic formula to tell you.

You certainly want to get to the point that the model is well-behaved and solved, with or without an objective function. Putting in an objective function related to constraint satisfaction, such as minimizing some function of slacks, might be useful, as part of the diagnostic process.

Yes, thank you mark, your advice is very helpful. I will try minimize the slacks. I mean I will try to simplify my problem firstly.

I also learn this paper and redo it. My QQ is 635620919,can I communicate with you about some question. Thank you.