Computation of Optimal Tuning Parameter Using fmincon

Hello dear colleagues. I am currently working out a problem based on energetically optimal trajectory planning of a 2-link equally actuated robotic manipulator platform. The control problem is somewhat based on Nonlinear prediction based on Pontryagin's maximum principle. I am having the following model of the system, based on the transformation:
2.jpg
3.jpg
4.jpg
5.jpg
Anyway....... I am not going into details of the maximum principle's derivations. However, I am coming up with J-approximations of the controls and state trajectories to be:
1.jpg
NOTE: J-approximations denotes the iterations here. J denotes J=0 i.e. the starting iteration and J+1 is next iteration. approximations are approximations that leads into region where some constraint is not satisfied and the value of the performance index is not decreased. The entities are all arrays/ vectors and are the functions of time t. So is .
The constructed variations along Japproximations are
6.jpg
Based on Hamiltonian, the performance indices are given as under:
7.jpg
8.jpg
9.jpg
PROBLEM: I need to find the optimal weighting function/ tuning tunning parameter by maximizing the cost function . I have to do this in nonlinearing programming framework. I have used fmincon but I don't exactly know how to define objective/cost function "fun" in fmincon with integral term. The range of should lie in range
[0 1]. The time T is the total prediction time/ horizon. I am defining "fun" as:
f = @(alfa) -(-2*trapz(alfa.*(e1.*(Mmz_t.*(w1_Jstar - w1)).^2 + e2.*(Mmm_t.*(w2_Jstar - w2)).^2 + e1.*(Mzz_t.*(w1_Jstar - w1)).^2 + e2.*(Mmz_t.*(w1_Jstar - w1)).^2)).*h);
I am chosing the starting value of to be zero. I am defining the nonlinear constraints function as:
function [c1,c2,ceq] = nonlin_constraints(x11_J_t,x12_J_t,x21_J_t,x22_J_t,w1,w2)
e1 = 1; % Weight
e2 = 1; % Weight
g=9.8;
m1=0.1;
m2=0.1;
l1=1;
l2=1;
I1=0.01;
I2=0.01;
% x11_J_t = x11;
% x12_J_t = x12;
% x21_J_t = x21;
% x22_J_t = x22;
%% Time Dependent Inertial Matrix Terms %%
Mmm_t = I2+((m2.*l2.^2)./4)+((m2.*l1.*l2.*cos(x12_J_t))./2);
Mmz_t = I1+I2+(m2.*l1).*(l1+l2.*cos(x12_J_t))+((m1.*l1.^2)+(m2.*l2.^2))./4;
Mzm_t = I2+((m2.*l2.^2)./4).*cos(0*x12_J_t);
Mzz_t = I2+((m2.*l2.^2)./4)+((m2.*l1.*l2.*cos(x12_J_t))./2);
Fm_t = m2.*l1.*l2.*sin(x12_J_t).*((x22_J_t.^2./2)+x21_J_t.*x22_J_t)-g.*(m2.*l2./2).*cos(x11_J_t+x12_J_t)-g.*l1.*(m1./2+m2).*cos(x12_J_t);
Fz_t = -m2.*l1.*l2.*sin(x12_J_t).*((x21_J_t.^2)./2)-g.*(m2.*l2./2).*cos(x11_J_t+x12_J_t);
%% Define Inequality Nonlinear Contraints %%
Q1 = (Mmz_t.*w1+ Mmm_t.*w2) - Fm_t;
Q2 =(Mzz_t.*w1+ Mzm_t.*w2) - Fz_t;
c1 = abs(Q1) - 1;
c2 = abs(Q2) - 1;
ceq = [];
end
If somebody can help me with that, specifically how to define "fun" with integral and using fmincon to compute optimal , I 'll be much obliged. Thanks in advance. Will be looking forward. Profound Regards.

Answers (0)

Categories

Asked:

on 25 Feb 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!