ChipMaster's bwBASIC This also includes history going back to v2.10. *WARN* some binary files might have been corrupted by CRLF.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

120 lines
3.5 KiB

  1. 1 REM ASSIGN
  2. 5 CLEAR 100
  3. 10 CLS:PRINT TAB(20);"ASSIGNMENT COST":PRINT
  4. 20 PRINT"THE ASSIGNMENT PROBLEM EXAMINED IN THIS PROGRAM IS OF THE
  5. 25 PRINT"FOLLOWING TYPE: THERE ARE A FIXED NUMBER OF JOBS TO BE DONE
  6. 30 PRINT"(SAY N JOBS), AND THE SAME NUMBER(N) OF POSSIBLE ASSIGNEES,
  7. 35 PRINT"I.E. THOSE WHO CAN DO THE JOB. THE ASSIGNEES HAVE DIFFERENT
  8. 40 PRINT"EFFICIENCIES FOR THE DIFFERENT JOBS. IN FACT FOR EACH
  9. 45 PRINT"JOB-ASSIGNEE COMBINATION WE CAN ASSIGN SOME COST. EACH
  10. 50 PRINT"ASSIGNEE IS ASSIGNED TO 1 AND ONLY 1 JOB. THE PROGRAM WILL
  11. 55 PRINT"FIND THE ASSIGNMENT WHICH MINIMIZES TOTAL COST.
  12. 60 PRINT:PRINT"THIS PROGRAM IS SET UP FOR A MAXIMUM OF 9 DIFFERENT JOBS
  13. 65 PRINT"AND 9 DIFFERENT POSSIBLE ASSIGNMENTS.
  14. 90 PRINT:INPUT"PRESS ENTER TO CONTINUE";Z9$
  15. 100 MAXX = 9
  16. 110 DIM C(MAXX+1,MAXX+1),MA(MAXX+1),JO(MAXX+1),SZ(MAXX+1),AU(MAXX+1),SA(MAXX+1)
  17. 120 CLS
  18. 130 PRINT"HOW MANY JOBS MUST BE ASSIGNED(<=";MAXX;:INPUT N
  19. 140 IF N<1 OR N>MAXX OR N<>INT(N) THEN GOSUB 10000:PRINT:GOTO 130
  20. 150 PRINT
  21. 160 FOR I=1 TO N
  22. 170 PRINT"FOR JOB";I
  23. 180 FOR J=1 TO N
  24. 190 PRINT" COST FOR ASSIGNEE";J;:INPUT C(I,J)
  25. 200 NEXT J
  26. 210 PRINT
  27. 220 NEXT I
  28. 230 PRINT:GOSUB 10100
  29. 235 CLS
  30. 240 INPUT"IS LINEPRINTER OUTPUT OF INITIAL COST ASSIGNMENT DESIRED(Y/N)";Z2$
  31. 250 IF Z2$<>"Y" AND Z2$<>"N" THEN GOSUB 10000:PRINT:GOTO 240
  32. 260 IF Z2$="N" THEN GOTO 300
  33. 270 PRINT:INPUT"PRESS ENTER WHEN PRINTER READY";Z9$
  34. 273 FOR I=1 TO N
  35. 275 LPRINT"FOR JOB";I
  36. 278 FOR J=1 TO N
  37. 280 LPRINT" COST FOR ASSIGNEE";J;"=";C(I,J)
  38. 285 NEXT J:NEXT I
  39. 300 CLS:PRINT:PRINT:PRINT:PRINT"COMPUTING"
  40. 305 FOR I=1 TO N:FOR J=1 TO N:C(I,J)=-C(I,J):NEXT:NEXT
  41. 320 ZL=0:FOR I=1 TO N:AU(I)=0:NEXT
  42. 326 FOR I=1 TO N:MA(I)=0:W=-1E9
  43. 332 FOR J=1 TO N
  44. 334 IF AU(J)=1 THEN GOTO 342
  45. 336 IF C(I,J)<=W THEN GOTO 342
  46. 338 W=C(I,J):J1=J
  47. 342 NEXT J
  48. 344 AU(J1)=1
  49. 346 ZL=ZL+W
  50. 348 SA(I)=J1
  51. 350 NEXT I
  52. 370 REM START SEARCH
  53. 375 I=1
  54. 380 J=1
  55. 390 FOR M=1 TO I
  56. 400 IF J=MA(M) THEN J=J+1:GOTO 390
  57. 410 NEXT M
  58. 420 MA(I)=J
  59. 430 GOSUB 1000
  60. 440 SZ(I)=ZU:IF ZU<=ZL THEN GOTO 600
  61. 460 I=I+1:IF I<=N THEN GOTO 380
  62. 480 FOR I=1 TO N:SA(I)=MA(I):NEXT I
  63. 510 I=N:ZL=ZU:REM NEW BOUND
  64. 540 IF SZ(I-1)<>ZL THEN GOTO 660
  65. 550 MA(I)=0:I=I-1:IF I=1 THEN GOTO 660
  66. 580 GOTO 540
  67. 600 J=MA(I)
  68. 610 J=J+1
  69. 620 IF J<=N THEN GOTO 680
  70. 630 MA(I)=0:I=I-1
  71. 660 IF I=0 THEN GOTO 740
  72. 670 GOTO 600
  73. 680 IM=I-1
  74. 690 IF IM=0 THEN IM=1
  75. 700 FOR L=1 TO IM:IF J=MA(L) THEN GOTO 610
  76. 720 NEXT L
  77. 730 GOTO 420
  78. 740 CLS
  79. 750 INPUT"IS LINE PRINTER OUTPUT DESIRED(Y/N)";Z2$
  80. 760 IF Z2$<>"Y" AND Z2$<>"N" THEN GOSUB 10000:GOTO 750
  81. 770 CLS:PRINT"OPTIMAL ASSIGNMENT"
  82. 780 FOR I=1 TO N
  83. 790 PRINT TAB(10);"JOB ";SA(I);"GETS ASSIGNEE";I;" COST = ";-C(SA(I),I)
  84. 800 NEXT
  85. 802 ZL=-ZL
  86. 805 PRINT:PRINT TAB(30);"TOTAL COST = ";ZL
  87. 810 IF Z2$="N" THEN GOTO 900
  88. 815 LPRINT TAB(20);"OPTIMAL ASSIGNMENT":LPRINT" "
  89. 820 FOR I=1 TO N
  90. 830 LPRINT "JOB ";SA(I);"GETS ASSIGNEE";I;" COST = ";-C(SA(I),I)
  91. 832 NEXT I
  92. 835 LPRINT TAB(20);"TOTAL COST = ";ZL
  93. 900 PRINT:INPUT"PRESS ENTER TO START AGAIN";Z9$
  94. 905 IF Z9$ = "0" THEN END
  95. 910 CLEAR 1000:GOTO 100
  96. 1000 FOR CI=1 TO N:AU(CI)=MA(CI):NEXT CI
  97. 1030 FOR CI=1 TO N
  98. 1040 IF AU(CI)=0 THEN GOTO 1070
  99. 1050 NEXT CI
  100. 1060 CI=N+1:CM=CI-1:GOTO 1210
  101. 1070 CM=CI-1
  102. 1080 FOR MN=CI TO N
  103. 1090 CW=-1E9
  104. 1100 FOR JB=1 TO N
  105. 1110 IF CI=1 THEN GOTO 1150
  106. 1120 FOR L=1 TO CM
  107. 1130 IF JB=AU(L) THEN GOTO 1170
  108. 1140 NEXT L
  109. 1150 IF C(MN,JB)<=CW THEN GOTO 1170
  110. 1160 CW=C(MN,JB)
  111. 1170 NEXT JB
  112. 1180 AU(MN)=CW
  113. 1190 NEXT MN
  114. 1200 IF CI=1 THEN GOTO 1240
  115. 1210 FOR CJ=1 TO CM:AU(CJ)=C(CJ,MA(CJ)):NEXT CJ
  116. 1240 ZU=0:FOR CJ=1 TO N:ZU=ZU+AU(CJ):NEXT CJ
  117. 1280 RETURN
  118. 10000 PRINT"INPUT ERROR!TRY AGAIN!":FOR JJ=1 TO 300:NEXT:RETURN
  119. 10100 INPUT"PRESS ENTER TO CONTINUE";Z9$:RETURN