Package org.jacop.examples.fd
Class ExampleFD
- java.lang.Object
-
- org.jacop.examples.fd.ExampleFD
-
- Direct Known Subclasses:
ArchFriends
,BabySitting
,BasicLogicPascal
,BIBD
,BlueberryMuffins
,BreakingNews
,BuildingBlocks
,CalendarMen
,CarSequencing
,Conference
,CrossWord
,Cryptogram
,DeBruijn
,Diet
,DollarAndTicket
,DonaldGeraldRobert
,Exodus
,FittingNumbers
,Flowers
,FourIslands
,FurnitureMoving
,Gates
,GeostExample
,Golf
,Golomb
,HistoricHomes
,Kakro
,KnapsackExample
,Langford
,LatinSquare
,LeastDiff
,LectureSeries
,MagicSquares
,MasterClass
,MineSweeper
,MUCA
,Newspaper
,Nonogram
,NonTransitiveDice
,Parcel
,PerfectSquare
,PigeonHole
,ProAndCon
,QCP
,Queens
,SendMoreMoney
,SiblingUproar
,SleepingArrangements
,StonesOfHeaven
,Sudoku
,SurvoPuzzle
,TSP
,Tunapalooza
,WhoKilledAgatha
,WolfGoatCabbage
,Zebra
public abstract class ExampleFD extends java.lang.Object
It is an abstract class to describe all necessary functions of any store.- Version:
- 4.7
-
-
Field Summary
Fields Modifier and Type Field Description IntVar
cost
It specifies the cost function, null if no cost function is used.Search<IntVar>
search
It specifies the search procedure used by a given example.Store
store
It specifies the constraint store responsible for holding information about constraints and variables.java.util.List<IntVar>
vars
It contains all variables used within a specific example.
-
Constructor Summary
Constructors Constructor Description ExampleFD()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
creditSearch(int credits, int backtracks, int maxDepth)
It uses credit search to solve a problem.Search<IntVar>
getSearch()
It returns the search used within an example.java.util.List<IntVar>
getSearchVariables()
It returns an array list of variables used to model the example.Store
getStore()
It specifies the constraint store used within an example.abstract void
model()
It specifies a standard way of modeling the problem.static void
printMatrix(IntVar[][] matrix, int rows, int cols)
It prints a matrix of variables.boolean
search()
It specifies simple search method based on input order and lexigraphical ordering of values.boolean
searchAllAtOnce()
It specifies simple search method based on most constrained static and lexigraphical ordering of values.boolean
searchAllOptimal()
It searches for all solutions with the optimal value.boolean
searchLDS(int noDiscrepancy)
It searches for solution using Limited Discrepancy Search.boolean
searchMasterSlave(java.util.List<Var> masterVars, java.util.List<Var> slaveVars)
It conducts master-slave search.boolean
searchMaxRegretOptimal()
It searches for optimal solution using max regret variable ordering and indomain min for value ordering.boolean
searchMiddle()
It searches using an input order search with indomain based on middle value.boolean
searchMostConstrainedStatic()
It specifies simple search method based variable order which takes into account the number of constraints attached to a variable and lexigraphical ordering of values.boolean
searchOptimal()
It specifies simple search method based on input order and lexigraphical ordering of values.boolean
searchSmallestDomain(boolean optimal)
It specifies simple search method based on smallest domain variable order and lexigraphical ordering of values.boolean
searchSmallestMedian()
It searches using smallest domain variable ordering and indomain middle value ordering.boolean
searchSmallestMiddle()
It searches using smallest domain variable ordering and indomain middle value ordering.boolean
searchSmallestMin()
It searches using Smallest Min variable ordering heuristic and indomainMin value ordering heuristic.boolean
searchWeightedDegree()
It specifies simple search method based on weighted degree variable order and lexigraphical ordering of values.boolean
searchWithMaxRegret()
It uses MaxRegret variable ordering heuristic to search for a solution.boolean
searchWithRestarts()
It conducts the search with restarts from which the no-goods are derived.boolean
shavingSearch(java.util.List<Constraint> guidingShaving, boolean printInfo)
It searches with shaving which is guided by supplied constraints.
-
-
-
Field Detail
-
vars
public java.util.List<IntVar> vars
It contains all variables used within a specific example.
-
cost
public IntVar cost
It specifies the cost function, null if no cost function is used.
-
store
public Store store
It specifies the constraint store responsible for holding information about constraints and variables.
-
-
Method Detail
-
model
public abstract void model()
It specifies a standard way of modeling the problem.
-
search
public boolean search()
It specifies simple search method based on input order and lexigraphical ordering of values.- Returns:
- true if there is a solution, false otherwise.
-
searchOptimal
public boolean searchOptimal()
It specifies simple search method based on input order and lexigraphical ordering of values. It optimizes the solution by minimizing the cost function.- Returns:
- true if there is a solution, false otherwise.
-
searchAllOptimal
public boolean searchAllOptimal()
It searches for all solutions with the optimal value.- Returns:
- true if any optimal solution has been found.
-
searchSmallestDomain
public boolean searchSmallestDomain(boolean optimal)
It specifies simple search method based on smallest domain variable order and lexigraphical ordering of values.- Parameters:
optimal
- it specifies if the search the optimal solution takes place.- Returns:
- true if there is a solution, false otherwise.
-
searchWeightedDegree
public boolean searchWeightedDegree()
It specifies simple search method based on weighted degree variable order and lexigraphical ordering of values. This search method is rather general any problem good fit. It can be a good first trial to see if the model is correct.- Returns:
- true if there is a solution, false otherwise.
-
searchMostConstrainedStatic
public boolean searchMostConstrainedStatic()
It specifies simple search method based variable order which takes into account the number of constraints attached to a variable and lexigraphical ordering of values.- Returns:
- true if there is a solution, false otherwise.
-
searchAllAtOnce
public boolean searchAllAtOnce()
It specifies simple search method based on most constrained static and lexigraphical ordering of values. It searches for all solutions.- Returns:
- true if there is a solution, false otherwise.
-
searchMiddle
public boolean searchMiddle()
It searches using an input order search with indomain based on middle value.- Returns:
- true if there is a solution, false otherwise.
-
shavingSearch
public boolean shavingSearch(java.util.List<Constraint> guidingShaving, boolean printInfo)
It searches with shaving which is guided by supplied constraints.- Parameters:
guidingShaving
- the array of constraints proposing shaving candidates.printInfo
- it specifies if that function should print any info.- Returns:
- true if the solution was found, false otherwise.
-
searchWithRestarts
public boolean searchWithRestarts()
It conducts the search with restarts from which the no-goods are derived. Every search contributes with new no-goods which are kept so eventually the search is complete (although can be very expensive to maintain explicitly all no-goods found during search).- Returns:
- true if there is a solution, false otherwise.
-
creditSearch
public boolean creditSearch(int credits, int backtracks, int maxDepth)
It uses credit search to solve a problem.- Parameters:
credits
- the number of credits available.backtracks
- the maximum number of backtracks used when a path exhausts its credits.maxDepth
- the maximum depth to which the credit distribution takes place.- Returns:
- true if a solution was found, false otherwise.
-
searchWithMaxRegret
public boolean searchWithMaxRegret()
It uses MaxRegret variable ordering heuristic to search for a solution.- Returns:
- true if there is a solution, false otherwise.
-
searchLDS
public boolean searchLDS(int noDiscrepancy)
It searches for solution using Limited Discrepancy Search.- Parameters:
noDiscrepancy
- maximal number of discrepancies- Returns:
- true if the solution was found, false otherwise.
-
searchMaxRegretOptimal
public boolean searchMaxRegretOptimal()
It searches for optimal solution using max regret variable ordering and indomain min for value ordering.- Returns:
- true if there is a solution, false otherwise.
-
searchSmallestMiddle
public boolean searchSmallestMiddle()
It searches using smallest domain variable ordering and indomain middle value ordering.- Returns:
- true if there is a solution, false otherwise.
-
searchSmallestMedian
public boolean searchSmallestMedian()
It searches using smallest domain variable ordering and indomain middle value ordering.- Returns:
- true if there is a solution, false otherwise.
-
searchSmallestMin
public boolean searchSmallestMin()
It searches using Smallest Min variable ordering heuristic and indomainMin value ordering heuristic.- Returns:
- true if there is a solution, false otherwise.
-
searchMasterSlave
public boolean searchMasterSlave(java.util.List<Var> masterVars, java.util.List<Var> slaveVars)
It conducts master-slave search. Both of them use input order variable ordering.- Parameters:
masterVars
- it specifies the search variables used in master search.slaveVars
- it specifies the search variables used in slave search.- Returns:
- true if the solution exists, false otherwise.
-
getSearch
public Search<IntVar> getSearch()
It returns the search used within an example.- Returns:
- the search used within an example.
-
getStore
public Store getStore()
It specifies the constraint store used within an example.- Returns:
- constraint store used within an example.
-
getSearchVariables
public java.util.List<IntVar> getSearchVariables()
It returns an array list of variables used to model the example.- Returns:
- the array list of variables used to model the example.
-
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.
-
-