这是我试图用代码解决的约束。 鉴于 L 是所有操作 l 的集合 K是所有工作中心k的集合 L(k) 是在工作中心 k 上处理的操作集合 l
float ProcessingTime[Products][Operations] = ...;
float Capacity[Workshops] = ...;
dvar int+ Y[Products][0..NbOperations][Periods];
{string} Products = ...;
{string} Workshops = ...;
int NbOperations = ...; range Operations = 1..NbOperations;
int NbPeriods = ...; range Periods = 1..NbPeriods;
subject to
{
forall(t in Periods,k in Workshops)
ct5:
sum(p in Products,l in Operations) (ProcessingTime[p][l]*Y[p][l][t]) <= Capacity[k];
}
其中一个求和应该是用 L(k) 表示的,但我无法在这里将其编码出来。因为l是int,k是字符串。另一件事是 L 已经在使用中,我不知道如何将这两个链接在一起。
您可以使用切片。
.mod
{string} Products = ...;
{string} Workshops = ...;
int NbOperations = ...;
range Operations = 1..NbOperations;
int NbPeriods = ...;
range Periods = 1..NbPeriods;
float ProcessingTime[Products][Operations] = ...;
float Capacity[Workshops] = ...;
{int} L[Workshops]=...;
dvar int+ Y[Products][0..NbOperations][Periods];
subject to
{
forall(t in Periods,k in Workshops)
ct5:
sum(p in Products,l in Operations:l in L[k]) (ProcessingTime[p][l]*Y[p][l][t]) <= Capacity[k];
}
.dat
Products = {P1 P2 P3};
NbOperations = 10;
NbPeriods = 3;
Workshops={"A","B"};
Capacity=[1,2];
ProcessingTime=[[1],[2]];
L=[{1,2,3,4,5,6},{7,8,9,10}];