can if conditions be used for equality constraint in fmincon?
Ältere Kommentare anzeigen
Value of beq depends on the SOC [u(2)] which is one of the input to the S function in simulink. Could this be done?
%define Matrix Aeq
Aeq=[0 1 0;1 0 1];
%define Matrix beq
SOCoptimal = .5
if u(2)<=0.9 && u(2)>=0.4
Kba = (1-(2*(u(2)-SOCoptimal))/(0.9-0.4))^4;
else if u(2)<0.4 | u(2)>0.9
Kba = (1-(2*(u(2)-SOCoptimal))/(0.9-0.4))^20
else
;
end
H_consumption = out.simout;
m_average = mean (H_consumption);
Pfc_average = mean (Pfc)
m_ba = (Pbatt*m_average*0.55)/Pfc_average
beq=[Kba*m_ba; u(1)];
%define boundary conditions
lb=[Pfc_min, 0, -Pbatt_char];
ub=[Pfc_max, 100, Pbatt_max];
%define initial conditions
%x0=[Pfc_min, 0, 0];
x0=[3000, 0.1, 3000];
options = optimoptions('fmincon','Algorithm','active-set','Display','off','MaxFunctionEvaluations',1000,'MaxIterations',100);
[y,fval] = fmincon('OF_ECMS',x0,[],[],Aeq,beq,lb,ub,[],options); %#ok<*ASGLU>
Pfc=y(1); Pbatt=y(3); alpha=y(2);
sys = [Pfc Pbatt alpha];
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Problem-Based Optimization Setup finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!