I am writing constraints for magic square. It seems something is off with my last constraint. Can any one tell me what is wrong? I get the correct answer as all 5’s which is still valid, but it doesnt give anything other than that.
class test;
rand int arr[3][3];
constraint ab_c {
foreach (arr[i,j]) {
arr[i][j] inside {[1:20]};
arr[i].sum() with (int'(item)) == 15; // rows
arr.sum() with (int'(arr[item.index][i])) == 15; //cols
arr.sum() with (int'(arr[i][i])) == 15; // diag1
arr.sum() with (int'(arr[2-j][i])) == 15;// diag2
}
}
endclass