Class NonTransitiveDice
- java.lang.Object
-
- org.jacop.examples.fd.ExampleFD
-
- org.jacop.examples.fd.NonTransitiveDice
-
public class NonTransitiveDice extends ExampleFD
It models and solves Nontransitive Dice Problem.- Version:
- 4.8
Nontransitive Dice problem is to assign to given number of dices a number to each side of the dice in such a way that
a) given cyclic order of dices, each dice wins with the next one with probability p larger than 0.5.
b) maximize minimum p.
c) no two dices which are matched against each other can result in draw. default approach to satisfy this condition is to require all sides of all dices to be assigned unique values.
-
-
Field Summary
Fields Modifier and Type Field Description int
currentBest
It specifies the currently best solution which is a bound for the next solution.int
noDices
It specifies number of dices in the problem.int
noSides
It specifies number of sides for each dice in the problem.boolean
reuseOfNumbers
If true then faces on non consequtive faces can be the same.java.util.List<Constraint>
shavingConstraints
It contains constraints which can be used for shaving guidance.
-
Constructor Summary
Constructors Constructor Description NonTransitiveDice()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
main(java.lang.String[] args)
It executes the program solving non transitive dice problem using two different methods.void
model()
It specifies a standard way of modeling the problem.boolean
searchSpecial()
It executes a specialized search to find a solution to this problem.-
Methods inherited from class org.jacop.examples.fd.ExampleFD
creditSearch, getSearch, getSearchVariables, getStore, printMatrix, search, searchAllAtOnce, searchAllOptimal, searchLDS, searchMasterSlave, searchMaxRegretOptimal, searchMiddle, searchMostConstrainedStatic, searchOptimal, searchSmallestDomain, searchSmallestMedian, searchSmallestMiddle, searchSmallestMin, searchWeightedDegree, searchWithMaxRegret, searchWithRestarts, shavingSearch
-
-
-
-
Field Detail
-
noDices
public int noDices
It specifies number of dices in the problem.
-
noSides
public int noSides
It specifies number of sides for each dice in the problem.
-
currentBest
public int currentBest
It specifies the currently best solution which is a bound for the next solution.The currentBest specifies the difference between noSides^2 and minimumWinning. Since we maximize minimumWinning we minimize currentBest. The next solution must have a lower value for currentBest. currentBest is an upperbound.
minimumWinning + currentBest = noSides^2
Good initial value for currentBest is noSides^2 / 2.
-
shavingConstraints
public java.util.List<Constraint> shavingConstraints
It contains constraints which can be used for shaving guidance.
-
reuseOfNumbers
public boolean reuseOfNumbers
If true then faces on non consequtive faces can be the same.
-
-
Method Detail
-
model
public void model()
Description copied from class:ExampleFD
It specifies a standard way of modeling the problem.
-
searchSpecial
public boolean searchSpecial()
It executes a specialized search to find a solution to this problem. It uses input order, indomain middle, and limit of backtracks. It prints major search statistics.- Returns:
- true if solution is found, false otherwise.
-
main
public static void main(java.lang.String[] args)
It executes the program solving non transitive dice problem using two different methods. The second method employs constraint guided shaving.- Parameters:
args
- the first argument specifies number of dices, the second argument specifies the number of sides of each dice.
-
-