简体   繁体   English

Minizinc Lazyfd解决方案忽略约束

[英]Minizinc lazyfd solution ignores constraint

The problem is to find a schedule for some people to play golf (or whatever) in groups of a fixed size. 问题是找到一些人以固定大小的团体打高尔夫球(或其他方式)的时间表。 We have to guarantee that every player is only in one group at a time. 我们必须保证每个玩家一次只能分组。

Here is my code: 这是我的代码:

int: gr;             % number of groups
int: sz;             % size of groups
int: we;             % number of weeks

int: n=gr*sz;        % number of players

set of int: G=1..gr; % set of group indices
set of int: P=1..n;  % set of players
set of int: W=1..we; % set of weeks

% test instance
gr = 2;
sz = 2;
we = 2;

array[G,W] of var set of P: X;
   %X[g,w] is the set of people that form group with index g in week w


% forall group x, |x| = sz
constraint forall (g in G, w in W) 
  (card (X[g,w]) = sz);

% one person cannot play in two groups simultaneously
constraint forall (g in G, w in W, p in X[g,w], g2 in (g+1..gr))
  (not(p in X[g2,w]));

solve satisfy;

My problem now is that if I use the G12 lazyfd solver, ie 我现在的问题是,如果我使用G12 lazyfd求解器,即

$ minizinc -b lazy this.mzn

I get 我懂了

X = array2d(1..2 ,1..2 ,[1..2, 1..2, 1..2, 1..2]);
----------

which seems to ignore my second constraint. 这似乎忽略了我的第二个约束。 On the other hand, using G12 without the lazy option, ie 另一方面,使用不带惰性选项的G12,即

$ minizinc this.mzn

yields 产量

X = array2d(1..2 ,1..2 ,[1..2, 1..2, 3..4, 3..4]);
----------

which is correct. 哪个是对的。 G12 MIP and Gecode also give a correct result. G12 MIP和Gecode也会给出正确的结果。

How is this possible? 这怎么可能? And how can I use the lazy solver such that I can rely on it? 以及如何使用懒惰的求解器,以便可以依靠它? Or is it just my installation that is messed up somehow? 还是只是我的安装以某种方式搞砸了?

G12/lazyFD is known to be broken in various places. 已知G12 / lazyFD在许多地方都被损坏。 The problem is that the G12 solvers are no longer being developed and will most likely be removed from the distributions soon. 问题在于,不再开发G12解算器,很可能很快将其从发行版中删除。

I would offer Chuffed as an alternative. 我会提供Chuffed作为替代。 Chuffed is FD solver written in C++ with lazy clause generation. Chuffed是用C ++编写的带有惰性子句生成的FD解算器。 It should be correct and will perform better then the G12 solver (at least when the solutions are correct). 它应该是正确的,并且比G12求解器的性能更好(至少在解决方案正确的情况下)。

Chuffed and other MiniZinc solvers can be found on the software page of the MiniZinc website . 在MiniZinc网站软件页面上找到Chuffed和其他MiniZinc解算器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM