minizinc sitting-friends-at-a-table-far-from-furius 那些

minizinc sitting-friends-at-a-table-far-from-furius ones

1.we骑自行车table 2.a 男人必须坐在女人旁边,女人必须坐在男人旁边 3.客人必须有共同的兴趣爱好(他们的兴趣爱好之间至少有一个共同点) 4. 来了几个脾气暴躁的客人。他们不能坐在一起 5. 狂暴客人名单中的任何人都不得坐在开始(座位 1)或结束(座位 N) -pR 是愤怒夫妇的数量

我的模特:

int :N;
set of int: GUESTS  = 1..N;
set of int: POSITIONS = 1..N;
array[GUESTS] of 1..2 : gender;
array[GUESTS] of set of int: hobbies;
enum PAIR = {first,second};
int : pR;
set of int: LIST = 1..pR;
array[LIST,PAIR] of GUESTS : furious;
array[POSITIONS] of var GUESTS : guest_at;
array[POSITIONS] of var 1..2: table_gender;
constraint forall(i in 1..length(table_gender)-1)(
   table_gender[i]!=table_gender[i+1]
   /\
   table_gender[1]!=table_gender[length(table_gender)]
)
   ;
include "alldifferent.mzn";
constraint alldifferent(guest_at);
constraint forall(i in 2..N-1)(card(hobbies[guest_at[i+1]] intersect hobbies[guest_at[i]]) >0);
constraint card(hobbies[guest_at[N]] intersect hobbies[guest_at[1]]) >0;
constraint forall(i in 2..N-1,l in LIST, p in PAIR)(if guest_at[i]=furious[i,first] then guest_at[i+1]!=furious[i,second] /\ guest_at[i-1]!=furious[i,second] else true endif);
constraint forall(l in LIST, p in PAIR)(guest_at[1]!=furious[l,p] /\ guest_at[N]!=furious[l,p]);
solve satisfy;
output 
       ["guest_at = \(guest_at);"]
       ++ ["\ntable_gender = \(table_gender); \n" ] 
       ++ ["Furious Placement\n"]
       ++ [show_int(4,furious[i,j]) | i in LIST, j in PAIR] ++["\n"] 
       ++ [if fix(guest_at[p]) = furious[i,j] then show_int(4,p) else "" endif | i in LIST, j in PAIR, p in POSITIONS]
       ;

我的模型的错误:

C:/Users/�������/Documents/������/����������/Gala/gala.mzn:36:
  in call 'forall'
  in array comprehension expression
    with i = 4
    with l = 3
    with p = 1
  in if-then-else expression
  in binary '=' operator expression
  in array access

  WARNING: Further warnings have been suppressed.

这个约束,其中提到了错误,包含一些奇怪的事情:

constraint 
     forall(i in 2..N-1,l in LIST, p in PAIR) (
         if guest_at[i]=furious[i,first] then 
            guest_at[i+1]!=furious[i,second] /\  
            guest_at[i-1]!=furious[i,second] 
         else 
             true 
         endif
     );

1) 第二个和第三个循环参数l in Listp in PAIR从来没有使用过,所以它们没有意义。

2) 出现警告的主要原因是 furious 矩阵只有两行,但在循环变量 i 中从 2 变为 16。错误 (array access out of bounds)表示当 i 大于 2 时,它超出了 furious 矩阵的范围。