Inputs for nonlinear constraints
Información
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Mostrar comentarios más antiguos
I have problems with my inputs and outputs, con someone help me please?
I have the following optimization in a matlab function block
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)
fun =@(x) (A/SOC_1)*(x(1))^2+(A/SOC_2)*(x(2))^2+(A/SOC_3)*(x(3))^2+(A/SOC_4)*(x(4))^2+d_delay_1-(SW_1+x(5))+d_delay_2-(SW_2+x(6))+d_delay_3-(SW_3+x(7))+d_delay_4-(SW_4+x(8));
x0 = [500,500,500,500,3,3,3,3];
A = [];
b = [];
Aeq = [];
beq = [];
end
lb = [P_min_1, P_min_2, P_min_3, P_min_4, d_min_vl-SW_1, d_min_vr-SW_2, d_min_hl-SW_3, d_min_hr-SW_4];
ub = (1:8);
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];
nlcon = @nonlnconstraints;
options = optimoptions(@fmincon, 'Algorithm', 'sqp');
x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nlcon,options);
%x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nlcon);
Fx1 = x(1);
Fx2 = x(2);
Fx3 = x(3);
Fx4 = x(4);
alpha1 = x(5);
alpha2 = x(6);
alpha3 = x(7);
alpha4 = x(8);
with these nonlinear constraints
ceq = [Fx_v-(x(1)*cos(x(1)+SW_1)+x(2)*cos(x(2)+SW_2)+x(3)*cos(x(3)+SW_3)+x(4)*cos(x(4)+SW_4)-x(5)*sin(x(1)+SW_1)*c_w-x(6)*sin(x(2)+SW_2)*c_w-x(7)*sin(x(3)+SW_3)*c_w-x(8)*sin(x(4)+SW_4)*c_w); Fy_v-(x(1)*sin(x(1)+SW_1)+x(2)*sin(x(2)+SW_2)+x(3)*sin(cos(x(3)+SW_3)+x(4)*sin(x(4)+SW_4)-x(5)*cos(x(1)+SW_1)*c_w-x(6)*cos(x(2)+SW_2)*c_w-x(7)*cos(x(3)+SW_3)*c_w-x(8)*cos(x(4)+SW_4)*c_w)); Mz_v-(x(1)*(cos(x(1)+SW_1)*w_vl-l_v*sin(x(1)+SW_1))+x(2)*(-cos(x(2)+SW_2)*w_vr+sin(x(2)+SW_2)*l_v)+x(3)*(cos(x(3)+SW_3)*w_hl+l_h*sin(x(3)+SW_3))+x(4)*(-cos(x(4)+SW_4)*w_hr+sin(x(4)+SW_4)*l_h)+x(5)*(sin(x(1)+SW_1)*c_w*w_vl+cos(x(1)+SW_1)*c_w*l_v)+x(6)*(sin(x(2)+SW_2)*c_w*w_vr+cos(x(2)+SW_2)*c_w*l_v)+x(7)*(-sin(x(3)+SW_3)*c_w*w_hl-cos(x(3)+SW_3)*c_w*l_h)+x(8)*(cos(x(4)+SW_4)*c_w*l_h+sin(x(4)+SW_4)*c_w*w_hl))];
c = [];
and a Parameter file with all the parameters.
Can anyone tell me how to give the Parameters and the inputs to the file with the nonlinear constraints?
Its not that easy with a matlab function block I feel.
Help would really be appreciated.
Thank you for reading
Respuestas (0)
La pregunta está cerrada.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!