How can I define two function in function handle for GAMULTIOBJ?

4 Ansichten (letzte 30 Tage)
I have 3 decision variables and 2 objective functions.
This is my code:
lb=[0.01,0.0075,0.01];
ub=[0.2,0.07,0.07];
func=@(x) [efficiency,LCCfunc];
[x,fvar]=gamultiobj(func,3,[],[],[],[],lb,ub);
My question:
Efficiency and LCCfunc are my objective functions. For example LCCfuns is:
function y=LCCfunc(var)
delta_PCM=var(3);
L=1.5;
W=1;
rho_PCMs=880;
m_PCM=W*L*delta_PCM*rho_PCMs;
phi_np=var(1);
m_nano=phi_np*m_PCM/(1-phi_np);
U_C_nano=100;
U_C_PCM=1;
cost_nanoPCM=(U_C_nano*m_nano)+(U_C_PCM*m_PCM);
IC=cost_nanoPCM;
k=0.2;
INR=0.12;
IFR=0.03;
MC=zeros(1,24);
MC(2)=1300*(1+IFR);
MCDiscount=zeros(1,24);
RC=zeros(1,24);
RC(2)=cost_nanoPCM;
RCDiscount=zeros(1,24);
% CRF=;
% RC=
% MC=k*IC*CRF;
for i=2:25
MC(i+1)=MC(i)*(1+IFR);
MCDiscount(i)=MC(i)/((1+INR)^(i-1));
end
MCtotal=sum(MCDiscount);
for i=2:25
RC(i+1)=RC(i)*(1+IFR);
RCDiscount(i)=RC(i)/((1+INR)^(i-1));
end
RCtotal=sum(RCDiscount);
LCC=IC+MCtotal+RCtotal;
y=LCC;
end
How can I define these two objective function in one function handle for using in GAMULTIOBJ?

Akzeptierte Antwort

Torsten
Torsten am 6 Okt. 2022
Bearbeitet: Torsten am 6 Okt. 2022
Since the functions are that long, better keep them separated.
But use
func=@(x) [efficiency(x),LCCfunc(x)];
instead of
func=@(x) [efficiency,LCCfunc];
to avoid an error message.
If you want to combine them in one function, simply use
func = @combined
and supply both columns in
function y = combined(x)
y(:,1) = ...;
y(:,2) = ...;
end
with y having 2 columns.

Weitere Antworten (0)

Kategorien

Mehr zu Problem-Based Optimization Setup finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by