Hi, I have the following parameterization of x,y and z
with N = 4
Then I have three forces defined as: (Clohessy-Wiltshire equations..)
and I'm trying to minimise the following cost function
which I have included in MATLAB as
% x,y,z and derivatives
x = @(t,c) c(1) + c(2)*t + c(3)*t.^2 + c(4)*t.^3 + c(5)*t.^4;y = @(t,c) c(6) + c(7)*t + c(8)*t.^2 + c(9)*t.^3 + c(10)*t.^4;z = @(t,c) c(11) + c(12)*t + c(13)*t.^2 + c(14)*t.^3 + c(15)*t.^4;xDot = @(t,c) c(2) + 2*c(3)*t + 3*c(4)*t.^2 + 4*c(5)*t.^3;yDot = @(t,c) c(7) + 2*c(8)*t + 3*c(9)*t.^2 + 4*c(10)*t.^3;zDot = @(t,c) c(12) + 2*c(13)*t + 3*c(14)*t.^2 + 4*c(15)*t.^3;xDdot = @(t,c) 2*c(3) + 6*c(4)*t + 12*c(5)*t.^2;yDdot = @(t,c) 2*c(8) + 6*c(9)*t + 12*c(10)*t.^2;zDdot = @(t,c) 2*c(13) + 6*c(14)*t + 12*c(15)*t.^2;% forces definition
uX = @(t,c) xDdot(t,c) - 3*(nOrbit^2)*x(t,c) - 2*nOrbit*yDot(t,c);uY = @(t,c) yDdot(t,c) + 2*nOrbit*xDot(t,c);uZ = @(t,c) zDdot(t,c) + (nOrbit^2)*z(t,c);% cost function
fun = @(t,c) ( uX(t,c).^2 + uY(t,c).^2 + uZ(t,c).^2 ).^0.5;
The formulation of the optimization problem includes some constraints and is formulated as
f = @(c) integral(@(t) fun(t,c),t0,tf);x0 = ones(1,15);A = [];b = [];Aeq = [... %Initial position and velocity constraints 1 t0 t0^2 t0^3 t0^4 zeros(1,5) zeros(1,5); ... zeros(1,5) 1 t0 t0^2 t0^3 t0^4 zeros(1,5);... zeros(1,5) zeros(1,5) 1 t0 t0^2 t0^3 t0^4;... 0 1 2*t0 3*t0^3 4*t0^3 zeros(1,5) zeros(1,5);... zeros(1,5) 0 1 2*t0 3*t0^3 4*t0^3 zeros(1,5);... zeros(1,5) zeros(1,5) 0 1 2*t0 3*t0^3 4*t0^3;... ...%Final position and velocity constraints
1 tf tf^2 tf^3 tf^4 zeros(1,5) zeros(1,5); ... zeros(1,5) 1 tf tf^2 tf^3 tf^4 zeros(1,5);... zeros(1,5) zeros(1,5) 1 tf tf^2 tf^3 tf^4;... 0 1 2*tf 3*tf^3 4*tf^3 zeros(1,5) zeros(1,5);... zeros(1,5) 0 1 2*tf 3*tf^3 4*tf^3 zeros(1,5);... zeros(1,5) zeros(1,5) 0 1 2*tf 3*tf^3 4*tf^3;... ];beq = [initState; finalState];lb = ones(1,15)*-inf;ub = ones(1,15)*inf;nonlc = [];options = optimoptions(@fmincon,'Algorithm','interior-point',... 'MaxIterations',400,'StepTolerance',1.0e-12,... 'MaxFunctionEvaluations',3000,'Display','notify');s = fmincon(@(a) f(a),x0,A,b,Aeq,beq,lb,ub,nonlc,options);
I'm running this iteratively over a period of 2000 (from 500-2500)
The result I get is far from optimal and so my question is.. is there something I did wrong in the formulation of this problem? (I'm particularly unsure about the computation of the integral.) Or could it just be something with the parameters of the optimization and should I try different settings?
Resulting plot should look something like:
but instead I'm given
thank you in advance for helping out
Best Answer