⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.pas

📁 很好运筹学的DEOPHI原代码.包括动态规划,原始单纯形法,对策论,决策论等
💻 PAS
字号:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, StdCtrls, Buttons, ExtCtrls;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Label1: TLabel;
    Panel2: TPanel;
    Label2: TLabel;
    Edit1: TEdit;
    Label3: TLabel;
    Edit2: TEdit;
    Label4: TLabel;
    BitBtn1: TBitBtn;
    Label5: TLabel;
    Label6: TLabel;
    StringGrid1: TStringGrid;
    BitBtn2: TBitBtn;
    BitBtn3: TBitBtn;
    Panel3: TPanel;
    StringGrid2: TStringGrid;
    StringGrid3: TStringGrid;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label11: TLabel;
    Memo1: TMemo;
    StringGrid4: TStringGrid;
    StringGrid5: TStringGrid;
    Edit3: TEdit;
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
type array2=array[1..99,1..99] of real;  //声明一个二维实型的数组类型
type array1=array[1..99] of real;        //声明一个一维实型的数组类型
//type array10=array[1..99] of integer;    //声明一个一维整型的数组类型
var
  Form1: TForm1;
  m,n,p1,p2,p3:integer;
  a:array2;  //a为二维实型的数组类型变量
  c,jia,erji,yiji:array1;  //c为一维实型的数组类型变量
//  d:array10; //d为一维整型的数组类型变量
implementation

{$R *.dfm}

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
  m:=strtoint(edit1.text);
  n:=strtoint(edit2.Text);
  stringgrid1.rowCount:=m+1;  //stringgrid1控件的行数(包括固定行)
  stringgrid1.ColCount:=n+2;  //stringgrid1控件的列数(包括固定列)
  stringgrid2.ColCount:=m+1;  //stringgrid1控件的列数(包括固定列)
  stringgrid3.ColCount:=n+1;  //stringgrid1控件的列数(包括固定列)
  stringgrid4.ColCount:=n+1;  //stringgrid1控件的列数(包括固定列)
  stringgrid5.ColCount:=3;  //stringgrid1控件的列数(包括固定列)
end;

procedure TForm1.BitBtn2Click(Sender: TObject);
var
  i,j:integer;
begin
  for i:=1 to m  do
    begin
      for j:=1 to n+1 do
        a[i,j]:=strtofloat(stringgrid1.cells[j,i]);
               //将stringgrid中所输入的矩阵数据映射到二维熟组中
    end;
  for j:=1 to m do
    jia[j]:=strtofloat(stringgrid2.Cells[j,1]);
  for j:=1 to n do
    c[j]:=strtofloat(stringgrid3.Cells[j,1]);
end;

procedure TForm1.BitBtn3Click(Sender: TObject);
var
  temp:array1;
  i,j:integer;
begin
  p1:=1;
  p2:=1;
  p3:=1;
  for j:=1 to n+1 do
  begin
    temp[j]:=0;
    for i:=1 to m do
      temp[j]:=temp[j]+a[i,j]*jia[i];
  end;

  erji[1]:=temp[1];
  erji[2]:=temp[2];
  erji[3]:=temp[1];
  erji[4]:=temp[4];
  if temp[3]>temp[2] then
  begin
    erji[2]:=temp[3];
    p2:=2;
  end;
  if temp[5]>temp[4] then
  begin
    erji[4]:=temp[5];
    p3:=2;
  end;
  for j:=1 to n do
    stringgrid4.Cells[j,1]:=floattostr(erji[j]);

  yiji[1]:=erji[1]*c[1]+erji[2]*c[2];
  yiji[2]:=erji[3]*c[3]+erji[4]*c[4];
  stringgrid5.Cells[1,1]:=floattostr(yiji[1]);
  stringgrid5.Cells[2,1]:=floattostr(yiji[2]);
  if yiji[2]>yiji[1] then p1:=2;
  if p1=1 then edit3.Text:='A1='+floattostr(yiji[1])
  else edit3.Text:='A2='+floattostr(yiji[2]);

  case p1*10+p2 of
    11:memo1.Text:='决策方案为A1,即购买专利,成功后采取产量不变的方案。能获得利益'+floattostr(yiji[1]*100)+'万元,这是最优的改革方案.';
    12:memo1.Text:='决策方案为A1,即购买专利,成功后采取增加产量的方案。能获得利益'+floattostr(yiji[1]*100)+'万元,这是最优的改革方案.';
    21:memo1.Text:='决策方案为A2,即自行研究,成功后采取产量不变的方案。能获得利益'+floattostr(yiji[2]*100)+'万元,这是最优的改革方案.';
    22:memo1.Text:='决策方案为A2,即自行研究,成功后采取增加产量的方案。能获得利益'+floattostr(yiji[2]*100)+'万元,这是最优的改革方案.';
  end;

end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -