2017-11-30 4 views
0

1.私たちはサイクリングテーブルを持っています 2.男は男の隣に女性と女性の隣に座っていなければなりません 3.ゲストは必ず趣味を分かち合う(少なくとも趣味の共通点1つ) 4.激怒しているカップルがいる。minizincフレンチの座っている友人のテーブル

:彼らは開始(シート1)または終了(シートN)で座ってしなければならないリスト0猛烈なゲストの相互 5.誰にも隣に近くに座ってはいけない -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. 
+2

これは問題ではありません。それを編集してください。有効な質問です。 – TPAKTOPA

+1

また、モデル全体を追加してください。 – hakank

+0

これは有効な質問に編集されました...どうすればバグを削除できますか?どのように私はそれを編集できますか? – Kotsos

答えて

1

この制約、奇妙な物事のカップルが含まれています

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)第2および第3のループパラメータl in Listおよびp in PAIRは決して使用されないので意味がありません。

2)警告のための主な理由はfurious行列はわずか2行であるということですが、ループ変数iにエラー(array access out of bounds)iが2よりも大きい場合、それはの境界の外だということを示している2から16に行きますfuriousマトリックス。

関連する問題