1

我有一个任务列表,它们之间存在一些相互依赖关系。9个任务。每个 cpu 组 6 个 cpu 2。有三个组 p1,p2,p3。

cost p1=4
COST p2=5
COST P3=2

给出了不同cpu上不同任务的执行时间。我们必须在任务之间传输数据数据。我们将使用点对点链接。我们需要在两个 cpu 之间购买一个点对点链接,这将花费我们 1。我们以后可以重用这些链接。

问题:我想指定这些约束。 r1!=r4 <=> b14=1; b14是任务 1 和 4 之间通信的通信时间。我还需要对链接进行成本。r1:CPU任务一分配给。

if r1!=r4 then cost[r1][r4]=1;

谁能告诉我如何在 Minizinc 中指定这两个约束?我不想使用 if then 约束,如果我可以使用 reified 一切会更好。

4

1 回答 1

2

In MiniZinc, you can't use "if condition then ... else ... endif" when the condition involves decision variables. Instead reifications must then be used and they are stated using "->", "<-" and "<->":

   c1 -> c2   implication
   c2 <- c1   implication (same as c1 -> c2) 
   c1 <-> c2   equivalence

So, the two constraints should be written like this (assuming that "r1" and "r4" are decision variables):

constraint 
     (r1 != r4 <-> b14=1) 
     /\
     (r1 != r4 -> cost[r1,r4] = 1)
;

Always put parenthesis around the reifications when working with more than one constraints in a "constraint" section, otherwise the parser may interpret the constraints the wrong way.

Also, note that an element in a matrix are written as

   cost[r1,r2]

That said, if you can use if/then/else/endif construct, then you probably should do that since translating a reification is normally more costly.

于 2014-02-27T06:36:09.180 回答