Wednesday, September 8, 2010

A Nonlinear Mixed Integer-Discrete-Continuous Programming Solver Applied to Estimation of Parameters, Second Edition

Jsun Yui Wong

The computer program listed below estimates the two parameters of the model on pages 55, 56, 285, and 286 of Englezos and Kalogerakis [2] and in the article by Gallot, Kapoor, and Kaliaguine [1]. It is similar to the computer program in the August 31 post of wongsblog-wong.blogspot.com.

0 DEFSNG A-Z
3 DEFINT I,J,K
4 DIM X(42),A(42),L(33),K(33)
75 FOR JJJJ=-32000 TO 32000
84 RANDOMIZE JJJJ
87 M=-1.7E+38
97 FOR IER=1 TO 2
98 A(IER)=RND
99 NEXT IER
126 IMAR=10+FIX(RND*32700)
128 FOR I=1 TO IMAR
129 FOR K=1 TO 2
131 X(K)=A(K)
132 NEXT K
181 J=1+FIX(RND*2)
183 R=1.5*(1-RND*2)*A(J)
185 IF R>1000 OR R<-1000 THEN 183
191 IF RND<.14 THEN X(J)=A(J)+RND^5*R ELSE IF RND<.17 THEN X(J)=A(J)+R ELSE IF RND<.2 THEN X(J)=A(J)+RND*R ELSE IF RND<.25 THEN X(J)=A(J)+RND^2*R ELSE IF RND<.33 THEN X(J)=A(J)+RND^3*R ELSE IF RND<.5 THEN X(J)=A(J)+RND^4*R ELSE X(J)=A(J)+RND^6*R
221 FOR IQA=1 TO 2
222 IF X(IQA)<0 THEN 181
223 NEXT IQA
400 X(3)=-.055+ X(1)*( 1-EXP(-X(2)*3) )
401 X(4)=-9.000001E-02+ X(1)*( 1-EXP(-X(2)*6) )
402 X(5)=-.12+ X(1)*( 1-EXP(-X(2)*13) )
403 X(6)=-.15+ X(1)*( 1-EXP(-X(2)*18) )
404 X(7)=-.165+ X(1)*( 1-EXP(-X(2)*26) )
405 X(8)=-.175+ X(1)*( 1-EXP(-X(2)*28) )
1333 P1NEWMAY=-X(4)^2 -X(5)^2 -X(6)^2 -X(7)^2 -X(8)^2 - X(3)^2
1448 P=P1NEWMAY
1451 IF P<=M THEN 1670
1657 FOR KEW=1 TO 8
1658 A(KEW)=X(KEW)
1659 NEXT KEW
1661 M=P
1666 GOTO 128
1670 NEXT I
1890 IF M>-.008218 THEN 1912 ELSE 1999
1912 PRINT A(1),A(2)
1913 REM PRINT A(4),A(5),A(6)
1914 REM PRINT A(7),A(8),A(9)
1915 PRINT M,JJJJ
1999 NEXT JJJJ

The BASIC computer program above was run with Microsoft's GW BASIC 3.11 interpreter. Its complete output through JJJJ=-31996 is presented below. What follows is a manual copy from the computer screen.

.1775962 .1055013
-2.953407E-04 -32000

.1776586 .1053942
-2.953421E-04 -31999

.1775872 .1055206
-2.95341E-04 -31998

.177636 .1054317
-2.953407E-04 -31997

.1776023 .1054964
-2.953405E-04 -31996

Interpreted in accordance with line 1912 and line 1915, the output above was produced in 13 seconds on a personal computer with an Intel 2.66 GHz. chip and the IBM basica/D interpreter.

References

[1] J. E. Gallot, M. P. Kapoor, and S. Kaliaguine, "Kinetics of 2-Hexanol and 3-Hexanol Oxidation Reaction over TS-1 Catalysts," American Institute of Chemical Engineers Journal, Vol. 44, No. 6 (June 1998), pp. 1438-1454.

[2] P. Englezos and N. Kalogerakis, Applied Parameter Estimation for Chemical Engineers, Marcel-Dekker, New York, 2001.

[3] Microsoft Corp. BASIC, 2nd Ed. (May 1982), Version 1.10. Boca Raton, Florida: IBM Corp., Personal Computer, P. O. Box 1328-C, Boca Raton, Florida 33432, 1981.

Wednesday, September 1, 2010

A Nonlinear Mixed Integer-Discrete-Continuous Programming Solver Applied to Estimation of Parameters

Jsun Yui Wong

The computer program listed below estimates the two parameters of the model on pages 55, 56, 285, and 286 of Englezos and Kalogerakis [2] and in the article by Gallot, Kapoor, and Kaliaguine [1]. It is similar to the computer program in the August 31 post of wongsblog-wong.blogspot.com.

