Файл: Содержание введение 3 глава основы теории и вопросы моделирования.docx
Добавлен: 09.11.2023
Просмотров: 961
Скачиваний: 1
ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.
WORD;
VAR
FLAG_ALL : BOOLEAN;
X, Y, CX, CY, DX , DY, R, R2, E, STEP : DOUBLE; I : INTEGER;
NT : WORD
; BEGIN
X := XB; Y := YB;
XT[ 1 ] := X; YT[ 1 ] := Y; NT := 1
;
STEP := SQRT( SQR( X_MAX ) + SQR ( Y_MAX ) ) * 0.02
;
FLAG_ALL := FALSE;
REPEAT
CX := 0; CY := 0;
FOR I := 1 TO N DO BEGIN
DX := X - XZ[ I ]; DY := Y - YZ[ I ];
R2 := SQR( DX ) + SQR ( DY );
CX := CX + E * DX / R; CY := CY + E * DY / R
END
;
R := SQRT ( SQR ( CX ) + SQR ( CY ) );
DX := STEP * CX / R; DY := STEP * CY / R
;
X := X + DX; Y := Y + DY;
IF ( ABS ( X ) < X_MAX ) AND ( ABS ( Y ) < Y_MAX ) THEN
BEGIN
INC(NT); XT[NT] := X; YT[NT] := Y END
;
IF ( ABS ( X ) > 4* X_MAX ) OR ( ABS ( Y ) > 4* Y_MAX ) THEN
FLAG_ALL := TRUE
;
FOR I := 1 TO N DO
IF ( SQR ( X - XZ[I] ) + SQR ( Y - YZ[I] ) )
FLAG_ALL := TRUE
UNTIL FLAG_ALL
; LS1 := NT
END
;
end.
unit MLINP; interface
USES MAINFM
;
FUNCTION LP1 ( NAPR: INTEGER; PB, XB, YB : DOUBLE; Z, XZ, YZ : M8; VAR NT : WORD; VAR XN, YN : DOUBLE ) : BOOLEAN;
implementation uses POT_MAXMIN
;
FUNCTION LP1 ( NAPR: INTEGER; PB, XB, YB : DOUBLE; Z, XZ, YZ : M8; VAR NT : WORD; VAR XN, YN : DOUBLE ) : BOOLEAN;
VAR
FLAG_ALL, FLAG_PROD, PERVYJ : BOOLEAN;
X, Y, CX, CY, DX , DY, R, R2, E, STEP, DXB, X_PRED, K, P, OSHP, OSH_OLD : DOUBLE;
I, ZNAK : INTEGER
// NT, NTP : WORD
; BEGIN
X := XB; Y := YB;
X_PRED := X;
// XTP[ 1 ] := X; YTP[ 1 ] := Y; NTP := 1;
XT[ 1 ] := X; YT[ 1 ] := Y; NT := 1
;
STEP := SQRT( SQR( X_MAX ) + SQR ( Y_MAX ) ) * 0.008;
K := 1.0
;
FLAG_ALL := FALSE; FLAG_PROD := FALSE; PERVYJ := TRUE
; REPEAT
CX := 0; CY := 0;
FOR I := 1 TO NZ DO BEGIN
DX := X - XZ[ I ]; DY := Y - YZ[ I ];
R2 := SQR( DX ) + SQR ( DY );
R := SQRT ( R2 ); E := Z[ I ] / R2;
CX := CX + E * DX / R; CY := CY + E * DY / R
END
;
R := SQRT ( SQR ( CX ) + SQR ( CY ) ); CY := CY / R; CX := CX / R;
DX := NAPR * STEP * CY; DY := - NAPR * STEP * CX
;
X := X + DX; Y := Y + DY;
{
P := 0;
FOR I := 1 TO NZ DO BEGIN
DX := X - XZ[ I ]; DY := Y - YZ[ I ];
R := SQRT ( SQR( DX ) + SQR ( DY ) ); P := P + Z[ I ] / R;
END
; }
P := POT ( X, Y, Z, XZ, YZ );
OSHP := P - PB; K := 0.15;
WHILE ( ABS( OSHP ) > 0 ) AND ( K*STEP > MIN_STEP ) DO BEGIN
CX := 0; CY := 0;
FOR I := 1 TO NZ DO BEGIN
DX := X - XZ[ I ]; DY := Y - YZ[ I ];
R2 := SQR( DX ) + SQR ( DY );
R := SQRT ( R2 ); E := Z[ I ] / R2;
CX := CX + E * DX / R; CY := CY + E * DY / R
END
;
R := SQRT ( SQR ( CX ) + SQR ( CY ) ); CY := CY / R; CX := CX / R;
IF OSHP> 0 THEN ZNAK := 1
ZNAK := -1
ELSE
;
DX := ZNAK * K * STEP * CX; DY := ZNAK * K * STEP * CY
;
X := X + DX; Y := Y + DY;
{ P := 0;
FOR I := 1 TO NZ DO BEGIN
DX := X - XZ[ I ]; DY := Y - YZ[ I ];
R := SQRT ( SQR( DX ) + SQR ( DY ) );
P := P + Z[ I ] / R;
END
; }
P := POT ( X, Y, Z, XZ, YZ );
OSH_OLD := OSHP; OSHP := P - PB;
IF OSHP * OSH_OLD < 0 THEN K := 0.8 * K
END
;
DX := X - X_PRED;
IF PERVYJ AND ( DX<> 0 ) THEN BEGIN
DXB := DX; PERVYJ := FALSE
END
;
X_PRED := X; IF DXB * DX < 0 THEN
BEGIN
XN := X; YN := Y;
FLAG_PROD := TRUE; BREAK
END
;
IF ( ABS ( X ) < X_MAX ) AND ( ABS ( Y ) < Y_MAX ) THEN
BEGIN
INC(NT); XT[NT] := X; YT[NT] := Y END
;
IF ( ABS ( X ) > 200 * X_MAX ) OR ( ABS ( Y ) > 200 * Y_MAX ) THEN
FLAG_ALL := TRUE
UNTIL FLAG_ALL
;
LP1 := FLAG_PROD
END
;
end.
unit MLINS; interface
USES MAINFM
;
FUNCTION LS1 (ZNAK : INTEGER; XB, YB : DOUBLE; Z, XZ, YZ : M8; VAR NT : WORD; VAR XN, YN : DOUBLE ) : BOOLEAN;
implementation
FUNCTION LS1 (ZNAK : INTEGER; XB, YB : DOUBLE; Z, XZ, YZ : M8; VAR NT : WORD; VAR XN, YN : DOUBLE ) : BOOLEAN;
VAR
FLAG_ALL, FLAG_PROD : BOOLEAN;
X, Y, CX, CY, DX , DY, R, R2, E, STEP, DXB : DOUBLE; I : INTEGER
; BEGIN
X := XB; Y := YB;
XT[ 1 ] := X; YT[ 1 ] := Y; NT := 1
;
STEP := SQRT( SQR( X_MAX ) + SQR ( Y_MAX ) ) * 0.02
;
FLAG_ALL := FALSE; FLAG_PROD := FALSE;
REPEAT
CX := 0; CY := 0;
FOR I := 1 TO NZ DO BEGIN
DX := X - XZ[ I ]; DY := Y - YZ[ I ];
R2 := SQR( DX ) + SQR ( DY );
R := SQRT ( R2 ); E := ZNAK * Z[ I ] / R2;
CX := CX + E * DX / R; CY := CY + E * DY / R
END
;
R := SQRT ( SQR ( CX ) + SQR ( CY ) );
DX := STEP * CX / R;
DY := STEP * CY / R
;
IF X = XB THEN
DXB := DX
;
IF DXB * DX < 0 THEN
BEGIN
XN := X; YN := Y;
FLAG_PROD := TRUE; BREAK
END
;
X := X + DX; Y := Y + DY;
IF ( ABS ( X ) <= 1.005 * X_MAX ) AND ( ABS ( Y ) <= 1.005 * Y_MAX ) THEN
BEGIN
INC(NT); XT[NT] := X; YT[NT] := Y END
;
IF ( ABS ( X ) > 200 * X_MAX ) OR ( ABS ( Y ) > 200 * Y_MAX ) THEN
FLAG_ALL := TRUE
;
FOR I := 1 TO NZ DO
IF ( SQR ( X - XZ[I] ) + SQR ( Y - YZ[I] ) )
FLAG_ALL := TRUE
UNTIL FLAG_ALL
;
LS1 := FLAG_PROD END
;
end.
unit POT_MAXMIN;
interface
USES MAINFM
;
FUNCTION POT ( X, Y : DOUBLE; Z, XZ, YZ : M8 ) : DOUBLE;
// PROCEDURE P_MAXMIN ( Z, XZ, YZ : M8 );
implementation
FUNCTION POT ( X, Y : DOUBLE; Z, XZ, YZ : M8 ) : DOUBLE; VAR
I : INTEGER;
DX, DY, P, R : DOUBLE
; BEGIN
P := 0;
FOR I := 1 TO NZ DO BEGIN
DX := X - XZ[ I ];
DY := Y - YZ[ I ];
R := SQRT ( SQR( DX ) + SQR ( DY ) );
P := P + Z[ I ] / R
END
; POT := P END;
end.
VAR
FLAG_ALL : BOOLEAN;
X, Y, CX, CY, DX , DY, R, R2, E, STEP : DOUBLE; I : INTEGER;
NT : WORD
; BEGIN
X := XB; Y := YB;
XT[ 1 ] := X; YT[ 1 ] := Y; NT := 1
;
STEP := SQRT( SQR( X_MAX ) + SQR ( Y_MAX ) ) * 0.02
;
FLAG_ALL := FALSE;
REPEAT
CX := 0; CY := 0;
FOR I := 1 TO N DO BEGIN
DX := X - XZ[ I ]; DY := Y - YZ[ I ];
R2 := SQR( DX ) + SQR ( DY );
-
:= SQRT ( R2 ); E := ZNAK * Z[ I ] / R2;
CX := CX + E * DX / R; CY := CY + E * DY / R
END
;
R := SQRT ( SQR ( CX ) + SQR ( CY ) );
DX := STEP * CX / R; DY := STEP * CY / R
;
X := X + DX; Y := Y + DY;
IF ( ABS ( X ) < X_MAX ) AND ( ABS ( Y ) < Y_MAX ) THEN
BEGIN
INC(NT); XT[NT] := X; YT[NT] := Y END
;
IF ( ABS ( X ) > 4* X_MAX ) OR ( ABS ( Y ) > 4* Y_MAX ) THEN
FLAG_ALL := TRUE
;
FOR I := 1 TO N DO
IF ( SQR ( X - XZ[I] ) + SQR ( Y - YZ[I] ) )
FLAG_ALL := TRUE
UNTIL FLAG_ALL
; LS1 := NT
END
;
end.
unit MLINP; interface
USES MAINFM
;
FUNCTION LP1 ( NAPR: INTEGER; PB, XB, YB : DOUBLE; Z, XZ, YZ : M8; VAR NT : WORD; VAR XN, YN : DOUBLE ) : BOOLEAN;
implementation uses POT_MAXMIN
;
FUNCTION LP1 ( NAPR: INTEGER; PB, XB, YB : DOUBLE; Z, XZ, YZ : M8; VAR NT : WORD; VAR XN, YN : DOUBLE ) : BOOLEAN;
VAR
FLAG_ALL, FLAG_PROD, PERVYJ : BOOLEAN;
X, Y, CX, CY, DX , DY, R, R2, E, STEP, DXB, X_PRED, K, P, OSHP, OSH_OLD : DOUBLE;
I, ZNAK : INTEGER
// NT, NTP : WORD
; BEGIN
X := XB; Y := YB;
X_PRED := X;
// XTP[ 1 ] := X; YTP[ 1 ] := Y; NTP := 1;
XT[ 1 ] := X; YT[ 1 ] := Y; NT := 1
;
STEP := SQRT( SQR( X_MAX ) + SQR ( Y_MAX ) ) * 0.008;
K := 1.0
;
FLAG_ALL := FALSE; FLAG_PROD := FALSE; PERVYJ := TRUE
; REPEAT
CX := 0; CY := 0;
FOR I := 1 TO NZ DO BEGIN
DX := X - XZ[ I ]; DY := Y - YZ[ I ];
R2 := SQR( DX ) + SQR ( DY );
R := SQRT ( R2 ); E := Z[ I ] / R2;
CX := CX + E * DX / R; CY := CY + E * DY / R
END
;
R := SQRT ( SQR ( CX ) + SQR ( CY ) ); CY := CY / R; CX := CX / R;
DX := NAPR * STEP * CY; DY := - NAPR * STEP * CX
;
X := X + DX; Y := Y + DY;
{
P := 0;
FOR I := 1 TO NZ DO BEGIN
DX := X - XZ[ I ]; DY := Y - YZ[ I ];
1 ... 4 5 6 7 8 9 10 11 12
R := SQRT ( SQR( DX ) + SQR ( DY ) ); P := P + Z[ I ] / R;
END
; }
P := POT ( X, Y, Z, XZ, YZ );
OSHP := P - PB; K := 0.15;
WHILE ( ABS( OSHP ) > 0 ) AND ( K*STEP > MIN_STEP ) DO BEGIN
CX := 0; CY := 0;
FOR I := 1 TO NZ DO BEGIN
DX := X - XZ[ I ]; DY := Y - YZ[ I ];
R2 := SQR( DX ) + SQR ( DY );
R := SQRT ( R2 ); E := Z[ I ] / R2;
CX := CX + E * DX / R; CY := CY + E * DY / R
END
;
R := SQRT ( SQR ( CX ) + SQR ( CY ) ); CY := CY / R; CX := CX / R;
IF OSHP> 0 THEN ZNAK := 1
ZNAK := -1
ELSE
;
DX := ZNAK * K * STEP * CX; DY := ZNAK * K * STEP * CY
;
X := X + DX; Y := Y + DY;
{ P := 0;
FOR I := 1 TO NZ DO BEGIN
DX := X - XZ[ I ]; DY := Y - YZ[ I ];
R := SQRT ( SQR( DX ) + SQR ( DY ) );
P := P + Z[ I ] / R;
END
; }
P := POT ( X, Y, Z, XZ, YZ );
OSH_OLD := OSHP; OSHP := P - PB;
IF OSHP * OSH_OLD < 0 THEN K := 0.8 * K
END
;
DX := X - X_PRED;
IF PERVYJ AND ( DX<> 0 ) THEN BEGIN
DXB := DX; PERVYJ := FALSE
END
;
X_PRED := X; IF DXB * DX < 0 THEN
BEGIN
XN := X; YN := Y;
FLAG_PROD := TRUE; BREAK
END
;
IF ( ABS ( X ) < X_MAX ) AND ( ABS ( Y ) < Y_MAX ) THEN
BEGIN
INC(NT); XT[NT] := X; YT[NT] := Y END
;
IF ( ABS ( X ) > 200 * X_MAX ) OR ( ABS ( Y ) > 200 * Y_MAX ) THEN
FLAG_ALL := TRUE
UNTIL FLAG_ALL
;
LP1 := FLAG_PROD
END
;
end.
unit MLINS; interface
USES MAINFM
;
FUNCTION LS1 (ZNAK : INTEGER; XB, YB : DOUBLE; Z, XZ, YZ : M8; VAR NT : WORD; VAR XN, YN : DOUBLE ) : BOOLEAN;
implementation
FUNCTION LS1 (ZNAK : INTEGER; XB, YB : DOUBLE; Z, XZ, YZ : M8; VAR NT : WORD; VAR XN, YN : DOUBLE ) : BOOLEAN;
VAR
FLAG_ALL, FLAG_PROD : BOOLEAN;
X, Y, CX, CY, DX , DY, R, R2, E, STEP, DXB : DOUBLE; I : INTEGER
; BEGIN
X := XB; Y := YB;
XT[ 1 ] := X; YT[ 1 ] := Y; NT := 1
;
STEP := SQRT( SQR( X_MAX ) + SQR ( Y_MAX ) ) * 0.02
;
FLAG_ALL := FALSE; FLAG_PROD := FALSE;
REPEAT
CX := 0; CY := 0;
FOR I := 1 TO NZ DO BEGIN
DX := X - XZ[ I ]; DY := Y - YZ[ I ];
R2 := SQR( DX ) + SQR ( DY );
R := SQRT ( R2 ); E := ZNAK * Z[ I ] / R2;
CX := CX + E * DX / R; CY := CY + E * DY / R
END
;
R := SQRT ( SQR ( CX ) + SQR ( CY ) );
DX := STEP * CX / R;
DY := STEP * CY / R
;
IF X = XB THEN
DXB := DX
;
IF DXB * DX < 0 THEN
BEGIN
XN := X; YN := Y;
FLAG_PROD := TRUE; BREAK
END
;
X := X + DX; Y := Y + DY;
IF ( ABS ( X ) <= 1.005 * X_MAX ) AND ( ABS ( Y ) <= 1.005 * Y_MAX ) THEN
BEGIN
INC(NT); XT[NT] := X; YT[NT] := Y END
;
IF ( ABS ( X ) > 200 * X_MAX ) OR ( ABS ( Y ) > 200 * Y_MAX ) THEN
FLAG_ALL := TRUE
;
FOR I := 1 TO NZ DO
IF ( SQR ( X - XZ[I] ) + SQR ( Y - YZ[I] ) )
FLAG_ALL := TRUE
UNTIL FLAG_ALL
;
LS1 := FLAG_PROD END
;
end.
unit POT_MAXMIN;
interface
USES MAINFM
;
FUNCTION POT ( X, Y : DOUBLE; Z, XZ, YZ : M8 ) : DOUBLE;
// PROCEDURE P_MAXMIN ( Z, XZ, YZ : M8 );
implementation
FUNCTION POT ( X, Y : DOUBLE; Z, XZ, YZ : M8 ) : DOUBLE; VAR
I : INTEGER;
DX, DY, P, R : DOUBLE
; BEGIN
P := 0;
FOR I := 1 TO NZ DO BEGIN
DX := X - XZ[ I ];
DY := Y - YZ[ I ];
R := SQRT ( SQR( DX ) + SQR ( DY ) );
P := P + Z[ I ] / R
END
; POT := P END;
end.
1 ... 4 5 6 7 8 9 10 11 12