- •Комплексная курсовая работа
- •Содержание
- •Введение
- •Сущность математического метода
- •1 Характеристика метода перевозки неоднородного груза
- •Аналитическое решение задачи перевозки неоднородного груза
- •Анализ и уточнение требований к программе
- •Анализ процесса обработки информации и выбор структур данных для ее хранения
- •Разработка основных алгоритмов решения задачи
- •Проектирование интерфейса пользователя
- •Граф состояния интерфейса
- •Формы ввода-вывода информации
- •Контрольный пример
- •Список литературы
- •Приложение а
Список литературы
1. А.В.Кузнецов, Г.И.Новикова, И.И.Холод – «Сборник задач по математическому программированию». Минск, Высшая школа, 1985г.
2. А.В.Кузнецов, Г.И.Новикова, И.И.Холод – «Высшая математика. Математическое программирование». Минск, Высшая школа, 2001г.
Приложение а
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, Menus;
type
TForm1 = class(TForm)
Button1: TButton;
Button3: TButton;
ka11: TEdit;
ka12: TEdit;
ka21: TEdit;
ka22: TEdit;
kb11: TEdit;
kb12: TEdit;
kb13: TEdit;
kb21: TEdit;
kb22: TEdit;
kb23: TEdit;
kc11: TEdit;
kc12: TEdit;
kc21: TEdit;
kc22: TEdit;
kp: TEdit;
kq: TEdit;
StringGrid1: TStringGrid;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
MainMenu1: TMainMenu;
My1: TMenuItem;
My2: TMenuItem;
My3: TMenuItem;
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure My2Click(Sender: TObject);
procedure My3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
Type predpr=Array [1..6] of real;
rasp=Array [1..4,1..6] of real;
Var
Lqp:real;
pl,ql:real;
B,alfa,betta,B_d:predpr;
c,p,cu:rasp;
a,f0:array [1..4] of real;
di,dj:array [1..4] of integer;
f,min,Sp:real;
l,i,j,x,y,xj,yi,n,k:byte;
d:char;
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.Button3Click(Sender: TObject);
begin
ka11.Text:=' ';
ka12.Text:=' ';
ka21.Text:=' ';
ka22.Text:=' ';
kb11.Text:=' ';
kb12.Text:=' ';
kb13.Text:=' ';
kb21.Text:=' ';
kb22.Text:=' ';
kb23.Text:=' ';
kc11.Text:=' ';
kc12.Text:=' ';
kc21.Text:=' ';
kc22.Text:=' ';
kp.Text:=' ';
kq.Text:=' ';
end;
procedure TForm1.Button1Click(Sender: TObject);
label l1;
begin
a[1]:=strtoint(ka11.Text);
a[2]:=strtoint(ka12.Text);
a[3]:=strtoint(ka21.Text);
a[4]:=strtoint(ka22.Text);
b[1]:=strtoint(kb11.Text);
b[2]:=strtoint(kb12.Text);
b[3]:=strtoint(kb13.Text);
b[4]:=strtoint(kb21.Text);
b[5]:=strtoint(kb22.Text);
b[6]:=strtoint(kb23.Text);
pl:=strtofloat(kp.Text);
ql:=strtofloat(kq.Text);
Lqp:=ql/pl;{ коэффициент взаимозаменяемости}
a[2]:=a[2]*Lqp;
a[4]:=a[4]*Lqp;
b[2]:=b[2]*Lqp;
b[3]:=b[3]*Lqp;
b[5]:=b[5]*Lqp;
b[6]:=b[6]*Lqp;
for i:=1 to 4 do
for j:=1 to 6 do begin { ввод цен на затраты перевозки}
if (i=1) and (j=1) then begin
c[i,j]:=strtofloat(kc12.Text);
c[i,j+1]:=strtofloat(kc12.Text);
c[i,j+2]:=strtofloat(kc12.Text);
end;
if (i=1) and (j=4) then begin
c[i,j]:=strtofloat(kc11.Text);
c[i,j+1]:=strtofloat(kc11.Text);
c[i,j+2]:=strtofloat(kc11.Text);
end;
if (i=2) and (j=1) then begin
c[i,j]:=strtofloat(kc12.Text)/lqp;
c[i,j+1]:=strtofloat(kc12.Text)/lqp;
c[i,j+2]:=strtofloat(kc12.Text)/lqp;
end;
if (i=2) and (j=4) then begin
c[i,j]:=strtofloat(kc11.Text)/lqp;
c[i,j+1]:=strtofloat(kc11.Text)/lqp;
c[i,j+2]:=strtofloat(kc11.Text)/lqp;
end;
if (i=3) and (j=1) then begin
c[i,j]:=strtoint(kc21.Text);
c[i,j+1]:=strtoint(kc21.Text);
c[i,j+2]:=strtoint(kc21.Text);
end;
if (i=3) and (j=4) then begin
c[i,j]:=strtofloat(kc22.Text);
c[i,j+1]:=strtofloat(kc22.Text);
c[i,j+2]:=strtofloat(kc22.Text);
end;
if (i=4) and (j=1) then begin
c[i,j]:=strtofloat(kc21.Text)/Lqp;
c[i,j+1]:=strtofloat(kc21.Text)/Lqp;
c[i,j+2]:=strtofloat(kc21.Text)/Lqp;
end;
if (i=4) and (j=4) then begin
c[i,j]:=strtofloat(kc22.Text)/Lqp;
c[i,j+1]:=strtofloat(kc22.Text)/Lqp;
c[i,j+2]:=strtofloat(kc22.Text)/Lqp;
end;
end;
{ блокировка поставок}
c[1,2]:= 100; c[1,5]:= 100; c[2,1]:= 100; c[2,4]:=100;
c[3,2]:= 100; c[3,5]:= 100; c[4,1]:= 100; c[4,4]:= 100;
{ распределение методом северо-западного угла}
for i:=1 to 4 do
for j:=1 to 6 do
if c[i,j]<>100 then begin
if a[i]=b[j] then begin
p[i,j]:=a[i];
b[j]:=0;
a[i]:=0;
end;
if a[i]>b[j] then begin
p[i,j]:=b[j];
a[i]:=a[i]-b[j];
b[j]:=0;
end;
if a[i]<b[j] then begin
p[i,j]:=a[i];
b[j]:=b[j]-a[i];
a[i]:=0;
end;
end;
l1:
for i:=1 to 4 do
for j:=1 to 6 do
if p[i,j]>0 then begin min:=c[i,j]; k:=j;
while k<7 do begin k:=k+1;
if (p[i,k]>0) and(p[i,k]>min) then alfa[i]:=c[i,j] - 2*c[i,j];
end;end;
for i:=1 to 4 do
for j:=1 to 6 do
if p[i,j]>0 then betta[j]:=betta[j]+c[i,j]+alfa[i];
for n:=1 to 6 do
if betta[n]>0 then betta[n]:= betta[n] - 2*betta[n];
for i:=1 to 4 do
for j:=1 to 6 do begin
cu[i,j]:=c[i,j];
cu[i,j]:=cu[i,j]+alfa[i]+betta[j];
end;
for i:=1 to 4 do
for j:=1 to 6 do
if cu[i,j]<0 then begin f0[1]:=p[i,j]; x:=j; y:=i; di[1]:=i; dj[1]:=j; end;
for i:=1 to 4 do
for j:=1 to 6 do
if (i=y)and (j=x) then begin while y>0 do begin
if p[y,j]>0 then begin f0[2]:=p[y,j]; yi:=y; di[2]:=y; dj[2]:=j;end;
y:=y-1;
end;
while x<7 do begin
if p[i,x]>0 then begin f0[4]:=p[i,x];xj:=x; di[4]:=i;dj[4]:=x;end;
x:=x+1;
end;
end;
f0[3]:=p[yi,xj];di[3]:=yi; dj[3]:=xj;
min:=f0[1];
for i:=1 to 4 do if (i mod 2 =0)and (f0[i]<min) then min:=f0[i];
for j:=1 to 4 do if j mod 2 = 0 then f0[j]:=f0[j]-min else f0[j]:=f0[j]+min;
for n:=1 to 4 do p[di[n],dj[n]]:=f0[n];
for i:=1 to 4 do
for j:=1 to 6 do
if (c[i,j]<0) and (p[i,j]>0) then goto l1;
{ вывод}
for i:=1 to 6 do begin
p[2,i]:=p[2,i]/lqp;
p[4,i]:=p[4,i]/lqp;
end;
for j:=1 to 4 do
if j mod 2<>0 then begin
p[j,2]:= p[j,2]/lqp;
p[j,3]:= p[j,3]/lqp;
p[j,5]:= p[j,5]/lqp;
p[j,6]:= p[j,6]/lqp;
end;
for l:=1 to 4 do
for k:=1 to 6 do
if p[l,k]>0 then Form1.StringGrid1.Cells[k,l]:=floattostr(p[l,k]);
f:=0;
for i:=1 to 4 do
for j:=1 to 6 do begin
if (i=2) and (j=1) then begin
c[i,j]:=c[i,j]*lqp;
c[i,j+1]:=c[i,j+1]*lqp;
c[i,j+2]:=c[i,j+2]*lqp;
end;
if (i=2) and (j=4) then begin
c[i,j]:=c[i,j]*lqp;
c[i,j+1]:=c[i,j+1]*lqp;
c[i,j+2]:=c[i,j+2]*lqp;
end;
if (i=4) and (j=1) then begin
c[i,j]:=c[i,j]*Lqp;
c[i,j+1]:=c[i,j+1]*Lqp;
c[i,j+2]:=c[i,j+2]*Lqp;
end;
if (i=4) and (j=4) then begin
c[i,j]:=c[i,j]*Lqp;
c[i,j+1]:=c[i,j+1]*Lqp;
c[i,j+2]:=c[i,j+2]*Lqp;
end;
end;
for i:=1 to 4 do
for j:=1 to 6 do
if p[i,j]>0 then f:=f+c[i,j]*p[i,j];
Form1.Canvas.Font.Name := 'Tahoma';
Form1.Canvas.Font.Size := 10;
Form1.Canvas.Font.Style:= [fsitalic,fsBold];
Form1.Canvas.Font.Color:=clBlue;
Form1.Canvas.TextOut(50,500,'F = '+floattostr(f)+' денежных ед.');
end;
procedure TForm1.My2Click(Sender: TObject);
begin
close;
end;
procedure TForm1.My3Click(Sender: TObject);
begin
Form2.Visible:=true;
end;
end.
