OptSeq |
#rcpsp11.py
from optseq import *
#====データセット
#i:[名前、期間、後続、資源]
data={
1:["A01",3,[4,6],3],
2:["A02",4,[5,7],1],
3:["A03",6,[8] ,1],
4:["A04",4,[5,7],4],
5:["A05",5,[8] ,4],
6:["A06",5,[9] ,4],
7:["A07",4,[10] ,5],
8:["A08",2,[10] ,2],
9:["A09",2,[10] ,5],
10:["A10",5,[0] ,3],
}
#====アクティビティ
prob=Model()
act={}
for i in data:
act[i]=prob.addActivity(data[i][0])
#====先行制約
for i in data:
for j in data[i][2]:
if j>0: prob.addTemporal(act[i],act[j])
#====資源制約
res=prob.addResource("Resource",capacity={(0,"inf"):10})
mode={}
for i in data:
mode[i]=Mode("M{0:02d}_{1:02d}".format(i,data[i][3]),\
duration=data[i][1])
mode[i].addResource(res,requirement=data[i][3])
act[i].addModes(mode[i])
#====求解
prob.Params.Makespan=True
prob.Params.TimeLimit=1
prob.optimize()
prob.write("rcpsp11.txt")
prob.writeExcel("rcpsp11.csv")
|