Package org.jacop.examples.fd
Class MagicSquares
java.lang.Object
org.jacop.examples.fd.ExampleFD
org.jacop.examples.fd.MagicSquares
It solves a Magic squares problem.
- Version:
- 4.9
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 Summary
FieldsModifier and TypeFieldDescriptionIt specifies the list of constraints which can be used for guiding shaving.int
It specifies the number -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
It executes the program which solves the MagicSquare problem.void
model()
It specifies a standard way of modeling the problem.void
It creates the model with specification of what constraint can help in guiding shaving.void
IT creates a dual model.static void
It executes the program which solves the MagicSquare problem using many different model and searches.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 Details
-
number
public int numberIt specifies the number -
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. -
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
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
It executes the program which solves the MagicSquare problem.- Parameters:
args
- the first argument allows to specify the size of magic square.
-