Решение задач оптимизации симплекс-методомРефераты >> Программирование и компьютеры >> Решение задач оптимизации симплекс-методом
4.3.Листинг
unit SimplexM;
interface
uses
Windows, Messages, SysUtils, Classes, Controls, ExtCtrls,StdCtrls,Grids,
Buttons,Chart, Dialogs;
type
TSimplexM = class(TCustomPanel)
private
FStrGr: TStringGrid;
FLabel1,
FLabel2: TLabel;
FBitBtn1,
FBitBtn2,
FBitBtn3,
FBitBtn4,
FBitBtn5: TBitBtn;
FColX: Integer;
FGroupBox: TGroupBox;
FBottomPanel,
FRightPanel,
FCenterPanel: TPanel;
FRadioButton1,
FRadioButton2: TRadioButton;
maxRow, maxCol, NumMinCol: integer;
Data: array of TStrings;
procedure SetColX (Value: integer);
procedure SGColRow;
{ Private declarations }
procedure Main(var flag: boolean; MaxRow: integer);
function Res(var NumMinCol:integer): boolean;
procedure Resultat(flag: boolean);
procedure MinPlusDate(var Answ: boolean; xov, NumMinCol: integer; var ColSet, RowSet: integer; var date:real);
procedure InputData(var xov, MaxRow: integer);
procedure Name0Str(xov: integer);
procedure Name0Col(xov: integer);
procedure divizion(NumMinCol: integer);
procedure Adding (RowSet, ColSet, Maxcol, MaxRow, NumMinCol:integer);
procedure SaveData;
procedure LoadData;
protected
{ Protected declarations }
FOnBitBtn1Click, FOnBitBtn2Click, FOnBitBtn3Click: TNotifyEvent;
procedure SetBitBtnClick(Sender: TObject);
procedure SetBitBtn4Click(Sender: TObject);
procedure SetBitBtn5Click(Sender: TObject);
public
constructor Create(AOwner: TComponent); override;
{ Public declarations }
published
{ Published declarations }
property Color;
property Caption;
property Align;
property Height;
property ColX: Integer read FColX write SetColX;
property StrGr: TStringGrid read FStrGr write FStrGr;
property Label1: TLabel read FLabel1 write FLabel1;
property Label2: TLabel read FLabel2 write FLabel2;
property BitBtn1: TBitBtn read FBitBtn1 write FBitBtn1;
property BitBtn2: TBitBtn read FBitBtn2 write FBitBtn2;
property BitBtn3: TBitBtn read FBitBtn3 write FBitBtn3;
property RadioButton1: TRadioButton read FRadioButton1 write FRadioButton1;
property RadioButton2: TRadioButton read FRadioButton2 write FRadioButton2;
property OnBitBtn1Click: TNotifyEvent read FOnBitBtn1Click
write FOnBitBtn1Click;
property OnBitBtn2Click: TNotifyEvent read FOnBitBtn2Click
write FOnBitBtn2Click;
property OnBitBtn3Click: TNotifyEvent read FOnBitBtn3Click
write FOnBitBtn3Click;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Probnic', [TSimplexM]);
end;
{ TSimplexTab }
constructor TSimplexM.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FCenterPanel := TPanel.Create(Self);
FCenterPanel.Align := alClient;
FCenterPanel.Parent := Self;
FStrGr := TSTringGrid.Create(Self);
with FStrGr do
begin
Parent := FCenterPanel;
Align := alClient;
Options := [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine,
goRangeSelect, GoEditing];
Left := 8;
Top := 8;
Width := 473;
Height := 105;
ColCount := 6;
RowCount := 4;
Cells[0,0] := 'Базис';
Cells[1,0] := 'Св.чл.';
Font.Name := 'Comic Sans MS';
end;
FRightPanel := TPanel.Create(Self);
with FRightPanel do
begin
Parent := Self;
Left := 511;
Top := 1;
Width := 89;
Height := 463;
Align := alRight;
end;
FBottomPanel := TPanel.Create(Self);
with FBottomPanel do
begin
Parent := Self;
Left := 1;
Top := 464;
Width := 599;
Height := 40;
Align := alBottom;
end;
FLabel1 := TLabel.Create(Self);
with FLabel1 do
begin
Parent := FBottomPanel;
Caption := ‘Оптимальное значение функции:';
Left := 8;
Top := 5;
Height := 13;
Anchors := [akLeft, akBottom];
end;
FLabel2 := TLabel.Create(Self);
with FLabel2 do
begin
Parent := FBottomPanel;
Left := 300;
Top := 5;
Height := 13;
Anchors := [akBottom];
Caption:= '';
end;
FBitBtn1 := TBitBtn.Create(Self);
with FBitBtn1 do
begin
Parent := FRightPanel;
Left := 5;
Top := 16;
Width := 81;
Height := 25;
Anchors := [akTop, akRight];
Kind := bkOk;
Caption := '&Вычислить';
OnClick := SetBitBtnClick;
end;
FBitBtn2 := TBitBtn.Create(Self);
with FBitBtn2 do
begin
Parent := FBottomPanel;
Left := 512;
Top := 5;
Width := 81;
Height := 25;
Anchors := [akRight, akBottom];
Kind := bkClose;
Caption := '&Выход';
TabOrder := 2;
end;
FBitBtn3 := TBitBtn.Create(Self);
with FBitBtn3 do
begin
Parent := FRightPanel;
Left := 5;
Top := 123;
Width := 81;
Height := 25;
Anchors := [akRight, akTop];
Kind := bkRetry;
Caption := '&Очистить';
TabOrder := 2;
OnClick := SetBitBtnClick;
end;
FBitBtn4 := TBitBtn.Create(Self);
with FBitBtn4 do
begin
Parent := FRightPanel;
Left := 5;
Top := 155;
Width := 81;
Height := 25;
Anchors := [akRight, akTop];
Caption := '&Сохранить';
OnClick := SetBitBtn4Click;
end;
FBitBtn5 := TBitBtn.Create(Self);
with FBitBtn5 do
begin
Parent := FRightPanel;
Left := 5;
Top := 182;
Width := 81;
Height := 25;
Anchors := [akRight, akTop];
Caption := '&Читать';
OnClick := SetBitBtn5Click;
end;
FGroupBox := TGroupBox.Create(Self);
with FGroupBox do
begin
Parent := FRightPanel;
Left := 5;
Top := 48;
Width := 81;
Height := 65;
Anchors := [akTop, akRight];
Caption := ' Найти ';
end;
FRadioButton1 := TRadioButton.Create(Self);
with FRadioButton1 do
begin
Parent := FGroupBox;
Caption := 'Min';
Left := 3;
Top := 15;
Width := 60;
Checked := True;
end;
FRadioButton2 := TRadioButton.Create(Self);
with FRadioButton2 do
begin
Parent := FGroupBox;
Caption := 'Max';
Left := 3;
Top := 35;
Width := 60;
end;
Height := 255;
Width := 490;
Constraints.MinHeight := 235;
Constraints.MinWidth := 490;
FColX := 2;
end;
procedure TSimplexM.SetBitBtnClick(Sender: TObject);
var
flag: boolean;
i, j: integer;
begin
if Sender = FBitBtn1 then
begin
if Assigned(FOnBitBtn1Click) then FOnBitBtn1Click(Sender)