Class MagicSquares


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

    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 Detail

      • number

        public int number
        It specifies the number
      • guidingShaving

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

      • MagicSquares

        public MagicSquares()
    • Method Detail

      • 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​(java.lang.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​(java.lang.String[] args)
        It executes the program which solves the MagicSquare problem.
        Parameters:
        args - the first argument allows to specify the size of magic square.