Uploaded by Ahmed Kaser

Document (7)

advertisement
Lab1
k2 = 2* 10^5;
k1=10^-4;
D = 0.08;
a= 50*10^-6 : 1*10^-6 : 100 *10^-6 ;
Cr = k1./a ;
Cf = k2*a*D ;
Ctot = Cr + Cf;
CtotMin = min(Ctot) ;
Point = find(Ctot == CtotMin);
amin = a(Point);
plot (a,Cr,a,Cf,a,Ctot ,amin, CtotMin, 'ro' )
grid on
title (' Optimal Cross Section Area ' )
xlabel('Cross Section Area (m^2)')
ylabel('Cost ($)')
text(amin , CtotMin+ 0.1 , 'Min total cost');
legend ('Runing cost','Fixed Cost','Total Cost', 'Min total cost' );
% Ahmed saed kaser
%sec 1
%No 17
Lab 2
clc
p=1.56*1000000; %initual value
s=60*1000; %salvage value
n=25; %life time
r=0.1; %annual rate of interest
%########### straight line method #########
a1=(p-s)./n; %amount of set aside per year
k=0:n; %counter for years
a1n=a1.*k; %accumulated amount of set aside at the end of each year
cq_vall=p-a1n; %equivalent value of the trans.after each year
dep1=p-a1n; %depreciation value after each year
plot(0:n,a1n,0:n,dep1)
figure
%################ Diminshing-value method ################
x2=(1-(s/p).^(1./(n))); %Annual unit depreciation
eq_val2=p.*(1-x2).^(0:n); %equivalent value of the trans.after each year
plot(0:n,eq_val2)
hold on
a2(1)=0; %initial value of accumulated amount of set aside money
k=1; %counter
for i=1:n %counter for the number of life years
a2(k+1)=a2(k)+p*x2*(1-x2).^(k-1); %accumulated amount of set aside money
k=k+1
end
plot(0:n,a2)
figure
%############### sinking-value method
a3=(r/((1+r)^n-1))*(p-s);
y=a3/r*((1+r).^(0:n)-1) %total amount of accumulation at the end of the n year
eq_val3=p-y; %equivalent value of the trans. after each year
plot(0:n,y,0:n,eq_val3);
Lab3
clear all;
clc
p=10:100;
%power range
F=(40+4.*p+0.0012*p.^2)*1000000;
%input fuel
plot(p,F)
figure
HR=F./p;
%heat rate
plot(p,HR)
figure
FC=0.12e-6*F;
plot(p,FC)
FC=0.12e-6*F;
%the fuel cost
IFC=0.12e-6*(4+0.024.*p)*1000000;
%the incremental fuel cost
plot(p,IFC)
Lab4
pd=input('enter the demand')
pmax=500;
pmin=80;
B=[4,3,3.8];
Y=[.004,.005,.0035];
n=3;
p=zeros(1,n);
sum1=0;
sum2=0;
for i=1:n
sum1=sum1+(B(i)/Y(i));
sum2=sum2+(1/Y(i));
end
h=(pd+sum1)/sum2;
for i=1:n
p(i)=(h-B(i))/Y(i);
end
i=1;
while(i<=n)
if p(i)<pmin
p(i)=pmin;
pd=pd-pmin;
sum1=sum1-(B(i)/Y(i));
sum2=sum2-(1/Y(i));
h=(pd+sum1)/sum2;
for x=1:n
if(x~=i)
p(x)=(h-B(x))/Y(x);
end
end
i=0;
elseif p(i)>pmax
p(i)=pmax;
pd=pd-pmax;
sum1=sum1-(B(i)/Y(i));
sum2=sum2-(1/Y(i));
h=(pd+sum1)/sum2;
for x=1:n
if(x~=i)
p(x)=(h-B(x))/Y(x);
end
end
i=0;
else
end
i=i+1;
end
p1=p(1);
p2=p(2);
p3=p(3);
L=h;
display(L);
display(p1);
display(p2);
display(p3);
clc ;clear all;
pd=input('enter the demand');
pmax=500;
pmin=80;
B=[4,3,3.8];
Y=[.08,.01,.007];
n=3;
p=zeros(1,n);
sum=0;
h=4.5;
tol=.02;
div=1;
while(abs(div)>tol)
for i=1:n
p(i)=(h-B(i))/Y(i);
sum=sum+p(i);
end
for x=1:n
if(p(x)<pmin)
p(x)=pmin;
end
if(p(x)>pmax)
p(x)=pmax;
end
end
div=pd-sum;
div=div/pd;
h=h*(1+div/2);
sum=0;
end
L=h;
display(L);
p1=p(1);
p2=p(2);
p3=p(3);
display(p1);
display(p2);
display(p3);
lab5
clc
clear all
n=input(‘No of units?’);
b= input(‘beta?’);
g= input(‘2*gamma?’);
𝑃𝑚𝑎𝑥 = input(‘Max constrains? ’);
𝑃𝑚𝑖𝑛 = input(‘Min constrains? ’);
𝑃𝑑 = input(‘Demand? ’);
𝑡𝑜𝑙 = input(‘tolerance in P. U? ’);
Lamda=max(b)+0.5;
Error=0.03;
It=0;
While (abs(error)>tol);
If it>0;
Lamda=lamda*(1+error/2);
end
It=it+1;
for i=1:n
P(i)=(lamda-b(i))./g(i);
if P(i)<Pmin(i);
P(i)=Pmin(i);
eslse if P(i)>Pmax(i);
P(i)=Pmax(i);
end
end
end
error=(Pd-sum(P))./Pd;
Download