ExamplesJaCoP
Class NonTransitiveDice

java.lang.Object
  extended by ExamplesJaCoP.Example
      extended by ExamplesJaCoP.NonTransitiveDice

public class NonTransitiveDice
extends Example

It models and solves Nontransitive Dice Problem.

Author:
Radoslaw Szymanek 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
 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.ArrayList<Constraint> shavingConstraints
          It contains constraints which can be used for shaving guidance.
 
Fields inherited from class ExamplesJaCoP.Example
cost, search, store, vars
 
Constructor Summary
NonTransitiveDice()
           
 
Method Summary
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 ExamplesJaCoP.Example
creditSearch, getSearch, getSearchVariables, getStore, printMatrix, search, searchAllAtOnce, searchAllOptimal, searchLDS, searchMasterSlave, searchMaxRegretOptimal, searchMiddle, searchMostConstrainedStatic, searchOptimal, searchSmallestDomain, searchSmallestMedian, searchSmallestMiddle, searchSmallestMin, searchWeightedDegree, searchWithMaxRegret, searchWithRestarts, shavingSearch
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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.ArrayList<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.

Constructor Detail

NonTransitiveDice

public NonTransitiveDice()
Method Detail

model

public void model()
Description copied from class: Example
It specifies a standard way of modeling the problem.

Specified by:
model in class Example

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.