1
0
This repository has been archived on 2025-03-06. You can view files and clone it, but cannot push or open issues or pull requests.
Jip J. Dekker 9b7e65e00b Squashed 'software/minizinc/' content from commit 5a577826
git-subtree-dir: software/minizinc
git-subtree-split: 5a577826da4d7cf6195f28b5604d8d20a01fbc6e
2021-06-18 09:34:50 +10:00

56 lines
1.3 KiB
MiniZinc

/***
!Test
expected:
- !Result
solution: !Solution
a:
- [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
- [0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0]
- [0, 1, 0, 0, 0, 0, 0, 0, 2, 0, 0]
- [0, 2, 0, 0, 0, 1, 0, 0, 3, 0, 0]
- [0, 0, 0, 1, 0, 2, 0, 0, 0, 0, 0]
- [0, 0, 0, 2, 0, 0, 0, 0, 0, 1, 0]
- [0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0]
- [0, 1, 0, 0, 0, 0, 1, 2, 3, 4, 0]
- [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0]
- [0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0]
- [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
col_sums: [4, 0, 3, 2, 2, 2, 1, 4, 2]
row_sums: [2, 2, 3, 2, 2, 1, 5, 1, 2]
***/
% Example battleships problem for battleships.mzn.model
%
include "battleships.mzn.model";
n = 9;
a = array2d(ROW, COL,
[| 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
| 0, 0, _, _, _, _, 0, _, _, _, 0
| 0, _, 0, _, _, _, _, _, _, _, 0
| 0, _, _, _, _, _, _, _, _, _, 0
| 0, 0, _, _, _, _, _, _, 0, _, 0
| 0, _, _, _, _, _, _, _, _, _, 0
| 0, _, 0, _, 0, _, _, _, _, _, 0
| 0, _, _, 0, _, _, _, _, _, _, 0
| 0, _, _, _, _, _, _, _, _, _, 0
| 0, _, _, _, _, _, _, _, _, _, 0
| 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|]
);
constraint a[3, 2] > 0;
constraint a[7, 4] > 0;
constraint a[8, 9] > 0;
row_sums = [2, 2, 3, 2, 2, 1, 5, 1, 2];
col_sums = [4, 0, 3, 2, 2, 2, 1, 4, 2];
n_classes = 4;
class_sizes = [4, 3, 2, 1];