Class MagicSquares

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

public class MagicSquares extends ExampleFD
It solves a Magic squares problem.
Version:
4.10

MagicSquare problem consists of filling the square of size n with numbers from 1 to n^2 in such a way that all rows, all columns, and main diagonals are equal to the same number K. K can be computed to be equal to (n * (n^2 + 1)) / 2.

  • Field Details

    • number

      public int number
      It specifies the number
    • guidingShaving

      public List<Constraint> guidingShaving
      It specifies the list of constraints which can be used for guiding shaving.
  • Constructor Details

    • MagicSquares

      public MagicSquares()
  • Method Details

    • model

      public void model()
      Description copied from class: ExampleFD
      It specifies a standard way of modeling the problem.
      Specified by:
      model in class ExampleFD
    • model4Shaving

      public void model4Shaving()
      It creates the model with specification of what constraint can help in guiding shaving.
    • modelDual

      public void modelDual()
      IT creates a dual model.
    • test

      public static void test(String[] args)
      It executes the program which solves the MagicSquare problem using many different model and searches.
      Parameters:
      args - the first argument allows to specify the size of magic square.
    • main

      public static void main(String[] args)
      It executes the program which solves the MagicSquare problem.
      Parameters:
      args - the first argument allows to specify the size of magic square.