Not able to solve the Objective Function for MPC #1230
Replies: 9 comments 26 replies
-
Adding that term to the objective makes the problem brutaly much harder, as it leads to a nonconvex problem. Not only is that a massive issue, the code should not even work, as you use the SOCP-represented norm operator in this nonconvex way, so it should simply yield an error message. I cannot test that though as you code does not run (and is completely broken as you haven't placed it in a code block but simply pasted as text) but I guess you haven't checked that it actually solves the problem (you are not looking at any diagnostics in the code) but then kept running the code anyway thus crashing Had you used a 1-norm or inf-norm, the term would be accepted, and lead to a MILP-representation |
Beta Was this translation helpful? Give feedback.
-
As far the literature regarding the flight formation using MPC is available I am seeing, I am finding the only possible way was to modify the objective function. Since I am new to the forum I am not very aware of the code cell. `clc B=[0 0 0 x02=[-50, 0,0, 0 0 0]'/1; x03=[-30,0,0, 0 0 0]'/1; xd1=[-30,-20,0,0,0,0]'/1; xd2=[30,-25,0,0,0,0]'/1; xd3=[0,32,0,0,0,0]'/1; %% MPC Parameters nx = 6; % Number of states % MPC data %% x_m(:,1)=x01; for j=1:500 j; % U = sdpvar (3, 1) ; |
Beta Was this translation helpful? Give feedback.
-
< clc B=[0 0 0 x02=[-50, 0,0, 0 0 0]'/1; x03=[-30,0,0, 0 0 0]'/1; xd1=[-30,-20,0,0,0,0]'/1; xd2=[30,-25,0,0,0,0]'/1; xd3=[0,32,0,0,0,0]'/1; %% MPC Parameters nx = 6; % Number of states % MPC data for k = 1:N |
Beta Was this translation helpful? Give feedback.
-
`clc B=[0 0 0 x02=[-50, 0,0, 0 0 0]'/1; x03=[-30,0,0, 0 0 0]'/1; xd1=[-30,-20,0,0,0,0]'/1; xd2=[30,-25,0,0,0,0]'/1; xd3=[0,32,0,0,0,0]'/1; %% MPC Parameters nx = 6; % Number of states % MPC data for k = 1:N |
Beta Was this translation helpful? Give feedback.
-
The moment I add, abs or inf norm. The optimizer is not giving any output. The control U is coming out as NAN |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
@johanlofberg sir, is it possible if I mail you the code. |
Beta Was this translation helpful? Give feedback.
-
This is working code. |
Beta Was this translation helpful? Give feedback.
-
Sir, my System is The changes I made from the original % MPC data The other changes were my own dynamics matrices.
|
Beta Was this translation helpful? Give feedback.
-
I am working on a problem of satellite formation. I am able to generate profile using YALMIP and Gurobi by minimizing the following function.
objective = objective+norm(x-xd1)+ 0norm(Qx,1) + 1norm(Ru{k},1);
where xd are the final reference states.
but let us suppose i want to make keep a certain distance between the satellite and the reference pints, lets say 10 meters, the code is not giving any output.
objective = objective+abs(norm(x-xd1)-10)+ 0norm(Qx,1) + 1norm(Ru{k},1);
full code
clc
clear
n0=0.00115691;
A=[0 0 0 1 0 0
0 0 0 0 1 0
0 0 0 0 0 1
3n0^2 0 0 0 2n0 0
0 0 0 -2*n0 0 0
0 0 -(n0)^2 0 0 0];
B=[0 0 0
0 0 0
0 0 0
1 0 0
0 1 0
0 0 1]/1000;
C=eye(6);
D=0;
Sys1=ss(A,B,C,D);
Dis_mod=c2d(Sys1,0.1);
Ad=Dis_mod.A;
Bd=Dis_mod.B;
Cd=Dis_mod.C;
Dd=Dis_mod.D;
rank(ctrb(Ad,Bd));
%%
x01=[-70, 0,0, 0 0 0]'/1;
x02=[-50, 0,0, 0 0 0]'/1;
x03=[-30,0,0, 0 0 0]'/1;
xd1=[-30,-20,0,0,0,0]'/1;
xd2=[30,-25,0,0,0,0]'/1;
xd3=[0,32,0,0,0,0]'/1;
%% MPC Parameters
nx = 6; % Number of states
nu = 3; % Number of inputs
% MPC data
Q = eye(6);
R = 1;
N = 2;
%%
x_m(:,1)=x01;
for j=1:500
x = x_m(:,j);
u = sdpvar(repmat(nu,1,N),repmat(1,1,N));
constraints = [];
objective = 0;
for k = 1:N
x = Adx + Bdu{k};
objective = objective+norm(x-xd1)+ 0norm(Qx,1) + 1norm(Ru{k},1);
constraints = [constraints, -100 <= u{k}<= 100];
end
%opts=sdpsettings('solver','gurobi','OutputFlag',0);
%opts = sdpsettings('solver','sdpa');
%optimize(constraints,objective,opts);
optimize(constraints,objective);
U_IN(:,j)=value(u{1});
x_m(:,j+1) = Adx_m(:,j) + BdU_IN(:,j);
clear constraints;
clear u;
end
figure(1)
plot(x_m(1,:),x_m(2,:))
%%
Beta Was this translation helpful? Give feedback.
All reactions