Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added missing problems and instances from the MiniZinc challenges 2012 to 2015 #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ghoulomb/3-11-29.dzn
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
m1 = 3;
m2 = 11;
m3 = 29;
3 changes: 3 additions & 0 deletions ghoulomb/5-7-22.dzn
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
m1 = 5;
m2 = 7;
m3 = 22;
146 changes: 146 additions & 0 deletions league/league_mznc2013.mzn
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
%
% Make Leagues (group tournament)
%
% Make group tournament for some games.
% - Ranking should be close in each group.
% - In one group, variety of country (where player comes from) is needed.

include "globals.mzn";

%
% Parameter: max persons in one group
%
int: n_persons_in_league;
int: n_persons_in_group = n_persons_in_league;

% n_persons_in_group = 3;

%
% Parameter: number of persons
%
int: n;

% n = 15;

%
% Parameter: ranking of persons
%
array [1..n] of int: ranking;

% ranking = [ 1, 2, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6 ];

%
% Parameter: where does he/she come from
%
array [1..n] of int: country;

% country = [ 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 3, 2, 1 ];


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% How many groups in this model?
int: n_groups = (n + n_persons_in_group - 1) div n_persons_in_group;

% How many people in each group
array [1..n_groups] of var 0..n_persons_in_group : n_persons;

% Which group person is assigned to
array [1..n] of var 1..n_groups: assign_to;

% Ranking in each groups
array [1..n_groups] of var min(ranking)..max(ranking): max_rank;
array [1..n_groups] of var min(ranking)..max(ranking): min_rank;
array [1..n_groups] of var 0..max(ranking): rank_diff;

% Count of countries in group
% if group G contains country C, countries_in_group_tmp[G, C] = 1
array[1..n_groups, 1..max(country)] of var 0..1: countries_in_group_tmp;
array[1..n_groups] of var 1..n_persons_in_group: countries_in_group;



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%
% apply n_persons_in_group
%
constraint
forall (i in 1..n_groups) (
count(assign_to, i, n_persons[i])
/\ (n_persons_in_group - 1) <= n_persons[i]
/\ n_persons[i] <= n_persons_in_group
);

%
% set rank_diff
%
constraint
forall (i in 1..n_groups) (
rank_diff[i] = max_rank[i] - min_rank[i]
);

%
% min, max rank in group
%
constraint
forall (i in 1..n_groups) (
max_rank[i] = max([ranking[j] * bool2int(assign_to[j] == i)
| j in 1..n])
);

constraint
forall (i in 1..n_groups) (
min_rank[i] = min([ranking[j] + 10000* bool2int(assign_to[j] != i)
| j in 1..n])
);

%
% how many countries in group?
%
constraint
forall (i in 1..n_groups) (
forall (j in 1..max(country)) (
countries_in_group_tmp[i, j]
= bool2int(exists(p in 1..n)
(assign_to[p] = i /\ country[p] = j))
)
);

constraint
forall (i in 1..n_groups) (
countries_in_group[i]
= sum([countries_in_group_tmp[i, j] | j in 1..max(country)])
);

%
% sort result
%
constraint
forall (i in 1..n_groups - 1) (
max_rank[i] <= max_rank[i + 1]
/\ min_rank[i] <= min_rank[i + 1]
);

var 1..100000 : objective = (100 * sum(rank_diff) - sum(countries_in_group));

solve
:: seq_search([
int_search(assign_to, first_fail, indomain_max, complete),
int_search([objective], input_order, indomain_min, complete)
])
minimize objective;

output [
"max_rank = ", show(max_rank), ";\n",
"min_rank = ", show(min_rank), ";\n",
"countries_in_group = ", show(countries_in_group), ";\n",
"objective = ", show(objective), ";\n"
] ++ [
show(assign_to[i]) ++
", person: " ++ show(i) ++
", ranking: " ++ show(ranking[i]) ++
", country: " ++ show(country[i]) ++
"\n"
| i in 1..n];

