【发布时间】:2020-03-20 19:52:40
【问题描述】:
我正在尝试使用 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 默认求解器在 Minizinc IDE 中运行它。如果它是相关的,我正在使用 Windows。我已经运行了其他模型并使用了其他搜索注释没有问题。
在示例中,有两个暖星块(一个在求解后,一个在 seq_search 内)。我不确定两者是否都是必要的。我尝试删除一个,然后删除另一个,但是对于所有剩余的热启动注释仍然会出现警告。我也不明白为什么在第一个块中没有引用“b”。
在 git https://github.com/google/or-tools/issues/539 中有一个类似的例子,但它也会产生警告。
如果有人能给我指出一个 warm_start 的工作示例,那就太好了。
【问题讨论】:
标签: constraint-programming minizinc