📄 pert2.pas
字号:
unit Pert2;
interface
uses
Windows, Messages, SysUtils, Variants, ClasSEs, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Buttons, Grids;
type
TForm1 = class(TForm)
Panel2: TPanel;
Label1: TLabel;
Edit1: TEdit;
BitBTN1: TBitBTN;
BitBTN3: TBitBTN;
CheckBox1: TCheckBox;
Panel3: TPanel;
Panel1: TPanel;
BitBtn2: TBitBtn;
BitBtn4: TBitBtn;
StringGrid1: TStringGrid;
Label2: TLabel;
Label3: TLabel;
StringGrid2: TStringGrid;
StringGrid3: TStringGrid;
Label4: TLabel;
Label5: TLabel;
procedure BitBTN1Click(SEnder: TObject);
procedure BitBTN3Click(SEnder: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn4Click(Sender: TObject);
privaTE
{ PrivaTE declarations }
public
{ Public declarations }
end;
type array2=array[1..99,1..99] of real; //声明的数组类型数据:二维数组
var
Form1: TForm1;
implementation
var CheckBox:array of array of TCheckBox;
var edt,edit:array of array of TEdit;
var CC:array[1..99,1..99]of Integer;
var szhs,FJJG,FF:array[1..99]of real;
//var szhs:array of integer;
var T,k,N,hangshu,hangshu1,hangshu2:InTEger;
{$R *.dfm}
procedure TForm1.BitBTN1Click(SEnder: TObject);
var i,j:inTEger;
begin
//创建事件名称输入编辑框
if edit<>nil then
for i:=0 to hangshu1-1 do
for j:=0 to 0 do
edit[i,j].Free;
hangshu1:=StrToInt(Edit1.TExt);
SETLength(edit,hangshu1);
for i:=low(edit) to high(edit) do
SETLength(edit[i],1);
for i:=low(edit) to high(edit) do
for j:=0 to 0 do
begin
edit[i,j]:=TEdit.CreaTE(SElf);
with edit[i,j] do
begin
Parent:=Panel1;
Width:=25;
Height:=25;
left:=40+j*40;
top:=65+i*40;
end;
end;
//创建紧前事件自动生成编辑框
if edt<>nil then
for j:=0 to hangshu2-1 do
edt[0,j].Free;
hangshu2:=StrToInt(Edit1.TExt);
SETLength(edt,hangshu2);
for J:=low(edt) to high(edt) do
SETLength(edt[J],hangshu2);
for j:=low(edt) to high(edt) do
begin
edt[0,j]:=TEdit.CreaTE(SElf);
with edt[0,j] do
begin
Parent:=Panel1;
Width:=25;
Height:=25;
left:=85+j*40;
top:=30;
end;
end;
//创建紧前工作人工选择输入框
if CheckBox<>nil then
for i:=0 to hangshu-1 do
for j:=0 to hangshu-1 do
CheckBox[i,j].Free;
hangshu:=StrToInt(Edit1.TExt);
SETLength(CheckBox,hangshu);
for i:=low(CheckBox) to high(CheckBox) do
SETLength(CheckBox[i],hangshu);
for i:=low(CheckBox) to high(CheckBox) do
for j:=0 to hangshu-1 do
begin
CheckBox[i,j]:=TCheckBox.CreaTE(SElf);
with CheckBox[i,j] do
begin
Parent:=Panel1;
left:=90+j*40;
top:=70+i*40;
end;
end;
label5.Caption:='在'+#13+'第'+#13+'一'+#13+'列'+#13+'输'+#13+'入'+#13+'工'+#13+'序'+#13+'名'+#13+'称';
end;
procedure TForm1.BitBTN3Click(SEnder: TObject);
begin
cloSE;
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
var i,j:inTEger;
label 1;
begin
for i:=0 to hangshu-1 do
edt[0,I].TExt:=edit[i,0].TExt;
label2.Caption:='紧前逻辑矩阵';
label3.Caption:='紧后逻辑矩阵';
label4.Caption:='工序分级结果';
n:=strtoint(edit1.Text); //n为变量的个数.它比对策矩阵的行数(或列数)多1
stringgrid1.RowCount:=n+1;
stringgrid1.ColCount:=n+1;
stringgrid2.RowCount:=n+1;
stringgrid2.ColCount:=n+1;
stringgrid3.RowCount:=n+1;
stringgrid3.ColCount:=n+1;
for i:=1 to n do
begin
stringgrid1.Cells[0,i]:=edt[0,I-1].TExt;
stringgrid1.Cells[i,0]:=edit[i-1,0].TExt;
stringgrid2.Cells[0,i]:=edt[0,I-1].TExt;
stringgrid2.Cells[i,0]:=edit[i-1,0].TExt;
end;
//生成紧前逻辑矩阵
for i:=1 to n do
for j:=1 to n do
begin
if CheckBox[i-1,j-1].Checked then
stringgrid1.Cells[J,I]:='1'
else stringgrid1.Cells[J,I]:='0';
end;
//生成紧后逻辑矩阵
for i:=1 to n do
for j:=1 to n do
begin
if CheckBox[i-1,j-1].Checked then
stringgrid2.Cells[i,j]:='1'
else stringgrid2.Cells[i,j]:='0';
end;
//计算分级过程
//第一步找0级事件
for i:=1 to n do
for j:=1 to n do
if CheckBox[i-1,j-1].Checked then
CC[j,i]:=1
else CC[j,i]:=0;
for i:=1 to n do
begin
FJJG[i]:=0;
for j:=1 to n do
if CC[j,i]=1 then FJJG[i]:=-1;
end;
//任一目工序的紧后作业,其级次比该目标作业增加1级。
1: i:=1;
while i<n+1 do
begin
for j:=1 to n do
if (CC[j,i]=1) and (FJJG[j]>=FJJG[i]) then
FJJG[i]:=FJJG[j]+1;
i:=i+1;
end;
for i:=1 to n do
for j:=1 to n do
if (CC[j,i]=1) and ((FJJG[j]=-1) or (FJJG[j]>=FJJG[i])) then
goto 1;
for i:=1 to n do
begin
stringgrid3.cells[i,0]:=edt[0,I-1].TExt;
stringgrid3.Cells[0,1]:='分级结果';
stringgrid3.Cells[i,1]:=floattostr(FJJG[i]);
end;
stringgrid3.refresh;
end;
procedure TForm1.BitBtn4Click(Sender: TObject);
var i:inTEger;
begin
for i:=0 to hangshu-1 do
edt[0,I].TExt:=edit[i,0].TExt;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -