Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Диссертация_2013_Даулбаева ММ.doc
Скачиваний:
67
Добавлен:
10.03.2016
Размер:
2.34 Mб
Скачать

Продолжение приложения б

plan.Top[index2] := plan.Top[index2]-t;

plan.Left[index] := plan.Left[index]-t;

if (plan.Top[index2] = 0) then

index2 := index2+1;

if (plan.Left[index] = 0) then

index := index+1;

end;

end;

procedure TForm1.Dump(data: TData; fl: integer);

function i2s( i: integer ): string;

var

r: string;

begin

r := IntToStr( i );

while( length(r) < 3 ) do

r := ' ' + r;

Result := r;

end;

var

index, index2: integer;

s: string;

begin

if ((fl and 2) <> 0) then

begin

s := ' ';

for index := 0 to data.Width-1 do

s := s + i2s( data.Top[index] );

Memo1.Lines.Add( s );

end;

if ((fl and 5) = 0) then

exit;

for index := 0 to data.Height-1 do

begin

if ((fl and 4) <> 0) then

s := i2s( data.Left[index] )

else

s := '';

if ((fl and 1) <> 0) then

for index2 := 0 to data.Width-1 do

s := s + i2s( data.Arr[index2,index] );

Продолжение приложения б

Memo1.Lines.Add( s );

end;

end;

function TForm1.CalcSum(data, plan: TData): integer;

var

index, index2, s: integer;

begin

s := 0;

for index := 0 to data.Height-1 do

for index2 := 0 to data.Width-1 do

s := s + data.Arr[index2,index] * plan.Arr[index2, index];

Result := s;

end;

function TData.Min: integer;

var

index, index2, m: integer;

begin

m := MaxInt;

for index := 0 to Height-1 do

for index2 := 0 to Width-1 do

if (m > Arr[index2,index]) then

m := Arr[index2,index];

Result := m;

end;

function TData.NoNulls: integer;

var

index, index2, c: integer;

begin

c := 0;

for index := 0 to Height-1 do

for index2:= 0 to Width-1 do

if (Arr[index2,index] > 0) then

inc(c);

Result := c;

end;

procedure TForm1.CalcMinEl( data: TData; var plan: TData );

var

index, index2, x_m, y_m, v_m, s, v: integer;

begin

s := 0;

plan.AssignLT( data );

for index := 0 to plan.Width-1 do

Продолжение приложения б

s := s + data.Top[index];

while (s > 0) do

begin

v_m := MaxInt;

x_m := -1;

y_m := -1;

for index := 0 to plan.Height-1 do

for index2 := 0 to plan.Width-1 do

if ((v_m > data.Arr[index2,index]) and

(plan.Arr[index2,index] = 0) and

(plan.Top[index2] > 0) and (plan.Left[index] > 0)) then

begin

v_m := data.Arr[index2,index];

x_m := index2;

y_m := index;

end;

if (v_m = MaxInt) then

break;

v := min( plan.Top[ x_m ], plan.Left[ y_m ] );

plan.Top[ x_m ] := plan.Top[ x_m ] - v;

plan.Left[ y_m ] := plan.Left[ y_m ] - v;

plan.Arr[ x_m, y_m ] := v;

s := s - v;

end;

end;

procedure TData.Reset;

begin

FillChar( Left, sizeof(Left), 0 );

FillChar( Top, sizeof(Top), 0 );

FillChar( Arr, sizeof(Arr), 0 );

end;

{ TEqSolve }

procedure TEqSolve.AddEq( p1,p2,s : integer );

begin

Eq[ fEqCount ].p1 := p1;

Eq[ fEqCount ].p2 := p2 + fH;

Eq[ fEqCount ].sum := s;

Eq[ fEqCount ].solved := false;

Form1.Memo1.Lines.Add( 'u' + IntToStr(p1+1) + ' + v' + IntToStr(p2+1) +

' = ' + IntToStr( s ) );

inc( fEqCount );

end;