Bearbeiten von: Abschnitt [Änderungshistorie]
  Zeilenumbrüche automatisch mache ich selbst mit HTML    

Ich möchte eine Mail an , nachdem mein Vorschlag bearbeitet ist.
  Nachricht zur Änderung:

Input assistance tools (JavaScript): [Link extern intern] [MathML?] [$$?]
[fed-area] [LaTeX-inline] [LaTeX-display] [Tikz] [hide-area][show-area] [Source code [num.]][?]
[Link zurück zum Artikelabschnitt]

Vorschau:
Neuer Abschnitt in Die Simplexmethode in Basic und Turbo

Listing Simplexmethode in Turbo Pascal/Free Pascal

\sourceon Pascal program simplex; {$N+} label 60, 110, 400, 490, 580, 770, 780, 920, 950, 970; label 1150,1170,1410,1470,1560,1610,1630,1640,1710,1720; label 1860,1880,1940,1980,2100; const MOG = 30; NOG = 30; OG1 = 3; OG2 = 5; OG3 = 10; OG4 = 15; var B:array[1..MOG] of Double; CI:array[1..NOG] of Double; CJ:array[1..NOG] of Double; Z:array[1..NOG] of Double; ZC:array[1..NOG] of Double; XI:array[1..NOG] of integer; XJ:array[1..NOG] of integer; A:array[1..MOG,1..NOG] of Double; F,I,IM,IT,J,JM,K,M,M0,M3,M4,MN,N,N1,N2,NB,NE,NS,PT : integer; CM,OB,XM,XX : Double; c:string; begin writeln('SIMPLEX-METHODE'); writeln; writeln('LINEARE PROGRAMMIERUNG'); writeln; {REM} 60: writeln('MAXIMIERUNG ODER MINIMIERUNG'); write('(MAX/MIN/ENDE) ');readln(C); IF C='ENDE' THEN halt; IF (C<>'MAX') AND (C<>'MIN') THEN GOTO 60; IF C='MIN' THEN PT:=-1; writeln('MINIMIERUNG DER ZIELFUNKTION'); GOTO 110; writeln('MAXIMIERUNG DER ZIELFUNKTION'); 110: PT:=1; {rem} write('ANZAHL DER ENTSCH.VARIAB.'); readln(MN); writeln('ANZAHL DER ENTSCH.VARIAB. ',MN); writeln; writeln('ANZAHL DER NEBENBEDINGUNGEN'); writeln('(AUSGEN.NICHTNEGATIVE NEBENBEDINGUNGEN):'); write(' <= '); readln(NS); writeln('KLEINER ODER GLEICH <= ? ',NS); write(' >= '); readln(NB); writeln('GROESSER ALS ODER GLEICH >= ? ',NB); write('GLEICH = '); readln(NE); writeln('GLEICH = ? ',NE); M:=NS+NB+NE; N:=M+MN+NB; {DIM B(M),CI(N),CJ(N),Z(N),ZC(N),XI(N),XJ(N),A(M,N)} writeln; writeln('DEFINITION DER INDIZ. VARIABLE :'); writeln; K:=1; FOR J:=M+1 TO M+MN DO begin writeln('ENTSCHEIDUNGSVARIABLE ',K); XJ[J]:=K; writeln('= X(',XJ[J]:OG1,')'); K:=K+1; end; {NEXT J:} writeln; IF NS<=0 THEN GOTO 400; writeln('SCHLUPFVARIABLE(N) DER'); writeln('KLEINER ODER GLEICH'); writeln('NEBENBEDINGUNG :'); K:=MN+1; FOR J:=1 TO NS DO begin write('NEBENBEDINGUNG ',J); XJ[J]:=K; writeln(' = X(',XJ[J]:OG1,')'); K:=K+1; end; { NEXT J:} writeln; FOR I:=1 TO N DO begin CJ[I]:=0; end; { NEXT I } 400: IF NB=0 THEN GOTO 490; writeln('SCHLUPFVARIABLE(N) DER'); writeln('GROESSER ODER GLEICH'); writeln('NEBENBEDINGUNG'); writeln('( RESTVARIABLE(N) ):'); K:=M+MN+1; FOR J:=M+MN+1 TO N DO begin write('NEBENBEDINGUNG ',J+NS-M-MN); XJ[J]:=K; writeln(' = X(',XJ[J]:OG1,')'); K:=K+1; end; {NEXT J:} writeln; 490: IF (NB=0) AND (NE=0) THEN GOTO 580; writeln('KUENSTLICHE VARIABLE(N) FURE DIE'); writeln(' >= UND = NEBENBEDINGUNG :'); K:=MN+NS+1; FOR J:=NS+1 TO M DO begin write('NEBENBEDINGUNG ',J); XJ[J]:=K; writeln(' = X(',XJ[J]:OG1,')'); CJ[J]:=10000; K:=K+1; end; { NEXT J:} writeln; 580: FOR I:=1 TO M DO begin XI[I]:=XJ[I]; end; { NEXT I } writeln; writeln('KOEFFIZIENTEN DER ZIELFUNKTION :'); writeln('---------------'); FOR I:=M+1 TO M+MN DO begin writeln('KOEFF.DER ENTSCH.VAR.'); writeln('X(',I-M,')= '); readln(CJ[I]); writeln('KOEFF.DER ENTSCH.VAR. ',I-M,' =',CJ[I]:OG3:OG2); CJ[I]:=CJ[I]*PT*(-1); end; { NEXT I:} writeln; writeln('WERT DER RECHTEN SEITE'); writeln('---------------'); FOR I:=1 TO M DO begin writeln('==DER NEBENBEDINGUNG '); writeln('X(',I,')='); readln(B[I]); writeln('==DER NEBENBEDINGUNG ',I,' = ',B[I]:OG3:OG2); end; { NEXT I } FOR I:=1 TO M DO begin FOR J:=1 TO N DO begin IF I<>J THEN GOTO 770; A[I][J]:=1; GOTO 780; 770: A[I][J]:=0; 780: { } end; end; { NEXT J: NEXT I } writeln; writeln('NEBENBED.KOEFFIZIENTEN :'); writeln('---------------'); FOR I:=1 TO M DO begin writeln('KOEFFIZ.DER NEBENBED.NR. ',I); FOR J:=M+1 TO M+MN DO begin write('ENTSCH.VARIABLE',I,',',J-M,'='); readln(A[I][J]); writeln('--ENTSCH.VARIABLE ',J-M,' =',A[I][J]:OG3:OG2); end; end; { NEXT J:NEXT I } IF NB=0 THEN GOTO 920; FOR I:=1 TO NB DO begin A[NS+I][M+MN+I]:=-1; end; { NEXT I } 920: FOR I:=1 TO M DO begin FOR J:=1 TO N DO begin IF XI[I]<>XJ[J] THEN GOTO 950; CI[I]:=CJ[J]; 950: { } end; end; { NEXT J: NEXT I } IT:=0; 970: FOR J:=1 TO N DO begin Z[J]:=0; FOR I:=1 TO M DO begin Z[J]:=Z[J]+CI[I]*A[I][J]; end; { NEXT I } ZC[J]:=Z[J]-CJ[J]; end; { NEXT J } OB:=0; FOR I:=1 TO M DO begin OB:=OB+CI[I]*B[I]; end; { NEXT I } writeln; writeln; writeln; writeln('ITERATION NR.',IT); writeln('---------------'); writeln('BASIS VARIABLEN WERT'); FOR I:=1 TO M DO begin writeln(' X(',XI[I]:OG1,') ',round(100*B[I])/100:OG3:OG2); end; { NEXT I } writeln; N1:=1; N2:=8; 1150: IF N2<=N THEN GOTO 1170; N2:=N; 1170: writeln('VARIABLEN DES SIMPLEX-TABLEAUS'); FOR I:=N1 TO N2 DO begin writeln( 'X(',XJ[I]:OG1,');'); end; { NEXT I } writeln; writeln; { REM } writeln('KOEFIZ.MATRIX A(I,J) :'); writeln('---------------'); K:=-10; FOR I:=1 TO M DO begin K:=K-25; F:=32; FOR J:=N1 TO N2 DO begin F:=F-32; { REM CURSOR } write( round(100*A[I][J])/100:OG3:OG2,' '); end; { NEXT J: } writeln; end; { NEXT I } { REM } writeln('MARG.DECK.BEITRAGSKOEFF. Z(J)-C(J) :'); FOR I:=N1 TO N2 DO begin write( round(100*ZC[I])/100:OG3:OG2,' '); end; { NEXT I: } writeln; IF N2>=N THEN GOTO 1410; N1:=N1+8; N2:=N2+8; GOTO 1150; 1410: writeln; writeln('ZIEFFUNKTION Z = ',round(100*OB)/100:OG4:OG2); writeln; write('WEITER ? J/N '); readln(C); IF C='N' THEN HALT; IT:=IT+1; CM:=ZC[1]; JM:=1; FOR J:=2 TO N DO begin IF ZC[J]<=CM THEN GOTO 1470; CM:=ZC[J]; JM:=J; 1470: { } end; { NEXT J } IF CM>0 THEN GOTO 1880; M3:=M+MN; M0:=M+1; IF M=NS THEN GOTO 1560; FOR I:=1 TO M DO begin M4:=NS+1; FOR J:=M4 TO M DO begin IF XI[I]=XJ[J] THEN GOTO 1860; end; end; { NEXT J: NEXT I } 1560: FOR K:=M0 TO M3 DO begin FOR I:=1 TO M DO begin IF XJ[K]=XI[I] THEN GOTO 1610; end; { NEXT I } IF ZC[K]=0 THEN GOTO 1630; 1610: { } end; { NEXT K } GOTO 1640; 1630: writeln('* MEHRERE OPT.LOESUNGEN MOEGLICH *'); 1640: writeln; writeln; writeln; writeln('*** OPTIMALE LOESUNG GEFUNDEN ***'); writeln('*** NACH ',IT,' ITERATIONEN ***'); FOR I:=1 TO M DO begin IF B[I]<>0 THEN GOTO 1710; writeln; writeln('*** DEGENERIERTE LOESUNG ***'); GOTO 1720; 1710: { } end; { NEXT I } 1720: writeln; writeln('---------------'); writeln('ENTSCH.VARIABLEN WERT'); writeln('---------------'); FOR I:=1 TO M DO begin writeln(' X(',XI[I]:OG1,') =',round(1000*B[I])/1000:OG3:OG2); end; { NEXT I } writeln('! BEACHTE !'); writeln('ALLE VARIABLEN, DIE IN DIESER TABELLE'); writeln('NICHT GEZEIGT WERDEN,'); writeln('HABEN DER WERT 0.'); writeln('---------------'); IF PT=1 THEN writeln('MAXIMUM Z = ',ABS(OB):OG4:OG2); IF PT=-1 THEN writeln('MINIMUM Z = ',ABS(OB):OG4:OG2); writeln('---------------'); readln(c); HALT; writeln; writeln; writeln; writeln; writeln; HALT; 1860: writeln; writeln('*** UNBESCHRAENKTE LOESUNG ***'); HALT; 1880: XM:=1.0E25; IM:=0; FOR I:=1 TO M DO begin IF A[I][JM]<=0 THEN GOTO 1940; XX:=B[I]/A[I][JM]; IF XX>=XM THEN GOTO 1940; XM:=XX; IM:=I; 1940: { } end; { NEXT I } IF IM>0 THEN GOTO 1980; writeln('*** LOESUNG UNMOEGLICH ***'); HALT; 1980: XX:=A[IM][JM]; B[IM]:=B[IM]/XX; FOR J:=1 TO N DO begin A[IM][J]:=A[IM][J]/XX; end; { NEXT J } FOR I:=1 TO M DO begin IF I=IM THEN GOTO 2100; XX:=A[I][JM]; B[I]:=B[I]-XX*B[IM]; FOR J:=1 TO N DO begin A[I][J]:=A[I][J]-XX*A[IM][J]; end; { NEXT J } 2100: { } end; { NEXT I } CI[IM]:=CJ[JM]; XI[IM]:=XJ[JM]; GOTO 970; writeln; writeln; writeln; writeln; writeln; end. \sourceoff
 
All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest © 2001-2023 by Matroids Matheplanet
This web site was originally made with PHP-Nuke, a former web portal system written in PHP that seems no longer to be maintained nor supported. PHP-Nuke is Free Software released under the GNU/GPL license.
Ich distanziere mich von rechtswidrigen oder anstößigen Inhalten, die sich trotz aufmerksamer Prüfung hinter hier verwendeten Links verbergen mögen.
Lesen Sie die Nutzungsbedingungen, die Distanzierung, die Datenschutzerklärung und das Impressum.
[Seitenanfang]