0 DEFSNG A-Z
3 DEFINT I,J,K
4 DIM X(42),A(42),L(33),K(33)
75 FOR JJJJ=-32000 TO 32000
84 RANDOMIZE JJJJ
87 M=-1.7E+38
97 FOR IER=1 TO 8
98 A(IER)=RND
99 NEXT IER
126 IMAR=10+FIX(RND*32700)
128 FOR I=1 TO IMAR
129 FOR K=1 TO 8
131 X(K)=A(K)
132 NEXT K
181 J=1+FIX(RND*8)
183 R=1.5*(1-RND*2)*A(J)
185 IF R>1000 OR R<-1000 THEN 183
191 IF RND<.14 THEN X(J)=A(J)+RND^5*R ELSE IF RND<.17 THEN X(J)=A(J)+R ELSE IF RND<.2 THEN X(J)=A(J)+RND*R ELSE IF RND<.25 THEN X(J)=A(J)+RND^2*R ELSE IF RND<.33 THEN X(J)=A(J)+RND^3*R ELSE IF RND<.5 THEN X(J)=A(J)+RND^4*R ELSE X(J)=A(J)+RND^6*R
221 FOR IQA=1 TO 2
222 IF X(IQA)<0 THEN 181
223 NEXT IQA
400 X(3)=-.055+ X(1)*( 1-EXP(-X(2)*3) )
401 X(4)=-9.000001E-02+ X(1)*( 1-EXP(-X(2)*6) )
402 X(5)=-.12+ X(1)*( 1-EXP(-X(2)*13) )
403 X(6)=-.15+ X(1)*( 1-EXP(-X(2)*18) )
404 X(7)=-.165+ X(1)*( 1-EXP(-X(2)*26) )
405 X(8)=-.175+ X(1)*( 1-EXP(-X(2)*28) )
1333 P1NEWMAY=-X(4)^2 -X(5)^2 -X(6)^2 -X(7)^2 -X(8)^2 - X(3)^2
1448 P=P1NEWMAY
1451 IF P<=M THEN 1670
1657 FOR KEW=1 TO 8
1658 A(KEW)=X(KEW)
1659 NEXT KEW
1661 M=P
1666 GOTO 128
1670 NEXT I
1890 IF M>-.008218 THEN 1912 ELSE 1999
1912 PRINT A(1),A(2)
1913 REM PRINT A(4),A(5),A(6)
1914 REM PRINT A(7),A(8),A(9)
1915 PRINT M,JJJJ
1999 NEXT JJJJ

The BASIC computer program above was run with Microsoft's GW BASIC 3.11 interpreter. Its complete output through JJJJ=-31996 is presented below. What follows is a manual copy from the computer screen.

.1776406 .1054267
-2.953409E-04 -32000

.1775906 .1055145
-2.95341E-04 -31999

.1776287 .1054403
-2.953407E-04 -31998

.1775846 .1055275
-2.953412E-04 -31997

.1775951 .10551
-2.953408E-04 -31996

Interpreted in accordance with line 1912 and line 1915, the output above was produced in 18 seconds on a personal computer with an Intel 2.66 GHz. chip and the IBM basica/D interpreter.

References

[1] J. E. Gallot, M. P. Kapoor, and S. Kaliaguine, "Kinetics of 2-Hexanol and 3-Hexanol Oxidation Reaction over TS-1 Catalysts," American Institute of Chemical Engineers Journal, Vol. 44, No. 6 (June 1998), pp. 1438-1454.

[2] P. Englezos and N. Kalogerakis, Applied Parameter Estimation for Chemical Engineers, Marcel-Dekker, New York, 2001.

[3] Microsoft Corp. BASIC, 2nd Ed. (May 1982), Version 1.10. Boca Raton, Florida: IBM Corp., Personal Computer, P. O. Box 1328-C, Boca Raton, Florida 33432, 1981.

Sunday, July 25, 2010

Applying a Nonlinear Integer Programming Solver to a Transformer Design Model

Jsun Yui Wong

Each of the two computer programs below tries to solve the transformer design problem on pages 258-272 of Papalambros and Wilde [1]. The computer programs below do not use the bounds on page 258 of Papalambros and Wilde [1]. Lines 126 below are different from each other. These programs are similar to the July 25 posts of wongsblog-wong.blogspot.com and to the July 25 post of wongsnewnewblog.blogspot.com.

Computer Program 1:

0 DEFINT A-Z
1 DEFSNG L,S,P,M,R,Q
2 REM DEFSNG A-Z
3 REM DEFINT I,J,K,X
4 DIM X(42),A(42),L(33),K(33)
75 FOR JJJJ=-32000 TO 32000
84 RANDOMIZE JJJJ
87 M=-1.7E+38
91 FOR KK=1 TO 6
94 A(KK)=RND*400
95 NEXT KK
126 IMAR=10+FIX(RND*3000)
128 FOR I=1 TO IMAR
129 FOR K=1 TO 6
131 X(K)=A(K)
132 NEXT K
181 J=1+FIX(RND*6)
182 JJ=1+FIX(RND*6)
183 R=(1-RND*2)*A(J)
185 IF RND<.5 THEN 188 ELSE 201
188 IF RND<.14 THEN 191 ELSE IF RND<.17 THEN 293 ELSE IF RND<.2 THEN 294 ELSE IF RND<.25 THEN 295 ELSE IF RND<.33 THEN 296 ELSE IF RND<.5 THEN 297 ELSE 298
191 IF RND<.14 THEN X(J)=RND*500 ELSE IF RND<.17 THEN X(J)=A(J)+R ELSE IF RND<.2 THEN X(J)=A(J)+RND*R ELSE IF RND<.25 THEN X(J)=A(J)+RND^2*R ELSE IF RND<.33 THEN X(J)=A(J)+RND^3*R ELSE IF RND<.5 THEN X(J)=A(J)+RND^4*R ELSE X(J)=INT(A(J))
192 GOTO 351
201 X(J)=A(JJ)
202 X(JJ)=A(J)
211 GOTO 351
293 X(1)=RND*500:GOTO 351
294 X(2)=RND*500:GOTO 351
295 X(3)=RND*500:GOTO 351
296 X(4)=RND*500:GOTO 351
297 X(5)=RND*500:GOTO 351
298 X(6)=RND*500:GOTO 351
351 L1=-.001*X(1)*X(2)*X(3)*X(4)*X(5)*X(6)+2.07
352 L2=.00062*X(1)*X(4)*X(5)^2*(X(1)+X(2)+X(3))+.00058*X(2)*X(3)*X(6)^2*(X(1)+1.57*X(2)+X(4))-1.2
511 IF L1>0 THEN L1=-1000000! ELSE L1=0
512 IF L2>0 THEN L2=-1000000! ELSE L2=0
1311 SS=L1+L2
1333 P1NEWMAY=-.0204*X(1)*X(4)*(X(1)+X(2)+X(3))-.0187*X(2)*X(3)*(X(1)+1.57*X(2)+X(4))-.0607*X(1)*X(4)*X(5)^2*(X(1)+X(2)+X(3))-.0437*X(2)*X(3)*X(6)^2*(X(1)+1.57*X(2)+X(4))+SS
1448 P=P1NEWMAY
1451 IF P<=M THEN 1670
1657 FOR KEW=1 TO 6
1658 A(KEW)=X(KEW)
1659 NEXT KEW
1661 M=P
1666 GOTO 128
1670 NEXT I
1890 IF M>-135 THEN 1912 ELSE 1999
1912 PRINT A(1),A(2),A(3),A(4),A(5),A(6),M,JJJJ
1917 REM PRINT M,JJJJ
1999 NEXT JJJJ

