set DICE := { 0 .. 2 };
set NUMBERS := { 1 .. 18};
var assignment[DICE * NUMBERS] binary;
var helper[* in DICE*NUMBERS*NUMBERS with j > k] binary;
# requested probability of "being better" in (1/36)s
# for original problem and modification 1
#param request := 19;
## modification 1: maximize the probability of "1 is better than 2" (while "2 is better than 3" and "3 is better than 1" have probability greater than 0.5)
#maximize probability:
#sum in NUMBERS*NUMBERS with j > k: helper[1,j,k];
##modification 2: maximize the probability of "being better"
var request real >= 0;
maximize probability:
request;
# constraint requiring that all numbers are assigned to one side of dice
subto all_used:
forall ** in NUMBERS:
sum in DICE: assignment[j,i] == 1;
# constraint requiring that there are 6 numbers on all dices
subto six_on_all:
forall in DICE:
sum ** in NUMBERS: assignment[j,i] == 6;
# testing the requested probability over helper variable
subto all:
forall ** in DICE:
sum ** in DICE*NUMBERS*NUMBERS with j > k: helper[i,j,k] >= request;
# constrainting helper variable
subto helper_ensure:
forall ** in DICE*NUMBERS*NUMBERS with j>k:
1/2*(assignment[i,j] + assignment[(i+1) mod 3,k]) >= helper[i,j,k];
### Example assignment, the first row lists the numbers assigned to a die, the second row tells how many numbers on the following die is lower than the number above (i.e. number 3 on die 1 is greater than numbers 1 and 2 on die 2, etc.).
#Die 1
#3 4 5 11 17 18
#2 2 2 3 6 6 = 21
#Die 2
#1 2 10 12 15 16
#0 0 4 4 6 6 = 20
#Die 3
#6 7 8 9 13 14
#3 3 3 3 4 4 = 20
*