11 changes: 11 additions & 0 deletions league/model20-5-4.dzn
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
n_persons_in_league = 3;
n = 20;
ranking = [ 1, 1, 1, 1
, 2
, 3, 3, 3, 3, 3, 3
, 4
, 5, 5, 5, 5, 5, 5, 5, 5
];
country = [ 1, 1, 1, 2, 4, 1, 3, 4, 1, 4
, 1, 4, 1, 4, 1, 1, 4, 1, 1, 4
];
15 changes: 15 additions & 0 deletions league/model30-8-4.dzn
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
n_persons_in_league = 4;
n = 30;
ranking = [ 1, 1, 1, 1, 1, 1, 1, 1, 1
, 2, 2, 2, 2, 2
, 3
, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
, 5, 5
, 6
, 7
, 8
];
country = [ 3, 3, 4, 3, 3, 3, 3, 3, 2, 1
, 1, 1, 3, 4, 1, 4, 3, 1, 1, 3
, 3, 3, 4, 1, 4, 2, 4, 3, 1, 1
];
13 changes: 13 additions & 0 deletions league/model40-5-11.dzn
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
n_persons_in_league = 4;
n = 40;
ranking = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
, 4, 4
, 5
];
country = [ 3, 8, 8, 3, 2, 2, 2, 2, 8, 8
, 1, 2, 3, 4, 10, 8, 1, 11, 6, 5
, 7, 8, 8, 8, 1, 8, 3, 1, 3, 2
, 3, 8, 9, 8, 3, 8, 1, 2, 8, 1
];
22 changes: 22 additions & 0 deletions league/model55-13-15.dzn
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
n_persons_in_league = 3;
n = 55;
ranking = [ 1
, 2
, 3
, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
, 5
, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6
, 7
, 8
, 9
, 10
, 11
, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12
, 13
];
country = [ 1, 7, 11, 1, 10, 8, 2, 1, 13, 1
, 4, 6, 14, 5, 14, 3, 14, 14, 14, 10
, 13, 14, 14, 1, 14, 15, 13, 14, 1, 10
, 11, 12, 1, 11, 14, 11, 11, 13, 14, 3
, 14, 10, 11, 13, 9, 14, 1, 11, 10, 1
, 11, 11, 10, 14, 1];
1 change: 1 addition & 0 deletions nmseq/143.dzn
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
n = 143;
1 change: 1 addition & 0 deletions nmseq/202.dzn
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
n = 202;
1 change: 1 addition & 0 deletions nmseq/395.dzn
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
n = 395;
1 change: 1 addition & 0 deletions nmseq/478.dzn
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
n = 478;
1 change: 1 addition & 0 deletions nmseq/99.dzn
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
n = 99;
31 changes: 31 additions & 0 deletions nonogram/dom_06.dzn
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
X = 13;
Y = 13;
maxlen = 5;
rows = [|1, 1, 1, -1, -1
|1, -1, -1, -1, -1
|1, 1, 1, 0, 1
|1, -1, -1, -1, -1
|1, 1, 1, 0, 1
|1, -1, -1, -1, -1
|1, 1, 1, 0, 1
|1, -1, -1, -1, -1
|1, 1, 1, 0, 1
|1, -1, -1, -1, -1
|1, 1, 1, 0, 1
|1, -1, -1, -1, -1
|1, -1, -1, -1, -1
|];
cols = [|1, -1, -1, -1, -1
|1, -1, -1, -1, -1
|1, 0, 1, 1, 1
|1, -1, -1, -1, -1
|1, 0, 1, 1, 1
|1, -1, -1, -1, -1
|1, 0, 1, 1, 1
|1, -1, -1, -1, -1
|1, 0, 1, 1, 1
|1, -1, -1, -1, -1
|1, 0, 1, 1, 1
|1, -1, -1, -1, -1
|1, 1, 1, -1, -1
|];
39 changes: 39 additions & 0 deletions nonogram/dom_08.dzn
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
X = 17;
Y = 17;
maxlen = 5;
rows = [|1, 1, 1, -1, -1
|1, -1, -1, -1, -1
|1, 1, 1, 0, 1
|1, -1, -1, -1, -1
|1, 1, 1, 0, 1
|1, -1, -1, -1, -1
|1, 1, 1, 0, 1
|1, -1, -1, -1, -1
|1, 1, 1, 0, 1
|1, -1, -1, -1, -1
|1, 1, 1, 0, 1
|1, -1, -1, -1, -1
|1, 1, 1, 0, 1
|1, -1, -1, -1, -1
|1, 1, 1, 0, 1
|1, -1, -1, -1, -1
|1, -1, -1, -1, -1
|];
cols = [|1, -1, -1, -1, -1
|1, -1, -1, -1, -1
|1, 0, 1, 1, 1
|1, -1, -1, -1, -1
|1, 0, 1, 1, 1
|1, -1, -1, -1, -1
|1, 0, 1, 1, 1
|1, -1, -1, -1, -1
|1, 0, 1, 1, 1
|1, -1, -1, -1, -1
|1, 0, 1, 1, 1
|1, -1, -1, -1, -1
|1, 0, 1, 1, 1
|1, -1, -1, -1, -1
|1, 0, 1, 1, 1
|1, -1, -1, -1, -1
|1, 1, 1, -1, -1
|];
47 changes: 47 additions & 0 deletions nonogram/dom_10.dzn
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
X = 21;
Y = 21;
maxlen = 5;
rows = [|1, 1, 1, -1, -1
|1, -1, -1, -1, -1
|1, 1, 1, 0, 1
|1, -1, -1, -1, -1
|1, 1, 1, 0, 1
|1, -1, -1, -1, -1
|1, 1, 1, 0, 1
|1, -1, -1, -1, -1
|1, 1, 1, 0, 1
|1, -1, -1, -1, -1
|1, 1, 1, 0, 1
|1, -1, -1, -1, -1
|1, 1, 1, 0, 1
|1, -1, -1, -1, -1
|1, 1, 1, 0, 1
|1, -1, -1, -1, -1
|1, 1, 1, 0, 1
|1, -1, -1, -1, -1
|1, 1, 1, 0, 1
|1, -1, -1, -1, -1
|1, -1, -1, -1, -1
|];
cols = [|1, -1, -1, -1, -1
|1, -1, -1, -1, -1
|1, 0, 1, 1, 1
|1, -1, -1, -1, -1
|1, 0, 1, 1, 1
|1, -1, -1, -1, -1
|1, 0, 1, 1, 1
|1, -1, -1, -1, -1
|1, 0, 1, 1, 1
|1, -1, -1, -1, -1
|1, 0, 1, 1, 1
|1, -1, -1, -1, -1
|1, 0, 1, 1, 1
|1, -1, -1, -1, -1
|1, 0, 1, 1, 1
|1, -1, -1, -1, -1
|1, 0, 1, 1, 1
|1, -1, -1, -1, -1
|1, 0, 1, 1, 1
|1, -1, -1, -1, -1
|1, 1, 1, -1, -1
|];
Loading