The BASIC computer program above was run with Microsoft's GW BASIC 3.11 interpreter, which is not a compiler. The complete output through JJJJ=-28005 is shown below. What immediately follows is a manual copy from the computer screen.

4 4 13 10 1
1 -133.9285 -31735

4 5 8 13 1
1 -133.718 -31369

4 5 8 13 1
1 -133.718 -31089

5 4 13 8 1
1 -133.9278 -30233

5 4 13 8 1
1 -133.9278 -28005

Interpreted in accordance with line 1912, the output above was obtained in eleven minutes on a personal computer with an Intel 2.66 GHz. chip and the IBM basica/D interpreter.

Computer Program 2:

0 DEFINT A-Z
1 DEFSNG L,S,P,M,R,Q
2 REM DEFSNG A-Z
3 REM DEFINT I,J,K,X
4 DIM X(42),A(42),L(33),K(33)
75 FOR JJJJ=-32000 TO 32000
84 RANDOMIZE JJJJ
87 M=-1.7E+38
91 FOR KK=1 TO 6
94 A(KK)=RND*400
95 NEXT KK
126 IMAR=10+FIX(RND*4000)
128 FOR I=1 TO IMAR
129 FOR K=1 TO 6
131 X(K)=A(K)
132 NEXT K
181 J=1+FIX(RND*6)
182 JJ=1+FIX(RND*6)
183 R=(1-RND*2)*A(J)
185 IF RND<.5 THEN 188 ELSE 201
188 IF RND<.14 THEN 191 ELSE IF RND<.17 THEN 293 ELSE IF RND<.2 THEN 294 ELSE IF RND<.25 THEN 295 ELSE IF RND<.33 THEN 296 ELSE IF RND<.5 THEN 297 ELSE 298
191 IF RND<.14 THEN X(J)=RND*500 ELSE IF RND<.17 THEN X(J)=A(J)+R ELSE IF RND<.2 THEN X(J)=A(J)+RND*R ELSE IF RND<.25 THEN X(J)=A(J)+RND^2*R ELSE IF RND<.33 THEN X(J)=A(J)+RND^3*R ELSE IF RND<.5 THEN X(J)=A(J)+RND^4*R ELSE X(J)=INT(A(J))
192 GOTO 351
201 X(J)=A(JJ)
202 X(JJ)=A(J)
211 GOTO 351
293 X(1)=RND*500:GOTO 351
294 X(2)=RND*500:GOTO 351
295 X(3)=RND*500:GOTO 351
296 X(4)=RND*500:GOTO 351
297 X(5)=RND*500:GOTO 351
298 X(6)=RND*500:GOTO 351
351 L1=-.001*X(1)*X(2)*X(3)*X(4)*X(5)*X(6)+2.07
352 L2=.00062*X(1)*X(4)*X(5)^2*(X(1)+X(2)+X(3))+.00058*X(2)*X(3)*X(6)^2*(X(1)+1.57*X(2)+X(4))-1.2
511 IF L1>0 THEN L1=-1000000! ELSE L1=0
512 IF L2>0 THEN L2=-1000000! ELSE L2=0
1311 SS=L1+L2
1333 P1NEWMAY=-.0204*X(1)*X(4)*(X(1)+X(2)+X(3))-.0187*X(2)*X(3)*(X(1)+1.57*X(2)+X(4))-.0607*X(1)*X(4)*X(5)^2*(X(1)+X(2)+X(3))-.0437*X(2)*X(3)*X(6)^2*(X(1)+1.57*X(2)+X(4))+SS
1448 P=P1NEWMAY
1451 IF P<=M THEN 1670
1657 FOR KEW=1 TO 6
1658 A(KEW)=X(KEW)
1659 NEXT KEW
1661 M=P
1666 GOTO 128
1670 NEXT I
1890 IF M>-135 THEN 1912 ELSE 1999
1912 PRINT A(1),A(2),A(3),A(4),A(5),A(6),M,JJJJ
1917 REM PRINT M,JJJJ
1999 NEXT JJJJ

The BASIC computer program above was run with Microsoft's GW BASIC 3.11 interpreter, which is not a compiler. The complete output through JJJJ=-29826 is shown below. What immediately follows is a manual copy from the computer screen.

4 4 13 10 1
1 -133.9285 -31916

4 5 8 13 1
1 -133.718 -31607

4 5 8 13 1
1 -133.718 -30681

4 5 8 13 1
1 -133.718 -30669

4 4 13 10 1
1 -133.9285 -29826

Interpreted in accordance with line 1912, the output above was obtained in seven minutes on a personal computer with an Intel 2.66 GHz. chip and the IBM basica/D interpreter.

