Where the system is a dynamic system and it is subjected to the equation of motion. The objective function is determined based on Lagrange integral parameterfun(F).
Fo=0;lb=0;ub=3000; options = optimset('Display','iter','TolFun',1e-8,'algorithm','sqp');[Fopt,fval,exitflag,output] = fmincon(@(F) parameterfun(F),Fo,... [],[],[],[],lb,ub,[],options);
where parameterfun(F) is the objective function which calculate the value of F
function [val,F] = parameterfun(F) val = 0; [xu,t,z0dot]=xu_det(F); xu_frame=xu; input=z0dot; r1 = 1e+5; r2 = 0.5; q = 1e-5; R = diag([r1, 0, 0, 0, q, r2]); xu_frame_zs = zeros(6,length(t)); for i=0:0.005:(t-0.005) dx = f(t(i),xu_frame(1:4,i), xu_frame(5,i),input(i)); xu_frame_zs(:,i) = [xu_frame(:,i); dx(4)]; val = val+ (t(i+0.005)-t(i))*xu_frame_zs(:,i)'*R*xu_frame_zs(:,i); end end
where xu_det(F) is a function which is:
function [xu,t,z0dot] = xu_det(F) param.ms = 325; % 1/4 sprung mass (kg)
param.mus = 65; % 1/4 unsprung mass (kg)
param.kus = 232.5e3; % tire stiffness (N/m)
ks=2.36e4; cs=1.03e3; Aqcar = [0 1 0 0;-param.kus/param.mus -cs/param.mus ks/param.mus cs/param.mus;0 -1 0 1;0 cs/param.ms -ks/param.ms -cs/param.ms]; Bqcar = [0 -1;-1/param.mus 0; 0 0; 1/param.ms 0]; Cqcar = [1 0 0 0; 0 1 0 0; 0 0 1 0; 0 0 0 1]; Dqcar = 0; qcar = ss(Aqcar,Bqcar,Cqcar,Dqcar); x0 = [0 0 0 0]'; % initial state
load IRI_737b % road profile data
ddx = road_x(2) - road_x(1); % spacial step for input data
v = 10; % vehicle velocity (m/s)
dt = 0.005; dt2 = ddx/v; % time step for input data
z0dot = [0 diff(road_z)/dt]; % road profile velocity
tmax = 5; % simulation time length
t = 0:dt:tmax; x = v*t; % time/space steps to record output
z0dot_f=zeros(length(z0dot),2); z0dot_f(:,1)=z0dot; z0dot_f(:,2)=F; u = interp1(road_x,z0dot_f,x);%umf = 3;
umf = 0.01; % Simulate quarter car model
y = lsim(qcar,u*umf,t,x0); yu=y; yu(:,5)=F; xu=yu'; end
and f() is another function is used to determine the states variables derivative dx at each F value
function dx = f(~, x,F,z0dot )J = jacobian();A = J(1:4,1:4);B = J(1:4, 5);b_ramp = [-1;0; 0; 0]; dx= A* x + B * F + b_ramp * z0dot; end
and jacobian is another function is used to determine A and B matrices
function J = jacobian()param.ms = 325; % 1/4 sprung mass (kg)param.mus = 65; % 1/4 unsprung mass (kg)param.kus = 232.5e3; % tire stiffness (N/m)ks=2.36e4;cs=1.03e3;A = [ 0 1 0 0; -param.kus/param.mus -cs/param.mus ks/param.mus cs/param.mus; 0 -1 0 1; 0 cs/param.ms -ks/param.ms -cs/param.ms];B = [0 -1/param.mus 0 1/param.ms]'; J = [A, B];end
when I run fmincon the results as:
Norm of First-order Iter F-count f(x) Feasibility Steplength step optimality 0 2 0.000000e+000 0.000e+000 1.000e+000 1 4 0.000000e+000 0.000e+000 1.000e+000 0.000e+000 0.000e+000Local minimum found that satisfies the constraints.Optimization completed because the objective function is non-decreasing in feasible directions, to within the selected value of the function tolerance,and constraints are satisfied to within the default value of the constraint tolerance.<stopping criteria details>
Best Answer