艤装計画
プログラム:Part I-4
●プログラムI-4.1
#プログラムI-4.1
#=======================================================================
#艤装工程計画 資源制約(配員)
#=======================================================================
mode1={}
for i in idata1:
if data[i][1] in ACT_gisou:
#-----
#1F #2W #3C #4CC #20ブラスト #31鉄艤 #32甲配 #33機配 #34PA #39_甲配 #40_機配
if data[i][1] in [1,2,3,4,20,31,32,33,34,39,40]:
n=math.ceil(data[i][9][0][0]/5) #1人で何日かかるか
if data[i][1] in [1,3]: #取付
mode1[i]=Mode("mode0["+i+"]",duration=n)
mode1[i].addBreak(0,0)
mode1[i].addResource(resWH,{(0,n):5})
mode1[i].addParallel(1,n,28)
if data[i][1] in [2,4]: #溶接
mode1[i]=Mode("mode0["+i+"]",duration=n)
mode1[i].addBreak(0,0)
mode1[i].addResource(resWW,{(0,n):5})
mode1[i].addParallel(1,n,43)
if data[i][1] in [31]: #鉄艤装
mode1[i]=Mode("mode2["+i+"]",duration=n)
mode1[i].addBreak(0,0)
mode1[i].addResource(resWF1,{(0,n):5})
mode1[i].addParallel(1,n,5)
if data[i][1] in [32,39]: #甲板配管
mode1[i]=Mode("mode2["+i+"]",duration=n)
mode1[i].addBreak(0,0)
mode1[i].addResource(resWF2,{(0,n):5})
mode1[i].addParallel(1,n,7)
if data[i][1] in [33,40]: #機関配管
mode1[i]=Mode("mode2["+i+"]",duration=n)
mode1[i].addBreak(0,0)
mode1[i].addResource(resWF3,{(0,n):5})
mode1[i].addParallel(1,n,10)
if data[i][1]==20: #塗装内
mode1[i]=Mode("mode2["+i+"]",duration=n)
mode1[i].addBreak(0,0)
mode1[i].addResource(resWP, {(0,n):5})
mode1[i].addParallel(1,n,8)
if data[i][1]==34: #塗装外
mode1[i]=Mode("mode2["+i+"]",duration=n)
mode1[i].addBreak(0,0)
mode1[i].addResource(resWP2,{(0,n):5})
mode1[i].addParallel(1,n,8)
act1[i].addModes(mode1[i])
#-----
#10:入荷 #7:社0 #8:検0 #9:W0 #16:運 #17:運0 #18:運2 #19:合体 #21:運ブ #25:運ブ2 #35:AT #0:搭載
elif data[i][1] in [10,7,8,9,16,17,18,19,21,25,35,0]:
mode1[i]=Mode("mode2["+i+"]",duration=data[i][2]) #艤装工程運搬作業時数未定のため期間だけ確保
act1[i].addModes(mode1[i])
#-----
#11:開始 #5:社 #6:検 #12:正 #13:反 #14:積み #15:一体 #36:磨き #37:O/P #38:_鉄艤 #16:運
elif data[i][1] in [11,5,6,12,13,14,15,36,37,38,16]:
mode1[i]=Mode("mode0["+i+"]",duration=data[i][2]) #組立工程運搬作業時数未定のため期間だけ確保
act1[i].addModes(mode1[i])
●プログラムI-4.2
#プログラムI-4.2
#=======================================================================
#艤装工程計画 資源制約(作業場所)
#=======================================================================
for i in idata1:
if data[i][1] in PL_gisou:
#-----
if data[i][1] in [22,23,24,70,71,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87]: #PL_gisou.remove(72): #72:D5_AH
if data[i][1] in [22,23,24]: data[i][6]=AB
for no in range(len(data[i][6])):
no1=data[i][6][no][0];
L=R[no1][1]; B=R[no1][2];
L1=data[i][6][no][1]; L2=data[i][6][no][2];
B1=data[i][6][no][3]; B2=data[i][6][no][4];
skipL=math.floor(L/8); skipL=1
skipB=math.floor(B/2);
l=math.floor(data[i][8][0]); b=math.floor(data[i][8][1]);
if data[i][1] in [22,23,24]: l=19; b=16;
for j in range(L1,L2-l+1,skipL):
for k in range(B1,B2-b+1,skipB):
mode1[i]=Mode("mode2["+i+"]_R[{0:03d}][{1:03d}_{2:03d}][{3:03d}_{4:03d}]".format(no1,j,k,l,b))
for s in range(0,l):
for t in range(0,b):
mode1[i].addBreak(0,0)
mode1[i].addResource(resPL[no1,j+s,k+t],1,"break")
act1[i].addModes(mode1[i])
#-----
elif data[i][1] in [51,53,54,55,56,57,58,59,60,61,62,63,64]: #PL_kumitate.remove(65): #65:K4_1AS1
for no in range(len(data[i][6])):
no1=data[i][6][no][0];
L=R[no1][1]; B=R[no1][2];
L1=data[i][6][no][1]; L2=data[i][6][no][2];
B1=data[i][6][no][3]; B2=data[i][6][no][4];
skipL=math.floor(L/8); skipL=1
skipB=math.floor(B/2);
l=math.floor(data[i][8][0]); b=math.floor(data[i][8][1]);
if data[i][1] in [22,23,24]: l=19; b=16;
for j in range(L1,L2-l+1,skipL):
for k in range(B1,B2-b+1,skipB):
mode1[i]=Mode("mode2["+i+"]_R[{0:03d}][{1:03d}_{2:03d}][{3:03d}_{4:03d}]".format(no1,j,k,l,b))
for s in range(0,l):
for t in range(0,b):
mode1[i].addBreak(0,0)
mode1[i].addResource(resPL[no1,j+s,k+t],1,"break")
act1[i].addModes(mode1[i])
#-----
elif i in {"A01431","A11701","A11711","A11721"}: #場所と期間が固定されている場合(1AS1,D5_AH)
if data[i][6]!=0:
for no in range(len(data[i][6])):
no1=data[i][6][no][0];
L=R[no1][1]; B=R[no1][2];
L1=data[i][6][no][1]; L2=data[i][6][no][2];
B1=data[i][6][no][3]; B2=data[i][6][no][4];
skipL=math.floor(L/4); skipL=2;
skipB=math.floor(B/2); # skipB=1;
l=math.floor(data[i][8][0]); b=math.floor(data[i][8][1]);
for j in range(L1,L2-l+1,skipL):
for k in range(B1,B2-b+1,skipB):
mode1[i]=Mode("mode2["+i+"]_R[{0:03d}][{1:03d}_{2:03d}][{3:03d}_{4:03d}]".format(no1,j,k,l,b),duration=int(data[i][2]))
for s in range(0,l):
for t in range(0,b):
mode1[i].addResource(resPL[no1,j+s,k+t],1)
act1[i].addModes(mode1[i])
●プログラムI-5
#プログラムI-5
#=======================================================================
#艤装工程計画 問題の規模
#=======================================================================
N=len(usuki1.act)
print("アクティビティ総数(含待機数):",N)
M=[]
for a in usuki1.act: M.append(len(a.modes))
print("モード数:",M)
print("平均モード数:",round(sum(M)/N))
P=math.ceil(math.log10(round(sum(M)/N)**N))
print("問題の規模: 10**",P)
#=======================================================================
#艤装工程計画 問題求解
#=======================================================================
usuki1.Params.Makespan=True
usuki1.Params.Initial=False
usuki1.Params.TimeLimit=3600
usuki1.Params.Neighborhood=20
# usuki1.Params.RandomSeed=10
usuki1.Params.OutputFlag=False
usuki1.optimize()
●プログラムI-6
#プログラムI-6
#=======================================================================
#データセットの更新
#=======================================================================
print("")
for a in usuki1.act:
for i in idata1:
if a.name==data[i][0]:
if len(a.modes)==1: nam=a.selected.name
else: nam=a.selected
#print("_"+a.name,len(a.modes),nam,a.start,a.completion)
data[i][3]=a.start
data[i][2]=a.completion-a.start
if len(nam)>15:
r=int(nam[16:19])
x=int(nam[21:24])
y=int(nam[25:28])
l=int(nam[30:33])
b=int(nam[34:37])
place=[[ r, x, x+l, y, y+b]]
data[i][6]=place
print(data[i][0:8])
#========================================================================
filename="usu_S1777_gisou_R040510a.csv"
print("writing "+filename)
usuki1.writeExcel(filename)
# import dill
# dill.dump_session('usukiR040510a.pkl')
# sys.exit()
#-----
#eof