Reference

[1] Panos Y. Papalambros, Douglas J. Wilde. Principles of Optimal Design, Second Edition. Cambridge University Press, 2000.

Sunday, May 30, 2010

How To Solve Nonlinear Programming Formulations/Problems

Jsun Yui Wong

The three similar computer programs listed below try to solve the three formulations in Chapter 6 of Floudas and Pardalos [1, pp. 58-61], respectively.

These computer programs are similar to those of the May 29 post of http://wongsblog-wong.blogspot.com.

Case I of Floudas and Pardalos:

0 DEFDBL A-Z
3 DEFINT I,J,K
4 DIM X(42),A(42),L(33),K(33)
5 FOR JJJJ=-32000 TO 32000
14 RANDOMIZE JJJJ
16 M=-1D+17
91 FOR KK=1 TO 8
94 A(KK)=RND*205
95 NEXT KK
126 IMAR=10+RND*32666
128 FOR I=1 TO IMAR
129 FOR K=1 TO 8
131 X(K)=A(K)
132 NEXT K
141 FOR IPHO=1 TO 2+FIX(RND*15)
181 J=1+FIX(RND*8)
183 R=(1-RND*2)*A(J)
191 IF RND<.14 THEN X(J)=FIX(RND*205) ELSE IF RND<.17 THEN X(J)=A(J)+R ELSE IF RND<.2 THEN X(J)=A(J)+RND*R ELSE IF RND<.25 THEN X(J)=A(J)+RND^2*R ELSE IF RND<.33 THEN X(J)=A(J)+RND^3*R ELSE IF RND<.5 THEN X(J)=A(J)+RND^4*R ELSE X(J)=INT(A(J))
277 NEXT IPHO
301 IF X(1)>100 THEN X(1)=0
302 IF X(2)>200 THEN X(2)=0
304 X(5)=X(1)-X(7)
305 X(6)=X(2)-X(8)
309 X(4)=X(7)+X(8)-X(3)
1117 IF X(7)+X(8)=0 THEN 1670
1119 W=(3*X(3)+X(4))/(X(7)+X(8))
1121 L1=W*X(7)+2*X(5)-2.5*X(1)
1122 IF L1>0 THEN 1670
1123 L2=W*X(8)+2*X(6)-1.5*X(2)
1124 IF L2>0 THEN 1670
1201 FOR IPO=1 TO 8
1203 IF X(IPO)<0 THEN 1670
1206 NEXT IPO
1225 P1NEWMAY=9*X(1)+15*X(2)-6*X(3)-16*X(4)-10*X(5)-10*X(6)
1448 P=P1NEWMAY
1451 IF P<=M THEN 1670
1657 FOR KEW=1 TO 8
1658 A(KEW)=X(KEW)
1659 NEXT KEW
1660 WA=W
1661 M=P
1666 GOTO 128
1670 NEXT I
1890 IF M>394 THEN 1912 ELSE 1999
1912 PRINT A(1),A(2),A(3),A(4),A(5),A(6),A(7),A(8),WA
1913 PRINT M,JJJJ
1999 NEXT JJJJ

The BASIC computer program above was run with Microsoft's GW BASIC 3.11 interpreter, which is not a compiler. Its complete output through
JJJJ=-31998 is presented below. What immediately follows is a manual copy from the computer screen.

0 200 0 100 0
100 0 100 1
400 -32000

0 200 0 100 0
100 0 100 1
400 -31999

0 199.999802785422 0 99.99990139281525
0 99.99990139260676 0 99.99990139281525
1
399.9996055702185 -31998

Interpreted in accordance with line 1912 and line 1913, the output above was obtained in 2 minutes on a personal computer with an Intel 2.66 GHz. chip and the IBM basica/D interpreter.

Case II of Floudas and Pardalos:

0 DEFDBL A-Z
3 DEFINT I,J,K
4 DIM X(42),A(42),L(33),K(33)
5 FOR JJJJ=-32000 TO 32000
14 RANDOMIZE JJJJ
16 M=-1D+17
91 FOR KK=1 TO 8
94 A(KK)=RND*605
95 NEXT KK
126 IMAR=10+RND*32666
128 FOR I=1 TO IMAR
129 FOR K=1 TO 8
131 X(K)=A(K)
132 NEXT K
141 FOR IPHO=1 TO 2+FIX(RND*15)
181 J=1+FIX(RND*8)
183 R=(1-RND*2)*A(J)
191 IF RND<.14 THEN X(J)=FIX(RND*605) ELSE IF RND<.17 THEN X(J)=A(J)+R ELSE IF RND<.2 THEN X(J)=A(J)+RND*R ELSE IF RND<.25 THEN X(J)=A(J)+RND^2*R ELSE IF RND<.33 THEN X(J)=A(J)+RND^3*R ELSE IF RND<.5 THEN X(J)=A(J)+RND^4*R ELSE X(J)=INT(A(J))
277 NEXT IPHO
301 IF X(1)>600 THEN X(1)=0
302 IF X(2)>200 THEN X(2)=0
304 X(5)=X(1)-X(7)
305 X(6)=X(2)-X(8)
309 X(4)=X(7)+X(8)-X(3)
1117 IF X(7)+X(8)=0 THEN 1670
1119 W=(3*X(3)+X(4))/(X(7)+X(8))
1121 L1=W*X(7)+2*X(5)-2.5*X(1)
1122 IF L1>0 THEN 1670
1123 L2=W*X(8)+2*X(6)-1.5*X(2)
1124 IF L2>0 THEN 1670
1201 FOR IPO=1 TO 8
1203 IF X(IPO)<0 THEN 1670
1206 NEXT IPO
1225 P1NEWMAY=9*X(1)+15*X(2)-6*X(3)-16*X(4)-10*X(5)-10*X(6)
1448 P=P1NEWMAY
1451 IF P<=M THEN 1670
1657 FOR KEW=1 TO 8
1658 A(KEW)=X(KEW)
1659 NEXT KEW
1660 WA=W
1661 M=P
1666 GOTO 128
1670 NEXT I
1890 IF M>594 THEN 1912 ELSE 1999
1912 PRINT A(1),A(2),A(3),A(4),A(5),A(6),A(7),A(8),WA
1913 PRINT M,JJJJ
1999 NEXT JJJJ

