admin管理员组文章数量:1130349
I am trying to solve a puzzle for my sporting event in which i want to equally place all matchups that variate enough without playing the sport more than twice (14 games per team in total) and also as much as possible with equal breaks during the games as 14 teams are playing at the same time and 6 teams are having a break in every round (20 teams total).
I am trying to use minizinc to solve this problem but no matter what i do i keep running into this confusing error. Can someone help me? :)
int: N_MATCHES = 140;
int: N_TEAMS = 20;
int: N_ROUNDS = 20;
int: N_SPORTS = 7;
array[1..N_MATCHES] of int: SportOf;
array[1..N_MATCHES] of set of int: TeamsOf;
var 1..N_ROUNDS: RoundOfMatch [m in 1..N_MATCHES];
% A. Voetbal (SportOf=1) alleen in rondes 1..10
% Estafette (SportOf=3) alleen in rondes 11..20
constraint
count(m in 1..N_MATCHES)(
(SportOf[m] == 1) /\ (RoundOfMatch[m] > 10)
) = 0
/\
count(m in 1..N_MATCHES)(
(SportOf[m] == 3) /\ (RoundOfMatch[m] < 11)
) = 0;
% B1. Ronde 1..10: precies 2x Voetbal(1),
% 1x Basketbal(4), Volleybal(2), Tag(6), Trefbal(7), Pionnenroof(5).
constraint
forall(r in 1..10) (
count(m in 1..N_MATCHES)((SportOf[m] == 1) /\ (RoundOfMatch[m] == r)) = 2
/\
count(m in 1..N_MATCHES)((SportOf[m] == 4) /\ (RoundOfMatch[m] == r)) = 1
/\
count(m in 1..N_MATCHES)((SportOf[m] == 2) /\ (RoundOfMatch[m] == r)) = 1
/\
count(m in 1..N_MATCHES)((SportOf[m] == 6) /\ (RoundOfMatch[m] == r)) = 1
/\
count(m in 1..N_MATCHES)((SportOf[m] == 7) /\ (RoundOfMatch[m] == r)) = 1
/\
count(m in 1..N_MATCHES)((SportOf[m] == 5) /\ (RoundOfMatch[m] == r)) = 1
);
% B2. Ronde 11..20: precies 2x Estafette(3),
% 1x Basketbal(4), Volleybal(2), Tag(6), Trefbal(7), Pionnenroof(5).
constraint
forall(r in 11..20) (
count(m in 1..N_MATCHES)((SportOf[m] == 3) /\ (RoundOfMatch[m] == r)) = 2
/\
count(m in 1..N_MATCHES)((SportOf[m] == 4) /\ (RoundOfMatch[m] == r)) = 1
/\
count(m in 1..N_MATCHES)((SportOf[m] == 2) /\ (RoundOfMatch[m] == r)) = 1
/\
count(m in 1..N_MATCHES)((SportOf[m] == 6) /\ (RoundOfMatch[m] == r)) = 1
/\
count(m in 1..N_MATCHES)((SportOf[m] == 7) /\ (RoundOfMatch[m] == r)) = 1
/\
count(m in 1..N_MATCHES)((SportOf[m] == 5) /\ (RoundOfMatch[m] == r)) = 1
);
% Geen team 2x in dezelfde ronde
constraint
forall(r in 1..N_ROUNDS, t in 1..N_TEAMS) (
count(m in 1..N_MATCHES)(
(t in TeamsOf[m]) /\ (RoundOfMatch[m] == r)
) <= 1
);
% Pauze-optimalisatie
array[1..N_TEAMS, 1..N_ROUNDS] of var bool: Play;
constraint
forall(t in 1..N_TEAMS, r in 1..N_ROUNDS) (
Play[t,r] <-> exists(m in 1..N_MATCHES)(
(t in TeamsOf[m]) /\ (RoundOfMatch[m] == r)
)
);
array[1..N_TEAMS, 1..(N_ROUNDS-1)] of var 0..1: consecutive;
constraint
forall(t in 1..N_TEAMS, r in 1..(N_ROUNDS-1)) (
consecutive[t,r] = bool2int( Play[t,r] /\ Play[t,r+1] )
);
solve minimize sum(t in 1..N_TEAMS, r in 1..(N_ROUNDS-1))( consecutive[t,r] );
output [
"Success: RoundOfMatch = [",
concat([
show(RoundOfMatch[m]) ++
if m < N_MATCHES then ", " else "" endif
| m in 1..N_MATCHES
]),
"]\n"
];
I tried converting it to UTF-8 without BOM but it didn't work:/
I am trying to solve a puzzle for my sporting event in which i want to equally place all matchups that variate enough without playing the sport more than twice (14 games per team in total) and also as much as possible with equal breaks during the games as 14 teams are playing at the same time and 6 teams are having a break in every round (20 teams total).
I am trying to use minizinc to solve this problem but no matter what i do i keep running into this confusing error. Can someone help me? :)
int: N_MATCHES = 140;
int: N_TEAMS = 20;
int: N_ROUNDS = 20;
int: N_SPORTS = 7;
array[1..N_MATCHES] of int: SportOf;
array[1..N_MATCHES] of set of int: TeamsOf;
var 1..N_ROUNDS: RoundOfMatch [m in 1..N_MATCHES];
% A. Voetbal (SportOf=1) alleen in rondes 1..10
% Estafette (SportOf=3) alleen in rondes 11..20
constraint
count(m in 1..N_MATCHES)(
(SportOf[m] == 1) /\ (RoundOfMatch[m] > 10)
) = 0
/\
count(m in 1..N_MATCHES)(
(SportOf[m] == 3) /\ (RoundOfMatch[m] < 11)
) = 0;
% B1. Ronde 1..10: precies 2x Voetbal(1),
% 1x Basketbal(4), Volleybal(2), Tag(6), Trefbal(7), Pionnenroof(5).
constraint
forall(r in 1..10) (
count(m in 1..N_MATCHES)((SportOf[m] == 1) /\ (RoundOfMatch[m] == r)) = 2
/\
count(m in 1..N_MATCHES)((SportOf[m] == 4) /\ (RoundOfMatch[m] == r)) = 1
/\
count(m in 1..N_MATCHES)((SportOf[m] == 2) /\ (RoundOfMatch[m] == r)) = 1
/\
count(m in 1..N_MATCHES)((SportOf[m] == 6) /\ (RoundOfMatch[m] == r)) = 1
/\
count(m in 1..N_MATCHES)((SportOf[m] == 7) /\ (RoundOfMatch[m] == r)) = 1
/\
count(m in 1..N_MATCHES)((SportOf[m] == 5) /\ (RoundOfMatch[m] == r)) = 1
);
% B2. Ronde 11..20: precies 2x Estafette(3),
% 1x Basketbal(4), Volleybal(2), Tag(6), Trefbal(7), Pionnenroof(5).
constraint
forall(r in 11..20) (
count(m in 1..N_MATCHES)((SportOf[m] == 3) /\ (RoundOfMatch[m] == r)) = 2
/\
count(m in 1..N_MATCHES)((SportOf[m] == 4) /\ (RoundOfMatch[m] == r)) = 1
/\
count(m in 1..N_MATCHES)((SportOf[m] == 2) /\ (RoundOfMatch[m] == r)) = 1
/\
count(m in 1..N_MATCHES)((SportOf[m] == 6) /\ (RoundOfMatch[m] == r)) = 1
/\
count(m in 1..N_MATCHES)((SportOf[m] == 7) /\ (RoundOfMatch[m] == r)) = 1
/\
count(m in 1..N_MATCHES)((SportOf[m] == 5) /\ (RoundOfMatch[m] == r)) = 1
);
% Geen team 2x in dezelfde ronde
constraint
forall(r in 1..N_ROUNDS, t in 1..N_TEAMS) (
count(m in 1..N_MATCHES)(
(t in TeamsOf[m]) /\ (RoundOfMatch[m] == r)
) <= 1
);
% Pauze-optimalisatie
array[1..N_TEAMS, 1..N_ROUNDS] of var bool: Play;
constraint
forall(t in 1..N_TEAMS, r in 1..N_ROUNDS) (
Play[t,r] <-> exists(m in 1..N_MATCHES)(
(t in TeamsOf[m]) /\ (RoundOfMatch[m] == r)
)
);
array[1..N_TEAMS, 1..(N_ROUNDS-1)] of var 0..1: consecutive;
constraint
forall(t in 1..N_TEAMS, r in 1..(N_ROUNDS-1)) (
consecutive[t,r] = bool2int( Play[t,r] /\ Play[t,r+1] )
);
solve minimize sum(t in 1..N_TEAMS, r in 1..(N_ROUNDS-1))( consecutive[t,r] );
output [
"Success: RoundOfMatch = [",
concat([
show(RoundOfMatch[m]) ++
if m < N_MATCHES then ", " else "" endif
| m in 1..N_MATCHES
]),
"]\n"
];
I tried converting it to UTF-8 without BOM but it didn't work:/
Share Improve this question asked 2 days ago DanielDaniel 111 silver badge New contributor Daniel is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.1 Answer
Reset to default 1I am not sure what you want to define in line below but syntax is not correct.
var 1..N_ROUNDS: RoundOfMatch [m in 1..N_MATCHES];
I guess you want to define an array of variables. In such case you should use something like this
array[1..N_MATCHES] of var 1..N_ROUNDS: RoundOfMatch;
I am trying to solve a puzzle for my sporting event in which i want to equally place all matchups that variate enough without playing the sport more than twice (14 games per team in total) and also as much as possible with equal breaks during the games as 14 teams are playing at the same time and 6 teams are having a break in every round (20 teams total).
I am trying to use minizinc to solve this problem but no matter what i do i keep running into this confusing error. Can someone help me? :)
int: N_MATCHES = 140;
int: N_TEAMS = 20;
int: N_ROUNDS = 20;
int: N_SPORTS = 7;
array[1..N_MATCHES] of int: SportOf;
array[1..N_MATCHES] of set of int: TeamsOf;
var 1..N_ROUNDS: RoundOfMatch [m in 1..N_MATCHES];
% A. Voetbal (SportOf=1) alleen in rondes 1..10
% Estafette (SportOf=3) alleen in rondes 11..20
constraint
count(m in 1..N_MATCHES)(
(SportOf[m] == 1) /\ (RoundOfMatch[m] > 10)
) = 0
/\
count(m in 1..N_MATCHES)(
(SportOf[m] == 3) /\ (RoundOfMatch[m] < 11)
) = 0;
% B1. Ronde 1..10: precies 2x Voetbal(1),
% 1x Basketbal(4), Volleybal(2), Tag(6), Trefbal(7), Pionnenroof(5).
constraint
forall(r in 1..10) (
count(m in 1..N_MATCHES)((SportOf[m] == 1) /\ (RoundOfMatch[m] == r)) = 2
/\
count(m in 1..N_MATCHES)((SportOf[m] == 4) /\ (RoundOfMatch[m] == r)) = 1
/\
count(m in 1..N_MATCHES)((SportOf[m] == 2) /\ (RoundOfMatch[m] == r)) = 1
/\
count(m in 1..N_MATCHES)((SportOf[m] == 6) /\ (RoundOfMatch[m] == r)) = 1
/\
count(m in 1..N_MATCHES)((SportOf[m] == 7) /\ (RoundOfMatch[m] == r)) = 1
/\
count(m in 1..N_MATCHES)((SportOf[m] == 5) /\ (RoundOfMatch[m] == r)) = 1
);
% B2. Ronde 11..20: precies 2x Estafette(3),
% 1x Basketbal(4), Volleybal(2), Tag(6), Trefbal(7), Pionnenroof(5).
constraint
forall(r in 11..20) (
count(m in 1..N_MATCHES)((SportOf[m] == 3) /\ (RoundOfMatch[m] == r)) = 2
/\
count(m in 1..N_MATCHES)((SportOf[m] == 4) /\ (RoundOfMatch[m] == r)) = 1
/\
count(m in 1..N_MATCHES)((SportOf[m] == 2) /\ (RoundOfMatch[m] == r)) = 1
/\
count(m in 1..N_MATCHES)((SportOf[m] == 6) /\ (RoundOfMatch[m] == r)) = 1
/\
count(m in 1..N_MATCHES)((SportOf[m] == 7) /\ (RoundOfMatch[m] == r)) = 1
/\
count(m in 1..N_MATCHES)((SportOf[m] == 5) /\ (RoundOfMatch[m] == r)) = 1
);
% Geen team 2x in dezelfde ronde
constraint
forall(r in 1..N_ROUNDS, t in 1..N_TEAMS) (
count(m in 1..N_MATCHES)(
(t in TeamsOf[m]) /\ (RoundOfMatch[m] == r)
) <= 1
);
% Pauze-optimalisatie
array[1..N_TEAMS, 1..N_ROUNDS] of var bool: Play;
constraint
forall(t in 1..N_TEAMS, r in 1..N_ROUNDS) (
Play[t,r] <-> exists(m in 1..N_MATCHES)(
(t in TeamsOf[m]) /\ (RoundOfMatch[m] == r)
)
);
array[1..N_TEAMS, 1..(N_ROUNDS-1)] of var 0..1: consecutive;
constraint
forall(t in 1..N_TEAMS, r in 1..(N_ROUNDS-1)) (
consecutive[t,r] = bool2int( Play[t,r] /\ Play[t,r+1] )
);
solve minimize sum(t in 1..N_TEAMS, r in 1..(N_ROUNDS-1))( consecutive[t,r] );
output [
"Success: RoundOfMatch = [",
concat([
show(RoundOfMatch[m]) ++
if m < N_MATCHES then ", " else "" endif
| m in 1..N_MATCHES
]),
"]\n"
];
I tried converting it to UTF-8 without BOM but it didn't work:/
I am trying to solve a puzzle for my sporting event in which i want to equally place all matchups that variate enough without playing the sport more than twice (14 games per team in total) and also as much as possible with equal breaks during the games as 14 teams are playing at the same time and 6 teams are having a break in every round (20 teams total).
I am trying to use minizinc to solve this problem but no matter what i do i keep running into this confusing error. Can someone help me? :)
int: N_MATCHES = 140;
int: N_TEAMS = 20;
int: N_ROUNDS = 20;
int: N_SPORTS = 7;
array[1..N_MATCHES] of int: SportOf;
array[1..N_MATCHES] of set of int: TeamsOf;
var 1..N_ROUNDS: RoundOfMatch [m in 1..N_MATCHES];
% A. Voetbal (SportOf=1) alleen in rondes 1..10
% Estafette (SportOf=3) alleen in rondes 11..20
constraint
count(m in 1..N_MATCHES)(
(SportOf[m] == 1) /\ (RoundOfMatch[m] > 10)
) = 0
/\
count(m in 1..N_MATCHES)(
(SportOf[m] == 3) /\ (RoundOfMatch[m] < 11)
) = 0;
% B1. Ronde 1..10: precies 2x Voetbal(1),
% 1x Basketbal(4), Volleybal(2), Tag(6), Trefbal(7), Pionnenroof(5).
constraint
forall(r in 1..10) (
count(m in 1..N_MATCHES)((SportOf[m] == 1) /\ (RoundOfMatch[m] == r)) = 2
/\
count(m in 1..N_MATCHES)((SportOf[m] == 4) /\ (RoundOfMatch[m] == r)) = 1
/\
count(m in 1..N_MATCHES)((SportOf[m] == 2) /\ (RoundOfMatch[m] == r)) = 1
/\
count(m in 1..N_MATCHES)((SportOf[m] == 6) /\ (RoundOfMatch[m] == r)) = 1
/\
count(m in 1..N_MATCHES)((SportOf[m] == 7) /\ (RoundOfMatch[m] == r)) = 1
/\
count(m in 1..N_MATCHES)((SportOf[m] == 5) /\ (RoundOfMatch[m] == r)) = 1
);
% B2. Ronde 11..20: precies 2x Estafette(3),
% 1x Basketbal(4), Volleybal(2), Tag(6), Trefbal(7), Pionnenroof(5).
constraint
forall(r in 11..20) (
count(m in 1..N_MATCHES)((SportOf[m] == 3) /\ (RoundOfMatch[m] == r)) = 2
/\
count(m in 1..N_MATCHES)((SportOf[m] == 4) /\ (RoundOfMatch[m] == r)) = 1
/\
count(m in 1..N_MATCHES)((SportOf[m] == 2) /\ (RoundOfMatch[m] == r)) = 1
/\
count(m in 1..N_MATCHES)((SportOf[m] == 6) /\ (RoundOfMatch[m] == r)) = 1
/\
count(m in 1..N_MATCHES)((SportOf[m] == 7) /\ (RoundOfMatch[m] == r)) = 1
/\
count(m in 1..N_MATCHES)((SportOf[m] == 5) /\ (RoundOfMatch[m] == r)) = 1
);
% Geen team 2x in dezelfde ronde
constraint
forall(r in 1..N_ROUNDS, t in 1..N_TEAMS) (
count(m in 1..N_MATCHES)(
(t in TeamsOf[m]) /\ (RoundOfMatch[m] == r)
) <= 1
);
% Pauze-optimalisatie
array[1..N_TEAMS, 1..N_ROUNDS] of var bool: Play;
constraint
forall(t in 1..N_TEAMS, r in 1..N_ROUNDS) (
Play[t,r] <-> exists(m in 1..N_MATCHES)(
(t in TeamsOf[m]) /\ (RoundOfMatch[m] == r)
)
);
array[1..N_TEAMS, 1..(N_ROUNDS-1)] of var 0..1: consecutive;
constraint
forall(t in 1..N_TEAMS, r in 1..(N_ROUNDS-1)) (
consecutive[t,r] = bool2int( Play[t,r] /\ Play[t,r+1] )
);
solve minimize sum(t in 1..N_TEAMS, r in 1..(N_ROUNDS-1))( consecutive[t,r] );
output [
"Success: RoundOfMatch = [",
concat([
show(RoundOfMatch[m]) ++
if m < N_MATCHES then ", " else "" endif
| m in 1..N_MATCHES
]),
"]\n"
];
I tried converting it to UTF-8 without BOM but it didn't work:/
Share Improve this question asked 2 days ago DanielDaniel 111 silver badge New contributor Daniel is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.1 Answer
Reset to default 1I am not sure what you want to define in line below but syntax is not correct.
var 1..N_ROUNDS: RoundOfMatch [m in 1..N_MATCHES];
I guess you want to define an array of variables. In such case you should use something like this
array[1..N_MATCHES] of var 1..N_ROUNDS: RoundOfMatch;
本文标签:
版权声明:本文标题:solver - MiniZinc: syntax error: syntax error, unexpected [, expecting end of file - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1735924108a1358794.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论