# [AMPL 24668] AMPL for modelling dice rolls

I need to create a model to assert which are the letters on each face of a 4 dices, given the results of generic 4 dices rolls. Each of the 6 faces of the 4 dices has a different letter (24 letters, J and X are missing). For example: rolling 12 times the dices and combining every time the obtained letters, we got the following words: AGHI EZIO SLAM BOVE MICK TAEG CLUB NAVE TUFO DROP QUAD YORK I can’t find an objective to solve this problem. Right now I got: .dat set I := “AGHI”,“EZIO”,“SLAM”,“BOVE”,“MICK”,“TAEG”,“CLUB”,“NAVE”,“TUFO”,“DROP”,“QUAD”,“YORK”;
set L:= A B C D E F G H I K L M N O P Q R S T U V W Y Z;
set D:= 1 2 3 4;
set F:= 1 2 3 4 5 6; .mod set I;
set L;
set D;
set F;

subject to Entry{i in I, d in D}: sum{f in F}(A[d,f,substr(i,0,1)] + A[d,f,substr(i,1,1)] + A[d,f,substr(i,2,1)] + A[d,f,substr(i,3,1)]) = 1;

subject to Unique{l in L}: sum{d in D, f in F}A[d,f,l] = 1;

subject to Unique2{d in D, f in F}: sum{l in L}A[d,f,l] = 1; But I can’t get anything out of it. Do you have suggestions? Thanks!!!

This problem seems to be very similar to some other puzzles (Labeled Dice and Building Blocks) that I modeled in AMPL many years ago.

At the AMPL repo (ampl.github.io/models/hakan at master · ampl/ampl.github.io · GitHub ) there are some AMPL models that you can be inspired by:

Note that all the models use the alldiff and element constraints which might not be suitable for you.

(These models are also available at my AMPL page: My AMPL page and my GitHub repo: hakank/ampl at master · hakank/hakank · GitHub . )

Hope this helps

/Hakan

You want to find an assignment of letters to the dice, so that all of the 12 observed words can be produced. So I would say that in AMPL, you just have a feasibility problem, where you want to assign values to the variables that satisfy all of the constraints. For a feasibility problem, you do not need to specify any objective.

The model that you give will not work, however, because it does not have a “var” statement to define the variables:

var A {D,F,L} binary;

You should choose a linear solver that accepts integer-valued variables, such as Gurobi, CPLEX, Xpress, or HiGHS.