The BASIC computer program above was run with Microsoft's GW BASIC 3.11 interpreter, which is not a compiler. Its complete output through
JJJJ=-31928 is presented below. What immediately follows is a manual copy from the computer screen.

599.9141480403103 0 299.9571890075342
1.149912691360555D-04 299.95684041507 0
299.9573039988033 0 2.99999923328242
599.9139180422116 -31968

599.9399224686729 0 299.9726214965366
2.660342267787996D-03 299.9646406298684 0
299.9752818388044 0 2.999982262923455
599.934601463867 -31951

599.9584589087624 0 299.4797050692913
4.756849602287616D-04 299.4782781545109 0
299.4801807542515 0 2.999996823262501
598.9575072586413 -31928

Interpreted in accordance with line 1912 and line 1913, the output above was obtained in 20 minutes on a personal computer with an Intel 2.66 GHz. chip and the IBM basica/D interpreter.

Case III of Floudas and Pardalos:

0 DEFDBL A-Z
3 DEFINT I,J,K
4 DIM X(42),A(42),L(33),K(33)
5 FOR JJJJ=-32000 TO 32000
14 RANDOMIZE JJJJ
16 M=-1D+17
91 FOR KK=1 TO 8
94 A(KK)=RND*205
95 NEXT KK
126 IMAR=10+RND*32666
128 FOR I=1 TO IMAR
129 FOR K=1 TO 8
131 X(K)=A(K)
132 NEXT K
141 FOR IPHO=1 TO 2+FIX(RND*15)
181 J=1+FIX(RND*8)
183 R=(1-RND*2)*A(J)
191 IF RND<.14 THEN X(J)=FIX(RND*205) ELSE IF RND<.17 THEN X(J)=A(J)+R ELSE IF RND<.2 THEN X(J)=A(J)+RND*R ELSE IF RND<.25 THEN X(J)=A(J)+RND^2*R ELSE IF RND<.33 THEN X(J)=A(J)+RND^3*R ELSE IF RND<.5 THEN X(J)=A(J)+RND^4*R ELSE X(J)=INT(A(J))
277 NEXT IPHO
301 IF X(1)>100 THEN X(1)=0
302 IF X(2)>200 THEN X(2)=0
304 X(5)=X(1)-X(7)
305 X(6)=X(2)-X(8)
309 X(4)=X(7)+X(8)-X(3)
1117 IF X(7)+X(8)=0 THEN 1670
1119 W=(3*X(3)+X(4))/(X(7)+X(8))
1121 L1=W*X(7)+2*X(5)-2.5*X(1)
1122 IF L1>0 THEN 1670
1123 L2=W*X(8)+2*X(6)-1.5*X(2)
1124 IF L2>0 THEN 1670
1201 FOR IPO=1 TO 8
1203 IF X(IPO)<0 THEN 1670
1206 NEXT IPO
1225 P1NEWMAY=9*X(1)+15*X(2)-6*X(3)-13*X(4)-10*X(5)-10*X(6)
1448 P=P1NEWMAY
1451 IF P<=M THEN 1670
1657 FOR KEW=1 TO 8
1658 A(KEW)=X(KEW)
1659 NEXT KEW
1660 WA=W
1661 M=P
1666 GOTO 128
1670 NEXT I
1890 IF M>740 THEN 1912 ELSE 1999
1912 PRINT A(1),A(2),A(3),A(4),A(5),A(6),A(7),A(8),WA
1913 PRINT M,JJJJ
1999 NEXT JJJJ

The BASIC computer program above was run with Microsoft's GW BASIC 3.11 interpreter, which is not a compiler. Its complete output through
JJJJ=-31996 is presented below. What immediately follows is a manual copy from the computer screen.

0 199.9999991702184 49.41530681308674
149.4153064337752 0 1.169385923356462
0 199.830613246862 1.497059341176343
749.4153038021134 -32000

0 199.9986815280429 49.72581889765022
149.7251596630286 0 .547702967364085
0 199.4509785606788 1.498626973469796
749.7212042417296 -31999

0 200 49.65246449766539 149.652464570163
0 .6950709321715749 0 199.3049290678284
1.498256262199792
749.6524642801725 -31998

0 199.99571121132 49.41544894619624
149.4133046782789 0 1.166957586844831
0 198.8287536244751 1.49706541981877
749.4004378065481 -31997

0 199.9999632134356 49.99196974992971
149.9919513841026 0 1.604207940330937D-02
0 199.9839211340323 1.499959891439716
749.991840914589 -31996

Interpreted in accordance with line 1912 and line 1913, the output above was obtained in 3 minutes on a personal computer with an Intel 2.66 GHz. chip and the IBM basica/D interpreter.

References

[1] C. A. Floudas, P. M. Pardalos. A collection of test problems for constrained global optimization algorithms. Lecture notes in computer science, edited by G. Goos and J. Hartmanis. Springer-Verlag, 1990.

[2] C. A. Haverly. Studies of the behavior of recursion for the pooling problem. ACM SIGMAP Bulletin, 25:19, 1978.

