Problem with nonlinear objective function

15 Ansichten (letzte 30 Tage)
Bashar
Bashar am 26 Mär. 2023
Kommentiert: Bashar am 28 Mär. 2023
Hello all
I have problem with running a script that written to excute a multi-objective optimization problem using the solver " gamultiobj ", the error message that appears in the commnad window is " Objective must be an OptimizationExpression or a struct containing scalar OptimizationExpressions."
The optimization problem is a problem-based type and the part of script related to the objective functions is presented below:
% The First Objective Function
Jems = optimexpr;
for i = 0:Hp-1
if i+k <=Ns+Hp
Jems = Jems + ((CCb./(2.*Nc_b.*Eb)).*DT.*Pb_ch(i+k))...
+((CCb./(2.*Nc_b.*Eb)).*DT.*Pb_disch(i+k))...
+ (nfc.*((CCfc./Nh_fc) + Com_fc).*Delta_fc(i+k).*DT + Css_fc.* ASegma_fc(i+k))...
+ (nez.*((CCez./Nh_ez) + Com_ez).*Delta_ez(i+k).*DT + Css_ez.* ASegma_ez(i+k))...
+ (Bid_imp.*Pg_imp(i+k).*DT) - (Bid_exp.*Pg_exp(i+k).*DT);
else
break
end
end
show(Jems);
prob.Objective.OF1 = Jems;
%==============================
% The Second Objective Function
Eff = optimexpr;
for i = 0:Hp-1
if i+k <=Ns+Hp
Eff = Eff + ((Pfc(i+k)+Pb_disch(i+k))) ./ ((Pez(i+k)+Pb_ch(i+k)));
else
break
end
end
show(Eff)
prob.Objective.OF2 = Eff;
prob.Objective.OF2 = "max";
%========================
show(prob);
the optimization variables are presented below
Pb_ch = optimvar('Pb_ch',Nhr,'LowerBound',0,'UpperBound',nb*Pb_ch_max);
Pb_disch = optimvar('Pb_disch',Nhr,'LowerBound',0,'UpperBound',nb*Pb_disch_max);
Pg_imp = optimvar('Pg_imp',Nhr,'LowerBound',0,'UpperBound',Pg_imp_max);
Pg_exp = optimvar('Pg_exp',Nhr,'LowerBound',0,'UpperBound',Pg_exp_max);
Pfc = optimvar('Pfc',Nhr,'LowerBound',0,'UpperBound',nfc*Pfc_max);% Watch out here
Pez = optimvar('Pez',Nhr,'LowerBound',0,'UpperBound',nez*Pez_max);% Watch out here
SoCb = optimvar('SoCb',Nhr,'LowerBound',SoCb_min,'UpperBound',SoCb_max);
SoCH2 = optimvar('SoCH2',Nhr,'LowerBound',SoCH2_min,'UpperBound',SoCH2_max);
Delta_fc = optimvar('Delta_fc',Nhr,'LowerBound',0,'UpperBound',1,'Type','integer');
Delta_ez = optimvar('Delta_ez',Nhr,'LowerBound',0,'UpperBound',1,'Type','integer');
Delta_b_ch = optimvar('Delta_b_ch',Nhr,'LowerBound',0,'UpperBound',1,'Type','integer');
Delta_b_disch = optimvar('Delta_b_disch',Nhr,'LowerBound',0,'UpperBound',1,'Type','integer');
Delta_g_imp = optimvar('Delta_g_imp',Nhr,'LowerBound',0,'UpperBound',1,'Type','integer');
Delta_g_exp = optimvar('Delta_g_exp',Nhr,'LowerBound',0,'UpperBound',1,'Type','integer');
Segma_fc = optimvar('Segma_fc',Nhr,'LowerBound',-1,'UpperBound',1,'Type','integer');
Segma_ez = optimvar('Segma_ez',Nhr,'LowerBound',-1,'UpperBound',1,'Type','integer');
ASegma_fc = optimvar('ASegma_fc',Nhr,'LowerBound',0,'Type','integer');
ASegma_ez = optimvar('ASegma_ez',Nhr,'LowerBound',0,'Type','integer');
Kindly, I need to know what is the wrong associated with the objective functions formulation, especially the second functions.
Thanks in advance

Akzeptierte Antwort

Matt J
Matt J am 26 Mär. 2023
Bearbeitet: Matt J am 26 Mär. 2023
prob.Objective.OF2 = "max";
"max" is just a string. There is no optimization expression that can be interpreted from it.

Weitere Antworten (0)

Kategorien

Mehr zu Multiobjective Optimization finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by