end;
if keyw=true then begin
// --------------------------------вычисление мат. ож. NPV
ENPV:=0;
For i:=1 to n do begin NPV:=0;
For j:=1 to i do begin
NPV:=NPV+Sij[j];
end;
NPV:=NPV/i;s:=1;
for j:=1 to i do begin s:=s*d;end;
ENPV:=ENPV+(NPV/s);
end;
ENPV:=ENPV-Ip;
//----------------------------------вычисление критерия покрытия Ct
For i:=1 to n do begin
if Zt[i]<>0 then Ct[i]:=At[i]/Zt[i] else Ct[i]:=0;
end;
For i:=0 to Form2.StringGrid1.ColCount-1 do begin
Form2.StringGrid1.ColWidths[i]:=Form2.Header1.SectionWidth[i]-1;
end;
//-----------------------------------вычисление критерия ликвидности Rt в том числе
//-----------------------------------и NPVt
NPV:=0;s:=d;
For i:=1 to n do begin
For j:=1 to i-1 do begin s:=s*d;end;
NPV:=NPV+(Simd[i]/s); s:=d;
end;
NPV:=NPV-Ip; // прогнозное NPV
For i:=1 to n-1 do begin
NPVi:=0;NPVj:=0;s:=d;
for j:=1 to i do begin
For l:=1 to j-1 do begin s:=s*d; end;
NPVi:=NPVi+(Sij[j]/s);s:=d; //то NPV, которое получаем по имеющ. данным
end;
s:=d;
for j:=i+1 to n do begin
For l:=1 to j-1 do begin s:=s*d; end;
NPVj:=NPVj+(Simd[j]/s);s:=d;
end;
NPVj:=NPVj-Ip; //то, что осталось от прогногзного NPV
Rt[i]:=(NPVi+NPVj)/NPV;
Form2.StringGrid1.Cells[2,i-1]:=FloatToStr(NPVi);
end;
NPVi:=0;s:=d;
for i:=1 to n do begin
For l:=1 to i-1 do begin s:=s*d; end;
NPVi:=NPVi+(Sij[i]/s);s:=d;
end;
Rt[n]:=NPVi/NPV;Form2.StringGrid1.Cells[2,n-1]:=FloatToStr(NPVi);
Form2.StringGrid1.RowCount:=n;
For i:=0 to n-1 do begin
Form2.StringGrid1.Cells[0,i]:=IntToStr(i+1);
Form2.StringGrid1.Cells[1,i]:=FloatToStr(Ct[i+1]);
Form2.StringGrid1.Cells[3,i]:=FloatToStr(Rt[i+1])
end;
Form2.Memo1.Lines.Clear;
Form2.Memo1.Lines.Add('E(NPV) = ' + FloatToStr(ENPV) + ';');
// Оценка общего риска проекта
For j:=1 to f do begin
Pfsr:=0;
For i:=1 to n do begin
Pfsr:=Pfsr+Pf[i,j];
end;
Pfsr:=Pfsr/n;
if Pfsr>Pkrit[j] then
Form2.Memo1.Lines.Add('Покупка ' + IntToStr(j) + '-го ресурса невыгодна');
end;
for i:=1 to n do begin
sum:=0;s:=1;
For j:=1 to i do begin
For l:=1 to 2*j do begin s:=s*d; end;
sum:=sum+(Covar[j,j]/s);s:=1;
end;
sum2:=0;sum3:=0;
for l:=1 to i-1 do begin
for j:=l+1 to i do begin
s:=1;
For ii:=1 to l+j do begin s:=s*d; end;
sum2:=sum2+(Covar[l,j]/s);
end;
end;
for l:=1 to i do begin
for j:=1 to i do begin
sum3:=sum3+(Xf[l]*Xf[j]*PCovar[l,j])
end;
end;
Vt[i]:=sum+(2*sum2)+sum3;
form2.StringGrid1.Cells[4,i-1]:=FloatToStr(Vt[i]);
end;
Form2.Show;
end;
end;
procedure TForm8.N4Click(Sender: TObject);
Var
Myfile : Textfile;
Date : String;
begin
If (OpenDialog1.Execute) then begin
AssignFile(Myfile,Opendialog1.FileName);
Try Reset(myFile);
Except
Showmessage('Ошибка при чтении файла!'); Exit;
end;
With Form1 do begin
ReadLn(MyFile,Date);SpinEdit1.Value:=StrToInt(Date);n:=StrToInt(Date);
ReadLn(MyFile,Date);SpinEdit2.Value:=StrToInt(Date);f:=StrToInt(Date);
ReadLn(MyFile,Date);Edit1.Text:=Date;d:=StrToFloat(Date);
ReadLn(MyFile,Date);Edit2.Text:=Date;Ip:=StrToFloat(Date);
For i:=0 to n-1 do begin
ReadLn(MyFile,Date);
StringGrid1.Cells[i,1]:=Date;
end;
For i:=0 to n-1 do begin
ReadLn(MyFile,Date);
StringGrid2.Cells[i,1]:=Date;
End;
For i:=0 to n-1 do begin
ReadLn(MyFile,Date);
StringGrid3.Cells[i,1]:=Date;
End;
For i:=0 to n-1 do begin
ReadLn(MyFile,Date);
StringGrid4.Cells[i,1]:=Date;
End;
For i:=0 to f-1 do begin
ReadLn(MyFile,Date);
StringGrid6.Cells[i,1]:=Date;
End;
For i:=1 to n do begin
For j:=1 to f do begin
ReadLn(MyFile,Date);
StringGrid7.Cells[i,j]:=Date;
end;
end;
For i:=0 to f-1 do begin
ReadLn(MyFile,Date);
StringGrid8.Cells[i,1]:=Date;
End;
end;
With Form3 do begin
For i:=1 to n do begin
For j:=1 to n do begin
ReadLn(MyFile,Date);
StringGrid1.Cells[i,j]:=Date;
end;
End;
BitBtn1Click(Sender);
end;
With Form4 do begin
For i:=1 to n do begin
For j:=1 to n do begin
ReadLn(MyFile,Date);
StringGrid1.Cells[i,j]:=Date;
end;
End;
BitBtn1Click(Sender);
end;
Closefile(myFile);
end
else Begin Showmessage('Файл не найден!'); Exit;end;
end;
procedure TForm8.N5Click(Sender: TObject);
Var
Myfile : Textfile;
Date : String;
begin
If (saveDialog1.Execute) then begin
AssignFile(Myfile,Savedialog1.FileName);
Try Rewrite(myFile);
Except
Showmessage('Ошибка при чтении файла!'); Exit;
end;
With Form8 do begin
Date:=IntToStr(SpinEdit1.Value);WriteLn(MyFile,Date);
Date:=IntToStr(SpinEdit2.Value);WriteLn(MyFile,Date);
Date:=Edit1.Text;WriteLn(MyFile,Date);
Date:=Edit2.Text;WriteLn(MyFile,Date);
For i:=0 to n-1 do begin
Date:=StringGrid1.Cells[i,1];
WriteLn(Myfile,Date);
end;
For i:=0 to n-1 do begin
Date:=StringGrid2.Cells[i,1];
WriteLn(Myfile,Date);
End;
For i:=0 to n-1 do begin
Date:=StringGrid3.Cells[i,1];
WriteLn(Myfile,Date);
End;
For i:=0 to n-1 do begin
Date:=StringGrid4.Cells[i,1];
WriteLn(Myfile,Date);
End;
{For i:=0 to n-1 do begin
Date:=StringGrid5.Cells[i,1];
WriteLn(Myfile,Date);
End; }
For i:=0 to f-1 do begin
Date:=StringGrid6.Cells[i,1];
WriteLn(Myfile,Date);
End;
For i:=1 to n do begin
for j:=1 to f do begin
Date:=StringGrid7.Cells[i,j];
WriteLn(Myfile,Date);
end;
end;
For i:=0 to f-1 do begin
Date:=StringGrid8.Cells[i,1];
WriteLn(Myfile,Date);
End;
end;
With Form3 do begin
For i:=1 to n do begin
For j:=1 to n do begin
Date:=StringGrid1.Cells[i,j];
WriteLn(Myfile,Date);
end;
end;
end;
With Form4 do begin
For i:=1 to n do begin
For j:=1 to n do begin
Date:=StringGrid1.Cells[i,j];
WriteLn(Myfile,Date);
end;
end;
end;
Closefile(myFile);
end
else Begin Showmessage('Ошибка!'); Exit;end;
end;
procedure TForm8.N9Click(Sender: TObject);
begin
Form7.show;
end;
procedure TForm8.CheckBox2Click(Sender: TObject);
begin
if checkBox2.Checked then Form3.Showmodal;
end;
procedure TForm8.StringGrid1KeyPress(Sender: TObject; var Key: Char);
begin
Case key of
chr(48),chr(49),chr(50),chr(51),chr(52),chr(53),chr(54), chr(55),chr(56),chr(57),chr(44):;
else key:=chr(0);end;
end;
procedure TForm8.StringGrid2KeyPress(Sender: TObject; var Key: Char);
begin
Case key of
chr(48),chr(49),chr(50),chr(51),chr(52),chr(53),chr(54), chr(55),chr(56),chr(57),chr(44):;
else key:=chr(0); end;
end;
procedure TForm8.StringGrid3KeyPress(Sender: TObject; var Key: Char);
begin
Case key of
chr(48),chr(49),chr(50),chr(51),chr(52),chr(53),chr(54), chr(55),chr(56),chr(57),chr(44):;
else key:=chr(0); end;
end;
procedure TForm8.StringGrid4KeyPress(Sender: TObject; var Key: Char);
begin
Case key of
chr(48),chr(49),chr(50),chr(51),chr(52),chr(53),chr(54), chr(55),chr(56),chr(57),chr(44),chr(45):;
else key:=chr(0); end;
end;
procedure TForm8.StringGrid6KeyPress(Sender: TObject; var Key: Char);
begin
Case key of
chr(48),chr(49),chr(50),chr(51),chr(52),chr(53),chr(54), chr(55),chr(56),chr(57),chr(44):;
else key:=chr(0); end;
end;
procedure TForm8.StringGrid7KeyPress(Sender: TObject; var Key: Char);
begin
Case key of
chr(48),chr(49),chr(50),chr(51),chr(52),chr(53),chr(54), chr(55),chr(56),chr(57),chr(44):;
else key:=chr(0);end;
end;
procedure TForm8.StringGrid8KeyPress(Sender: TObject; var Key: Char);
begin
Страницы: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25