[3] Microsoft Corp. BASIC, second edition (May 1982), Version 1.10. Boca Raton, Florida: IBM Corp., Personal Computer, P. O. Box 1328-C, Boca Raton, Florida 33432, 1981.

[4] C. Mohan, H. T. Nguyen. A controlled random search technique incorporating the simulated annealing concept for solving integer and mixed integer global optimization problems. Computational Optimiztion and Applications 14, 103-132 (1999).

Tuesday, April 27, 2010

Searching for Multiple Integer Solutions of a Nonlinear System of Nine Equations from the Literature, Second Edition

Jsun Yui Wong

"Solving systems of nonlinear equations is perhaps the most difficult problem in all of numerical computation," Rice [1, 1993, p. 355].

Modeled after the computer program in the June 30 post of the present blog, the computer program below tries to find multiple integer solutions of the following nonlinear system from Bellido [2, p. 348; 3, p. I-14]. These equations are used in line 1142 through line 1225 below.

Line 0 and line 3 of the computer program below are noteworthy.

X(1)^2+X(2)^2+X(3)^2-12*X(1)-68=0
X(4)^2+X(5)^2+X(6)^2-12*X(5)-68=0
X(7)^2+X(8)^2+X(9)^2-24*X(8)-12*X(9)+100=0
X(1)*X(4)+X(2)*X(5)+X(3)*X(6)-6*X(1)-6*X(5)-52=0
X(1)*X(7)+X(2)*X(8)+X(3)*X(9)-6*X(1)-12*X(8)-6*X(9)+64=0
X(4)*X(7)+X(5)*X(8)+X(6)*X(9)-6*X(5)-12*X(8)-6*X(9)+32=0
2*X(2)+2*X(3)-X(4)-X(5)-2*X(6)-X(7)-X(9)+18=0
X(1)+X(2)+2*X(3)+2*X(4)+2*X(6)-2*X(7)+X(8)-X(9)-38=0
X(1)+X(3)-2*X(4)+X(5)-X(6)+2*X(7)-2*X(8)+8=0

0 DEFINT A-Z
3 DEFDBL M,P,L
4 DIM X(42),A(42),L(33),K(33)
5 FOR JJJJ=-32000 TO 32000
14 RANDOMIZE JJJJ
16 M=-1D+17
91 FOR KK=1 TO 9
94 A(KK)=-100+FIX(RND*201)
95 NEXT KK
126 IMAR=10+FIX(RND*10000)
128 FOR I=1 TO IMAR
129 FOR K=1 TO 9
131 X(K)=A(K)
132 NEXT K
181 J=1+FIX(RND*9)
182 X(J)=-100+FIX(RND*201)
1142 L1=X(1)^2+X(2)^2+X(3)^2-12*X(1)-68
1143 L2=X(4)^2+X(5)^2+X(6)^2-12*X(5)-68
1144 L3=X(7)^2+X(8)^2+X(9)^2-24*X(8)-12*X(9)+100
1145 L4=X(1)*X(4)+X(2)*X(5)+X(3)*X(6)-6*X(1)-6*X(5)-52
1146 L5=X(1)*X(7)+X(2)*X(8)+X(3)*X(9)-6*X(1)-12*X(8)-6*X(9)+64
1147 L6=X(4)*X(7)+X(5)*X(8)+X(6)*X(9)-6*X(5)-12*X(8)-6*X(9)+32
1221 L7=2*X(2)+2*X(3)-X(4)-X(5)-2*X(6)-X(7)-X(9)+18
1223 L8=X(1)+X(2)+2*X(3)+2*X(4)+2*X(6)-2*X(7)+X(8)-X(9)-38
1225 L9=X(1)+X(3)-2*X(4)+X(5)-X(6)+2*X(7)-2*X(8)+8
1230 P1NEWMAY=-ABS(L1)-ABS(L2)-ABS(L3)-ABS(L4)-ABS(L5)-ABS(L6)-ABS(L7)-ABS(L8)-ABS(L9)
1448 P=P1NEWMAY
1451 IF P<=M THEN 1670
1657 FOR KEW=1 TO 9
1658 A(KEW)=X(KEW)
1659 NEXT KEW
1661 M=P
1663 LL1=L1:LL2=L2:LL3=L3:LL4=L4:LL5=L5:LL6=L6:LL7=L7:LL8=L8:LL9=L9
1666 GOTO 128
1670 NEXT I
1890 IF M>-1 THEN 1912 ELSE 1999
1912 PRINT A(1),A(2),A(3),A(4),A(5),A(6),A(7),A(8),A(9)
1913 PRINT M,JJJJ
1914 PRINT LL1,LL2,LL3,LL4,LL5,LL6,LL7,LL8,LL9,M
1999 NEXT JJJJ

The BASIC computer program above was run with Microsoft's GW BASIC 3.11 interpreter, which is not a compiler. Its complete output through
JJJJ=-19985 is presented below. What immediately follows is a manual copy from the computer screen.

4 0 10 0 4
10 0 8 14
0 -27393
0 0 0 0 0
0 0 0 0 0

4 0 10 0 4
10 0 8 14
0 -25657
0 0 0 0 0
0 0 0 0 0

4 0 10 0 4
10 0 8 14
0 -24235
0 0 0 0 0
0 0 0 0 0

12 8 2 8 12
2 8 16 6
0 -19985
0 0 0 0 0
0 0 0 0 0

Interpreted in accordance with line 1912 through line 1914, the output above was obtained in two hours on a personal computer with an Intel 2.66 GHz. chip and the IBM basica/D interpreter.

References

[1] J. Rice. Numerical methods, software, and analysis, second ed. Academic Press, 1993.

