我有以下限制条件
我尝试使用以下代码在AMPL中对其进行建模:
var y {1..njobs} binary;
subject to overlap
{i in 1..njobs, j in i+1..njobs: i<>j}:
xi[i] + si[i] <= xi[j]+m*y[i];
subject to order
{i in 1..njobs, j in i+1..njobs: i<j}:
y[i] + y[j] = 1;
我是这个主题的新手,似乎错过了上面代码中的某些内容。有什么建议吗?
根据约束,y具有两个索引i和j,但是您的代码仅给它一个索引。
应该是这样的:
var y {1..njobs,1..njobs} binary;
subject to overlap
{i in 1..njobs, j in i+1..njobs: i<>j}:
xi[i] + si[i] <= xi[j]+m*y[i,j];
subject to order
{i in 1..njobs, j in i+1..njobs: i<j}:
y[i,j] + y[j,i] = 1;
当前,当i = j时的行为是不确定的。您可能想要添加定义该情况下行为的约束,或者在声明y时将其从索引空间中排除,例如:]
var y {i in 1..njobs,j in 1..njobs: i <> j} binary;