i’m working on an UAV trajedy optimization problem,and my code is like following
cvx_begin
%two-dimension location
variable Q(2,100)
%objective
expressions R(100)
for i = 1:100
R(i) = pow_pos(norm(Q(:,i)-W(:,i),2),2);
end
minimize sum(R)
subject to
%initial location constraint
Q(:,1) == [0;0];
Q(:,100) == [3000;0];
for i = 2:100
norm(Q(:,i)-Q(:,i-1),2) <= 40;
end
cvx_end
it doesn’t work,the status is ‘‘infeasiable’’,but if I delete the initial location constraint ,it works
cvx_begin
%two-dimension location
variable Q(2,100)
%objective
expressions R(100)
for i = 1:100
R(i) = pow_pos(norm(Q(:,i)-W(:,i),2),2);
end
minimize sum(R)
subject to
%initial location constraint
for i = 2:100
norm(Q(:,i)-Q(:,i-1),2) <= 40;
end
cvx_end
so how can i solve it?I would be grateful if you could answer my questions. Thanks, everyone.
thank you for your help!this is my original problem formula ,and I simplify it to this,
cvx_begin
%two-dimension location
variable Q(2,100)
%objective
expressions R(100)
for i = 1:100
R(i) = pow_pos(norm(Q(:,i)-W(:,i),2),2);
end
minimize sum(R)
subject to
%initial location constraint
Q(:,1) == [0;0];
Q(:,100) == [3000;0];
%distance constraint
for i = 2:100
norm(Q(:,i)-Q(:,i-1),2) <= 40;
end
cvx_end
this seems to be convex,but when i run it, the output is Inf and Q is NaN,is that any question with my
object function? I’d really appreciate it if you could help me
yes it is, but i’m very confusing because norm is convex to Q, and square is convex,so the problem seems to be convex, and it should get a solution,and the site you provided is a little bit abstract to me
Apply item 2 in the link, which is the first one applicable to CVX. Remove the objective function and see whether it i feasible. You can easily see anlaytically it is feasible. But I ran it in CVX nevertheless, using Mosek as solver.
cvx_begin
%two-dimension location
variable Q(2,100)
%initial location constraint
Q(:,1) == [0;0];
Q(:,100) == [3000;0];
%distance constraint
for i = 2:100
norm(Q(:,i)-Q(:,i-1),2) <= 40;
end
cvx_end
it is reported feasible. I can 't reproduce your problem with the objective function, because you have not provided W. Nor have you shown the solver output. Perhaps W is badly scaled numerically, and has some non-zero elements which are not within a small number of orders of magnitude.of one, which if so, can confuse the solver.
it is the bad scaling in W causing the difficulty, which is exacerbated by the squaring going on in the objective function.
Divide W and the RHS of all constraints by 1000. Which would change meters to km. Then the problem is easily solved by SDPT3 and Mosek, with cvx_optval = 7513.83. You need to multiply this cvx_optval by 1000^2 to put it back in original units. And multiply the optimal Q by 1000 to put it back in the original units.