如何在 Minizinc 中使用热启动?

Ano*_*non 1 constraint-programming 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] );
Run Code Online (Sandbox Code Playgroud)

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

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()]])])
Run Code Online (Sandbox Code Playgroud)

我没有修改示例中的任何内容,只是复制粘贴它并使用 Geocode 默认解算器在 Minizinc IDE 中运行它。如果相关的话,我正在使用 Windows。我运行了其他模型并使用了其他搜索注释,没有出现任何问题。

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

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

如果有人能给我指出一个 Warm_start 的工作示例,那就太好了。

Dek*_*er1 7

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