Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set Day; # 日付
- set ProductName; # 製品名
- set RestrictPlan dimen 2 within Day cross ProductName; # 生産できる日が限定される場合
- set RestrictProduct := setof{(d,p) in RestrictPlan}(p);
- set AvailableDayProduct := {Day, ProductName diff RestrictProduct} union RestrictPlan; # 製品別の生産可能な日
- set LotParam := {"lotSize", "workerHour", "minNLot", "maxNLot"};
- param productLotParam{ProductName, LotParam};
- param totalProductionLot{ProductName} integer;
- # 設定の出力
- printf "期間中のロット総数 総生産数 総工数\n";
- for{p in ProductName}{
- printf "%s %8d %8d %f\n", p, totalProductionLot[p], totalProductionLot[p]*productLotParam[p,"lotSize"],totalProductionLot[p]*productLotParam[p,"workerHour"];
- }
- printf "\n";
- printf (if card(RestrictPlan) >0 then "生産可能日が限定される製品\n" else "");
- for{p in RestrictProduct}{
- printf "%s ", p;
- printf{(d,p) in RestrictPlan} " %s", d;
- printf "\n";
- }
- printf (if card(RestrictPlan) >0 then "\n" else "");
- var nLotTable{AvailableDayProduct} integer, >=0; # 日別製品別ロット数
- var totalWorkerTimeInDay{Day}; # 日別総工数
- var binaryForNLot{AvailableDayProduct} binary; # ロット数制限用
- var minimumWorkerTimeInDay; # 工数最低日の工数
- s.t. sumLot{p in ProductName}: sum{d in Day: (d,p) in AvailableDayProduct}nLotTable[d,p]==totalProductionLot[p];
- s.t. maxLotNum{(d,p) in AvailableDayProduct}: nLotTable[d,p]<=productLotParam[p, "maxNLot"]*binaryForNLot[d,p];
- s.t. minLotNum{(d,p) in AvailableDayProduct}: nLotTable[d,p]>=productLotParam[p, "minNLot"]*binaryForNLot[d,p];
- s.t. sumWorkerTime{d in Day}: sum{p in ProductName:(d,p) in AvailableDayProduct}nLotTable[d,p]*productLotParam[p, "workerHour"]==totalWorkerTimeInDay[d];
- s.t. minWorkerTimeInDay{d in Day}: totalWorkerTimeInDay[d]>=minimumWorkerTimeInDay;
- maximize miniWT: minimumWorkerTimeInDay;
- solve;
- # 結果出力
- printf "日ごとの生産数\n";
- for{d in Day}{
- printf "%s 総工数 %f\n", d, totalWorkerTimeInDay[d];
- printf " 製品名 ロット数 生産数 工数\n";
- 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]*productLotParam[p,"lotSize"], nLotTable[d,p]*productLotParam[p,"workerHour"];
- }
- data;
- # 製品名を列挙
- set ProductName := "製品A" "製品B" "製品C" "製品D" "製品E";
- # 一日の生産ロット数は0または1日の最低ロット数以上1日の最大ロット数以下になる
- # 製品名 1ロットの数量 1ロットの工数 1日の最低ロット数 1日の最大ロット数
- param productLotParam : lotSize workerHour minNLot maxNLot:=
- "製品A" 50 5.0 2 2
- "製品B" 50 5.0 2 2
- "製品C" 25 2.5 2 6
- "製品D" 25 2.5 2 3
- "製品E" 25 2.5 2 3
- ;
- # 日付
- set Day:= 715 718 719 720;
- # 製品の総生産ロット数
- param totalProductionLot :=
- "製品A" 6
- "製品B" 6
- "製品C" 6
- "製品D" 12
- "製品E" 6
- ;
- # 生産が限定される製品があれば製品名とその日付
- set RestrictPlan :=
- # (*, "製品E") 715 718 # 先頭の#を外すと生産日が限定される
- ;
- end;
Advertisement
Add Comment
Please, Sign In to add comment