
Posted by Moby Dick
![]()
on 21/10/2009, 6:04 pm, in reply to "Fore!"
Player a:
Hole 1 (par 3) score was 4
Hole 2 (par 5) score was 5
Hole 3 (par 4) score was 3
Player b:
Hole 1 (par 3) score was 3
Hole 2 (par 5) score was 7
Hole 3 (par 4) score was 5
Player c:
Hole 1 (par 3) score was 5
Hole 2 (par 5) score was 6
Hole 3 (par 4) score was 4
set player:= {"a", "b", "c"};
set hole:= {1, 2, 3};
set par:= {3, 4, 5};
set scoreRange:= {2..7};
var cPar3 <=7;
var cPar4 <= 6;
var score{p in player, h in hole, s in scoreRange} binary;
s.t. oneScorePerPlayerPerHole{p in player, h in hole}: sum{s in scoreRange}score[p,h,s] = 1;
var holePar{h in hole, p in par} binary;
s.t. oneParPerHole{h in hole}: sum{p in par}holePar[h,p] = 1;
s.t. oneHolePerPar{p in par}: sum{h in hole}holePar[h,p] = 1;
minimize cparvals: cPar3 + cPar4;
s.t. not2Better{p in player, h in hole, s in 2..3}: score[p,h,s] + holePar[h, s+2] <= 1;
s.t. not3Better{p in player, h in hole}: score[p,h,2] + holePar[h,5] <= 1;
s.t. not3Worse{p in player, h in hole, s in 6..7}: score[p,h,s] + holePar[h, s-3] <= 1;
s.t. not4Worse{p in player, h in hole}: score[p,h,7] + holePar[h, 3] <= 1;
s.t. diffScores{p in player, s in scoreRange}: sum{h in hole}score[p,h,s] <= 1;
s.t. noTiedScores{h in hole, s in scoreRange}: sum{p in player}score[p,h,s] <= 1;
s.t. bWonPar3_1{h in hole}: sum{sm in scoreRange}score["a",h,sm]*sm -
sum{s in scoreRange}score["b",h,s]*s + 10 * (1 - holePar[h,3]) >= 1;
s.t. bWonPar3_2{h in hole}: sum{sm in scoreRange}score["c",h,sm]*sm -
sum{s in scoreRange}score["b",h,s]*s + 10 * (1 - holePar[h,3]) >= 1;
s.t. bLostPar5_1{h in hole}: sum{s in scoreRange}score["b",h,s]*s -
sum{sm in scoreRange}score["a",h,sm]*sm + 10 * (1 - holePar[h,5]) >= 1;
s.t. bLostPar5_2{h in hole}: sum{s in scoreRange}score["b",h,s]*s -
sum{sm in scoreRange}score["c",h,sm]*sm + 10 * (1 - holePar[h,5]) >= 1;
s.t. aWonPar4_1{h in hole}: sum{sm in scoreRange}score["b",h,sm]*sm -
sum{s in scoreRange}score["a",h,s]*s + 10 * (1 - holePar[h,4]) >= 1;
s.t. aWonPar4_2{h in hole}: sum{sm in scoreRange}score["c",h,sm]*sm -
sum{s in scoreRange}score["a",h,s]*s + 10 * (1 - holePar[h,4]) >= 1;
s.t. par4SumLT13: sum{p in player, h in hole, s in scoreRange}score[p,h,s]*s -
sum{p in player, h in hole, s in scoreRange}s*(1 - holePar[h, 4]) <= 12.5;
s.t. cPar3Lower{h in hole, s in scoreRange}: cPar3 >= s * score["c",h,s] - s * (1 - holePar[h,3]);
s.t. cPar4Lower{h in hole, s in scoreRange}: cPar4 >= s * score["c",h,s] - s * (1 - holePar[h,4]);
s.t. cPar4LTcPar3: cPar4 + 1 <= cPar3;
s.t. fixCpar3{h in hole}: sum{s in scoreRange}s*score["c",h,s] + 100 * (1 - holePar[h,3]) >= cPar3;
solve;
for {p in player}{
printf "Player %s:\n", p;
for {h in hole}{
printf "Hole %s ", h;
for {pr in par: holePar[h, pr] = 1}{
printf "(par %s) score was ", pr;
}
for {s in scoreRange: score[p, h, s] = 1}{
printf "%s\n", s;
}
}
}
end;


Message Thread:
![]()
« Back to thread