How to create an objective function c(t) to use fminserch , struggle with the summatoin , i used the following code for the optimization but it doesn't seem to work

4 ビュー (過去 30 日間)
lamia 2022 年 8 月 28 日
コメント済み: lamia 2022 年 9 月 20 日
function i= cout(cc,cp,crg,alpha,delta,eta,rho,beta,K,T )
cc=15000;
cp=10000;
crg=200000;
rho=0.5;
eta=56.9;
beta=2.6;
alpha=1.63;
delta=0.015;
s=0;
T=1:1:600;
K=20;
ct=[];Y=[];X=[];
for K=20
s=s+((((K-((K-1).*rho))/eta).^beta-(((K-1)-(K-1).*rho)/eta).^beta)-((((K-1)/eta).^beta).*(beta*delta))).*alpha
ct=[ct;((crg+cp*(K-1))/(K))*(T.^(-1))+((cc*s)*(T.^(beta-1)))/(K)]
X=[X,min(ct)];
Y=min(ct);
end
[T,K]=meshgrid(1:1:600,20);
figure
plot(T,ct)
X;
Y;
i=find(X==min(X))
j=find(Y==min(Y))
4 件のコメント表示非表示 3 件の古いコメント
lamia 2022 年 9 月 5 日
K is a variable that I didn't know how to define in the script, so I opted for the approach above, in order to find the optimal k and T. but I think it's not the right one
T is the value of the optimal period and K is the number of optimal periods

サインインしてコメントする。

回答 (1 件)

Alan Stevens 2022 年 8 月 30 日
Do you mean something like this:
KT0 = [1, 10]; % initial guesses
[KT, C] = fminsearch(@FN, KT0);
K = KT(1); T = KT(2);
disp(['K = ', num2str(K), ' T = ', num2str(T)])
K = 2 T = 108.5802
disp(['C = ', num2str(C)])
C = 1571.1955
function C = FN(KT)
K = KT(1); T = KT(2);
cc=15000;
cp=10000;
crg=200000;
rho=0.5;
eta=56.9;
beta=2.6;
alpha=1.63;
delta=0.015;
fn1 = @(K,T) ((K.*T-rho*(K-1).*T)/eta).^beta;
fn2 = @(K,T) (((K-1).*T-rho*(K-1).*T)/eta).^beta;
fn3 = @(K,T) ((K-1).^(beta-1).*T.^beta)/eta^beta;
H = @(K,T) alpha*(fn1(K,T) - fn2(K,T)) - delta*beta*fn3(K,T);
SM = 0;
for m = 1:K
SM = SM + H(m,T);
end
C = ((K-1)*cp + crg + cc*SM)./(K.*T);
end
Unfortunately, I think the function has many local minima, so there's no certainty that the above is a global minimum!
3 件のコメント表示非表示 2 件の古いコメント
lamia 2022 年 9 月 20 日
Thank you, that helped so much
please I did not understand how you declared the values of k I mean it is an integer
may i mail you ?

サインインしてコメントする。

カテゴリ

Find more on Choose a Solver in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by