Monday, August 7, 2017

An Illustration of the General Mixed-Integer Nonlinear Programming (MINLP) Solver Presented Here

Jsun Yui Wong

The computer program listed below seeks to solve the following example from Tsai, Lin, and Hu [10]:

Maximize 10 * (X(1) + X(2) + X(3)) + 8 * (X(4) + X(5) + X(6)) - 4 * (X(1) + X(4)) - 5 * (X(2) + X(5)) - 6 * (X(3) + X(6))

subject to        X(1) + X(4)<=400

         X(2) + X(5)<=300

         X(3) + X(6)<=500

         .2 * (X(1) + X(2) + X(3)) >= X(1)

         .1 * (X(1) + X(2) + X(3)) >= X(2)

        .2 * (X(1) + X(2) + X(3)) <= X(3)

         .4 * (X(4) + X(5) + X(6)) >= X(4)

         .5 * (X(4) + X(5) + X(6)) >= X(6)

 X(i)=0, 1, 2, 3, ... where i=1 to 6.

In the following computer program X(7) through X(14) are slack variables.

0 REM DEFDBL A-Z

2 DEFINT I, J, K

3 DIM B(99), N(99), A(99), H(99), L(99), U(99), X(1111), D(111), P(111), PS(33), PE(111)

12 FOR JJJJ = -32000 TO 32111

    14 RANDOMIZE JJJJ
    16 M = -1D+37

    64 FOR J44 = 1 TO 6

        65 A(J44) = FIX(RND * 1001)


    66 NEXT J44


    128 FOR I = 1 TO 25000


        129 FOR KKQQ = 1 TO 6
            130 X(KKQQ) = A(KKQQ)
        131 NEXT KKQQ
        133 FOR IPP = 1 TO (1 + FIX(RND * 4))


            181 J = 1 + FIX(RND * 6)

            183 R = (1 - RND * 2) * A(J)
            187 X(J) = A(J) + (RND ^ (RND * 10)) * R
        222 NEXT IPP

        251 FOR J41 = 1 TO 6

            253 X(J41) = INT(X(J41))
        255 NEXT J41
        261 FOR J42 = 1 TO 6
            263 IF X(J42) < 0 THEN 1670
        265 NEXT J42


        291 X(7) = 400 - X(1) - X(4)


        292 X(8) = 500 - X(2) - X(5)

        293 X(9) = 300 - X(3) - X(6)


        301 X(10) = .2 * (X(1) + X(2) + X(3)) - X(1)

        302 X(11) = .1 * (X(1) + X(2) + X(3)) - X(2)

        303 X(12) = -.2 * (X(1) + X(2) + X(3)) + X(3)

        304 X(13) = .4 * (X(4) + X(5) + X(6)) - X(4)

        305 X(14) = .5 * (X(4) + X(5) + X(6)) - X(6)


        401 FOR J44 = 7 TO 14
            402 IF X(J44) < 0 THEN PE(J44) = 1000000 * X(J44) ELSE PE(J44) = 0


        403 NEXT J44


        428 POBA = 10 * (X(1) + X(2) + X(3)) + 8 * (X(4) + X(5) + X(6)) - 4 * (X(1) + X(4)) - 5 * (X(2) + X(5)) - 6 * (X(3) + X(6)) + PE(7) + PE(8) + PE(9) + PE(10) + PE(11) + PE(12) + PE(13) + PE(14)


        459 POB1 = POBA
        463 P1NEWMAY = POB1
        466 P = P1NEWMAY
        1111 IF P <= M THEN 1670
        1452 M = P
        1453 PPOBA2 = POBA2
        1454 FOR KLX = 1 TO 14


            1455 A(KLX) = X(KLX)
        1456 NEXT KLX
        1557 REM   GOTO 128

    1670 NEXT I
    1889 IF M < 4515 THEN 1999


    1900 PRINT A(1), A(2), A(3), A(4)
    1901 PRINT A(5), A(6), A(7), A(8)

    1904 PRINT A(9), A(10), A(11), A(12), A(13), A(14), M, JJJJ

1999 NEXT JJJJ

This BASIC computer program was run with qb64v1000-win [11].  The complete output through JJJJ=-31298 is shown below:

85            41            300        306
459           0             9            0
0             .2             1.6          214.8          0
382.5        4516        -31929

85            41            300        306
459           0             9            0
0             .2             1.6          214.8          0
382.5        4516        -31889

85            42            299        306
458           1             9            0
0             .2             .6          213.8          0
381.5        4516        -31860

85            41            300        306
459           0             9            0
0             .2             1.6          214.8          0
382.5        4516        -31726

85            41            300        306
459           0             9            0
0             .2             1.6          214.8          0
382.5        4516        -31712

85            41            300        306
459           0             9            0
0             .2             1.6          214.8          0
382.5        4516        -31662

85            41            300        306
459           0             9            0
0             .2             1.6          214.8          0
382.5        4516        -31646

85            41            300        306
459           0             9            0
0             .2             1.6          214.8          0
382.5        4516        -31624

85            41            300        306
459           0             9            0
0             .2             1.6          214.8          0
382.5        4516        -31619

85            41            300        306
459           0             9            0
0             .2             1.6          214.8          0
382.5        4516        -31590

85            41            300        306
459           0             9            0
0             .2             1.6          214.8          0
382.5        4516        -31565

85            41            300        306
459           0             9            0
0             .2             1.6          214.8          0
382.5        4516        -31530

85            41            300        306
459           0             9            0
0             .2             1.6          214.8          0
382.5        4516        -31490

85            41            300        306
459           0             9            0
0             .2             1.6          214.8          0
382.5        4516        -31460

85            41            300        306
459           0             9            0
0             .2             1.6          214.8          0
382.5        4516        -31445

85            41            300        306
459           0             9            0
0             .2             1.6          214.8          0
382.5        4516        -31391

85            41            300        306
459           0             9            0
0             .2             1.6          214.8          0
382.5        4516        -31365

85            41            300        306
459           0             9            0
0             .2             1.6          214.8          0
382.5        4516        -31363

