Library for finite domain constraint solving.
An FD problem is specified as an expression of type FDConstr
using the constraints and expressions offered in this library.
FD variables are created by the operation domain
.
An FD problem is solved by calling solveFD
with labeling options,
the FD variables whose values should be included in the output,
and a constraint. Hence, the typical program structure to solve
an FD problem is as follows:
main :: [Int] main = let fdvars = take n (domain u o) fdmodel = {description of FD problem} in solveFD {options} fdvars fdmodel
where n
are the number of variables and [u..o]
is the
range of their possible values.
Note that this library defines the operation to describe an FD problem.
The actual solveFD
operations are defined in the solver libraries
which also exports this library.
Author: Michael Hanus, Tom Hueser
Version: March 2016
domainWPrefix
:: String -> Int -> Int -> [FDExpr]
Returns an infinite list of named FD variables with given domain |
domain
:: Int -> Int -> [FDExpr]
Returns infinite list of named FD variables with given domain and default prefix "fdv_"
|
fd
:: Int -> FDExpr
Ints as FDExpr |
notC
:: FDConstr -> FDConstr
Negated FD constraint |
(+#)
:: FDExpr -> FDExpr -> FDExpr
Addition of FD expressions. |
(-#)
:: FDExpr -> FDExpr -> FDExpr
Subtraction of FD expressions. |
(*#)
:: FDExpr -> FDExpr -> FDExpr
Multiplication of FD expressions. |
(=#)
:: FDExpr -> FDExpr -> FDConstr
Equality of FD expressions. |
(/=#)
:: FDExpr -> FDExpr -> FDConstr
Disequality of FD expressions. |
(<#)
:: FDExpr -> FDExpr -> FDConstr
"Less than" constraint on FD expressions. |
(<=#)
:: FDExpr -> FDExpr -> FDConstr
"Less than or equal" constraint on FD expressions. |
(>#)
:: FDExpr -> FDExpr -> FDConstr
"Greater than" constraint on FD expressions. |
(>=#)
:: FDExpr -> FDExpr -> FDConstr
"Greater than or equal" constraint on FD expressions. |
true
:: FDConstr
The always satisfied FD constraint. |
false
:: FDConstr
The always unsatisfied constraint |
(/\)
:: FDConstr -> FDConstr -> FDConstr
Conjunction of FD constraints. |
(\/)
:: FDConstr -> FDConstr -> FDConstr
|
andC
:: [FDConstr] -> FDConstr
Conjunction of a list of FD constraints. |
orC
:: [FDConstr] -> FDConstr
Disnjunction of a list of FD constraints. |
allC
:: (a -> FDConstr) -> [a] -> FDConstr
Maps a constraint abstraction to a list of FD constraints and joins them. |
allDifferent
:: [FDExpr] -> FDConstr
"All different" constraint on FD variables. |
sum
:: [FDExpr] -> FDRel -> FDExpr -> FDConstr
Relates the sum of FD variables with some integer of FD variable. |
scalarProduct
:: [FDExpr] -> [FDExpr] -> FDRel -> FDExpr -> FDConstr
(scalarProduct cs vs relop v)
is satisfied if (sum (cs*vs) relop v)
is satisfied.
|
count
:: FDExpr -> [FDExpr] -> FDRel -> FDExpr -> FDConstr
(count v vs relop c)
is satisfied if (n relop c) ,
where n
is the number of elements in the
list of FD variables vs
that are equal to v , is satisfied.
|
abs
:: FDExpr -> FDExpr
Absolute value of expression. |
getFDVarName
:: FDExpr -> String
Get the name of a FDVar. |
getFDVal
:: FDExpr -> Int
Get value (possibly an unbound variable) of an FD expression. |
allFDVars
:: FDConstr -> [FDExpr]
Compute set of all variables occurring in a constraint. |
allFDVars'
:: FDConstr -> [FDExpr]
|
filterFDVars
:: [FDExpr] -> [FDExpr]
Compute a set of all variables occuring in a list of expressions |
fdVarEq
:: FDExpr -> FDExpr -> Bool
|
filterVars
:: [FDExpr] -> [FDExpr]
|
allEFDVars
:: FDExpr -> [FDExpr]
|
Constructors:
FDVar
:: String -> Int -> Int -> Int -> FDExpr
FDInt
:: Int -> FDExpr
FDBinExp
:: FDOp -> FDExpr -> FDExpr -> FDExpr
FDAbs
:: FDExpr -> FDExpr
Constructors:
Plus
:: FDOp
Minus
:: FDOp
Times
:: FDOp
Possible relations between FD values.
Constructors:
Equ
:: FDRel
: Equal
Neq
:: FDRel
: Not equal
Lt
:: FDRel
: Less than
Leq
:: FDRel
: Less than or equal
Gt
:: FDRel
: Greater than
Geq
:: FDRel
: Greater than or equal
Constructors:
FDTrue
:: FDConstr
FDFalse
:: FDConstr
FDRelCon
:: FDRel -> FDExpr -> FDExpr -> FDConstr
FDAnd
:: FDConstr -> FDConstr -> FDConstr
FDOr
:: FDConstr -> FDConstr -> FDConstr
FDNot
:: FDConstr -> FDConstr
FDAllDiff
:: [FDExpr] -> FDConstr
FDSum
:: [FDExpr] -> FDRel -> FDExpr -> FDConstr
FDScalar
:: [FDExpr] -> [FDExpr] -> FDRel -> FDExpr -> FDConstr
FDCount
:: FDExpr -> [FDExpr] -> FDRel -> FDExpr -> FDConstr
Returns an infinite list of named FD variables with given domain
|
Returns infinite list of named FD variables with given domain and default
prefix
|
Ints as FDExpr
|
Negated FD constraint
|
Addition of FD expressions.
|
Subtraction of FD expressions.
|
Multiplication of FD expressions.
|
Equality of FD expressions.
|
Disequality of FD expressions.
|
"Less than" constraint on FD expressions.
|
"Less than or equal" constraint on FD expressions.
|
"Greater than" constraint on FD expressions.
|
"Greater than or equal" constraint on FD expressions.
|
The always satisfied FD constraint.
|
The always unsatisfied constraint
|
Conjunction of FD constraints.
|
|
Maps a constraint abstraction to a list of FD constraints and joins them. |
"All different" constraint on FD variables.
|
Relates the sum of FD variables with some integer of FD variable.
|
|
|
Absolute value of expression.
|
Get the name of a FDVar. |
|
Compute a set of all variables occuring in a list of expressions |
|
|