Package org.jacop.examples.fd
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.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 Summary
Fields Modifier and Type Field Description java.util.List<Constraint>
guidingShaving
It specifies the list of constraints which can be used for guiding shaving.int
number
It specifies the number
-
Constructor Summary
Constructors Constructor Description MagicSquares()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
main(java.lang.String[] args)
It executes the program which solves the MagicSquare problem.void
model()
It specifies a standard way of modeling the problem.void
model4Shaving()
It creates the model with specification of what constraint can help in guiding shaving.void
modelDual()
IT creates a dual model.static void
test(java.lang.String[] args)
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 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.
-
-
Method Detail
-
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
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.
-
-