[2] A.-M. Bellido. Construction of iteration functions for the simultaneous computation of the solutions of equations and algebraic systems. Numerical Algorithms 6 (1994) 317-351.

[3] A.-M. Bellido. "Construction of iteration functions for the simultaneous computation of the solutions of equations and algebraic systems," Seminaire d'ANALYSE NUMERIQUE, Annee 1991-1992, pp. I-1 to I-16. Universite Paul Sabatier de Toulouse, U.F.R. Mathematiques, Informatique, Gestion.

[4] W. H. Press, S. A. Teukolsky, W. T. Vetterling, B. P. Flannery. Numerical recipes: the art of scientific computing, third ed. Cambridge University Press, 2007.

[5] Microsoft Corp. BASIC, second edition (May 1982), Version 1.10. Boca Raton, Florida: IBM Corp., Personal Computer, P. O. Box 1328-C, Boca Raton, Florida 33432, 1981.

Sunday, April 25, 2010

In Search of Multiple Integer Solutions of a Nonlinear System of Nine Equations from the Literature

Jsun Yui Wong

"Solving systems of nonlinear equations is perhaps the most difficult problem in all of numerical computation," Rice [1, 1993, p. 355].

Modelled on the computer program in the June 30 post of the present blog, the computer program below tries to find multiple integer solutions of the following nonlinear system from Bellido [2, p. 348; 3, p. I-14]. These equations are used in line 1142 through line 1225 below.

X(1)^2+X(2)^2+X(3)^2-12*X(1)-68=0
X(4)^2+X(5)^2+X(6)^2-12*X(5)-68=0
X(7)^2+X(8)^2+X(9)^2-24*X(8)-12*X(9)+100=0
X(1)*X(4)+X(2)*X(5)+X(3)*X(6)-6*X(1)-6*X(5)-52=0
X(1)*X(7)+X(2)*X(8)+X(3)*X(9)-6*X(1)-12*X(8)-6*X(9)+64=0
X(4)*X(7)+X(5)*X(8)+X(6)*X(9)-6*X(5)-12*X(8)-6*X(9)+32=0
2*X(2)+2*X(3)-X(4)-X(5)-2*X(6)-X(7)-X(9)+18=0
X(1)+X(2)+2*X(3)+2*X(4)+2*X(6)-2*X(7)+X(8)-X(9)-38=0
X(1)+X(3)-2*X(4)+X(5)-X(6)+2*X(7)-2*X(8)+8=0

0 DEFDBL A-Z
3 DEFINT I,J,K
4 DIM X(42),A(42),L(33),K(33)
5 FOR JJJJ=-32000 TO 32000
14 RANDOMIZE JJJJ
16 M=-1D+17
91 FOR KK=1 TO 9
94 A(KK)=-100+FIX(RND*201)
95 NEXT KK
126 IMAR=10+FIX(RND*10000)
128 FOR I=1 TO IMAR
129 FOR K=1 TO 9
131 X(K)=A(K)
132 NEXT K
181 J=1+FIX(RND*9)
182 X(J)=-100+FIX(RND*201)
1142 L1=X(1)^2+X(2)^2+X(3)^2-12*X(1)-68
1143 L2=X(4)^2+X(5)^2+X(6)^2-12*X(5)-68
1144 L3=X(7)^2+X(8)^2+X(9)^2-24*X(8)-12*X(9)+100
1145 L4=X(1)*X(4)+X(2)*X(5)+X(3)*X(6)-6*X(1)-6*X(5)-52
1146 L5=X(1)*X(7)+X(2)*X(8)+X(3)*X(9)-6*X(1)-12*X(8)-6*X(9)+64
1147 L6=X(4)*X(7)+X(5)*X(8)+X(6)*X(9)-6*X(5)-12*X(8)-6*X(9)+32
1221 L7=2*X(2)+2*X(3)-X(4)-X(5)-2*X(6)-X(7)-X(9)+18
1223 L8=X(1)+X(2)+2*X(3)+2*X(4)+2*X(6)-2*X(7)+X(8)-X(9)-38
1225 L9=X(1)+X(3)-2*X(4)+X(5)-X(6)+2*X(7)-2*X(8)+8
1230 P1NEWMAY=-ABS(L1)-ABS(L2)-ABS(L3)-ABS(L4)-ABS(L5)-ABS(L6)-ABS(L7)-ABS(L8)-ABS(L9)
1448 P=P1NEWMAY
1451 IF P<=M THEN 1670
1657 FOR KEW=1 TO 9
1658 A(KEW)=X(KEW)
1659 NEXT KEW
1661 M=P
1663 LL1=L1:LL2=L2:LL3=L3:LL4=L4:LL5=L5:LL6=L6:LL7=L7:LL8=L8:LL9=L9
1666 GOTO 128
1670 NEXT I
1890 IF M>-1 THEN 1912 ELSE 1999
1912 PRINT A(1),A(2),A(3),A(4),A(5),A(6),A(7),A(8),A(9)
1913 PRINT M,JJJJ
1914 PRINT LL1,LL2,LL3,LL4,LL5,LL6,LL7,LL8,LL9,M
1999 NEXT JJJJ

The BASIC computer program above was run with Microsoft's GW BASIC 3.11 interpreter, which is not a compiler. Its complete output through
JJJJ=-19985 is presented below. What immediately follows is a manual copy from the computer screen.

4 0 10 0 4
10 0 8 14
0 -27393
0 0 0 0 0
0 0 0 0 0

4 0 10 0 4
10 0 8 14
0 -25657
0 0 0 0 0
0 0 0 0 0

4 0 10 0 4
10 0 8 14
0 -24235
0 0 0 0 0
0 0 0 0 0

