如何在 Minizinc 中使用热启动?

How to use warm starts in Minizinc?

我正在尝试使用 Minizinc 中的热启动注释为模型提供已知的次优解决方案。

我首先尝试执行 Minizinc 文档(他们提供的唯一文档)中的这个热启动示例:

array[1..3] of var 0..10: x;
array[1..3] of var 0.0..10.5: xf;
var bool: b;
array[1..3] of var set of 5..9: xs;
constraint b+sum(x)==1;
constraint b+sum(xf)==2.4;
constraint 5==sum( [ card(xs[i]) | i in index_set(xs) ] );
solve
  :: warm_start_array( [                     %%% Can be on the upper level
    warm_start( x, [<>,8,4] ),               %%% Use <> for missing values
    warm_start( xf, array1d(-5..-3, [5.6,<>,4.7] ) ),
    warm_start( xs, array1d( -3..-2, [ 6..8, 5..7 ] ) )
  ] )
  :: seq_search( [
    warm_start_array( [                      %%% Now included in seq_search to keep order
      warm_start( x, [<>,5,2] ),             %%% Repeated warm_starts allowed but not specified
      warm_start( xf, array1d(-5..-3, [5.6,<>,4.7] ) ),
      warm_start( xs, array1d( -3..-2, [ 6..8, 5..7 ] ) )
    ] ),
    warm_start( [b], [true] ),
    int_search(x, first_fail, indomain_min)
  ] )
  minimize x[1] + b + xf[2] + card( xs[1] intersect xs[3] );

实例运行,得到最优解。但是,输出显示警告,指出所有热启动注释都被忽略了。

Warning, ignored search annotation: warm_start_array([warm_start([[xi(1), xi(2)], [i(5), i(2)]]), warm_start([[xf(0), xf(2)], [f(5.6), f(4.7)]]), warm_start([[xs(0), xs(1), xs(2)], [s(), s()]])])
Warning, ignored search annotation: warm_start([[xb(0)], [b(true)]])
Warning, ignored search annotation: warm_start_array([warm_start([[xi(1), xi(2)], [i(8), i(4)]]), warm_start([[xf(0), xf(2)], [f(5.6), f(4.7)]]), warm_start([[xs(0), xs(1), xs(2)], [s(), s()]])])

我没有修改示例中的任何内容,只是将其复制粘贴并 运行 使用 Geocode 默认求解器将其 IDE 中。如果相关,我使用 Windows。我有 运行 其他模型,并且使用其他搜索注释没有问题。

示例中有两块暖星(一个在求解后,一个在 seq_search 内)。我不确定两者是否都是必要的。我尝试删除一个,然后删除另一个,但所有剩余的热启动注释仍然会出现警告。我也不明白为什么 'b' 在第一个块中没有被引用。

git https://github.com/google/or-tools/issues/539 中有一个类似的示例,但它也会产生警告。

如果有人可以向我指出 warm_start 的工作示例,那就太好了。

您对 warm_start 注释的使用是正确的,但大多数求解器目前不支持热启动注释。在撰写本文时,我认为只有混合整数编程接口(CoinBC、Gurobi、CPlex、XPress 和 SCIP)支持热启动注释。尽管我们一直致力于在 Gecode 和 Chuffed 中添加对注释的支持,但尚未在任何已发布版本中包含对此注释的支持。