How to minimizing a function depending on last term value ?

1 view (last 30 days)
I just want to minimizing this function:
Supply(horizon)=exp((x(1)+x(2)*log(It(horizon))+x(3)*log(B1))/(1-B2*x(3)));
f=-sum(Supply);
But It(horizon) changes each horizon .and it depends on the Supply(horizon).
function f=myfun(x)
B1=473610;
B2=-1.67;
Y=[3.5;5.5];
Ta=[10.522;9.524];
Tmsy=[120;100];
Rc=[6500;8500];
L=[1406;7468];
load('IArea.mat')
load('V12.mat')
horizon=1;
while horizon<=200;
Stock=IA.*V12./1000;
It(horizon)=sum(Stock(1,60:120))+sum(Stock(2,60:120));
Supply(horizon)=exp((x(1)+x(2)*log(It(horizon))+x(3)*log(B1))/(1-B2*x(3)));
Pt(horizon)=B1*Supply(horizon)^B2;
for k=1:2
for a=60:119
Eg(k,a)=((Pt(horizon)-95)*V12(k,a+1)+L(k))*exp(-0.03)-((Pt(horizon)-95)*V12(k,a))-L(k);
end
for a=1:59
Eg(k,a)=1000000000;
end
Eg(k,120)=((Pt(horizon)-95)*V12(k,120)+L(k))*(exp(-0.03)-1);
end
[a,Index]=sort(Eg(:));
UnitStock=V12.*IA./1000;
q=0;
i=1;
forest1=0;
forest2=0;
while Supply(horizon)-q>0;
q=UnitStock(Index(i))+q;
[xp,yp]=ind2sub([2 120],Index(i));
if xp==1;
forest1=forest1+IA(Index(i));
else
forest2=forest2+IA(Index(i));
end
IA(Index(i))=0;
i=i+1;
end
[xf,yf]=ind2sub([2 120],Index(i-1));
if xf==1;
forest1=forest1+IA(Index(i-1))-(q-Supply(horizon)).*1000/V12(Index(i-1));
else
forest2=forest2+IA(Index(i-1))-(q-Supply(horizon)).*1000/V12(Index(i-1));
end
IA(Index(i-1))=(q-Supply(horizon))*1000/V12(Index(i-1));
IA(:,119) = IA(:,119)+IA(:,120);
IA(:,[2:120,1]) = IA(:,1:120);
IA(1,1)=forest1;
IA(2,1)=forest2;
horizon=horizon+1
end
Supply(horizon)=exp((x(1)+x(2)*log(It(horizon))+x(3)*log(B1))/(1-B2*x(3)));
f=-sum(Supply);

Answers (0)

Categories

Find more on Problem-Based Optimization Setup 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!