12 8 2 8 12
2 8 16 6
0 -19985
0 0 0 0 0
0 0 0 0 0

Interpreted in accordance with line 1912 through line 1914, the output above was obtained in four hours on a personal computer with an Intel 2.66 GHz. chip and the IBM basica/D interpreter.

References

[1] J. Rice. Numerical methods, software, and analysis, second ed. Academic Press, 1993.

[2] A.-M. Bellido. Construction of iteration functions for the simultaneous computation of the solutions of equations and algebraic systems. Numerical Algorithms 6 (1994) 317-351.

[3] A.-M. Bellido. "Construction of iteration functions for the simultaneous computation of the solutions of equations and algebraic systems," Seminaire d'ANALYSE NUMERIQUE, Annee 1991-1992, pp. I-1 to I-16. Universite Paul Sabatier de Toulouse, U.F.R. Mathematiques, Informatique, Gestion.

[4] W. H. Press, S. A. Teukolsky, W. T. Vetterling, B. P. Flannery. Numerical recipes: the art of scientific computing, third ed. Cambridge University Press, 2007.

[5] Microsoft Corp. BASIC, second edition (May 1982), Version 1.10. Boca Raton, Florida: IBM Corp., Personal Computer, P. O. Box 1328-C, Boca Raton, Florida 33432, 1981.

Thursday, April 15, 2010

Solving a Nonlinear System of Four Equations from the Literature

Solving a Nonlinear System of Four Equations from the Literature

Jsun Yui Wong

"Solving systems of nonlinear equations is perhaps the most difficult problem in all of numerical computation," Rice [1, 1993, p. 355].

Originally intended for nonlinear integer programming, the following computer program tries to solve the following nonlinear system, which is based on a system in Shoup [2, pp. 40-41]. These equations are used in line 1141 through line 1150 below. As indicated in line 1157 through line 1160, tolerances of .0001s are used.

5*X(1)+3*X(2)+X(3)+X(4)=15
X(1)*X(2)+X(2)*X(3)+X(3)*X(4)=17
X(1)^2+X(2)^2+X(3)^2-X(4)^2=9
X(1)*X(3)+X(2)*X(4)+X(1)^3=8

0 DEFDBL A-Z
3 DEFINT I,J,K
4 DIM X(42),A(42),L(33),K(33)
5 FOR JJJJ=-32000 TO 32000
14 RANDOMIZE JJJJ
16 M=-1D+17
91 FOR KK=1 TO 4
94 A(KK)=-5+RND*10
95 NEXT KK
126 IMAR=10+FIX(RND*5000)
128 FOR I=1 TO IMAR
129 FOR K=1 TO 4
131 X(K)=A(K)
132 NEXT K
181 J=1+FIX(RND*4)
183 R=(1-RND*2)*A(J)
191 IF RND<.14 THEN X(J)=-5+RND*10 ELSE IF RND<.17 THEN X(J)=A(J)+R ELSE IF RND<.2 THEN X(J)=A(J)+RND*R ELSE IF RND<.25 THEN X(J)=A(J)+RND^2*R ELSE IF RND<.33 THEN X(J)=A(J)+RND^3*R ELSE IF RND<.5 THEN X(J)=A(J)+RND^4*R ELSE X(J)=INT(-5+RND*10)
1141 X(4)=-5*X(1)-3*X(2)-X(3)+15
1145 L1=X(1)*X(2)+X(2)*X(3)+X(3)*X(4)-17
1149 L2=X(1)^2+X(2)^2+X(3)^2-X(4)^2-9
1150 L3=X(1)*X(3)+X(2)*X(4)+X(1)^3-8
1152 L1K=L1
1153 L2K=L2
1154 L3K=L3
1157 IF ABS(L1)>.0001 THEN L1=-ABS(L1)*9999999! ELSE L1=0
1159 IF ABS(L2)>.0001 THEN L2=-ABS(L2)*9999999! ELSE L2=0
1160 IF ABS(L3)>.0001 THEN L3=-ABS(L3)*9999999! ELSE L3=0
1230 P1NEWMAY=L1+L2+L3
1448 P=P1NEWMAY
1451 IF P<=M THEN 1670
1657 FOR KEW=1 TO 4
1658 A(KEW)=X(KEW)
1659 NEXT KEW
1661 M=P
1663 LL1=L1K:LL2=L2K:LL3=L3K
1670 NEXT I
1890 IF M>-5 THEN 1912 ELSE 1999
1912 PRINT A(1),A(2),A(3),A(4),M,JJJJ,LL1,LL2,LL3
1999 NEXT JJJJ

The BASIC computer program above was run with Microsoft's GW BASIC 3.11 interpreter, which is not a compiler. Its complete output through JJJJ=-21946 is presented below. What immediately follows is a manual copy from the computer screen.

1 1 4 3 0
-30258 0 0 0

1 1 4 3 0
-28543 0 0 0

1 1 4 3 0
-21946 0 0 0

Interpreted in accordance with line 1912, the output above was obtained in thirty minutes on a personal computer with an Intel 2.66 GHz. chip and the IBM basica/D interpreter.

References

[1] J. Rice. Numerical methods, software, and analysis, second ed. Academic Press, 1993.

[2] T. E. Shoup. A Practical guide to computer methods for engineers. Prentice-Hall, 1979.

[3] W. H. Press, S. A. Teukolsky, W. T. Vetterling, B. P. Flannery. Numerical recipes: the art of scientific computing, third ed. Cambridge University Press, 2007.

[4] Microsoft Corp. BASIC, second edition (May 1982), Version 1.10. Boca Raton, Florida: IBM Corp., Personal Computer, P. O. Box 1328-C, Boca Raton, Florida 33432, 1981.