UNIDADES USADAS

Anuncio
Apéndice I
UNIT MSR;
{ **********
INTERFACE
{ **********
90
UNIDADES USADAS
**********}
UNIDADES USADAS
**********}
Uses Crt, Tool1, Skeleton, Impripa6, Simul;
Procedure Superficies;
IMPLEMENTATION
{ **********
IMPLEMENTACION DE FUNCIONES
**********}
Var
Rw, Reordenw, Qw, TRevw, MaxR, MinR,
MaxReorden, MinReorden, MaxQ, MinQ,MaxTRev,
MinTRev,i,j, h, renglon, columna,n
: Integer;
MidR, MidQ, MidReorden, MidTRev,
SumY, Yprom, SSR, Fcalc, Fc, FTab, FT, Alpha,
R1, Reorden1, Q1, TRev1, CTA1, eigenvalor1,
eigenvalor2, eigenvalor3, AnnualDem
: Real;
X
: Array [1..13, 1..4] of
Real;
Y
: Array [1..13] of Real;
XT
: Array [1..4, 1..13] of
Real;
XTX
: Array [1..11, 1..11] of
Real;
XTY
: Array [1..11] of Real;
Mat
: Array [1..11, 1..22] of
Real;
Beta
: Array [1..4] of Real;
Yest
: Array [1..13] of Real;
Y2
: Array [1..19] of Real;
A
: Array [1..19, 1..3] of
Real;
B
: Array [1..3,1..6] of
Real;
Beta2
: Array [1..11] of Real;
Signo
: Array [1..11] of Char;
Yest2
: Array [1..19] of Real;
P0
: Array [1..3] of Real;
{__________________________________________________________________}
Procedure InicioVar;
Begin
Rw:=0; Reordenw:=0; Qw:=0; TRevw:=0; MaxR:=0; MinR:=0; MaxReorden:=0;
MinReorden:=0; MaxQ:=0; MinQ:=0; MaxTRev:=0; MinTRev:=0; i:=0; j:=0;
h:=0; renglon:=0; columna:=0; n:=0; MidR:=0; MidQ:=0; MidReorden:=0;
MidTRev:=0; AnnualDem:=0; SumY:=0; Yprom:=0; Fcalc:=0; Fc:=0; R1:=0;
Reorden1:=0; Q1:=0; TRev1:=0; CTA1:=0;
For i:=1 to 13 do
Y[i]:=0;
End;{del procedure InicioVar}
Procedure SolInicial;
Var
Answer
: string [2];
Apéndice I
91
Qwaux, TRevwaux : Real;
Begin
Repeat
ClrScr;
CuadroColor (1, 80, 1, 24, 9);
Locate (20, 3, 'MINIMIZATION PHASE USING Surface Response
Methodology');
Locate (13, 5, 'Do you want to use some initial solution?');
Readln (Answer);
If (Answer='YE') or (Answer='ye') then
Begin
Locate (13, 7, 'Type the next values:');
Case NumMod of
1: ;
2: Begin
Locate (20, 9, '
R= '); Read (Rw);
Locate (20, 10, '
r= '); Read (Reordenw);
End;
3: Begin
Locate (20, 9, '
Q= '); Read (Qw);
Locate (20, 10, '
r= '); Read (Reordenw);
End;
4: Begin
Locate (20, 9, '
R= '); Read (Rw);
Locate (20, 10, '
T= '); Read (TRevw);
End;
5: Begin
Locate (20, 9, '
Q= '); Read (Qw);
Locate (20, 10, '
r= '); Read (Reordenw);
Locate (20, 11, '
T= '); Read (TRevw);
End;
6: Begin
Locate (20, 9, '
R= '); Read (Rw);
Locate (20, 10, '
r= '); Read (Reordenw);
Locate (20, 11, '
T= '); Read (TRevw);
End;
End; {del Case}
Locate (13, 13, 'In the search for the minimum, it is necessary
to');
Locate (13, 14, 'use intervals for each variable, please type the
');
Locate (13, 15, 'maximum and the minimum value (in these intervals
');
Locate (13, 16, 'include the values above): ');
Case NumMod of
1: ;
2: Begin
Qw:=0; TRevw:=0;
Locate (16, 17, 'Max. Value of R= '); Read (MaxR);
Locate (16, 18, 'Min. Value of R= '); Read (MinR);
Locate (16, 19, 'Max. Value of r= '); Read (MaxReorden);
Locate (16, 20, 'Min. Value of r= '); Read (MinReorden);
End;
3: Begin
Rw:=0; TRevw:=0;
Locate (16, 17, 'Max. Value of Q= '); Read (MaxQ);
Locate (16, 18, 'Min. Value of Q= '); Read (MinQ);
Apéndice I
92
Locate (16, 19, 'Max. Value of r= '); Read (MaxReorden);
Locate (16, 20, 'Min. Value of r= '); Read (MinReorden);
End;
4: Begin
Reordenw:=0; Qw:=0;
Locate (16, 17, 'Max. Value of R= '); Read (MaxR);
Locate (16, 18, 'Min. Value of R= '); Read (MinR);
Locate (16, 19, 'Max. Value of T= '); Read (MaxTRev);
Locate (16, 20, 'Min. Value of T= '); Read (MinTRev);
End;
5: Begin
Rw:=0;
Locate (16, 17, 'Max. Value of Q= '); Read (MaxQ);
Locate (16, 18, 'Min. Value of Q= '); Read (MinQ);
Locate (16, 19, 'Max. Value of r= '); Read (MaxReorden);
Locate (16, 20, 'Min. Value of r= '); Read (MinReorden);
Locate (16, 21, 'Max. Value of T= '); Read (MaxTRev);
Locate (16, 22, 'Min. Value of T= '); Read (MinTRev);
End;
6: Begin
Qw:=0;
Locate (16, 17, 'Max. Value of R= '); Read (MaxR);
Locate (16, 18, 'Min. Value of R= '); Read (MinR);
Locate (16, 19, 'Max. Value of r= '); Read (MaxReorden);
Locate (16, 20, 'Min. Value of r= '); Read (MinReorden);
Locate (16, 21, 'Max. Value of T= '); Read (MaxTRev);
Locate (16, 22, 'Min. Value of T= '); Read (MinTRev);
End;
End; {del case}
End {del if}
Else
Begin
AnnualDem:=D;
Locate (13, 7, 'The initial solution generated uses the Wilson
Q.');
Qwaux:= Sqrt (2*Co*AnnualDem/Ca); Qw:= Trunc (Qwaux);
Reordenw:= Trunc (Qw/2);
Rw:= Qw + Reordenw;
TRevwaux:= Sqrt (2*(Co+Cr)/(AnnualDem*Ca)); TRevw:= (Round
(TRevwaux)+1);
Locate (13, 13, 'In the search for the minimum, it is necessary
to');
Locate (13, 14, 'use intervals for each variable, please type the
');
Locate (13, 15, 'maximum and the minimum value (in these intervals
');
Locate (13, 16, 'include the values above): ');
Case NumMod of
1: ;
2: Begin
Qw:=0; TRevw:=0;
Locate (13, 11, 'The R value calculated is: '); Write (Rw);
Locate (13, 12, 'The r value calculated is: '); Write
(Reordenw);
Locate (16, 17, 'Max. Value of R= '); Read (MaxR);
Locate (16, 18, 'Min. Value of R= '); Read (MinR);
Locate (16, 19, 'Max. Value of r= '); Read (MaxReorden);
Apéndice I
93
Locate (16, 20, 'Min. Value of r= '); Read (MinReorden);
End;
3: Begin
Rw:=0; TRevw:=0;
Locate (13, 11, 'The Wilson Q value calculated is: '); Write
(Qw);
Locate (13, 12, 'The r value calculated is: '); Write
(Reordenw);
Locate
Locate
Locate
Locate
End;
4: Begin
Qw:=0;
Locate
Locate
(16,
(16,
(16,
(16,
Locate
Locate
Locate
Locate
End;
5: Begin
Rw:=0;
Locate
(16,
(16,
(16,
(16,
17,
18,
19,
20,
'Max.
'Min.
'Max.
'Min.
Value
Value
Value
Value
of
of
of
of
Q=
Q=
r=
r=
');
');
');
');
Read
Read
Read
Read
(MaxQ);
(MinQ);
(MaxReorden);
(MinReorden);
Reordenw:=0;
(13, 11, 'The R value calculated is: '); Write (Rw);
(13, 12, 'The T value calculated is: '); Write
(TRevw);
17,
18,
19,
20,
'Max.
'Min.
'Max.
'Min.
Value
Value
Value
Value
of
of
of
of
R=
R=
T=
T=
');
');
');
');
Read
Read
Read
Read
(MaxR);
(MinR);
(MaxTRev);
(MinTRev);
(13, 11, 'The Wilson Q value calculated is: '); Write
(Qw);
Locate (13, 12, 'The r value calculated is: '); Write
(Reordenw);
Locate (13, 13, 'The T value calculated is: '); Write
(TRevw);
Locate (16, 17, 'Max. Value of Q= '); Read (MaxQ);
Locate (16, 18, 'Min. Value of Q= '); Read (MinQ);
Locate (16, 19, 'Max. Value of r= '); Read (MaxReorden);
Locate (16, 20, 'Min. Value of r= '); Read (MinReorden);
Locate (16, 21, 'Max. Value of T= '); Read (MaxTRev);
Locate (16, 22, 'Min. Value of T= '); Read (MinTRev);
End;
6: Begin
Qw:=0;
Locate (13, 11, 'The R value calculated is: '); Write (Rw);
Locate (13, 12, 'The r value calculated is: '); Write
(Reordenw);
Locate (13, 13, 'The T value calculated is: '); Write
(TRevw);
Locate (16, 17, 'Max. Value of R= '); Read (MaxR);
Locate (16, 18, 'Min. Value of R= '); Read (MinR);
Locate (16, 19, 'Max. Value of r= '); Read (MaxReorden);
Locate (16, 20, 'Min. Value of r= '); Read (MinReorden);
Locate (16, 21, 'Max. Value of T= '); Read (MaxTRev);
Locate (16, 22, 'Min. Value of T= '); Read (MinTRev);
End;
End; {del case}
End; {del else}
If (MaxR<Rw) or (MinR>Rw) then
Locate (16,23, 'Incorrect MaxR or MinR Value');
If (MaxReorden<Reordenw) or (MinReorden>Reordenw) then
Apéndice I
94
Locate (16,23, 'Incorrect MaxReorden or MinReorden Value');
If (MaxQ<Qw) or (MinQ>Qw) then
Locate (16,23, 'Incorrect MaxQ or MinQ Value');
If (MaxTRev<TRevw) or (MinTRev>TRevw) then
Locate (16,23, 'Incorrect MaxTRev or MinTRev Value');
readln;
Until ((MaxR>=Rw) and (MinR<=Rw)) and ((MaxReorden>=Reordenw) and
(MinReorden<=
Reordenw)) and ((MaxQ>=Qw) and (MinQ<=Qw)) and ((MaxTrev>=TRevw) and
(MinTRev<=
TRevw));
End; {del procedure SolInicial}
Procedure RellenaX;
Begin
MidR:= (MaxR+MinR)/2;
MidReorden:= (MaxReorden+MinReorden)/2;
MidQ:= (MaxQ+MinQ)/2;
MidTRev:= (MaxTrev+MinTrev)/2;
Case NumMod of
1: ;
2: Begin
For i:=1 to 9 do
X[i,1]:=1;
X[1,2]:=MinR;
X[2,2]:=MaxR;
X[3,2]:=MinR;
X[4,2]:=MaxR;
X[1,3]:=MinReorden;
X[2,3]:=MinReorden;
X[3,3]:=MaxReorden;
X[4,3]:=MaxReorden;
For i:=5 to 9 do
Begin
X[i,2]:=MidR;
X[i,3]:=MidReorden;
End;
End;
3: Begin
For i:=1 to 9 do
X[i,1]:=1;
X[1,2]:=MinQ;
X[2,2]:=MaxQ;
X[3,2]:=MinQ;
X[4,2]:=MaxQ;
X[1,3]:=MinReorden;
X[2,3]:=MinReorden;
X[3,3]:=MaxReorden;
X[4,3]:=MaxReorden;
For i:=5 to 9 do
Begin
X[i,2]:=MidQ;
X[i,3]:=MidReorden;
End;
End;
4: Begin
For i:=1 to 9 do
X[i,1]:=1;
X[1,2]:=MinR;
X[2,2]:=MaxR;
X[3,2]:=MinR;
X[4,2]:=MaxR;
X[1,3]:=MinTRev;
X[2,3]:=MinTRev;
X[3,3]:=MaxTRev;
X[4,3]:=MaxTRev;
For i:=5 to 9 do
Begin
X[i,2]:=MidR;
X[i,3]:=MidTRev;
End;
Apéndice I
End;
5: Begin
For i:=1 to 13 do
X[i,1]:=1;
X[1,2]:=MinQ;
X[2,2]:=MaxQ;
X[3,2]:=MinQ;
X[4,2]:=MaxQ;
X[5,2]:=MinQ;
X[6,2]:=MaxQ;
X[7,2]:=MinQ;
X[8,2]:=MaxQ;
X[1,3]:=MinReorden;
X[2,3]:=MinReorden;
X[3,3]:=MaxReorden;
X[4,3]:=MaxReorden;
X[5,3]:=MinReorden;
X[6,3]:=MinReorden;
X[7,3]:=MaxReorden;
X[8,3]:=MaxReorden;
X[1,4]:=MinTRev;
X[2,4]:=MinTRev;
X[3,4]:=MinTRev;
X[4,4]:=MinTRev;
X[5,4]:=MaxTRev;
X[6,4]:=MaxTRev;
X[7,4]:=MaxTRev;
X[8,4]:=MaxTRev;
For i:=9 to 13 do
Begin
X[i,2]:=MidQ; X[i,3]:=MidReorden; X[i,4]:=MidTRev;
End;
End;
6: Begin
For i:=1 to 13 do
X[i,1]:=1;
X[1,2]:=MinR;
X[2,2]:=MaxR;
X[3,2]:=MinR;
X[4,2]:=MaxR;
X[5,2]:=MinR;
X[6,2]:=MaxR;
X[7,2]:=MinR;
X[8,2]:=MaxR;
X[1,3]:=MinReorden;
X[2,3]:=MinReorden;
X[3,3]:=MaxReorden;
X[4,3]:=MaxReorden;
X[5,3]:=MinReorden;
X[6,3]:=MinReorden;
X[7,3]:=MaxReorden;
X[8,3]:=MaxReorden;
X[1,4]:=MinTrev;
X[2,4]:=MinTrev;
X[3,4]:=MinTrev;
X[4,4]:=MinTrev;
X[5,4]:=MaxTrev;
X[6,4]:=MaxTrev;
X[7,4]:=MaxTrev;
X[8,4]:=MaxTrev;
For i:=9 to 13 do
Begin
X[i,2]:=MidR; X[i,3]:=MidReorden; X[i,4]:=MidTRev;
End;
End;
End; {del case}
End; {del procedure RellenaX}
Procedure Colecta;
Begin
Semilla:=SemillaAux;
ContNumSimul:=1;
SumaTC:=0;
Repeat
Simula (0, Semilla);
SumaTC:= SumaTC+CTA;
ContNumSimul:=ContNumSimul+1;
Until (ContNumSimul>NumSimul);
CTA:= SumaTC/NumSimul;
End;{del procedure Colecta}
95
Apéndice I
Procedure Diseno1;
Begin
Case NumMod of
1: ;
2: Begin
Q:=0; TRev:=0;
For i:=1 to 9 do
Begin
R:=X[i,2];
Reorden:=X[i,3];
Colecta;
Y[i]:=CTA;
End;
End;
3: Begin
R:=0; TRev:=0;
For i:=1 to 9 do
Begin
Q:=X[i,2];
Reorden:=X[i,3];
Colecta;
Y[i]:=CTA;
End;
End;
4: Begin
Reorden:=0; Q:=0;
For i:=1 to 9 do
Begin
R:=X[i,2];
TRev:=X[i,3];
Colecta;
Y[i]:=CTA;
End;
End;
5: Begin
R:=0;
For i:=1 to 13 do
Begin
Q:=X[i,2];
R:=X[i,3];
TRev:=X[i,4];
Colecta;
Y[i]:=CTA;
End;
End;
6: Begin
Q:=0;
For i:=1 to 13 do
Begin
R:=X[i,2]; Reorden:=X[i,3]; TRev:=X[i,4];
Colecta;
Y[i]:=CTA;
End;
End;
End; {del Case}
End; {del procedure Diseno1}
Procedure Transpuesta;
Begin
If NumMod in [2, 3, 4] then
Begin
96
Apéndice I
renglon:=9;
columna:=3;
End
Else
Begin
renglon:=13;
columna:=4;
End;
For i:=1 to columna do
Begin
For j:=1 to renglon do
XT[i,j]:=X[j,i];
End;
End; {del procedure Transpuesta}
Procedure Multiplica_XTX;
Begin
For i:=1 to 4 do
Begin
For j:=1 to 4 do
XTX[i,j]:=0;
End;
For i:=1 to columna do
Begin
For j:=1 to columna do
Begin
For h:=1 to renglon do
XTX[i,j]:=XT[i,h]*X[h,j]+XTX[i,j];
End;
End;
For i:=1 to columna do
Begin
For j:=1 to columna do
Mat[i,j]:=XTX[i,j];
End;
End; {del procedure Multiplica_XTX}
Procedure MatrizIdentidad;
Var
ni:
Integer;
Begin
n:=columna;
ni:=n+1;
i:=0;
j:=0;
For i:=1 to n do {Renglon}
For j:=ni to n*2 do {Columna}
Begin
If (i=(j-n)) then
Mat[i,j]:=1
Else
Mat[i,j]:=0;
End;
End; {del procedure MatrizIdntidad}
Procedure ResolverMatriz;
97
Apéndice I
98
VAR
i,j,jc,jr,pv,kc,m,nv,k,x,y:integer;
tm,det,eps,eps2,r,temp,va:real;
BEGIN
eps:=1.0;
WHILE((1.0+eps)> 1.0) DO
eps:= eps/2.0;
eps:=eps*2;
eps2:=eps*2;
det:=1.0;
FOR i:=1 TO n-1 DO
BEGIN
pv:=i;
FOR j:=i+1 TO n DO
BEGIN
IF(ABS(mat[pv,i]) < ABS(mat[j,i])) THEN
pv:=j;
END;
IF(pv <> i) THEN
BEGIN
FOR jc:=1 TO n*2 DO
BEGIN
tm:=mat[i,jc];
mat[i,jc]:=mat[pv,jc];
mat[pv,jc]:=tm;
END;
det:=-det;
END;
IF (mat[i,i]<>0.0) THEN
BEGIN
FOR jr:= i+1 TO n DO
BEGIN
IF (mat[jr,i]<>0.0) THEN
BEGIN
r:=mat[jr,i]/mat[i,i];
FOR kc:=i+1 TO n*2 DO
BEGIN
temp:=mat[jr,kc];
mat[jr,kc]:=mat[jr,kc]-r*mat[i,kc];
IF (ABS(mat[jr,kc])<(eps2*temp)) THEN
mat[jr,kc]:=0.0;
END;
END;
END;
END;{ELSE}
END;
FOR i:=1 TO n DO
det:=det*mat[i,i];
IF (mat[n,n]<>0.0) THEN
BEGIN
FOR m:=n+1 TO n*2 DO
BEGIN
mat[n,m]:=mat[n,m]/mat[n,n];
FOR nv:= n-1 DOWNTO 1 DO
BEGIN
Apéndice I
va:=mat[nv,m];
FOR k:=nv+1 TO n DO
va:=va-mat[nv,k]*mat[k,m];
mat[nv,m]:=va/mat[nv,nv];
END;
END;
END;{ELSE}
End; {del procedure ResolverMatriz}
Procedure Multiplica_XTY;
Begin
For i:=1 to 10 do
XTY[i]:=0;
For i:=1 to columna do
Begin
For j:=1 to renglon do
XTY[i]:=XT[i,j]*Y[j]+XTY[i];
End;
End; {del procedure Multiplica_XTY}
Procedure Betas1;
Begin
For i:=1 to 4 do
Beta[i]:=0;
For i:=1 to columna do
Begin
For j:=1 to columna do
Beta[i]:=Mat[i,j+n]*XTY[j]+Beta[i];
End;
ClrScr;
CuadroColor (1, 80, 1, 24, 9);
Locate (15,3, 'The first-order fit model is: ');
For i:=2 to 4 do
Begin
If Beta[i]>=0 then
Signo[i]:='+'
Else
Signo[i]:=' ';
End;
Case NumMod of
1: ;
2: Begin
Gotoxy (23, 6);
Writeln ('Y=', Beta[1]:6:4, Signo[2], Beta[2]:6:4,'*R',
Signo[3], Beta[3]:6:4,'*r'); Readln;
End;
3: Begin
Gotoxy (23, 6);
Writeln ('Y=', Beta[1]:6:4, Signo[2], Beta[2]:6:4,'*Q',
Signo[3], Beta[3]:6:4,'*r'); Readln;
End;
4: Begin
Gotoxy (23, 6);
Writeln ('Y=', Beta[1]:6:4, Signo[2], Beta[2]:6:4,'*R',
Signo[3], Beta[3]:6:4,'*T'); Readln;
99
Apéndice I
100
End;
5: Begin
Gotoxy (23, 6);
Writeln ('Y=', Beta[1]:6:4, Signo[2], Beta[2]:6:4,'*Q',
Signo[3], Beta[3]:6:4,'*r', Signo[4], Beta[4]:6:4,'*T');
Readln;
End;
6: Begin
Gotoxy (23, 6);
Writeln ('Y=', Beta[1]:6:2, Signo[2], Beta[2]:6:2,'*R',
Signo[3], Beta[3]:6:2,'*r', Signo[4], Beta[4]:6:2,'*T');
Readln;
End;
End; {del case}
End; {del procedure Betas1}
Procedure Respredicha1;
Begin
For i:=1 to 13 do
Yest[i]:=0;
For i:=1 to renglon do
Begin
For j:=1 to columna do
Yest[i]:=X[i,j]*Beta[j]+Yest[i];
End;
End;{del procedure Respredicha1}
Procedure Pruebas1;
Var
SumY, SumYc, Yprom, Ycprom, SST, SSE, SSErrorPuro,
SSFaltajuste
: Real;
Begin
SumY:=0; SumYc:=0; Yprom:=0; Ycprom:=0; SST:=0; SSR:=0;
SSE:=0; SSErrorPuro:=0; SSFaltajuste:=0; Fcalc:=0; Fc:=0;
ClrScr;
CuadroColor (1, 80, 1, 24, 9);
Locate (13, 3, 'In the search for the minimum, it is necessary to');
Locate (13, 4, 'test for the significance of the coefficient
estimates');
Locate (13, 5, 'and for the lack of fit in the fitted model. Please
type ');
Locate (13, 6, 'an alpha value(0.25, 0.10, 0.05, 0.025 or 0.01): ');
Read(Alpha);
If NumMod in [2, 3, 4] then
Begin
For i:=1 to 9 do
SumY:=Y[i]+SumY;
Yprom:=SumY/9;
For i:=1 to 9 do
Begin
SST:=(Y[i]-Yprom)*(Y[i]-Yprom)+SST;
SSR:=(Yest[i]-Yprom)*(Yest[i]-Yprom)+SSR;
End;
SSE:= SST-SSR;
Fcalc:=(SSR/2)/(SSE/6);
Apéndice I
For i:=5 to 9 do
SumYc:=Y[i]+SumYc;
Ycprom:=SumYc/5;
For i:=5 to 9 do
SSErrorPuro:=(Y[i]-Ycprom)*(Y[i]-Ycprom)+SSErrorPuro;
SSFaltajuste:=SSE-SSErrorPuro;
Fc:=(SSFaltajuste/2)/(SSErrorPuro/4);
If Alpha=0.25 then
Begin
FTab:=1.76;
FT:=2.0;
End;
If Alpha=0.10 then
Begin
FTab:=3.46;
FT:=4.32;
End;
If Alpha=0.05 then
Begin
FTab:=5.14;
FT:=6.94;
End;
If Alpha=0.025 then
Begin
FTab:=7.26;
FT:=10.65;
End;
If Alpha=0.01 then
Begin
FTab:=10.92;
FT:=18.0;
End;
End {del if}
Else
Begin
For i:=1 to 13 do
SumY:=Y[i]+SumY;
Yprom:=SumY/13;
For i:=1 to 13 do
Begin
SST:=(Y[i]-Yprom)*(Y[i]-Yprom)+SST;
SSR:=(Yest[i]-Yprom)*(Yest[i]-Yprom)+SSR;
End;
SSE:= SST-SSR;
Fcalc:=(SSR/3)/(SSE/9);
For i:=9 to 13 do
SumYc:=Y[i]+SumYc;
Ycprom:=SumYc/5;
For i:=9 to 13 do
SSErrorPuro:=(Y[i]-Ycprom)*(Y[i]-Ycprom)+SSErrorPuro;
SSFaltajuste:=SSE-SSErrorPuro;
Fc:=(SSFaltajuste/5)/(SSErrorPuro/4);
If Alpha=0.25 then
Begin
FTab:=1.63;
FT:=2.07;
End;
If Alpha=0.10 then
Begin
FTab:=2.81;
FT:=4.05;
End;
If Alpha=0.05 then
Begin
101
Apéndice I
102
FTab:=3.86;
FT:=6.26;
End;
If Alpha=0.025 then
Begin
FTab:=5.08;
FT:=9.36;
End;
If Alpha=0.01 then
Begin
FTab:=6.99;
FT:=15.52;
End;
End; {del else}
End; {del procedure Pruebas1}
Procedure Rangos;
Begin
ClrScr;
CuadroColor (1, 80, 1, 24, 9);
Locate (13, 13, 'In the search for the minimum, it is necessary to');
Locate (13, 14, 'use intervals for each variable, please type the ');
Locate (13, 15, 'maximum and the minimum value (in these intervals ');
Locate (13, 16, 'include the values above): ');
Repeat
Case NumMod of
1: ;
2: Begin
Q:=0; TRev:=0;
Locate (13, 11, 'The new R value is: '); Write (R:3:2);
Locate (13, 12, 'The new r value is: '); Write (Reorden:3:2);
Locate (16, 17, 'Max. Value of R= '); Read (MaxR);
Locate (16, 18, 'Min. Value of R= '); Read (MinR);
Locate (16, 19, 'Max. Value of r= '); Read (MaxReorden);
Locate (16, 20, 'Min. Value of r= '); Read (MinReorden);
End;
3: Begin
R:=0; TRev:=0;
Locate (13, 11, 'The new Q value is: '); Write (Q:3:2);
Locate (13, 12, 'The new r value is: '); Write (Reorden:3:2);
Locate (16, 17, 'Max. Value of Q= '); Read (MaxQ);
Locate (16, 18, 'Min. Value of Q= '); Read (MinQ);
Locate (16, 19, 'Max. Value of r= '); Read (MaxReorden);
Locate (16, 20, 'Min. Value of r= '); Read (MinReorden);
End;
4: Begin
Reorden:=0; Q:=0;
Locate (13, 11, 'The new R value is: '); Write (R:3:2);
Locate (13, 12, 'The new T value is: '); Write (TRev:3:2);
Locate (16, 17, 'Max. Value of R= '); Read (MaxR);
Locate (16, 18, 'Min. Value of R= '); Read (MinR);
Locate (16, 19, 'Max. Value of T= '); Read (MaxTRev);
Locate (16, 20, 'Min. Value of T= '); Read (MinTRev);
End;
5: Begin
R:=0;
Locate (13, 11, 'The new Q value is: '); Write (Q:3:2);
Locate (13, 12, 'The new r value is: '); Write (Reorden:3:2);
Apéndice I
103
Locate (13, 13, 'The T value calculated is: '); Write
(TRev:3:2);
Locate (16, 17, 'Max. Value of Q= '); Read (MaxQ);
Locate (16, 18, 'Min. Value of Q= '); Read (MinQ);
Locate (16, 19, 'Max. Value of r= '); Read (MaxReorden);
Locate (16, 20, 'Min. Value of r= '); Read (MinReorden);
Locate (16, 21, 'Max. Value of T= '); Read (MaxTRev);
Locate (16, 22, 'Min. Value of T= '); Read (MinTRev);
End;
6: Begin
Q:=0;
Locate (13, 11, 'The new R value is: '); Write (R:3:2);
Locate (13, 12, 'The new r value is: '); Write (Reorden:3:2);
Locate (13, 13, 'The new T value is: '); Write (TRev:3:2);
Locate (16, 17, 'Max. Value of R= '); Read (MaxR);
Locate (16, 18, 'Min. Value of R= '); Read (MinR);
Locate (16, 19, 'Max. Value of r= '); Read (MaxReorden);
Locate (16, 20, 'Min. Value of r= '); Read (MinReorden);
Locate (16, 21, 'Max. Value of T= '); Read (MaxTRev);
Locate (16, 22, 'Min. Value of T= '); Read (MinTRev);
End;
End; {del case}
If (MaxR<R) or (MinR>R) then
Locate (16,23, 'Incorrect MaxR or MinR Value');
If (MaxReorden<Reorden) or (MinReorden>Reorden) then
Locate (16,23, 'Incorrect MaxReorden or MinReorden Value');
If (MaxQ<Q) or (MinQ>Q) then
Locate (16,23, 'Incorrect MaxQ or MinQ Value');
If (MaxTRev<TRev) or (MinTRev>TRev) then
Locate (16,23, 'Incorrect MaxTRev or MinTRev Value');
readln;
Until ((MaxR>=R) and (MinR<=R)) and ((MaxReorden>=Reorden) and
(MinReorden<=
Reorden)) and ((MaxQ>=Q) and (MinQ<=Q)) and ((MaxTrev>=TRev) and
(MinTRev<=
TRev));
End;{del procedure Rangos}
Procedure Trayectoria;
Var
Control
: Integer;
Valor1, Valor2, Valor3
: Real;
Aux
: Array [1..30, 1..4] of Real;
Begin
Valor1:=0;
Valor2:=0;
Valor3:=0;
Control:=1;
ClrScr;
CuadroColor (1, 80, 1, 24, 9);
Locate (13, 3, 'In the search for the minimum, it is necessary to ');
Locate (13, 4, 'determine a decrement value for a variable (the');
Locate (13, 5, 'one with the higer coefficient at the adjusted');
Locate (13, 6, 'equation). This program decrement the variable,');
Locate (13, 7, 'in this value, until the Total Annual Cost is higher');
Locate (13, 8, 'than the previous one. In this way it is possible');
Locate (13, 9, 'find a new solution. Please type the value for the ');
Case NumMod of
Apéndice I
104
1: ;
2: Begin
If (abs(Beta[2])) >= (abs(Beta[3])) then
Begin
Locate (13, 10, 'increment of R if itïs actual value is:
Write (R:3:2,': ');
Readln (Valor1);
R:=R+Valor1;
Valor2:=Beta[3]/(Beta[2]/Valor1);
Reorden:=Reorden+Valor2;
End {del if}
Else
Begin
Locate (13, 10, 'increment of r if itïs actual value is:
Write (Reorden:3:2,': ');
Readln (Valor2);
Reorden:=Reorden+Valor2;
Valor1:=Beta[2]/(Beta[3]/Valor2);
R:=R+Valor1;
End;{del else}
Colecta;
Aux[1,1]:=R; Aux[1,2]:=Reorden; Aux [1,3]:=CTA;
Repeat
Control:=Control+1;
R:=R+Valor1;
Reorden:=Reorden+Valor2;
Colecta;
Aux[Control,1]:=R; Aux[Control,2]:=Reorden; Aux
[Control,3]:=CTA;
Until Aux[Control,3] > Aux[(Control-1),3];
ClrScr;
CuadroColor (1, 80, 1, 24, 9);
Locate (22,2, 'R
r
TC');
For i:=1 to Control do
Begin
Gotoxy(20,2+i); Write(Aux[i,1]:3:2,'
', Aux[i,2]:3:2,'
Aux[i,3]:4:2);
End;
Readln;
R:=Aux[(Control-1),1];
Reorden:=Aux[(Control-1),2];
R1:=R; Reorden1:=Reorden; CTA1:=Aux[(Control-1),3];
End;
3: Begin
If (abs(Beta[2])) >= (abs(Beta[3])) then
Begin
Locate (13, 10, 'increment of Q if itïs actual value is:
Write (Q:3:2,': ');
Readln (Valor1);
Q:=Q+Valor1;
Valor2:=Beta[3]/(Beta[2]/Valor1);
Reorden:=Reorden+Valor2;
End {del if}
Else
Begin
Locate (13, 10, 'increment of r if itïs actual value is:
Write (Reorden:3:2,': ');
Readln (Valor2);
Reorden:=Reorden+Valor2;
');
');
',
');
');
Apéndice I
105
Valor1:=Beta[2]/(Beta[3]/Valor2);
Q:=Q+Valor1;
End; {del else}
Colecta;
Aux[1,1]:=Q; Aux[1,2]:=Reorden; Aux [1,3]:=CTA;
Repeat
Control:=Control+1;
Q:=Q+Valor1;
Reorden:=Reorden+Valor2;
Colecta;
Aux[Control,1]:=Q; Aux[Control,2]:=Reorden; Aux
[Control,3]:=CTA;
Until Aux[Control,3] > Aux[(Control-1),3];
ClrScr;
CuadroColor (1, 80, 1, 24, 9);
Locate (22,2, 'Q
r
TC');
For i:=1 to Control do
Begin
Gotoxy(20,2+i); Write(Aux[i,1]:3:2,'
', Aux[i,2]:3:2,'
',
Aux[i,3]:4:2);
End;
Readln;
Q:=Aux[(Control-1),1];
Reorden:=Aux[(Control-1),2];
Q1:=Q; Reorden1:=Reorden; CTA1:=Aux[(Control-1),3];
End;
4: Begin
If (abs(Beta[2])) >= (abs(Beta[3])) then
Begin
Locate (13, 10, 'increment of R if itïs actual value is: ');
Write (R:3:2,': ');
Readln (Valor1);
R:=R+Valor1;
Valor2:=Beta[3]/(Beta[2]/Valor1);
TRev:=TRev+Valor2;
End {del if}
Else
Begin
Locate (13, 10, 'increment of T if itïs actual value is: ');
Write (TRev:3:2,': ');
Readln (Valor2);
TRev:=TRev+Valor2;
Valor1:=Beta[2]/(Beta[3]/Valor2);
R:=R+Valor1;
End;{del else}
Colecta;
Aux[1,1]:=R; Aux[1,2]:=TRev; Aux [1,3]:=CTA;
Repeat
Control:=Control+1;
R:=R+Valor1;
TRev:=TRev+Valor2;
Colecta;
Aux[Control,1]:=R; Aux[Control,2]:=TRev; Aux [Control,3]:=CTA;
Until Aux[Control,3] > Aux[(Control-1),3];
ClrScr;
CuadroColor (1, 80, 1, 24, 9);
Locate (22,2, 'R
T
TC');
For i:=1 to Control do
Begin
Apéndice I
106
Gotoxy(20,2+i); Write(Aux[i,1]:3:2,'
', Aux[i,2]:3:2,'
',
Aux[i,3]:4:2);
End;
Readln;
R:=Aux[(Control-1),1];
TRev:=Aux[(Control-1),2];
R1:=R; TRev1:=TRev; CTA1:=Aux[(Control-1),3];
End;
5: Begin
If ((abs(Beta[2])) >= (abs(Beta[3]))) and ((abs(Beta[2])) >=
(abs(Beta[4]))) then
Begin
Locate (13, 10, 'increment of Q if itïs actual value is: ');
Write (Q:3:2,': ');
Readln (Valor1);
Q:=Q+Valor1;
Valor2:=Beta[3]/(Beta[2]/Valor1);
Reorden:=Reorden+Valor2;
Valor3:=Beta[4]/(Beta[2]/Valor1);
TRev:=TRev+Valor3;
End {del if}
Else
Begin
If (abs(Beta[3])) >= (abs(Beta[4])) then
Begin
Locate (13, 10, 'increment of r if itïs actual value is: ');
Write (Reorden:3:2,': ');
Readln (Valor2);
Reorden:=Reorden+Valor2;
Valor1:=Beta[2]/(Beta[3]/Valor2);
Q:=Q+Valor1;
Valor3:=Beta[4]/(Beta[3]/Valor2);
TRev:=TRev+Valor3;
End {del if}
Else
Begin
Locate (13, 10, 'increment of T if itïs actual value is: ');
Write (TRev:3:2,': ');
Readln (Valor3);
TRev:=TRev+Valor3;
Valor1:=Beta[2]/(Beta[4]/Valor3);
Q:=Q+Valor1;
Valor2:=Beta[3]/(Beta[4]/Valor3);
Reorden:=Reorden+Valor2;
End; {del else}
End; {del else}
Colecta;
Aux[1,1]:=Q;
Aux[1,2]:=Reorden;
Aux [1,3]:=TRev;
Aux[1,4]:=CTA;
Repeat
Control:=Control+1;
Q:=Q+Valor1; Reorden:=Reorden+Valor2; TRev:=TRev+Valor3;
Colecta;
Aux[Control,1]:=Q;
Aux[Control,2]:=Reorden;
Aux [Control,3]:=TRev; Aux[Control,4]:=CTA;
Until Aux[(Control),4] > Aux[(Control-1),4];
ClrScr;
Apéndice I
107
CuadroColor (1, 80, 1, 24, 9);
Locate (22,2, 'Q
r
T
TC');
For i:=1 to Control do
Begin
Gotoxy(20,2+i); Write(Aux[i,1]:3:2,'
',Aux[i,2]:3:2,'
',
Aux[i,3]:3:2,'
',Aux[i,4]:4:2);
End;
Readln;
Q:=Aux[(Control-1),1]; Reorden:=Aux[(Control-1),2];
TRev:=Aux[(Control-1),3];
Q1:=Q;
Reorden1:=Reorden;
TRev1:=TRev; CTA1:=Aux[(Control1),4];
End;
6: Begin
If ((abs(Beta[2])) >= (abs(Beta[3]))) and ((abs(Beta[2])) >=
(abs(Beta[4]))) then
Begin
Locate (13, 10, 'increment of R if itïs actual value is: ');
Write (R:3:2,': ');
Readln (Valor1);
R:=R+Valor1;
Valor2:=Beta[3]/(Beta[2]/Valor1);
Reorden:=Reorden+Valor2;
Valor3:=Beta[4]/(Beta[2]/Valor1);
CTA1:=Aux[(Control-1),3];
TRev:=TRev+Valor3;
End {del if}
Else
Begin
If (abs(Beta[3])) >= (abs(Beta[4])) then
Begin
Locate (13, 10, 'increment of r if itïs actual value is: ');
Write (Reorden:3:2,': ');
Readln (Valor2);
Reorden:=Reorden+Valor2;
Valor1:=Beta[2]/(Beta[3]/Valor2);
R:=R+Valor1;
Valor3:=Beta[4]/(Beta[3]/Valor2);
TRev:=TRev+Valor3;
End {del if}
Else
Begin
Locate (13, 10, 'increment of T if itïs actual value is: ');
Write (TRev:3:2,': ');
Readln (Valor3);
TRev:=TRev+Valor3;
Valor1:=Beta[2]/(Beta[4]/Valor3);
R:=R+Valor1;
Valor2:=Beta[3]/(Beta[4]/Valor3);
Reorden:=Reorden+Valor2;
End; {del else}
End; {del else}
Colecta;
Aux[1,1]:=R;
Aux[1,2]:=Reorden;
Aux [1,3]:=TRev;
Aux[1,4]:=CTA;
Repeat
Control:=Control+1;
Apéndice I
108
R:=R+Valor1; Reorden:=Reorden+Valor2; TRev:=TRev+Valor3;
Colecta;
Aux[Control,1]:=R;
Aux[Control,2]:=Reorden;
Aux [Control,3]:=TRev; Aux[Control,4]:=CTA;
Until Aux[Control,4] > Aux[(Control-1),4];
ClrScr;
CuadroColor (1, 80, 1, 24, 9);
Locate (22,2, 'R
r
T
TC');
For i:=1 to Control do
Begin
Gotoxy(20,2+i); Write(Aux[i,1]:3:2,'
', Aux[i,2]:3:2,'
',
Aux[i,3]:3:2,'
',Aux[i,4]:4:2);
End;
Readln;
R:=Aux[(Control-1),1]; Reorden:=Aux[(Control-1),2];
TRev:=Aux[(Control-1),3];
R1:=R;
Reorden1:=Reorden;
TRev1:=TRev; CTA1:=Aux[(Control1),4];
End;
End; {del Case}
End; {del procedure Trayectoria}
Procedure Diseno2;
Var
AnegR, AposR, AnegReorden, AposReorden, AnegQ,
AposQ, AnegTRev, AposTRev
: Real;
Begin
If NumMod in [2, 3, 4] then
Begin
AnegR:=MidR-(1.4142*(MaxR-MidR));
AposR:=MidR+(1.4142*(MaxR-MidR));
AnegReorden:=MidReorden-(1.4142*(MaxReorden-MidReorden));
AposReorden:=MidReorden+(1.4142*(MaxReorden-MidReorden));
AnegQ:=MidQ-(1.4142*(MaxQ-MidQ));
AposQ:=MidQ+(1.4142*(MaxQ-MidQ));
AnegTRev:=MidTRev-(1.4142*(MaxTRev-MidTRev));
AposTRev:=MidTRev+(1.4142*(MaxTRev-MidTRev));
End
Else
Begin
AnegR:=MidR-(1.682*(MaxR-MidR));
AposR:=MidR+(1.682*(MaxR-MidR));
AnegReorden:=MidReorden-(1.682*(MaxReorden-MidReorden));
AposReorden:=MidReorden+(1.682*(MaxReorden-MidReorden));
AnegQ:=MidQ-(1.682*(MaxQ-MidQ));
AposQ:=MidQ+(1.682*(MaxQ-MidQ));
AnegTRev:=MidTRev-(1.682*(MaxTRev-MidTRev));
AposTRev:=MidTRev+(1.682*(MaxTRev-MidTRev));
End;
Case NumMod of
1: ;
2: Begin
Q:=0; TRev:=0;
A[1,1]:=MinR;
A[2,1]:=MaxR;
A[3,1]:=MinR;
A[4,1]:=MaxR;
A[5,1]:=AnegR;
A[6,1]:=AposR;
Apéndice I
109
A[7,1]:=MidR;
A[8,1]:=MidR;
A[1,2]:=MinReorden;
A[2,2]:=MinReorden; A[3,2]:=MaxReorden; A[4,2]:=MaxReorden;
A[5,2]:=MidReorden; A[6,2]:=MidReorden; A[7,2]:=AnegReorden;
A[8,2]:=AposReorden;
For i:=9 to 13 do
Begin
A[i,1]:=MidR;
A[i,2]:=MidReorden;
End;
For i:=1 to 13 do
Begin
R:=A[i,1];
Reorden:=A[i,2];
Colecta;
Y2[i]:=CTA;
End;
End;
3: Begin
R:=0; TRev:=0;
A[1,1]:=MinQ;
A[2,1]:=MaxQ;
A[3,1]:=MinQ;
A[4,1]:=MaxQ;
A[5,1]:=AnegQ;
A[6,1]:=AposQ;
A[7,1]:=MidQ;
A[8,1]:=MidQ;
A[1,2]:=MinReorden;
A[2,2]:=MinReorden; A[3,2]:=MaxReorden; A[4,2]:=MaxReorden;
A[5,2]:=MidReorden; A[6,2]:=MidReorden; A[7,2]:=AnegReorden;
A[8,2]:=AposReorden;
For i:=9 to 13 do
Begin
A[i,1]:=MidQ;
A[i,2]:=MidReorden;
End;
For i:=1 to 13 do
Begin
Q:=A[i,1];
Reorden:=A[i,2];
Colecta;
Y2[i]:=CTA;
End;
End;
4: Begin
Reorden:=0; Q:=0;
A[1,1]:=MinReorden; A[2,1]:=MaxReorden;
A[3,1]:=MinReorden;
A[4,1]:=MaxReorden; A[5,1]:=AnegReorden;
A[6,1]:=AposReorden;
A[7,1]:=MidReorden; A[8,1]:=MidReorden;
A[1,2]:=MinTRev;
A[2,2]:=MinTRev; A[3,2]:=MaxTRev; A[4,2]:=MaxTRev;
A[5,2]:=MidTRev; A[6,2]:=MidTRev; A[7,2]:=AnegTRev;
A[8,2]:=AposTRev;
For i:=9 to 13 do
Begin
A[i,1]:=MidReorden;
A[i,2]:=MidTRev;
End;
For i:=1 to 13 do
Begin
Reorden:=A[i,1];
TRev:=A[i,2];
Colecta;
Y2[i]:=CTA;
End;
End;
5: Begin
R:=0;
A[1,1]:=MinQ;
A[2,1]:=MaxQ;
A[3,1]:=MinQ;
A[4,1]:=MaxQ;
A[5,1]:=MinQ;
A[6,1]:=MaxQ;
A[7,1]:=MinQ;
A[8,1]:=MaxQ;
Apéndice I
110
A[9,1]:=AnegQ; A[10,1]:=AposQ; A[11,1]:=MidQ;
A[12,1]:=MidQ;
A[13,1]:=MidQ; A[14,1]:=MidQ;
A[1,2]:=MinReorden;
A[2,2]:=MinReorden;
A[3,2]:=MaxReorden;
A[4,2]:=MaxReorden;
A[5,2]:=MinReorden;
A[6,2]:=MinReorden;
A[7,2]:=MaxReorden;
A[8,2]:=MaxReorden;
A[9,2]:=MidReorden;
A[10,2]:=MidReorden; A[11,2]:=AnegReorden;
A[12,2]:=AposReorden;
A[13,2]:=MidReorden; A[14,2]:=MidReorden;
A[1,3]:=MinTRev;
A[2,3]:=MinTRev;
A[3,3]:=MinTRev;
A[4,3]:=MinTRev;
A[5,3]:=MaxTRev;
A[6,3]:=MaxTRev;
A[7,3]:=MaxTRev;
A[8,3]:=MaxTRev;
A[9,3]:=MidTRev;
A[10,3]:=MidTRev;
A[11,3]:=MidTRev;
A[12,3]:=MidTRev;
A[13,3]:=AnegTRev; A[14,3]:=AposTRev;
For i:=15 to 19 do
Begin
A[i,1]:=MidQ;
A[i,2]:=MidReorden;
A[i,3]:=MidTRev;
End;
For i:=1 to 19 do
Begin
Q:=A[i,1];
Reorden:=A[i,2];
TRev:=A[i,3];
Colecta;
Y2[i]:=CTA;
End;
End;
6: Begin
Q:=0;
A[1,1]:=MinR;
A[2,1]:=MaxR;
A[3,1]:=MinR;
A[4,1]:=MaxR;
A[5,1]:=MinR;
A[6,1]:=MaxR;
A[7,1]:=MinR;
A[8,1]:=MaxR;
A[9,1]:=AnegR; A[10,1]:=AposR; A[11,1]:=MidR;
A[12,1]:=MidR;
A[13,1]:=MidR; A[14,1]:=MidR;
A[1,2]:=MinReorden;
A[2,2]:=MinReorden;
A[3,2]:=MaxReorden;
A[4,2]:=MaxReorden;
A[5,2]:=MinReorden;
A[6,2]:=MinReorden;
A[7,2]:=MaxReorden;
A[8,2]:=MaxReorden;
A[9,2]:=MidReorden;
A[10,2]:=MidReorden; A[11,2]:=AnegReorden;
A[12,2]:=AposReorden;
A[13,2]:=MidReorden; A[14,2]:=MidReorden;
A[1,3]:=MinTRev;
A[2,3]:=MinTRev;
A[3,3]:=MinTRev;
A[4,3]:=MinTRev;
A[5,3]:=MaxTRev;
A[6,3]:=MaxTRev;
A[7,3]:=MaxTRev;
A[8,3]:=MaxTRev;
A[9,3]:=MidTRev;
A[10,3]:=MidTRev;
A[11,3]:=MidTRev;
A[12,3]:=MidTRev;
A[13,3]:=AnegTRev; A[14,3]:=AposTRev;
For i:=15 to 19 do
Begin
A[i,1]:=MidR;
A[i,2]:=MidReorden;
A[i,3]:=MidTRev;
End;
For i:=1 to 19 do
Begin
R:=A[i,1]; Reorden:=A[i,2]; TRev:=A[i,3];
Colecta;
Y2[i]:=CTA;
End;
End;
End; {del Case}
End; {del procedure Diseno2}
Apéndice I
111
Procedure Betas2;
Begin
For i:=1 to 11 do
Begin
For j:=1 to 11 do
XTX[i,j]:=0;
End;
If NumMod in [2, 3, 4] then
Begin
XTX[1,1]:=13;
For i:=1 to 13 do
Begin
XTX[1,2]:=A[i,1]+XTX[1,2];
XTX[1,3]:=A[i,2]+XTX[1,3];
XTX[1,4]:=A[i,1]*A[i,1]+XTX[1,4];
XTX[1,5]:=A[i,2]*A[i,2]+XTX[1,5];
XTX[1,6]:=A[i,1]*A[i,2]+XTX[1,6];
XTX[2,4]:=A[i,1]*A[i,1]*A[i,1]+XTX[2,4];
XTX[2,5]:=A[i,1]*A[i,2]*A[i,2]+XTX[2,5];
XTX[2,6]:=A[i,1]*A[i,1]*A[i,2]+XTX[2,6];
XTX[3,4]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10]:=Y2[i]*A[i,2]*A[i,3]+XTY[10];
XTY[11]:=Y2[i]*A[i,1]*A[i,2]*a[i,3]+XTY[11];
End;
End; {del else}
For i:=1 to columna do
Begin
For j:=1 to columna do
Mat[i,j]:=XTX[i,j];
End;
MatrizIdentidad;
ResolverMatriz;
For i:=1 to 11 do
Beta2[i]:=0;
For i:=1 to columna do
Begin
For j:=1 to columna do
Beta2[i]:=Mat[i,j+n]*XTY[j]+Beta2[i];
End;
ClrScr;
CuadroColor (1, 80, 1, 24, 9);
Locate (15,3, 'The second-order model fit is: ');
For i:=2 to 10 do
Begin
If Beta2[i]>=0 then
Signo[i]:='+'
Apéndice I
114
Else
Signo[i]:=' ';
End;
Case NumMod of
1: ;
2: Begin
Gotoxy (3, 10);
Writeln ('Y=',Beta2[1]:6:4, Signo[2], Beta2[2]:6:4,'*R',
Signo[3], Beta2[3]:6:4,'*r',Signo[4], Beta2[4],'*R^2',
Signo[5], Beta2[5]:6:4,'*r^2');
Writeln (' ',Signo[6], Beta2[6],'*R*r');Readln;
End;
3: Begin
Gotoxy (3, 10);
Writeln ('Y=', Beta2[1]:6:4, Signo[2], Beta2[2]:6:4,'*Q',
Signo[3], Beta2[3]:6:4,'*r',Signo[4], Beta2[4],'*Q^2',
Signo[5], Beta2[5]:6:4,'*r^2');
Writeln (' ',Signo[6], Beta2[6],'*Q*r');Readln;
End;
4: Begin
Gotoxy (16, 20);
Writeln ('Y=', Beta2[1]:6:4, Signo[2], Beta2[2]:6:4,'*R',
Signo[3], Beta2[3]:6:4,'*T',Signo[4], Beta2[4],'*R^2',
Signo[5], Beta2[5]:6:4,'*T^2');
Writeln (' ',Signo[6], Beta2[6],'*R*T');Readln;
End;
5: Begin
Gotoxy (16, 20);
Writeln ('Y=',Beta2[1]:6:4, Signo[2], Beta2[2]:6:4,'*Q',
Signo[3], Beta2[3]:6:4,'*r',Signo[4],
Beta2[4]:6:4,'*T',
Signo[5], Beta2[5]:6:4,'*Q^2', Signo[6], Beta2[6]:6:4,
'*r^2', Signo[7], Beta2[7]:6:4,'*T^2', Signo[8],
Beta2[8]:6:4,
'*Q*r', Signo[9], Beta2[9]:6:4,'*Q*T', Signo[10],
Beta2[10]:6:4,
'*r*T', Signo[11], Beta2[11]:6:4,'Q*r*T'); Readln;
End;
6: Begin
Gotoxy (16, 15);
Writeln ('Y=',Beta2[1]:6:4, Signo[2], Beta2[2]:6:4,'*R',
Signo[3], Beta2[3]:6:4,'*r',Signo[4],
Beta2[4]:6:4,'*T',
Signo[5], Beta2[5]:6:4,'*R^2', Signo[6], Beta2[6]:6:4,
'*r^2', Signo[7], Beta2[7]:6:4,'*T^2', Signo[8],
Beta2[8]:6:4,
'*R*r', Signo[9], Beta2[9]:6:4,'*R*T', Signo[10],
Beta2[10]:6:4,
'*r*T', Signo[11], Beta2[11]:6:4,'R*r*T'); Readln;
End;
End; {del case}
End; {del procedure Betas2}
Procedure Respredicha2;
Begin
For i:=1 to 19 do
Apéndice I
115
Yest2[i]:=0;
If NumMod in [2, 3, 4] then
Begin
For i:=1 to 13 do
Yest2[i]:=Beta2[1]+(Beta2[2]*A[i,1])+(Beta2[3]*A[i,2])+(Beta2[4]*
A[i,1]*A[i,1])+(Beta2[5]*A[i,2]*A[i,2])+(Beta2[6]*A[i,1]*
A[i,2]);
End
Else
Begin
For i:=1 to 19 do
Yest2[i]:=Beta2[1]+(Beta2[2]*A[i,1])+(Beta2[3]*A[i,2])+(Beta2[4]*
A[i,3])+(Beta2[5]*A[i,1]*A[i,1])+(Beta2[6]*A[i,2]*A[i,2])+
(Beta2[7]*A[i,3]*A[i,3])+(Beta2[8]*A[i,1]*A[i,2])+(Beta2[9]*
A[i,1]*A[i,3])+(Beta2[10]*A[i,2]*A[i,3])+(Beta2[11]*A[i,1]*
A[i,2]*A[i,3]);
End;
End; {del procedure Respredicha2}
Procedure Suficiencia;
Var
SumY, SumYc, Yprom, Ycprom, SST, SSE, SSErrorPuro,
SSFaltajuste
: Real;
Begin
SumY:=0; SumYc:=0; Yprom:=0; Ycprom:=0; SST:=0; SSR:=0;
SSE:=0; SSErrorPuro:=0; SSFaltajuste:=0; Fcalc:=0; Fc:=0;
ClrScr;
CuadroColor (1, 80, 1, 24, 9);
Locate (13, 3, 'In the search for the minimum, it is necessary to');
Locate (13, 4, 'test for the significance of the coefficient
estimates');
Locate (13, 5, 'and for the lack of fit in the fitted model. Please
type ');
Locate (13, 6, 'an alpha value(0.25, 0.10, 0.05, 0.025 or 0.01): ');
Read(Alpha);
If NumMod in [2, 3, 4] then
Begin
For i:=1 to 13 do
SumY:=Y2[i]+SumY;
Yprom:=SumY/13;
For i:=1 to 13 do
Begin
SST:=(Y2[i]-Yprom)*(Y2[i]-Yprom)+SST;
SSR:=(Yest2[i]-Yprom)*(Yest2[i]-Yprom)+SSR;
End;
SSE:= SST-SSR;
Fcalc:=(SSR/5)/(SSE/7);
For i:=9 to 13 do
SumYc:=Y2[i]+SumYc;
Ycprom:=SumYc/5;
For i:=9 to 13 do
SSErrorPuro:=(Y2[i]-Ycprom)*(Y2[i]-Ycprom)+SSErrorPuro;
SSFaltajuste:=SSE-SSErrorPuro;
Apéndice I
Fc:=(SSFaltajuste/3)/(SSErrorPuro/4);
If Alpha=0.25 then
Begin
FTab:=1.71;
FT:=2.05;
End;
If Alpha=0.10 then
Begin
FTab:=2.88;
FT:=4.19;
End;
If Alpha=0.05 then
Begin
FTab:=3.97;
FT:=6.59;
End;
If Alpha=0.025 then
Begin
FTab:=5.29;
FT:=9.98;
End;
If Alpha=0.01 then
Begin
FTab:=7.46;
FT:=16.69;
End;
End {del if}
Else
Begin
For i:=1 to 19 do
SumY:=Y[i]+SumY;
Yprom:=SumY/19;
For i:=1 to 19 do
Begin
SST:=(Y2[i]-Yprom)*(Y2[i]-Yprom)+SST;
SSR:=(Yest2[i]-Yprom)*(Yest2[i]-Yprom)+SSR;
End;
SSE:= SST-SSR;
Fcalc:=(SSR/9)/(SSE/10);
For i:=15 to 19 do
SumYc:=Y2[i]+SumYc;
Ycprom:=SumYc/5;
For i:=15 to 19 do
SSErrorPuro:=(Y2[i]-Ycprom)*(Y2[i]-Ycprom)+SSErrorPuro;
SSFaltajuste:=SSE-SSErrorPuro;
Fc:=(SSFaltajuste/6)/(SSErrorPuro/4);
If Alpha=0.25 then
Begin
FTab:=1.56;
FT:=2.08;
End;
If Alpha=0.10 then
Begin
FTab:=2.35;
FT:=4.01;
End;
If Alpha=0.05 then
Begin
FTab:=3.02;
FT:=6.16;
End;
If Alpha=0.025 then
Begin
FTab:=3.78;
FT:=9.20;
End;
116
Apéndice I
117
If Alpha=0.01 then
Begin
FTab:=4.94;
FT:=15.21;
End;
End; {del else}
End; {del procedure Suficiencia}
Procedure PtoEstacionario;
Var
F
: Array [1..3] of Real;
P
: Array [1..3] of Real;
Begin
If NumMod in [2, 3, 4] then
Begin
B[1,1]:=Beta2[4]; B[1,2]:=Beta2[6]/2; B[2,1]:=Beta2[6]/2;
B[2,2]:=Beta2[5]; F[1]:=Beta2[2]; F[2]:=Beta2[3]; P[1]:=0;
P[2]:=0; renglon:=2; columna:=2;
End
{del if}
Else
Begin
B[1,1]:=Beta2[5]; B[1,2]:=Beta2[8]/2; B[1,3]:=Beta2[9]/2;
B[2,1]:=Beta2[8]/2; B[2,2]:=Beta2[6]; B[2,3]:=Beta2[10]/2;
B[3,1]:=Beta2[9]/2; B[3,2]:=Beta2[10]/2; B[3,3]:=Beta2[7];
F[1]:=Beta2[2]; F[2]:=Beta2[3]; F[3]:=Beta2[4]; P[1]:=0;
P[2]:=0; P[3]:=0; renglon:=3; columna:=3;
End; {del else}
For i:=1 to renglon do
Begin
For j:=1 to columna do
Mat[i,j]:=B[i,j];
End;
MatrizIdentidad;
ResolverMatriz;
For i:=1 to renglon do
Begin
For j:=1 to columna do
P[i]:=(Mat[i,j+columna]*F[j])+P[i];
End;
For i:=1 to renglon do
P0[i]:=-0.5*P[i];
ClrScr;
CuadroColor (1, 80, 1, 24, 9);
Locate (13,3, 'The stationary point is: ');
Case NumMod of
1: ;
2: Begin
Gotoxy (16, 7); Write ('R= ',P0[1]:6:2,'
r= ',P0[2]:6:2);
Readln;
End;
3: Begin
Gotoxy (16, 7); Write ('Q= ',P0[1]:6:2,'
r= ',P0[2]:6:2);
Readln;
End;
4: Begin
Gotoxy (16, 7); Write ('R= ',P0[1]:6:2,'
T= ',P0[2]:6:2);
Readln;
Apéndice I
End;
5: Begin
Gotoxy (16, 7);
Write ('Q= ',P0[1]:6:2,'
r= ',P0[2]:6:2,'
Readln;
End;
6: Begin
Gotoxy (16, 7);
Write ('R= ',P0[1]:6:2,'
r= ',P0[2]:6:2,'
Readln;
End;
End; {del case}
End; {del procedure PtoEstacionario}
118
T= ', P0[3]:6:2) ;
T= ', P0[3]:6:2) ;
Procedure Caracteriza;
Var
a, v, c, a0, a1, a2, a3, ap0, ap1, ap2, discr,m :Real;
PX
:Array [1..20, 1..3] of
Real;
Begin
If NumMod in [2, 3, 4] then
Begin
a:=1;
v:=(-1*B[1,1])+(-1*B[2,2]);
c:=(B[1,1]*B[2,2])-(B[2,1]*B[1,2]);
eigenvalor3:=0;
End
Else
Begin
a0:=B[1,2]*B[2,1]*B[3,1]+B[1,3]*B[2,1]*B[3,2]-B[1,1]*B[2,3]*B[3,3]
-B[1,2]*B[2,1]*B[3,3]-B[1,3]*B[2,2]*B[3,1];
a1:=-B[3,3]-B[1,1]*B[2,2]+B[2,3]*B[3,2]+B[1,2]*B[2,1]+B[1,3]*B[3,1];
a2:=B[1,1]+B[2,2]+B[3,3];
a3:=-1;
ap0:=a1;
ap1:=2*a2;
ap2:=3*a3;
PX[1,1]:=0;
PX[1,2]:=a0+PX[1,1]*(a1+PX[1,1]*(a2+a3*PX[1,1]));
PX[1,3]:=ap0+PX[1,1]*(ap1+PX[1,1]*ap2);
For i:=2 to 20 do
Begin
PX[i,1]:=PX[i-1,1]-PX[i-1,2]/PX[i-1,3];
PX[i,2]:=a0+PX[i,1]*(a1+PX[i,1]*(a2+a3*PX[i,1]));
PX[i,3]:=ap0+PX[i,1]*(ap1+PX[i,1]*ap2);
End;
a:=a3;
v:=a*PX[20,1]+a2;
c:=v*PX[20,1]+a1;
eigenvalor3:=PX[20,1];
End;
{del else}
discr:=v*v-4*a*c;
m:=sqrt(discr);
If discr>=0 then
Begin
eigenvalor1:=(-v+sqrt(discr))/2*a;
eigenvalor2:=(-v-sqrt(discr))/2*a;
End
Else
Apéndice I
Begin
eigenvalor1:=-v/2*a;
eigenvalor2:=-v/2*a;
End;
End; {del procedure Caracteriza}
Procedure Optimo;
Begin
Case NumMod of
1: ;
2: Begin
Q:=0; TRev:=0;
R:=P0[1];
Reorden:=P0[2];
Colecta;
End;
3: Begin
R:=0; TRev:=0;
Q:=P0[1];
Reorden:=P0[2];
Colecta;
End;
4: Begin
Reorden:=0; Q:=0;
R:=P0[1];
TRev:=P0[2];
Colecta;
End;
5: Begin
R:=0;
Q:=P0[1];
R:=P0[2];
TRev:=P0[3];
Colecta;
End;
6: Begin
Q:=0;
R:=P0[1]; Reorden:=P0[2]; TRev:=P0[3];
Colecta;
End;
End; {del Case}
End; {del procedure Optimo}
Procedure Alternativa;
Begin
ClrScr;
Gotoxy (10,5); Write ('The best solution found was:');
If (R1<>0) or (Reorden1<>0) or (Q1<>0) or (TRev<>0) then
Begin
Case NumMod of
1: ;
2: Begin
Gotoxy (15,7); Write ('R =' , R1:3:2);
Gotoxy (15,9); Write ('r =' , Reorden1:3:2);
Gotoxy (15,11); Write ('TC =' , CTA1:6:2);
Readln;
End;
3: Begin
Gotoxy (15,7); Write ('Q =' , Q1:3:2);
Gotoxy (15,9); Write ('r =' , Reorden1:3:2);
119
Apéndice I
120
Gotoxy (15,11); Write ('TC =' , CTA1:6:2);
Readln;
End;
4: Begin
Gotoxy (15,7); Write ('R =' , R1:3:2);
Gotoxy (15,9); Write ('T =' , TRev1:3:2);
Gotoxy (15,11); Write ('TC =' , CTA1:6:2);
Readln;
End;
5: Begin
Gotoxy (15,7); Write ('Q =' , Q1:3:2);
Gotoxy (15,9); Write ('r =' , Reorden1:3:2);
Gotoxy (15,11); Write ('T =' , TRev1:3:2);
Gotoxy (15,13); Write ('TC =' , CTA1:6:2);
Readln;
End;
6: Begin
Gotoxy (15,7); Write ('R =' , R1:3:2);
Gotoxy (15,9); Write ('r =' , Reorden1:3:2);
Gotoxy (15,11); Write ('T =' , TRev1:3:2);
Gotoxy (15,13); Write ('TC =' , CTA1:6:2);
Readln;
End;
End; {del Case}
End {del if}
Else
Begin
ClrScr;
CuadroColor (1, 80, 1, 24, 9);
Locate (12, 9, 'It is not possible find a solution using Response');
Locate (12, 10, 'Surface Methodology'); Readln;
End;
End; {del procedure Alternativa}
Procedure Ruta;
Begin
RellenaX;
Diseno1;
Transpuesta;
Multiplica_XTX;
MatrizIdentidad;
ResolverMatriz;
Multiplica_XTY;
Betas1;
Respredicha1;
Pruebas1;
End; {del procedure Ruta}
Procedure Superficies;
Begin
Apéndice I
121
{___________________________________________________
|
|
|
Inicia la busqueda de un Minimo utilizando
|
|
SUPERFICIES DE RESPUESTA
|
|___________________________________________________|
}
InicioVar;
SolInicial;
ImprimPar;
ClrScr;
CuadroColor (1, 80, 1, 24, 9);
Locate (10,2, 'MINIMIZATION PHASE USING Response Surface Methodology');
RellenaX;
Diseno1;
Transpuesta;
Multiplica_XTX;
MatrizIdentidad;
ResolverMatriz;
Multiplica_XTY;
Betas1;
Respredicha1;
Pruebas1;
While (Fcalc>FTab) and (Fc<FT) do
Begin
Trayectoria;
Rangos;
Ruta;
End;
ClrScr;
CuadroColor (1, 80, 1, 24, 9);
Locate (10, 8, 'The first-degree coefficient estimates is not');
Locate (10, 9, 'significance at the alpha level of significance,');
Locate (10, 10, 'or the hypothesis of adequacy of fit was rejected');
Locate (10, 11, 'at the alpha level of significance');
Readln; readln;
Diseno2;
Betas2;
Respredicha2;
Suficiencia;
If (Fcalc>FTab) and (Fc<FT) then
Begin
PtoEstacionario;
Caracteriza;
If (eigenvalor1>0) and (eigenvalor2>0) and (eigenvalor3>=0) then
Begin
Optimo;
ClrScr;
Gotoxy (10,5); Write ('The better solution found was:');
Case NumMod of
1: ;
2: Begin
Gotoxy (15,7); Write ('R =' , R:3:2);
Gotoxy (15,9); Write ('r =' , Reorden:3:2);
Gotoxy (15,11); Write ('TC =' , CTA:6:2);Readln;
End;
3: Begin
Apéndice I
122
Gotoxy (15,7); Write ('Q =' , Q:3:2);
Gotoxy (15,9); Write ('r =' , Reorden:3:2);
Gotoxy (15,11); Write ('TC =' , CTA:6:2);Readln;
End;
4: Begin
Gotoxy (15,7); Write ('R =' , R:3:2);
Gotoxy (15,9); Write ('T =' , TRev:3:2);
Gotoxy (15,11); Write ('TC =' , CTA:6:2);Readln;
End;
5: Begin
Gotoxy (15,7); Write ('Q =' , Q:3:2);
Gotoxy (15,9); Write ('r =' , Reorden:3:2);
Gotoxy (15,11); Write ('T =' , TRev:3:2);
Gotoxy (15,13); Write ('TC =' , CTA:6:2); Readln;
End;
6: Begin
Gotoxy (15,7); Write ('R =' , R:3:2);
Gotoxy (15,9); Write ('r =' , Reorden:3:2);
Gotoxy (15,11); Write ('T =' , TRev:3:2);
Gotoxy (15,13); Write ('TC =' , CTA:6:2); Readln;
End;
End; {del Case}
End {del if}
Else
Begin
ClrScr;
CuadroColor (1, 80, 1, 24, 9);
Locate (12, 10, 'The stationary point found was not a minimun. ');
Readln;
Alternativa;
End;
End {del if}
Else
Begin
ClrScr;
CuadroColor (1, 80, 1, 24, 9);
Locate (10, 8, 'It is not possible continue searching a solution
using');
Locate (10, 9, 'Response Surface Methodology, because the seconddegree');
Locate (10, 10, 'coefficient estimates is not significance at the
alpha');
Locate (10, 11, 'level of significance, or the hypothesis of adequacy
of ');
Locate (10, 12, 'fit was rejected at the alpha level of
significance');
Readln; readln;
Alternativa;
End;
End;
END.
{de la unidad}
Descargar