通过gecode快速仓库约束(地理代码文件的Ch15)

时间:2014-03-25 16:18:34

标签: c++ constraint-programming gecode

无法理解第192页的限制,“不要超过容量”。

IntSetArgs c(n_warehouses);
for(int w = 0; w < n_warehouses; ++w){
  c[w] = IntSet(0, capacity[w]);
  //IntSet(0, 1) == {}, {0}, {1}, {0, 1}
}
count(*this, supplier, c, ICL_DOM);

该文件称计数功能构建一个等于“不要超过容量”的约束。 但我不知道为什么?

1:ICL_DOM与ICL_DOM有什么不同?

2:根据4.4.8(第63页)

如果c不是一个集合,而是一个IntArrayArgs而没有ICL_DOM,就像发布了 约束如下?

int capacity[] = {1, 4, 2, 1, 3};

supplier[0] == 0  == c[0] == 1
supplier[0] == 1  == c[1] == 4
supplier[0] == 2  == c[2] == 2
supplier[0] == 3  == c[3] == 1
supplier[0] == 4  == c[4] == 3

supplier[1] == 0 == c[0] == 1 //and so on

如果c是一组怎么办?这意味着约束将成为

supplier[0] == 0 == c[0] == 0, 1
supplier[0] == 1 == c[1] == 0, 1, 2, 3, 4
//....
supplier[1] == 0 == c[0] == 0, 1
supplier[1] == 1 == c[1] == 0, 1, 2, 3, 4 //and so on?

我不明白为什么这会导致“不要超过容量”约束。

对我来说,它应该是(伪代码)

rel(*this, sum(supplier == 0) <= 1);
rel(*this, sum(supplier == 1) <= 4);
rel(*this, sum(supplier == 2) <= 2);
rel(*this, sum(supplier == 3) <= 1);
rel(*this, sum(supplier == 4) <= 3);

0 个答案:

没有答案