optimization problem wont find any solutions

1 Ansicht (letzte 30 Tage)
Sarah Kern
Sarah Kern am 24 Jan. 2020
Kommentiert: Sarah Kern am 28 Jan. 2020
I have the following optimization problem
function [ Fx1, Fx2, Fx3, Fx4, alpha1, alpha2, alpha3, alpha4] = fcn(Fx_v, Fy_v, Mz_v, P_max_1, P_max_2, P_max_3, P_max_4, M_reg_1, M_reg_2, M_reg_3, M_reg_4, k, delta_T_aA, SW_1, SW_2, SW_3, SW_4, w_1, w_4, w_3, w_2, d_delay_1, d_delay_2, d_delay_3, d_delay_4, r_dyn_1, r_dyn_2, r_dyn_3, SOC_1, SOC_2, r_dyn_4, SOC_3, SOC_4, f_lag, n, j,w_vr, w_vl, w_hr, w_hl, l_h, l_v, c_w,d_min_vl, d_max_vl, d_min_vr, d_max_vr, d_min_hl, d_max_hl, d_min_hr, d_max_hr, A, B, FxB_max, SOC_krit)
fun =@(x) (f_lag >= 0).*((A/SOC_1)*(x(1))^2+(A/SOC_2)*(x(2))^2+(A/SOC_3)*(x(3))^2+(A/SOC_4)*(x(4))^2) + (f_lag == -1).*((((B*(M_reg_1/(M_reg_1+M_reg_2+M_reg_3+M_reg_4)))/SOC_1)*(1/(x(1)^2)))+(((B*(M_reg_2/(M_reg_1+M_reg_2+M_reg_3+M_reg_4)))/SOC_2)*(1/(x(2)^2)))+(((B*(M_reg_3/(M_reg_1+M_reg_2+M_reg_3+M_reg_4))/SOC_3)*(1/(x(3)^2)))+(((B*(M_reg_4/(M_reg_1+M_reg_2+M_reg_3+M_reg_4)))/SOC_4)*(1/(x(4)^2)))));
x0 = [(Fx_v/4)*cos(SW_1),(Fx_v/4)*cos(SW_2),(Fx_v/4)*cos(SW_3),(Fx_v/4)*cos(SW_4),(d_delay_1-SW_1),(d_delay_2-SW_2),(d_delay_3-SW_3),(d_delay_4-SW_4)];
A = [];
b = [];
Aeq = [ 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 0];
SOC_dif1=SOC_1-((SOC_1+SOC_2+SOC_3+SOC_4)/4); %negative when
SOC_dif2=SOC_2-((SOC_1+SOC_2+SOC_3+SOC_4)/4);
SOC_dif3=SOC_3-((SOC_1+SOC_2+SOC_3+SOC_4)/4);
SOC_dif4=SOC_4-((SOC_1+SOC_2+SOC_3+SOC_4)/4);
if f_lag>=0
if (SOC_dif1 < SOC_krit) % state of charge of one actor is really low, actor is only used for steering %during driving mode
%SOC_krit =-0.2(evaluate in tests)
Aeq(2,1) = 1;
end
if (SOC_dif2 < SOC_krit) % state of charge of one actor is really low, actor is only used for steering %during driving mode
Aeq(2,2) = 1;
end
if (SOC_dif3 < SOC_krit) % state of charge of one actor is really low, actor is only used for steering %during driving mode
Aeq(2,3) = 1;
end
if (SOC_dif4 < SOC_krit) % state of charge of one actor is really low, actor is only used for steering %during driving mode
Aeq(2,4) = 1;
end
end
% jedes eine eigene Linie??
% Erfahrungswerte aus Testsimulation
beq = [ 0, 0];
% active stimulation for beta
%if k = 1 there is a stimulation
% k, j and n are Inputs, j and n are the actors stimulated
if k == 1
(Aeq(1,j) == 1) && (Aeq(1,n) == -1); % target moduls
end
if k == 1
beq(1) = delta_T_aA; %target torque
end
if f_lag == -1
%if it is possible the regenerative braking torque is the limit
% sum of the Force from the regenerative braking torque in vehiclecoordinates is bigger than the demanded force for the whole vehicle
% M_reg is always positive and Fx_v can be either positive or negative in the braking case
if (cos(SW_1)*(M_reg_1/r_dyn_1)+cos(SW_2)*(M_reg_2/r_dyn_2)+cos(SW_3)*(M_reg_3/r_dyn_3)+cos(SW_3)*(M_reg_4/r_dyn_4))> abs(Fx_v)
% max. regenerative braking torque
lb = [-M_reg_1/r_dyn_1, -M_reg_2/r_dyn_2, -M_reg_3/r_dyn_3, -M_reg_4/r_dyn_4, d_min_vl-SW_1, d_min_vr-SW_2, d_min_hl-SW_3, d_min_hr-SW_4]; %d and betato the left side are positive, to the right side are negative %regenerative braking torque must be positive
ub = [M_reg_1/r_dyn_1, M_reg_2/r_dyn_2, M_reg_3/r_dyn_3, M_reg_4/r_dyn_4, d_max_vl-SW_1, d_max_vr-SW_2, d_max_hl-SW_3, d_max_hr-SW_4];
else
% mechanical braking
%FxB_max is positive
lb = [-FxB_max, -FxB_max, -FxB_max, -FxB_max, d_min_vl-SW_1, d_min_vr-SW_2, d_min_hl-SW_3, d_min_hr-SW_4]; %d and betato the left side are positive, to the right side are negative %FxB_max is negative
ub = [FxB_max, FxB_max, FxB_max, FxB_max, d_min_vl-SW_1, d_min_vr-SW_2, d_min_hl-SW_3, d_min_hr-SW_4];
end % close conditions for braking loop, max braking torque is positive
%driving mode
else
lb = [-P_max_1/(r_dyn_1*w_1), -P_max_2/(r_dyn_2*w_2), -P_max_3/(r_dyn_3*w_3), -P_max_4/(r_dyn_4*w_4), d_min_vl-SW_1, d_min_vr-SW_2, d_min_hl-SW_3, d_min_hr-SW_4];
ub = [P_max_1/(r_dyn_1*w_1), P_max_2/(r_dyn_2*w_2), P_max_3/(r_dyn_3*w_3), P_max_4/(r_dyn_4*w_4), d_max_vl-SW_1, d_max_vr-SW_2, d_max_hl-SW_3, d_max_hr-SW_4];
end
nlcon = @nonlnconstraints;
%options = optimoptions(@fmincon, 'MaxFunctionEvaluations',10.000000e+03);
options = optimoptions(@fmincon, 'Algorithm', 'sqp');
x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nlcon(Fx_v,Fy_v,Mz_v,SW_1,SW_2,SW_3,SW_4,w_vr, w_vl, w_hr, w_hl, l_h, l_v, c_w),options);
with these nonlinear constraints
function [c,ceq] = nonlnconstraints(Fx_v,Fy_v,Mz_v,SW_1,SW_2,SW_3,SW_4,c_w,l_v,l_h,w_hl,w_hr,w_vl,w_vr)
%following of the input trajectory
ceq =@(x) [Fx_v-(x(1)*cos(x(5)+SW_1)+x(2)*cos(x(6)+SW_2)+x(3)*cos(x(7)+SW_3)+x(4)*cos(x(8)+SW_4)-x(5)*sin(x(5)+SW_1)*c_w-x(6)*sin(x(6)+SW_2)*c_w-x(7)*sin(x(7)+SW_3)*c_w-x(8)*sin(x(8)+SW_4)*c_w); Fy_v-(x(1)*sin(x(5)+SW_1)+x(2)*sin(x(6)+SW_2)+x(3)*sin(x(7)+SW_3)+x(4)*sin(x(8)+SW_4)-x(5)*cos(x(5)+SW_1)*c_w-x(6)*cos(x(6)+SW_2)*c_w-x(7)*cos(x(7)+SW_3)*c_w-x(8)*cos(x(8)+SW_4)*c_w); Mz_v-(-x(1)*(cos(x(5)+SW_1)*w_vl+l_v*sin(x(5)+SW_1))+x(2)*(cos(x(6)+SW_2)*w_vr+sin(x(6)+SW_2)*l_v)+x(3)*(-cos(x(7)+SW_3)*w_hl-l_h*sin(x(7)+SW_3))+x(4)*(cos(x(8)+SW_4)*w_hr-sin(x(8)+SW_4)*l_h)+x(5)*(sin(x(5)+SW_1)*c_w*w_vl-cos(x(5)+SW_1)*c_w*l_v)+x(6)*(sin(x(6)+SW_2)*c_w*w_vr-cos(x(6)+SW_2)*c_w*l_v)+x(7)*(sin(x(7)+SW_3)*c_w*w_hl+cos(x(7)+SW_3)*c_w*l_h)+x(8)*(cos(x(8)+SW_4)*c_w*l_h-sin(x(8)+SW_4)*c_w*w_hl))];
c = [];
end
But matlab cant find any results for it.
Can anyone tell me whats wrong with it?
Thank you very much

Akzeptierte Antwort

Matt J
Matt J am 24 Jan. 2020
The problem is infeasible, or your initial guess x0 is too far from a feasible point.
  18 Kommentare
Walter Roberson
Walter Roberson am 28 Jan. 2020
sqp gives the optimum near
-127.239597103982 128.835753420144 121.456350412052 125.969244882211 14.7285335181627 5.30599633554605 -19.9353352041771 5.15727654258455
with a function value of about 127529.373794526
Interior point gives the optimum near
-124.126884753518 129.235303885167 122.479502387116 127.655545239724 2.16075485377955 -0.98830809315363 -1.11150462680378 5.15802574308162
with a function value of about 126889.507492473
Using other techniques I find you can do slightly better, near
-124.113421979527 129.245561766186 122.471919627735 127.665321535654 2.16126732836261 -0.988860425787402 -1.11254769030373 5.15909384957014
with a function value of about 126889.418322864
Sarah Kern
Sarah Kern am 28 Jan. 2020
I gonna look into all of them, thank you.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Vehicle Scenarios finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by