85            42            299        306
458           1             9            0
0             .2             .6          213.8          0
381.5        4516        -31298
                       
Above there is no rounding by hand; it is just straight copying by hand from the monitor screen.

On a personal computer with a Pentium Dual-Core CPU E5200 @2.50GHz, 2.50 GHz, 960 MB of RAM and qb64v1000-win [11], the wall-clock time for obtaining the output through JJJJ=-31298 was one minute.

Acknowledgment

I would like to acknowledge the encouragement of Roberta Clark and Tom Clark.

References

[1]  Yuichiro Anzai (1974).  On Integer Fractional Programming.  Journal Operations Research Society of Japan, Volume 17, No. 1, March 1974, pp. 49-66.
www..orsj.or.jp/~archiv/pdf/e_mag/Vol.17_01_049.pdf.

[2]  Sjirk Boon. Solving systems of nonlinear equations. Sci. Math. Num-Analysis,1992, Newsgroup Article 3529.    

[3]  Han-Lin Li, Jung-Fa Tsai (2008).  A distributed computational algorithm for solving portfolio problems with integer variables.  European Journal of Operational Research 186 (2008) pp.882-891.

[4]   Harry Markowitz  (1952).   Portfolio Selection.   The Journal of Finance  7 (2008) pp. 77-91.

