ki0073

Untitled

Aug 6th, 2016
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.72 KB | None | 0 0
  1. # version 0.2 GLPK
  2. set Day; # カレンダーの日付
  3. set Holiday; # 休業日
  4. set WorkingDay := Day diff Holiday; # 稼働日
  5. set ProductName; # 製品名
  6. param lotSize{ProductName} symbolic; # 1ロットの生産数量
  7. param workerHour{ProductName}; # 1ロットの工数
  8. param minNLot{ProductName} integer; # 1日の最底ロット数
  9. param maxNLot{ProductName} integer; # 1日の最大ロット数
  10. set RestrictPlan dimen 2 within WorkingDay cross ProductName; # 生産日が限定される条件読み込み
  11. set RestrictProduct := setof{(d,p) in RestrictPlan}(p); # 生産日が限定される製品
  12. set AvailableDayProduct := {WorkingDay, ProductName diff RestrictProduct} union RestrictPlan; # 製品別の生産可能な日
  13. param totalProductionLot{ProductName} integer;
  14. param workerHourRatio{WorkingDay} default 1.0; # 目標工数比率
  15. param targetWorkerHour{d in WorkingDay} := (sum{p in ProductName}totalProductionLot[p]*workerHour[p]/sum{d1 in WorkingDay}workerHourRatio[d1])*workerHourRatio[d]; # 日別の目標工数
  16.  
  17. # 設定値の出力
  18. printf "期間中のロット総数 総生産数 総工数\n";
  19. for{p in ProductName}{
  20. printf "%s %8d %8d %8.2f\n", p, totalProductionLot[p], totalProductionLot[p]*lotSize[p],totalProductionLot[p]*workerHour[p];
  21. }
  22. printf "\n";
  23. printf "日ごとの目標工数\n";
  24. for{d in Day}{
  25. printf "%s " & (if d in WorkingDay then "%8.2f" else " -") & "\n", d, targetWorkerHour[d];
  26. }
  27. printf "\n";
  28. printf (if card(RestrictPlan) >0 then "生産可能日が限定される製品\n" else "");
  29. for{p in RestrictProduct}{
  30. printf "%s ", p;
  31. printf{(d,p) in RestrictPlan} " %s", d;
  32. printf "\n";
  33. }
  34. printf (if card(RestrictPlan) >0 then "\n" else "");
  35.  
  36. var nLotTable{AvailableDayProduct} integer, >=0; # 日別製品別ロット数
  37. var totalWorkerTime{WorkingDay}; # 日別総工数
  38. var binaryForNLot{AvailableDayProduct} binary; # ロット数制限用
  39. var differenceFromTargetWorkerTime{WorkingDay} >=0; # 目標工数との差
  40.  
  41. s.t. sumLot{p in ProductName}: sum{d in WorkingDay: (d,p) in AvailableDayProduct}nLotTable[d,p]==totalProductionLot[p]; # ロット数合計を合わす
  42. s.t. maxLotNum{(d,p) in AvailableDayProduct}: nLotTable[d,p]<=maxNLot[p]*binaryForNLot[d,p]; # 最大ロット数に制限
  43. s.t. minLotNum{(d,p) in AvailableDayProduct}: nLotTable[d,p]>=minNLot[p]*binaryForNLot[d,p]; # 最小ロット数に制限
  44. s.t. sumWorkerTime{d in WorkingDay}: sum{p in ProductName:(d,p) in AvailableDayProduct}nLotTable[d,p]*workerHour[p]==totalWorkerTime[d];
  45. s.t. diffWorkerTime1{d in WorkingDay}: totalWorkerTime[d]-targetWorkerHour[d]<=differenceFromTargetWorkerTime[d];
  46. s.t. diffWorkerTime2{d in WorkingDay}: totalWorkerTime[d]-targetWorkerHour[d]>=-differenceFromTargetWorkerTime[d];
  47. minimize diffminWT: sum{d in WorkingDay}differenceFromTargetWorkerTime[d];
  48.  
  49. solve;
  50. # 結果出力
  51. printf "日ごとの生産数\n";
  52. for{d in WorkingDay}{
  53. printf "%s 総工数 %10.2f\n", d, totalWorkerTime[d];
  54. printf " 製品名 ロット数  生産数  工数\n";
  55. printf{p in ProductName: (d,p) in AvailableDayProduct and nLotTable[d,p]>0} " %s %8d %8d %8.2f\n", p, nLotTable[d,p], nLotTable[d,p]*lotSize[p], nLotTable[d,p]*workerHour[p];
  56. }
  57.  
  58. data;
  59. # 一日の生産ロット数は0または1日の最低ロット数以上1日の最大ロット数以下になる
  60. # 製品名 1ロットの数量 1ロットの工数 1日の最低ロット数 1日の最大ロット数
  61. param : ProductName : lotSize workerHour minNLot maxNLot:=
  62. "製品1" 3000 3000 1 2
  63. "製品2" 1800 1800 1 3
  64. "製品3" 1800 1800 1 3
  65. "製品4" 1900 1900 1 2
  66. "製品5" 2160 2160 1 2
  67. "製品6" 1440 1440 1 1
  68. "製品7" 1900 1900 1 1
  69. "製品8" 1260 1260 1 2
  70. "製品9" 2520 2520 1 1
  71. "製品10" 2080 2080 1 2
  72. ;
  73.  
  74. # カレンダーの日付
  75. set Day:= 1 2 3 4 5 6 7;
  76. # 休業日 出力はカレンダーの日付で行うが生産を割り当てない
  77. set Holiday := 3 4;
  78. # 製品の総生産ロット数
  79. param totalProductionLot :=
  80. "製品1" 1
  81. "製品2" 5
  82. "製品3" 3
  83. "製品4" 2
  84. "製品5" 3
  85. "製品6" 2
  86. "製品7" 2
  87. "製品8" 2
  88. "製品9" 1
  89. "製品10" 3
  90. ;
  91. # 生産日が限定される製品名とその日付
  92. set RestrictPlan :=
  93. (*, "製品1") 1 2 5 # 製品1を1 2 5 日に限定
  94. (*, "製品2") 1 2 5
  95. (*, "製品3") 1 2 5
  96. (*, "製品4") 2 5 6
  97. (*, "製品5") 2 5 6
  98. (*, "製品6") 2 5 6 # 製品6を2 5 6 日に限定
  99. (*, "製品7") 5 6 7
  100. (*, "製品8") 5 6 7
  101. (*, "製品9") 5 6 7
  102. (*, "製品10") 5 6 7
  103. ;
  104. # 行事等で目標工数を変えたい場合 日付と比率
  105. param workerHourRatio :=
  106. # 7 0.8 # 先頭の#を外すと稼働日の目標工数が変えられる、12日が8割に減少
  107. ;
  108. end;
Advertisement
Add Comment
Please, Sign In to add comment