dvar[1,1]:=StrToFloat(str);
dvar[2,1]:=StrToFloat(str);
dvar[3,1]:=StrToFloat(str);
except
showmessage('Îøèáêà ïðè ââîäå çíà÷åíèÿ áåçðèñêîâîé ïðîöåíòíîé ñòàâêè!');
FocusControl(Stringgrid4);
end; end;
for i:=2 to n do begin
dvar[1,i]:=dvar[1,1];
dvar[2,i]:=dvar[2,1];
dvar[3,i]:=dvar[2,1];
end;
end;
cbUnchecked: begin
for j:=0 to n-1 do begin
str:=StringGrid4.Cells[j,1];
if pos(';',str)<>0 then begin str2:='';k:=1;
for i:=1 to Length(str)do begin
if (str[i]<>';') then str2:=str2+str[i]
else begin
dvar[k,j+1]:=StrToFloat(str2);
k:=k+1;str2:='';
end;
if i=Length(str) then dvar[k,j+1]:=StrToFloat(str2);
end;
end else try
dvar[1,j+1]:=StrToFloat(str);
dvar[2,j+1]:=StrToFloat(str);
dvar[3,j+1]:=StrToFloat(str);
except
showmessage('Îøèáêà ïðè ââîäå çíà÷åíèé áåçðèñêîâîé ïðîöåíòíîé ñòàâêè!');
FocusControl(Stringgrid4);
end;
end;
end;end;
//------------------------------Ðàññ÷åò
çíà÷åíèÿ êîýô-òà ïîêðûòèÿ Ñt
for i:=1 to
n do begin
Ct[1,i]:=1;
Ct[2,i]:=1;
end;
for i:=1 to n do begin
if Zt[2,i]<>0 then Ct[1,i]:=At[1,i]/Zt[2,i];
if Zt[1,i]<>0 then Ct[2,i]:=At[2,i]/Zt[1,i];
j:=3;
if (Ct[1,i]*Ct[2,i])<=(kCt[1]*kCt[1]) then
Cto[i]:=(Ct[1,i]*Ct[2,i])/(kCt[1]*kCt[1]);
if ((Ct[1,i]*Ct[2,i])>(kCt[1]*kCt[1]))and
(Ct[1,i]*Ct[2,i]<=(kCt[2]*kCt[2]))then j:=0;
if ((Ct[1,i]*Ct[2,i])>(kCt[2]*kCt[2]))and
(Ct[1,i]*Ct[2,i]<=(kCt[3]*kCt[3])) then j:=1;
if ((Ct[1,i]*Ct[2,i])>(kCt[3]*kCt[3]))and (Ct[1,i]*Ct[2,i]<1) then j:=2;
if (Ct[1,i]*Ct[2,i]>=1) then Cto[i]:=1;
if (j = 0) or (j = 1) then
Cto[i]:=kCt[1+j]+((((Ct[1,i]*Ct[2,i])-(kCt[1+j]*kCt[1+j]))*(kCt[2+j]-kCt[1+j]))/((kCt[2+j]*kCt[2+j])-(kCt[1+j]*kCt[1+j])));
if j = 2 then
Cto[i]:=kCt[1+j]+((((Ct[1,i]*Ct[2,i])-(kCt[1+j]*kCt[1+j]))*(1-kCt[1+j]))/(1-(kCt[1+j]*kCt[1+j])));
end;
for i:=1 to n do begin
for j:=1 to 3 do begin
NPVvar[j,i]:=0;
end;
end;
//------------------------------Ðàññ÷åò èíåðâàëîâ NPVt
if Rtkey=false then begin
for ii:=1 to n do begin
for i:=1 to ii do begin
smin:=1;smax:=1;sav:=1;
for j:=1 to i do begin smax:=smax*dvar[1,i];
smin:=smin*dvar[3,i];
sav:=sav*dvar[2,i];
end;
NPVvar[3,ii]:=NPVvar[3,ii]+(Svar[3,i]/smax);
NPVvar[1,ii]:=NPVvar[1,ii]+(Svar[1,i]/smin);
NPVvar[2,ii]:=NPVvar[2,ii]+(Svar[2,i]/sav);
end;
NPVvar[1,ii]:=NPVvar[1,ii]-Ip[3];
NPVvar[2,ii]:=NPVvar[2,ii]-Ip[2];
NPVvar[3,ii]:=NPVvar[3,ii]-Ip[1];
end;
end else begin
for ii:=1 to nRt do begin
for i:=1 to ii do begin
smax:=1;
for j:=1 to i do begin smax:=smax*Rdvar[i];end;
NPVvar[3,ii]:=NPVvar[3,ii]+(RSvar[i]/smax);
end;
NPVvar[1,ii]:=NPVvar[3,ii]-Ir;
NPVvar[2,ii]:=NPVvar[3,ii]-Ir;
NPVvar[3,ii]:=NPVvar[3,ii]-Ir;
end;
for ii:=nRt+1 to n do begin
for i:=1 to nRt do begin
smax:=1;
for j:=1 to i do begin smax:=smax*Rdvar[i];end;
NPVvar[3,ii]:=NPVvar[3,ii]+(RSvar[i]/smax);
end;
NPVvar[2,ii]:=NPVvar[3,ii];
NPVvar[1,ii]:=NPVvar[3,ii];
for i:=nRt+1 to ii do begin
smin:=1;smax:=1;sav:=1;
for j:=1 to i do begin smax:=smax*dvar[1,i];
smin:=smin*dvar[3,i];
sav:=sav*dvar[2,i];
end;
NPVvar[3,ii]:=NPVvar[3,ii]+(Svar[3,i]/smax);
NPVvar[1,ii]:=NPVvar[1,ii]+(Svar[1,i]/smin);
NPVvar[2,ii]:=NPVvar[2,ii]+(Svar[2,i]/sav);
end;
NPVvar[1,ii]:=NPVvar[1,ii]-Ir;
NPVvar[2,ii]:=NPVvar[2,ii]-Ir;
NPVvar[3,ii]:=NPVvar[3,ii]-Ir;
end;
end;
//------------------------------Ðàññ÷åò
çíà÷åíèÿ êîýôôèöèåíòà ðèñêà Vt
for i:=1 to
n do begin
if (NPVvar[3,i]=NPVvar[1,i]) or (NPVvar[2,i]=NPVvar[1,i]) or
(NPVvar[3,i]=NPVvar[2,i]) then begin
if (NPVvar[1,i]>G) then Vt[i]:=0;
if (NPVvar[1,i]<=G) and (NPVvar[3,i]>=G) then Vt[i]:=(G-NPVvar[1,i])/(NPVvar[3,i]-NPVvar[1,i]);
if (NPVvar[3,i]<G) then Vt[i]:=1;
end else begin
smin:=(G-NPVvar[1,i])/(NPVvar[3,i]-NPVvar[1,i]);
if G<NPVvar[1,i] then Vt[i]:=0;
if (G>=NPVvar[1,i]) and (G<NPVvar[2,i]) then begin
smax:=(G-NPVvar[1,i])/(NPVvar[2,i]-NPVvar[1,i]);
Vt[i]:=smin*(1+((1-smax)/smax)*Ln(1-smax));
end;
if (G>=NPVvar[2,i]) and (G<NPVvar[3,i]) then begin
if G=NPVvar[2,i] then smax:=1 else
smax:=(NPVvar[3,i]-G)/(NPVvar[3,i]-NPVvar[2,i]);
Vt[i]:=1-((1-smin)*(1+((1-smax)/smax)*Ln(1-smax)));
end;
if G>=NPVvar[3,i] then Vt[i]:=1;
end;
end;
//-----------------------------Ðàññ÷åò
çíà÷åíèÿ êîý-òà ëèêâèäíîñòè Rt
For i:=1 to
n do begin
Rt[1,i]:=1;Rto[i]:=1;
Rt[2,i]:=1;
end;
//-----------------------------ðàññ÷åò
ïðîãíîçíîãî çàí÷åíèÿ NPV è Rt
if
Rtkey=true then begin
for ii:=1 to n do begin
NPVpmin:=0;NPVpmax:=0;NPVpav:=0;
for i:=1 to ii do begin
smin:=1;smax:=1;sav:=1;
for j:=1 to i do begin
smin:=smin*dvar[3,i];smax:=smax*dvar[1,i];sav:=sav*dvar[2,i];end;
NPVpmax:=NPVpmax+(Svar[3,i]/smax);
NPVpmin:=NPVpmin+(Svar[1,i]/smin);
NPVpav:=NPVpav+(Svar[2,i]/sav);
end;
NPVpmin:=NPVpmin-Ip[3];
if NPVpmin<>0 then Rt[1,ii]:=NPVvar[1,ii]/NPVpmin;
NPVpmax:=NPVpmax-Ip[1];
if NPVpmax<>0 then Rt[3,ii]:=NPVvar[3,ii]/NPVpmax;
NPVpav:=NPVpav-Ip[2];
if NPVpav<>0 then Rt[2,ii]:=NPVvar[2,ii]/NPVpav;
if (NPVpmin<=0) and (NPVvar[1,ii]>=0) then Rt[1,ii]:=1;
if (NPVpmax<=0) and (NPVvar[3,ii]>=0) then Rt[3,ii]:=1;
if (NPVpav<=0) and (NPVvar[2,ii]>=0) then Rt[2,ii]:=1;
if (NPVpmin>=0) and (NPVvar[1,ii]<0) then Rt[1,ii]:=0;
if (NPVpmax>=0) and (NPVvar[3,ii]<0) then Rt[3,ii]:=0;
if (NPVpav>=0) and (NPVvar[2,ii]<0) then Rt[2,ii]:=0;
end;
for i:=1 to n do begin
j:=3;
if (Rt[1,i]*Rt[2,i]*Rt[3,i])<=(kRt[1]*kRt[1]*kRt[1]) then
Rto[i]:=(Rt[1,i]*Rt[2,i]*Rt[3,i])/(kRt[1]*kRt[1]);
if ((Rt[1,i]*Rt[2,i]*Rt[3,i])>(kRt[1]*kRt[1]*kRt[1]))and (Rt[1,i]*Rt[2,i]*Rt[3,i]<=(kRt[2]*kRt[2]*kRt[2]))then
j:=0;
if ((Rt[1,i]*Rt[2,i]*Rt[3,i])>(kRt[2]*kRt[2]*kRt[2]))and
(Rt[1,i]*Rt[2,i]*Rt[3,i]<=(kRt[3]*kRt[3]*kRt[3])) then j:=1;
if ((Rt[1,i]*Rt[2,i]*Rt[3,i])>(kRt[3]*kRt[3]*kRt[3]))and
(Rt[1,i]*Rt[2,i]*Rt[3,i]<1) then j:=2;
if (Rt[1,i]*Rt[2,i]*Rt[3,i]>=1) then Rto[i]:=1;
if (j = 0) or (j = 1) then
Rto[i]:=kRt[1+j]+((((Rt[1,i]*Rt[2,i]*Rt[3,i])-(kRt[1+j]*kRt[1+j]*kRt[1+j]))*(kRt[2+j]-kRt[1+j]))/((kRt[2+j]*kRt[2+j]*kRt[2+j])-(kRt[1+j]*kRt[1+j]*kRt[1+j])));
if j = 2 then
Rto[i]:=kRt[1+j]+((((Rt[1,i]*Rt[2,i]*Rt[3,i])-(kRt[1+j]*kRt[1+j]*kRt[1+j]))*(1-kRt[1+j]))/(1-(kRt[1+j]*kRt[1+j]*kRt[1+j])));
end;
end;
for i:=1 to n do begin
//----------------------------------Çíà÷åíèÿ
ô. ïðèíàäëåæíîñòè äëÿ Ñt
if Cto[i]<=((kCt[2]+kCt[3])/2) then mCt[1,i]:=0;
if
(Cto[i]>((kCt[2]+kCt[3])/2)) and (Cto[i]<kCt[3]) then
mCt[1,i]:=(2*Cto[i]-kCt[2]-kCt[3])/(kCt[3]-kCt[2]);
if Cto[i]>=kCt[3] then mCt[1,i]:=1;
if (Cto[i]<=((kCt[1]+kCt[2])/2)) or (Cto[i]>=((kCt[3]+1)/2)) then
mCt[2,i]:=0;
if (Cto[i]>((kCt[1]+kCt[2])/2)) and (Cto[i]<((kCt[2]+kCt[3])/2)) then
mCt[2,i]:=(2*Cto[i]-kCt[1]-kCt[2])/(kCt[3]-kCt[1]);
if (Cto[i]>=((kCt[2]+kCt[3])/2)) and (Cto[i]<=((kCt[3]+1)/2)) then
mCt[2,i]:=1-((2*Cto[i]-kCt[2]-kCt[3])/(1-kCt[2]));
if (Cto[i]<=(kCt[1]/2)) or (Cto[i]>((kCt[2]+kCt[3])/2)) then mCt[3,i]:=0;
if (Cto[i]>(kCt[1]/2)) and (Cto[i]<((kCt[1]+kCt[2])/2)) then
mCt[3,i]:=(2*Cto[i]-kCt[1])/(kCt[2]);
if (Cto[i]>=((kCt[1]+kCt[2])/2)) and (Cto[i]<=((kCt[2]+kCt[3])/2)) then
mCt[3,i]:=1-(2*Cto[i]-kCt[1]-kCt[2])/(kCt[3]-kCt[1]);
if Cto[i]>=((kCt[1]+kCt[2])/2) then mCt[4,i]:=0;
if (Cto[i]<((kCt[1]+kCt[2])/2)) and (Cto[i]>kCt[1]) then mCt[4,i]:=1-(2*(Cto[i]-kCt[1])/(kCt[2]-kCt[1]));
if Cto[i]<=kCt[1] then mCt[4,i]:=1;
//----------------------------------Çíà÷åíèÿ
ô. ïðèíàäëåæíîñòè äëÿ Rt
if Rto[i]<=((kRt[2]+kRt[3])/2) then mRt[1,i]:=0;
if
(Rto[i]>((kRt[2]+kRt[3])/2)) and (Rto[i]<kRt[3]) then
mRt[1,i]:=(2*Rto[i]-kRt[2]-kRt[3])/(kRt[3]-kRt[2]);
if Rto[i]>=kRt[3] then mRt[1,i]:=1;
if (Rto[i]<=((kRt[1]+kRt[2])/2)) or (Rto[i]>=((kRt[3]+1)/2)) then
mRt[2,i]:=0;
if (Rto[i]>((kRt[1]+kRt[2])/2)) and (Rto[i]<((kRt[2]+kRt[3])/2)) then
mRt[2,i]:=(2*Rto[i]-kRt[1]-kRt[2])/(kRt[3]-kRt[1]);
if (Rto[i]>=((kRt[2]+kRt[3])/2)) and (Rto[i]<=((kRt[3]+1)/2)) then
mRt[2,i]:=1-((2*Rto[i]-kRt[2]-kRt[3])/(1-kRt[2]));
if (Rto[i]<=(kRt[1]/2)) or (Rto[i]>=((kRt[2]+kRt[3])/2)) then
mRt[3,i]:=0;
if (Rto[i]>=(kRt[1]/2)) and (Rto[i]<((kRt[1]+kRt[2])/2)) then
mRt[3,i]:=(2*Rto[i]-kRt[1])/(kRt[2]);
if (Rto[i]>=((kRt[1]+kRt[2])/2)) and (Rto[i]<((kRt[2]+kRt[3])/2)) then
mRt[3,i]:=1-((2*Rto[i]-kRt[1]-kRt[2])/(kRt[3]-kRt[1]));
if Rto[i]>=((kRt[1]+kRt[2])/2) then mRt[4,i]:=0;
if (Rto[i]<((kRt[1]+kRt[2])/2)) and (Rto[i]>kRt[1]) then
mRt[4,i]:=1-(2*(Rto[i]-kRt[1])/(kRt[2]-kRt[1]));
if Rto[i]<=kRt[1] then mRt[4,i]:=1;
//----------------------------------Çíà÷åíèÿ
ô. ïðèíàäëåæíîñòè äëÿ Vt
if Vt[i]<=((kVt[2]+kVt[3])/2) then mVt[4,i]:=0;
if
(Vt[i]>((kVt[2]+kVt[3])/2)) and (Vt[i]<kVt[3]) then
mVt[4,i]:=(2*Vt[i]-kVt[2]-kVt[3])/(kVt[3]-kVt[2]);
if Vt[i]>=kVt[3] then mVt[4,i]:=1;
if (Vt[i]<=((kVt[1]+kVt[2])/2)) or (Vt[i]>=((kVt[3]+1)/2)) then
mVt[3,i]:=0;
if (Vt[i]>((kVt[1]+kVt[2])/2)) and (Vt[i]<((kVt[2]+kVt[3])/2)) then
mVt[3,i]:=(2*Vt[i]-kVt[1]-kVt[2])/(kVt[3]-kVt[1]);
if (Vt[i]<((kVt[3]+1)/2)) and (Vt[i]>((kVt[2]+kVt[3])/2)) then
mVt[3,i]:=1-((2*Vt[i]-kVt[2]-kVt[3])/(1-kVt[2]));
if (Vt[i]<=(kVt[1]/2)) or (Vt[i]>=((kVt[2]+kVt[3])/2)) then mVt[2,i]:=0;
if (Vt[i]>(kVt[1]/2)) and (Vt[i]<((kVt[1]+kVt[2])/2)) then mVt[2,i]:=(2*Vt[i]-kVt[1])/(kVt[2]);
if (Vt[i]>=((kVt[1]+kVt[2])/2)) and (Vt[i]<=((kVt[2]+kVt[3])/2)) then
mVt[2,i]:=1-((2*Vt[i]-kVt[1]-kVt[2])/(kVt[3]-kVt[1]));
if Vt[i]>=((kVt[1]+kVt[2])/2) then mVt[1,i]:=0;
if (Vt[i]<((kVt[1]+kVt[2])/2)) and (Vt[i]>kVt[1]) then
mVt[1,i]:=1-(2*(Vt[i]-kVt[1])/(kVt[2]-kVt[1]));
if Vt[i]<=kVt[1] then mVt[1,i]:=1;
end;
//-----------------------------Âûâîä çíà÷åíèé
For i:=1 to n do begin
str:='('+FloatToStrF(Ct[1,i],ffFixed,9,2)+'; '+FloatToStrF(Ct[2,i],ffFixed,9,2)+')';
Form3.StringGrid1.Cells[1,i]:=str;
Form3.StringGrid1.Cells[4,i]:=FloatToStrF(Vt[i],ffFixed,9,2);
str:='('+FloatToStrF(NPVvar[1,i],ffFixed,9,2)+';
'+FloatToStrF(NPVvar[2,i],ffFixed,9,2)+'; '+FloatToStrF(NPVvar[3,i],ffFixed,9,2)+')';
Form3.StringGrid1.Cells[2,i]:=str;
str:='('+FloatToStrF(Rt[1,i],ffFixed,9,2)+';
'+FloatToStrF(Rt[2,i],ffFixed,9,2)+'; '+FloatToStrF(Rt[3,i],ffFixed,9,2)+')';
Form3.StringGrid1.Cells[3,i]:=str;
end;
for j:=1 to n do begin
//
Form3.StringGrid2.Cells[1,j]:=FloatToStr(Cto[j]);
//
Form3.StringGrid2.Cells[2,j]:=FloatToStr(Rto[j]);
k:=1; ii:=1;iv:=1;
for i:=2 to 4 do begin
if mCt[i-1,j]<mCt[i,j] then k:=i;
if mRt[i-1,j]<mRt[i,j] then ii:=i;
if mVt[i-1,j]<mVt[i,j] then iv:=i;
end;
if k=1 then Form3.StringGrid2.Cells[1,j]:=FloatToStrF(mCt[k,j],ffFixed,9,2)+'-ìèíèìàëüíûé';
if k=2 then Form3.StringGrid2.Cells[1,j]:=FloatToStrF(mCt[k,j],ffFixed,9,2)+'-ïîâûøåííûé';
if k=3 then Form3.StringGrid2.Cells[1,j]:=FloatToStrF(mCt[k,j],ffFixed,9,2)+'-êðèòè÷åñêèé';
if k=4 then Form3.StringGrid2.Cells[1,j]:=FloatToStrF(mCt[k,j],ffFixed,9,2)+'-íåäîïóñòèìûé';
if ii=1 then
Form3.StringGrid2.Cells[2,j]:=FloatToStrF(mRt[ii,j],ffFixed,9,2)+'-ìèíèìàëüíûé';
if ii=2 then
Form3.StringGrid2.Cells[2,j]:=FloatToStrF(mRt[ii,j],ffFixed,9,2)+'-ïîâûøåííûé';
if ii=3 then
Form3.StringGrid2.Cells[2,j]:=FloatToStrF(mRt[ii,j],ffFixed,9,2)+'-êðèòè÷åñêèé';
if ii=4 then
Form3.StringGrid2.Cells[2,j]:=FloatToStrF(mRt[ii,j],ffFixed,9,2)+'-íåäîïóñòèìûé';
if iv=1 then Form3.StringGrid2.Cells[3,j]:=FloatToStrF(mVt[iv,j],ffFixed,9,2)+'-ìèíèìàëüíûé';
if iv=2 then
Form3.StringGrid2.Cells[3,j]:=FloatToStrF(mVt[iv,j],ffFixed,9,2)+'-ïîâûøåííûé';
if iv=3 then
Form3.StringGrid2.Cells[3,j]:=FloatToStrF(mVt[iv,j],ffFixed,9,2)+'-êðèòè÷åñêèé';
if iv=4 then Form3.StringGrid2.Cells[3,j]:=FloatToStrF(mVt[iv,j],ffFixed,9,2)+'-íåäîïóñòèìûé';
Ñòðàíèöû: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
|