[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.

[6]  H. S. Ryoo, N. V. Sahinidis (1995).  Global optimization of nonconvex NLP and MINLP with applications in process design. Computers and Chemical Engineering Vol. 19 (5) (1995) pp. 551-566.

[7]  Jung-Fa Tsai, Ming-Hua Lin, Yi-Chung Hu (2007).  On generalized geometric programming problems with non-positive variables.  European Journal of Operational Research 178 (2007) pp. 10-19.

[8]  Jung-Fa Tsai, Ming-Hua Lin (2008).  Global optimization of signomial mixed-integer nonlinear programming with free variables.  Journal of Global Optimization  (2008) 42  pp. 39-49.

[9]  Jung-Fa Tsai, Ming-Hua Lin (2007).  Finding all solutions of systems of nonlinear equations with free variables.  Engineering Optimization  (2007) 39:6, pp. 649-659

[10]  Jung-Fa Tsai, Ming-Hua Lin, Yi-Chung Hu (2008).  Fing multiple integer solutions to general integer linear programs.  European Journal of Operational Research 184 (2008) pp. 802-809.

[11] Wikipedia, QB64, https://en.wikipedia.org/wiki/QB64    

[12] Jsun Yui Wong (2012, April 12).  The Domino Method of General Integer Nonlinear Programming Applied to a Nonlinear Fractional Programming Problem from the Literature. http://myblogsubstance.typepad.com/substance/2012/04/12/

Thursday, August 3, 2017

Adapting the Mixed-Integer Nonlinear Programming (MINLP) Solver Presented Here for Solving Nonlinear Systems of Equations

Jsun Yui Wong

The computer program listed below seeks to solve the following Sjirk Boon [2] nonlinear system of equations used in Tsai and Lin [9]:

         X(1) ^2+ X(3) ^ 2-1=0

        X(2) ^2+ X(4) ^ 2 -1=0

     X(5)*X(3) ^ 3 +    X(6) * X(4) ^ 3    -1.2 =0

        X(5) * X(1) ^ 3 + X(6) * X(2) ^ 3 - 1.2=0

        X(5) * X(3) ^ 2 * X(1) + X(6) * X(4) ^ 2 * X(2) - .7=0

         X(5) * X(3) * X(1) ^ 2 + X(6) * X(4) * X(2) ^ 2 - .7=0

-10<= X(i)<=10, i=1 to 6.

0 REM DEFDBL A-Z

2 DEFINT I, J, K

3 DIM B(99), N(99), A(99), H(99), L(99), U(99), X(1111), D(111), P(111), PS(33)
12 FOR JJJJ = -32000 TO 32111

    14 RANDOMIZE JJJJ
    16 M = -1D+37

    64 FOR J44 = 1 TO 6

        65 A(J44) = -1 + RND * 2

    66 NEXT J44
    126 REM IMAR=10+FIX(RND*32000)
    128 FOR I = 1 TO 30000


        129 FOR KKQQ = 1 TO 6
            130 X(KKQQ) = A(KKQQ)
        131 NEXT KKQQ
        133 FOR IPP = 1 TO (1 + FIX(RND * 4))


            181 J = 1 + FIX(RND * 6)

            183 R = (1 - RND * 2) * A(J)
            187 X(J) = A(J) + (RND ^ (RND * 10)) * R
        222 NEXT IPP
        366 IF X(3) ^ 2 > 1 THEN GOTO 373


        367 IF RND < .5 THEN X(1) = -(1 - X(3) ^ 2) ^ .5 ELSE X(1) = (1 - X(3) ^ 2) ^ .5



        373 IF X(4) ^ 2 > 1 THEN GOTO 379


        374 IF RND < .5 THEN X(2) = -(1 - X(4) ^ 2) ^ .5 ELSE X(2) = (1 - X(4) ^ 2) ^ .5

        379 X(5) = (1.2 - X(6) * X(4) ^ 3) / X(3) ^ 3


        386 PS(4) = X(5) * X(1) ^ 3 + X(6) * X(2) ^ 3 - 1.2

        387 PS(5) = X(5) * X(3) ^ 2 * X(1) + X(6) * X(4) ^ 2 * X(2) - .7


        388 PS(6) = X(5) * X(3) * X(1) ^ 2 + X(6) * X(4) * X(2) ^ 2 - .7


        393 FOR J59 = 1 TO 6

            394 IF X(J59) < -10 THEN GOTO 1670

            395 IF X(J59) > 10 THEN GOTO 1670
        398 NEXT J59

        417 POBA = -ABS(PS(4)) - ABS(PS(5)) - ABS(PS(6))


        459 POB1 = POBA
        463 P1NEWMAY = POB1
        466 P = P1NEWMAY
        1111 IF P <= M THEN 1670
        1452 M = P
        1453 PPOBA2 = POBA2
        1454 FOR KLX = 1 TO 6



            1455 A(KLX) = X(KLX)
        1456 NEXT KLX
        1557 REM   GOTO 128

    1670 NEXT I
    1889 IF M < -.0003 THEN 1999


    1900 PRINT A(1), A(2), A(3), A(4)


    1904 PRINT A(5), A(6), M, JJJJ

1999 NEXT JJJJ

This BASIC computer program was run with qb64v1000-win [10].  The complete output through JJJJ=32111 is shown below:

-.915316          .4572198        -.4027364         1.040711
-1.442559        .9810117       -2.02933E-04              -31423  

.4021955           -.9152884             .9155538           -.402799
1.440758        -1.44273           -2.408289E-04            -21010

-.5961376           .9154932            -1.355668         .4023333
-.4439624    1.441352         -8.565298E-05                -14235

.5550773    -.9154617          1.262391             -.4024051
     .5497942     -1.441529             -4.222878E-05       4313

.8124468         .9154342         1.848123       .4024675      
 .1752132       1.441746      -1.225971E-05                  9206

.4026785           -.9155846             .9153415           -.4021255
1.442545        -1.440738           -2.219319E-04           10583

-.4021617           -.9152779            -.91555686           -.4028229
-1.440658        -1.442819           -2.638689E-04            10628

-.4022661           .9153302            -.9155228           .4027041
-1.441015        1.442447           -1.750053E-04            12645

.5349895    -3.031289               1.217944               -1.333414      
.6120817   -.0397175              -1.921458 E-04                18546

.4617415         .9153111           1.0513                .4027475
.9516512        1.442687           -2.454814E-04               23106

-.4872388         .9154198        -1.108508           .4025003
-.8119524         1.441869         -4.427775E-05            23690

.5734121         -.9154607        1.304184     -.4024074
.4986132       -1.441561    -3.151143E-05               31575

Above there is no rounding by hand; it is just straight copying by hand from the monitor screen.

On a personal computer with a Pentium Dual-Core CPU E5200 @2.50GHz, 2.50 GHz, 960 MB of RAM and qb64v1000-win [10], the wall-clock time for obtaining the output through JJJJ=32111 was 90 minutes.

Acknowledgment

I would like to acknowledge the encouragement of Roberta Clark and Tom Clark.

References

[1]  Yuichiro Anzai (1974).  On Integer Fractional Programming.  Journal Operations Research Society of Japan, Volume 17, No. 1, March 1974, pp. 49-66.
www..orsj.or.jp/~archiv/pdf/e_mag/Vol.17_01_049.pdf.

[2]  Sjirk Boon. Solving systems of nonlinear equations. Sci. Math. Num-Analysis,1992, Newsgroup Article 3529.     .

[3]  Han-Lin Li, Jung-Fa Tsai (2008).  A distributed computational algorithm for solving portfolio problems with integer variables.  European Journal of Operational Research 186 (2008) pp.882-891.

[4]   Harry Markowitz  (1952).   Portfolio Selection.   The Journal of Finance  7 (2008) pp. 77-91.

[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.

[6]  H. S. Ryoo, N. V. Sahinidis (1995).  Global optimization of nonconvex NLP and MINLP with applications in process design. Computers and Chemical Engineering Vol. 19 (5) (1995) pp. 551-566.

[7]  Jung-Fa Tsai, Ming-Hua Lin, Yi-Chung Hu (2007).  On generalized geometric programming problems with non-positive variables.  European Journal of Operational Research 178 (2007) pp. 10-19.

[8]  Jung-Fa Tsai, Ming-Hua Lin (2008).  Global optimization of signomial mixed-integer nonlinear programming with free variables.  Journal of Global Optimization  (2008) 42  pp. 39-49.

[9]  Jung-Fa Tsai, Ming-Hua Lin (2007).  Finding all solutions of systems of nonlinear equations with free variables.  Engineering Optimization  (2007) 39:6, pp. 649-659

[10] Wikipedia, QB64, https://en.wikipedia.org/wiki/QB64.    

[11] Jsun Yui Wong (2012, April 12).  The Domino Method of General Integer Nonlinear Programming Applied to a Nonlinear Fractional Programming Problem from the Literature. http://myblogsubstance.typepad.com/substance/2012/04/12/

Monday, July 31, 2017

Using the MINLP Solver Presented Here

Jsun Yui Wong

The computer program listed below seeks to solve the nonconvex example on pp. 45-47 of Tsai and Lin [7].

The X(6), X(7), and X(8) of the following computer program are slack variables.  Line 403 below refers to the given objective function.

0 REM  DEFDBL A-Z

2 DEFINT I, J, K

3 DIM B(99), N(99), A(99), H(99), L(99), U(99), X(1111), D(111), P(111), PS(33)
12 FOR JJJJ = -32000 TO 32111

    14 RANDOMIZE JJJJ
    16 M = -1D+37
    64 FOR J44 = 1 TO 5
        65 A(J44) = 1 + RND * 9


    66 NEXT J44

    77 A(1) = -7 + RND * 12


    126 REM IMAR=10+FIX(RND*32000)
    128 FOR I = 1 TO 10000


        129 FOR KKQQ = 1 TO 5
            130 X(KKQQ) = A(KKQQ)
        131 NEXT KKQQ
        133 FOR IPP = 1 TO (1 + FIX(RND * 3))
            181 J = 1 + FIX(RND * 5)
            183 R = (1 - RND * 2) * A(J)
            187 X(J) = A(J) + (RND ^ (RND * 10)) * R
        222 NEXT IPP
        223 REM GOTO 233

        225 REM FOR J23 = 1 TO 4

        227 X(3) = INT(X(3))



        229 REM NEXT J23


        233 X(6) = 2 - X(1) - 6 * X(2) + X(3) + 5 * X(4)

        244 X(7) = -10 - (X(3) ^ 1.5) * X(4) - .5 * X(2) - 3 * X(1)


        249 X(8) = 6 + X(1) + .5 * X(4) - X(5)

        283 IF X(1) < -7 THEN 1670

        284 IF X(1) > 5 THEN 1670

        286 IF X(2) < 1 THEN 1670

        287 IF X(2) > 10 THEN 1670

        288 IF X(3) < 1 THEN 1670

        289 IF X(3) > 5 THEN 1670

        291 IF X(4) < 2 THEN 1670

        292 IF X(4) > 8 THEN 1670

        297 IF X(5) < 2 THEN 1670

        298 IF X(5) > 9 THEN 1670


        331 FOR J44 = 6 TO 8

            335 IF X(J44) < 0 THEN PS(J44) = ABS(X(J44)) ELSE PS(J44) = 0

        339 NEXT J44
        403 POBA2 = -(X(1) ^ 2 * X(2) ^ -2 * X(3) - 2 * X(2) ^ .7 * X(3) ^ .2 + X(4) * X(5) ^ -2 - 2 * X(1) - 4 * X(3))




        411 POBA = POBA2 - 1000000 * PS(6) - 1000000 * PS(7) - 1000000 * PS(8)



        422 REM POBA = POBA2 + (PS(4))
        459 POB1 = POBA
        463 P1NEWMAY = POB1
        466 P = P1NEWMAY
        1111 IF P <= M THEN 1670
        1452 M = P
        1453 PPOBA2 = POBA2
        1454 FOR KLX = 1 TO 8


            1455 A(KLX) = X(KLX)
        1456 NEXT KLX
        1557 REM   GOTO 128

    1670 NEXT I
    1889 IF M < -2.906 THEN 1999

    1900 PRINT A(1), A(2), A(3), A(4)

    1904 PRINT A(5), A(6), A(7), A(8), M, JJJJ, PPOBA2

1999 NEXT JJJJ

This BASIC computer program was run with qb64v1000-win [8].  The complete output through JJJJ=-30627 is shown below:

-5.341226                4.52466                1           3.761347
2.539448                   1.907349E-06             2.384186E-07
0         -2.905618      -31874        -2.905618

-5.321954                4.488379                1            3.721663
2.538877                9.536743E-07             1.001358E-05
0         -2.905934      -31454        -2.905934

-5.333839                4.510576                1            3.745927
2.53912             1.502037E-05             3.020763E-04
3.933907E-06         -2.905985      -31356        -2.905985

-5.374219                4.586674                1           3.829311
2.540405      7.281303E-04      1.0252E-05             3.147125E-05
-2.905988      -30627        -2.905988

Above there is no rounding by hand; it is just straight copying by hand from the monitor screen.

On a personal computer with a Pentium Dual-Core CPU E5200 @2.50GHz, 2.50 GHz, 960 MB of RAM and qb64v1000-win [8], the wall-clock time for obtaining the output through JJJJ=-30627 was 35 seconds.

Acknowledgment

I would like to acknowledge the encouragement of Roberta Clark and Tom Clark.

References

[1]  Yuichiro Anzai (1974).  On Integer Fractional Programming.  Journal Operations Research Society of Japan, Volume 17, No. 1, March 1974, pp. 49-66.
www..orsj.or.jp/~archiv/pdf/e_mag/Vol.17_01_049.pdf.

[2]  Han-Lin Li, Jung-Fa Tsai (2008).  A distributed computational algorithm for solving portfolio problems with integer variables.  European Journal of Operational Research 186 (2008) pp.882-891.

[3]   Harry Markowitz  (1952).   Portfolio Selection.   The Journal of Finance  7 (2008) pp. 77-91.

[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.

[5]  H. S. Ryoo, N. V. Sahinidis (1995).  Global optimization of nonconvex NLP and MINLP with applications in process design. Computers and Chemical Engineering Vol. 19 (5) (1995) pp. 551-566.

[6]  Jung-Fa Tsai, Ming-Hua Lin, Yi-Chung Hu (2007).  On generalized geometric programming problems with non-positive variables.  European Journal of Operational Research 178 (2007) pp. 10-19.

[7]  Jung-Fa Tsai, Ming-Hua Lin (2008).  Global optimization of signomial mixed-integer nonlinear programming with free variables.  Journal of Global Optimization  (2008) 42  pp. 39-49.

[8] Wikipedia, QB64, https://en.wikipedia.org/wiki/QB64.    

[9] Jsun Yui Wong (2012, April 12).  The Domino Method of General Integer Nonlinear Programming Applied to a Nonlinear Fractional Programming Problem from the Literature. http://myblogsubstance.typepad.com/substance/2012/04/12/

Saturday, July 29, 2017

A Computer Program about Markowitz Portfolio Selection

Jsun Yui Wong

The computer program listed below seeks to solve the small example about Markowitz portfolio selection [3] on pp. 888-890 of Li and Tsai [2].

Minimize           .0108 * X(1) ^ 2 + .0584 * X(2) ^ 2 + .0942 * X(3) ^ 2 + .0248 * X(1) * X(2) + .0262 * X(1) * X(3) + .1108 * X(2) * X(3)

subject to          1.089 * X(1) + 1.214 * X(2) + 1.235 * X(3)  >=  115

X(1) + X(2) + X(3)  =  100

where X(1),  X(2), and X(3) are integers.

Below X(1) through X(3) are integer variables, and X(4) is a slack variable.


0 REM  DEFDBL A-Z

2 DEFINT I, J, K

3 DIM B(99), N(99), A(99), H(99), L(99), U(99), X(1111), D(111), P(111), PS(33)
12 FOR JJJJ = -32000 TO 32000


    14 RANDOMIZE JJJJ
    16 M = -1D+37
    64 FOR J44 = 1 TO 3
        65 A(J44) = RND * 10

    66 NEXT J44
    126 REM IMAR=10+FIX(RND*32000)
    128 FOR I = 1 TO 10000


        129 FOR KKQQ = 1 TO 3
            130 X(KKQQ) = A(KKQQ)
        131 NEXT KKQQ
        133 FOR IPP = 1 TO (1 + FIX(RND * 2))
            181 J = 1 + FIX(RND * 3)
            183 R = (1 - RND * 2) * A(J)
            187 X(J) = A(J) + (RND ^ (RND * 10)) * R
        222 NEXT IPP

        223 X(1) = 100 - X(2) - X(3)


        224 FOR J33 = 1 TO 3

            226 X(J33) = INT(X(J33))

        227 NEXT J33

        229 REM X(5) = 1
        233 X(4) = -115 + 1.089 * X(1) + 1.214 * X(2) + 1.235 * X(3)
   
        281 FOR J44 = 1 TO 3


            283 IF X(J44) < 0 THEN 1670

            284 IF X(J44) > 100 THEN 1670

        285 NEXT J44

        331 FOR J44 = 4 TO 4

            332 IF X(J44) < 0 THEN PS(J44) = ABS(X(J44)) ELSE PS(J44) = 0
        333 NEXT J44
        403 POBA2 = -(.0108 * X(1) ^ 2 + .0584 * X(2) ^ 2 + .0942 * X(3) ^ 2 + .0248 * X(1) * X(2) + .0262 * X(1) * X(3) + .1108 * X(2) * X(3))


        411 POBA = POBA2 - 1000000 * (PS(4))


        459 POB1 = POBA
        463 P1NEWMAY = POB1
        466 P = P1NEWMAY
        1111 IF P <= M THEN 1670
        1452 M = P
        1453 PPOBA2 = POBA2
        1454 FOR KLX = 1 TO 11

            1455 A(KLX) = X(KLX)
        1456 NEXT KLX
        1557 GOTO 128
    1670 NEXT I
    1889 IF M < -224.647 THEN 1999

    1900 PRINT A(1), A(2), A(3), A(4)
 
    1904 PRINT M, JJJJ, PPOBA2
1999 NEXT JJJJ

This BASIC computer program was run with qb64v1000-win [5].  The complete output through JJJJ=-24202 is shown below:

53    36     11      .006
-223.8916       -28885       -223.8916

53    35     12        .027
-224.6452         -27481           -224.6452

53    36     11      .006
-223.8916       -25873       -223.8916

53    35     12        .027
-224.6452         -24202           -224.6452

Above there is no rounding by hand; it is just straight copying by hand from the monitor screen.

On a personal computer with a Pentium Dual-Core CPU E5200 @2.50GHz, 2.50 GHz, 960 MB of RAM and qb64v1000-win [5], the wall-clock time for obtaining the output through JJJJ=-24202 was 2 minutes and 15 seconds.

Acknowledgment

I would like to acknowledge the encouragement of Roberta Clark and Tom Clark.

References

[1]  Yuichiro Anzai (1974).  On Integer Fractional Programming.  Journal Operations Research Society of Japan, Volume 17, No. 1, March 1974, pp. 49-66.
www..orsj.or.jp/~archiv/pdf/e_mag/Vol.17_01_049.pdf.

[2]  Han-Lin Li, Jung-Fa Tsai (2008).  A distributed computational algorithm for solving portfolio problems with integer variables.  European Journal of Operational Research 186 (2008) pp.882-891.

[3]   Harry Markowitz  (1952).   Portfolio Selection.   The Journal of Finance 7 (2008) pp. 77-91.

[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.

[5] Wikipedia, QB64, https://en.wikipedia.org/wiki/QB64.    

[6] Jsun Yui Wong (2012, April 12).  The Domino Method of General Integer Nonlinear Programming Applied to a Nonlinear Fractional Programming Problem from the Literature. http://myblogsubstance.typepad.com/substance/2012/04/12/

Sunday, July 23, 2017

A Computer Program for Integer Fractional Programming, Revised Edition


Jsun Yui Wong

The computer program listed below seeks to solve the integer fractional programming example on pages 55-57 of Anzai [1].

Here X(1) through X(5) are integer variables, and X(6) through X(11) are slack variables.  

Whereas line 128 and line 1454 of the preceding paper are 128 FOR I = 1 TO 1000 and 1454 FOR KLX = 1 TO 8, here line 128 and line 1454 are 128 FOR I = 1 TO 50 and 1454 FOR KLX = 1 TO 11, respectively.

0 DEFDBL A-Z
2 DEFINT I, J, K

3 DIM B(99), N(99), A(99), H(99), L(99), U(99), X(1111), D(111), P(111), PS(33)
12 FOR JJJJ = -32000 TO 32000

    14 RANDOMIZE JJJJ
    16 M = -1D+37
    64 FOR J44 = 1 TO 5
        65 A(J44) = .1 + RND * 9.899999
    66 NEXT J44
    126 REM IMAR=10+FIX(RND*32000)
    128 FOR I = 1 TO 50

        129 FOR KKQQ = 1 TO 5
            130 X(KKQQ) = A(KKQQ)
        131 NEXT KKQQ
        133 FOR IPP = 1 TO (1 + FIX(RND * 4))
            181 J = 1 + FIX(RND * 5)
            183 R = (1 - RND * 2) * A(J)
            187 X(J) = A(J) + (RND ^ (RND * 10)) * R
            188 GOTO 222
            189 REM   X(J)=A(J)+PA
            190 REM X(J)=A(J)+FIX(RND*2 )-FIX(RND*2)
            191 REM   X(J)=A(J)+FIX(RND*3)-FIX(RND*3)
        222 NEXT IPP

        224 FOR J33 = 1 TO 5

            226 X(J33) = INT(X(J33))

        227 NEXT J33

        229 X(5) = 1

        231 REM FOR J44=1 TO 5
        233 REM IF X(J44)<.1 THEN 1670
        234 REM IF X(J44)>10 THEN 1670
        235 REM NEXT J44

        240 X(6) = X(1) - 2 * X(2) + 9

        259 X(7) = -4 * X(1) - X(2) + 21

        261 X(8) = -X(1) + 3 * X(2)

        266 X(9) = 4 * X(1) + 5 * X(2) - 12

        268 X(10) = 2 * X(3) - 6 * X(4) + 21

        270 X(11) = -7 * X(3) - 4 * X(4) + 39

        281 FOR J44 = 1 TO 5

            283 IF X(J44) < 0 THEN 1670

            284 IF X(J44) > 10 THEN 1670
        285 NEXT J44

        331 FOR J44 = 6 TO 11
            332 IF X(J44) < 0 THEN PS(J44) = ABS(X(J44)) ELSE PS(J44) = 0
        333 NEXT J44
        403 POBA2 = -(-X(1) - 3 * X(2) - X(3) + X(4) - X(5)) / (2 * X(1) + X(2) + 3 * X(3) + 5 * X(4) + X(5))
        411 POBA = POBA2 - 999999999# * (PS(6) + PS(7) + PS(8) + PS(9) + PS(10) + PS(11))
        459 POB1 = POBA
        463 P1NEWMAY = POB1
        466 P = P1NEWMAY
        1111 IF P <= M THEN 1670
        1452 M = P
        1453 PPOBA2 = POBA2
        1454 FOR KLX = 1 TO 11

            1455 A(KLX) = X(KLX)
        1456 NEXT KLX
        1557 GOTO 128
    1670 NEXT I
    1889 REM IF M<0 THEN 1999
    1900 PRINT A(1), A(2), A(3), A(4)
    1901 PRINT A(5), A(6), A(7), A(8)

    1902 PRINT A(9), A(10), A(11)

    1904 PRINT M, JJJJ, PPOBA2
1999 NEXT JJJJ

This BASIC computer program was run with qb64v1000-win [3].  The complete output through JJJJ=-31996 is shown below:

0         4         0          0
1         1         17        12
8         21         39
2.6        -32000         2.6

0         4         0          0
1         1         17        12
8         21         39
2.6        -31999         2.6

0         4         0          0
1         1         17        12
8         21         39
2.6        -31998         2.6

0         2          0          0
1         5         19        6
-2        21        39
-1999999995.666667        -31997         2.333333333333334

0         4         0          0
1         1         17        12
8         21         39
2.6        -31996         2.6

Above there is no rounding by hand; it is just straight copying by hand from the monitor screen.

On a personal computer with a Pentium Dual-Core CPU E5200 @2.50GHz, 2.50 GHz, 960 MB of RAM and qb64v1000-win [3], the wall-clock time for obtaining the output through JJJJ=-31996 was 3 seconds, not including "Creating .EXEC file" time..

Acknowledgment

I would like to acknowledge the encouragement of Roberta Clark and Tom Clark.

References

[1]  Yuichiro Anzai (1974).  On Integer Fractional Programming.  Journal Operations Research Society of Japan, Volume 17, No. 1, March 1974, pp. 49-66.
www..orsj.or.jp/~archiv/pdf/e_mag/Vol.17_01_049.pdf.

[2] 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.

[3] Wikipedia, QB64, https://en.wikipedia.org/wiki/QB64      

[4] Jsun Yui Wong (2012, April 12).  The Domino Method of General Integer Nonlinear Programming Applied to a Nonlinear Fractional Programming Problem from the Literature. http://myblogsubstance.typepad.com/substance/2012/04/12/  

A Computer Program for Integer Fractional Programming

Jsun Yui Wong

The computer program listed below seeks to solve the integer fractional programming example on pages 55-57 of Anzai [1].

Here X(1) through X(5) are integer variables, and X(6) through X(11) are slack variables.  

0 DEFDBL A-Z
2 DEFINT I, J, K

3 DIM B(99), N(99), A(99), H(99), L(99), U(99), X(1111), D(111), P(111), PS(33)
12 FOR JJJJ = -32000 TO 32000
    14 RANDOMIZE JJJJ
    16 M = -1D+37
    64 FOR J44 = 1 TO 5
        65 A(J44) = .1 + RND * 9.899999
    66 NEXT J44
    126 REM IMAR=10+FIX(RND*32000)
    128 FOR I = 1 TO 1000
        129 FOR KKQQ = 1 TO 5
            130 X(KKQQ) = A(KKQQ)
        131 NEXT KKQQ
        133 FOR IPP = 1 TO (1 + FIX(RND * 4))
            181 J = 1 + FIX(RND * 5)
            183 R = (1 - RND * 2) * A(J)
            187 X(J) = A(J) + (RND ^ (RND * 10)) * R
            188 GOTO 222
            189 REM   X(J)=A(J)+PA
            190 REM X(J)=A(J)+FIX(RND*2 )-FIX(RND*2)
            191 REM   X(J)=A(J)+FIX(RND*3)-FIX(RND*3)
        222 NEXT IPP

        224 FOR J33 = 1 TO 5

            226 X(J33) = INT(X(J33))


        227 NEXT J33

        229 X(5) = 1

        231 REM FOR J44=1 TO 5
        233 REM IF X(J44)<.1 THEN 1670
        234 REM IF X(J44)>10 THEN 1670
        235 REM NEXT J44


        240 X(6) = X(1) - 2 * X(2) + 9

        259 X(7) = -4 * X(1) - X(2) + 21

        261 X(8) = -X(1) + 3 * X(2)

        266 X(9) = 4 * X(1) + 5 * X(2) - 12

        268 X(10) = 2 * X(3) - 6 * X(4) + 21

        270 X(11) = -7 * X(3) - 4 * X(4) + 39

        281 FOR J44 = 1 TO 5

            283 IF X(J44) < 0 THEN 1670

            284 IF X(J44) > 10 THEN 1670
        285 NEXT J44

        331 FOR J44 = 6 TO 11
            332 IF X(J44) < 0 THEN PS(J44) = ABS(X(J44)) ELSE PS(J44) = 0
        333 NEXT J44
        403 POBA2 = -(-X(1) - 3 * X(2) - X(3) + X(4) - X(5)) / (2 * X(1) + X(2) + 3 * X(3) + 5 * X(4) + X(5))
        411 POBA = POBA2 - 999999999# * (PS(6) + PS(7) + PS(8) + PS(9) + PS(10) + PS(11))
        459 POB1 = POBA
        463 P1NEWMAY = POB1
        466 P = P1NEWMAY
        1111 IF P <= M THEN 1670
        1452 M = P
        1453 PPOBA2 = POBA2
        1454 FOR KLX = 1 TO 8
            1455 A(KLX) = X(KLX)
        1456 NEXT KLX
        1557 GOTO 128
    1670 NEXT I
    1889 REM IF M<0 THEN 1999
    1900 PRINT A(1), A(2), A(3), A(4)
    1901 PRINT A(5), A(6), A(7), A(8)

    1902 PRINT A(9), A(10), A(11)

    1904 PRINT M, JJJJ, PPOBA2
1999 NEXT JJJJ

This BASIC computer program was run with qb64v1000-win [3].  The complete output through JJJJ=-31995 is shown below:

0         4         0          0
1         1         17        12
0         0         0
2.6        -32000         2.6

0         4         0          0
1         1         17        12
0         0         0
2.6        -31999         2.6

2         1         0          0
1         9         12        1
0         0         0
1        -31998         1

0         4         0          0
1         1         17        12
0         0         0
2.6        -31997         2.6

0         4         0          0
1         1         17        12
0         0         0
2.6        -31996         2.6

0         4         0          0
1         1         17        12
0         0         0
2.6        -31995         2.6

Above there is no rounding by hand; it is just straight copying by hand from the monitor screen.

On a personal computer with a Pentium Dual-Core CPU E5200 @2.50GHz, 2.50 GHz, 960 MB of RAM and qb64v1000-win [3], the wall-clock time for obtaining the output through JJJJ=-31995 was 10 seconds.

Acknowledgment

I would like to acknowledge the encouragement of Roberta Clark and Tom Clark.

References

[1]  Y. Anzai (1974).  On Integer Fractional Programming.  Journal Operations Research Society of Japan, Volume 17, No. 1, March 1974, pp. 49-66.

[2] 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.

[3] Wikipedia, QB64, https://en.wikipedia.org/wiki/QB64      

[4] Jsun Yui Wong (2012, April 12).  The Domino Method of General Integer Nonlinear Programming Applied to a Nonlinear Fractional Programming Problem from the Literature. http://myblogsubstance.typepad.com/substance/2012/04/12/  

Monday, June 19, 2017

Solving a Double Row Layout Problem Having 16 Facilities

Jsun Yui Wong

Based on the computer program in Wong [17], the following computer program seeks to solve the problem named P16_a in Fischer, Fischer, and Hungerlander [10, p. 129, Table 1]. The data come from the PROP Instances-Amaral 2013 section of Anjos [8].

0 REM DEFDBL A-Z
1 DEFINT I, J, K, X, A
2 DIM B(99), N(99), A(2002), H(99), L(99), U(99), X(2002), D(111), P(111), PS(33), J44(2002), J(99), AA(99), HR(32), HHR(32), Y(33), C(33), CC(33)
3 DIM HS(49, 49)
4 DIM PE(49, 49)
5 DIM SD(49, 49)
27 HR(1) = 14: HR(2) = 11: HR(3) = 9: HR(4) = 5: HR(5) = 13

28 REM   HR(6)=4:HR(7)=6:HR(8)=8:HR(9)=9
29 HR(6) = 5: HR(7) = 14: HR(8) = 7: HR(9) = 10: HR(10) = 11

30 HR(11) = 8: HR(12) = 14: HR(13) = 10: HR(14) = 11: HR(15) = 8: HR(16) = 5

31 FOR IL = 1 TO 16
    32 FOR JL = 1 TO 16
        33 READ HS(IL, JL)
    34 NEXT JL
35 NEXT IL
61 DATA 999,0,5,0,5,2,10,3,1,5,5,5,0,0,5,4

62 DATA 0,999,3,10,5,1,5,1,2,4,2,5,0,10,10,3
63 DATA 5,3,999,2,0,5,2,4,4,5,0,0,0,5,1,0
64 DATA 0,10,2,999,1,0,5,2,1,0,10,2,2,0,2,1

66 DATA 5,5,0,1,999,5,6,5,2,5,2,0,5,1,1,1
67 DATA 2,1,5,0,5,999,5,2,1,6,0,0,10,0,2,0

68 DATA 10,5,2,5,6,5,999,0,0,0,5,10,2,2,5,1


69 DATA 3,1,4,2,5,2,0,999,1,1,10,10,2,0,10,2

70 DATA 1,2,4,1,2,1,0,1,999,2,0,3,5,5,0,5

71 DATA 5,4,5,0,5,6,0,1,2,999,5,5,0,5,1,0

72 DATA 5,2,0,10,2,0,5,10,0,5,999,5,2,5,1,10
73 DATA 5,5,0,2,0,0,10,10,3,5,5,999,2,10,5,0

74 DATA 0,0,0,2,5,10,2,2,5,0,2,2,999,2,2,1

75 DATA 0,10,5,0,1,0,2,0,5,5,5,10,2,999,5,5
76 DATA 5,10,1,2,1,2,5,10,0,1,1,5,2,5,999,3
77 DATA 4,3,0,1,1,0,1,2,5,0,10,0,1,5,3,999
78 FOR JJJJ = -32000 TO 32000
    79 RANDOMIZE JJJJ
    80 M = -1D+37


    81 IMAX = 2 + FIX(RND * 13)


    82 FOR J44 = 1 TO 16

        83 A(J44) = J44
    84 NEXT J44
    111 REM IF RND < 1 / 4 THEN IMAX = 8 ELSE IF RND < 1 / 3 THEN IMAX = 9 ELSE IF RND < 1 / 2 THEN IMAX = 10 ELSE IMAX = 11

    126 REM IMAR=10+FIX(RND*1000)
    128 FOR I = 1 TO 1000


        129 FOR KKQQ = 1 TO 16
            130 X(KKQQ) = A(KKQQ)
        131 NEXT KKQQ
        133 III = 1 + FIX(RND * 16)
        134 JJJ = 1 + FIX(RND * 16)
        221 X(III) = A(JJJ)
        223 X(JJJ) = A(III)
        231 FOR J44 = 1 TO 16
            233 FOR J45 = 1 TO 16
                234 IF X(J44) = J45 THEN HHR(J44) = HR(J44) ELSE GOTO 238
                237 Y(J45) = J44
            238 NEXT J45
            253 FOR ISE20 = 1 TO IMAX
                254 C(ISE20) = .5 * HHR(Y(ISE20))
                258 FOR ISE2000 = ISE20 + 1 TO IMAX
                    259 C(ISE20) = C(ISE20) + HHR(Y(ISE2000))
                263 NEXT ISE2000
            269 NEXT ISE20
            386 FOR ISE20N = IMAX + 1 TO 16
                387 C(ISE20N) = .5 * HHR(Y(ISE20N))
                388 FOR ISE2000N = ISE20N + 1 TO 16
                    389 C(ISE20N) = C(ISE20N) + HHR(Y(ISE2000N))
                390 NEXT ISE2000N
            391 NEXT ISE20N
        395 NEXT J44
        411 PROD = 0
        412 FOR J44 = 1 TO 16
            413 FOR J45 = J44 + 1 TO 16
                414 PROD = PROD - HS(Y(J44), Y(J45)) * ABS(C(J44) - C(J45))
            415 NEXT J45
        416 NEXT J44
        422 P = PROD
        1111 IF P <= M THEN 1670
        1452 M = P
        1453 FOR KLX = 1 TO 16
            1454 CC(KLX) = C(KLX)
            1455 A(KLX) = X(KLX)
        1456 NEXT KLX
        1559 Iimax = IMAX
        1657 GOTO 128
    1670 NEXT I
    1889 IF M < -7371 THEN 1999


    1901 PRINT A(1), A(2), A(3), A(4), A(5)
    1902 PRINT A(6), A(7), A(8), A(9), A(10)
    1903 PRINT A(11), A(12), A(13), A(14), A(15), A(16)

    1905 REM PRINT  CC(1), CC(2), CC(3), CC(4), CC(5)
    1906 REM PRINT CC(6), CC(7), CC(8), CC(9), CC(10)
    1907 REM PRINT CC(11), CC(12), CC(13), CC(14), CC(15)
    1919 PRINT M, JJJJ, Iimax
1999 NEXT JJJJ

This computer program was run with qb64v1000-win [16]. The complete output through JJJJ=-29826 is shown below:

16    4       3       13      2
9      7      14      1        10
5      6       8       11      15
12
-7370    -31479        7

16    4   3     13     2
9    7   14      1    10
5    6     8     11    15
12
-7370    -31269        7

16    4   3     13     2
9    7   14      1    10
5    6     8     11    15
12
-7370    -30457        7

9       13      12      6       11
2       16      7        10     3
14     15      1        4       8
5
-7370     -29826      9

Above there is no rounding by hand; it is just straight copying by hand from the monitor screen.

On a personal computer with a Pentium Dual-Core CPU E5200 @2.50GHz, 2.50 GHz, 960 MB of RAM and qb64v1000-win [16], the wall-clock time for obtaining the output through JJJJ=-29826 was five minutes.

Acknowledgment

I would like to acknowledge the encouragement of Roberta Clark and Tom Clark.

References

[1] Andre R. S. Amaral (2006), On the Exact Solution of a Facility Layout Problem. European Journal of Operational Research 173 (2006), pp. 508-518.

[2] Andre R. S. Amaral (2008), An Exact Approach to the One-Dimensional Facility Layout Problem. Operations Research, Vol. 56, No. 4 (July-August, 2008), pp. 1026-1033.

[3] Andre R. S. Amaral (2011), Optimal Solutions for the Double Row Layout Problem. Optimization Letters, DOI 10.1007/s11590-011-0426-8, published on line 30 November 2011, Springer-Verlag 2011.

[4] Andre R. S. Amaral (2012), The Corridor Allocation Problem. Computers and Operations Research 39 (2012), pp. 3325-3330.

[5] Andre R. S. Amaral (2013), A Parallel Ordering Problem in Facilities Layout. Computers and Operations Research, Vol. 40, Issue 12, December 2013, pp. 2930-2939.

[6] Miguel F. Anjos, Anthony Vannelli, Computing Globally Optimal Solutions for Single-Row Layout Problems Using Semidefinite Programming and Cutting Planes. INFORMS Journal on Computing, Vol. 20, No. 4, Fall 2008, pp. 611-617.

[7] Miguel F. Anjos (2012), FLPLIB–Facility Layout Database. Retrieved on September 25 2012 from http://www.gerad.ca/files/Sites/Anjos/indexFR.html

[8] Miguel F. Anjos, FLPLIB–Facility Layout Database. http://www.miguelanjos.com.

[9] Miguel Anjos.  QAP - A Quadratic Assignment Problem Library.  www.anjos.mgi.polymtl.ca/qaplib/data.d/sko49.dat

[10] Anja Fischer, Frank Fischer. Philipp Hungerlaender, A New Exact Approach to the Space-Free Double Row Layout Problem.
K. Doerner et al. (eds) Operations Research Proceedings 2015. Springer 2017.

[11] S. S. Heragu, A. Kusiak. Efficient Models for the Facility Layout Problem. European Journal of Operational Research 53 (1), 1991, pp. 1-13.

[12] Philipp Hungerlaender, Miguel F. Anjos (January 2012), A Semidefinite Optimization Approach to Free-Space Multi-Row Facility Layout. Les Cahiers du GERAD. Retrieved from http://www.gerad.ca/fichiers/cahiers/G-2012-03.pdf

[13] Robert F. Love, Jsun Yui Wong (1976), On Solving a One-Dimensional Space Allocation Problem with Integer Programming,  INFOR 14(2), pp. 139-143.

[14] 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.

[15] C. E. Nugent, T. E Vollmann, J. Ruml (1968), An Experimental Comparison of Techniques for the Assignment of Facilities to Locations. Operations Research, Vol. 16, pp. 150-173.

[16] Wikipedia, QB64, https://en.wikipedia.org/wiki/QB64

[17] Jsun Yui Wong (2012, September 20). A General Nonlinear Integer/Discrete/Continuous Programming Solver Applied to the Corridor Allocation Problem with Fifteen Facilities, Fifth Edition. https://myblogsubstance.typepad.com/substance/2012/09/index.html/

[18] Ginger Yen (2008). Cutting-Plane Separation Strategies for Semidefinite Programming Models to Solve Single-Row Facility Layout Problems. A Master Thesis Presented to the University of Waterloo