Class SurvoPuzzle

java.lang.Object
org.jacop.examples.fd.ExampleFD
org.jacop.examples.fd.SurvoPuzzle

public class SurvoPuzzle extends ExampleFD
It solves Survo puzzle.

http://en.wikipedia.org/wiki/Survo_Puzzle """ Survo puzzle is a kind of logic puzzle presented (in April 2006) and studied by Seppo Mustonen. The name of the puzzle is associated to Mustonen's Survo system which is a general environment for statistical computing and related areas.

In a Survo puzzle the task is to fill an m * n table by integers 1,2,...,m*n so that each of these numbers appears only once and their row and column sums are equal to integers given on the bottom and the right side of the table. Often some of the integers are given readily in the table in order to guarantee uniqueness of the solution and/or for making the task easier. """

See also http://www.survo.fi/english/index.html http://www.survo.fi/puzzles/index.html

References: - Mustonen, S. (2006b). "On certain cross sum puzzles" http://www.survo.fi/papers/puzzles.pdf - Mustonen, S. (2007b). "Enumeration of uniquely solvable open Survo puzzles." http://www.survo.fi/papers/enum_survo_puzzles.pdf - Kimmo Vehkalahti: "Some comments on magic squares and Survo puzzles" http://www.helsinki.fi/~kvehkala/Kimmo_Vehkalahti_Windsor.pdf

Version:
4.10
  • Field Details

    • r

      int r
    • c

      int c
    • rowsums

      int[] rowsums
    • colsums

      int[] colsums
    • matrix

      int[][] matrix
    • x

      IntVar[][] x
    • x_arr

      IntVar[] x_arr
  • Constructor Details

    • SurvoPuzzle

      public SurvoPuzzle()
  • Method Details

    • model

      public void model()
      model()
      Specified by:
      model in class ExampleFD
    • printMatrix

      public static void printMatrix(IntVar[][] matrix, int rows, int cols)
      It prints a matrix of variables. All variables must be grounded.
      Parameters:
      matrix - matrix containing the grounded variables.
      rows - number of elements in the first dimension.
      cols - number of elements in the second dimension.
    • readFile

      public void readFile(String file)
      readFile()

      Reads a Survo puzzle in the following format

      % From http://www.survo.fi/puzzles/280708.txt % Survo puzzle 128/2008 (1700) #364-35846 A B C D E F 1 * * * * * * 30 2 * * 18 * * * 86 3 * * * * * * 55 22 11 42 32 27 37

      Parameters:
      file - the filename containing the problem description.
    • main

      public static void main(String[] args)
      It executes the program to solve the specified SurvoPuzzle.
      Parameters:
      args - the first argument specifies the filename containing the puzzle to be solved.