Copyright | (c) OleksandrZhabenko 2020-2023 |
---|---|
License | MIT |
Maintainer | oleksandr.zhabenko@yahoo.com |
Stability | Experimental |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Extensions |
|
Provides a way to encode the needed constraint with possibly less symbols. Uses arrays instead of vectors.
Synopsis
- data EncodedContraints a b c
- type EncodedCnstrs = EncodedContraints Int (Array Int Int) (Array Int (Int, Int))
- readMaybeECG :: Int -> String -> Maybe EncodedCnstrs
- decodeConstraint1 :: (InsertLeft t (Array Int Int), Monoid (t (Array Int Int))) => EncodedCnstrs -> t (Array Int Int) -> t (Array Int Int)
- decodeLConstraints :: (InsertLeft t (Array Int Int), Monoid (t (Array Int Int))) => [EncodedCnstrs] -> t (Array Int Int) -> t (Array Int Int)
- isConstraint1 :: Bool -> Array Int Int -> EncodedCnstrs -> Bool
- getIEl :: EncodedCnstrs -> Int
- setIEl :: Int -> EncodedCnstrs -> EncodedCnstrs
- isE :: EncodedCnstrs -> Bool
- isP :: EncodedCnstrs -> Bool
- isF :: EncodedCnstrs -> Bool
- isQ :: EncodedCnstrs -> Bool
- isT :: EncodedCnstrs -> Bool
- isSA :: EncodedCnstrs -> Bool
- isSB :: EncodedCnstrs -> Bool
- isV :: EncodedCnstrs -> Bool
- isW :: EncodedCnstrs -> Bool
- isH :: EncodedCnstrs -> Bool
- isR :: EncodedCnstrs -> Bool
- isM :: EncodedCnstrs -> Bool
- isN :: EncodedCnstrs -> Bool
- isD :: EncodedCnstrs -> Bool
- isI :: EncodedCnstrs -> Bool
- validOrdStr :: String -> Bool
- generalConversion :: Int -> String -> Array Int Int -> Bool
- filterGeneralConv :: Int -> String -> [Array Int Int] -> [Array Int Int]
Data types
data EncodedContraints a b c Source #
E | Represents no additional constraint, corresponds to the whole set of theoretically possible permutations. |
P a b | Represents the set of permutations with the fixed positions of some elements. |
Q a a a a a | Represents the set of permutations with the preserved pairwise order between first and second, second and third, third and fourth elements. |
T a a a a | Represents the set of permutations with the preserved pairwise order between first and second, second and third elements. |
SA a a b | Represents the set of permutations with the preserved position of the elements AFTER the another selected one. |
SB a a b | Represents the set of permutations with the preserved position of the elements BEFORE the another selected one. |
F a a a | Represents the set of permutations with the preserved order between first and second elements. |
V a a a | Represents the set of permutations with the preserved both distance between and order of the two elements. |
W a a a | Represents the set of permutations with the preserved distance between the two elements. |
H a a a a | Represents the set of permutations with the preserved both distances between and order of the three elements. |
R a a a a | Represents the set of permutations with the preserved pairwise distances between the first and second, second and third elements. |
M a a a a | Represents the set of permutations with the preserved pairwise distances between the first and second, second and third elements, and additionally the order of the first and second elements. |
N a c | Represents the set of permutations with the moved fixed positions of some elements (at least one). |
D a a a a | Pepresents the set of permutations with the specified order and distance between the two elements. |
I | |
|
Instances
Functions to work with them
Read functions
readMaybeECG :: Int -> String -> Maybe EncodedCnstrs Source #
Inspired by the: https://hackage.haskell.org/package/base-4.14.0.0/docs/Data-Maybe.html
Is provided here as a more general way to read the String
into a EncodedCnstrs
.
It is up to user to check whether the parameters are in the correct form, the function does
not do the full checking.
Process-encoding functions
decodeConstraint1 :: (InsertLeft t (Array Int Int), Monoid (t (Array Int Int))) => EncodedCnstrs -> t (Array Int Int) -> t (Array Int Int) Source #
Must be applied to the correct array of permutation indeces. Otherwise, it gives runtime error (exception). All the integers inside the
EncodedCnstrs
must be in the range [0..n-1] where n
corresponds to the maximum element in the permutation Array
Int
Int
.
decodeLConstraints :: (InsertLeft t (Array Int Int), Monoid (t (Array Int Int))) => [EncodedCnstrs] -> t (Array Int Int) -> t (Array Int Int) Source #
Must be applied to the correct array of permutation indeces. Otherwise, it gives runtime error (exception). All the integers inside the
EncodedCnstrs
must be in the range [0..n-1] where n
corresponds to the maximum element in the permutation Array
Int
Int
.
isConstraint1 :: Bool -> Array Int Int -> EncodedCnstrs -> Bool Source #
Modifiers and getters
getIEl :: EncodedCnstrs -> Int Source #
Works only with the correctly defined argument though it is not checked. Use with this caution.
setIEl :: Int -> EncodedCnstrs -> EncodedCnstrs Source #
Works only with the correctly defined arguments though it is not checked. Use with this caution.
Predicates
isE :: EncodedCnstrs -> Bool Source #
isP :: EncodedCnstrs -> Bool Source #
isF :: EncodedCnstrs -> Bool Source #
isQ :: EncodedCnstrs -> Bool Source #
isT :: EncodedCnstrs -> Bool Source #
isSA :: EncodedCnstrs -> Bool Source #
isSB :: EncodedCnstrs -> Bool Source #
isV :: EncodedCnstrs -> Bool Source #
isW :: EncodedCnstrs -> Bool Source #
isH :: EncodedCnstrs -> Bool Source #
isR :: EncodedCnstrs -> Bool Source #
isM :: EncodedCnstrs -> Bool Source #
isN :: EncodedCnstrs -> Bool Source #
isD :: EncodedCnstrs -> Bool Source #
isI :: EncodedCnstrs -> Bool Source #
Algebraic general conversion
validOrdStr :: String -> Bool Source #
An extended predicate to check whether the String
is a probably correct representation of the
constraints algebraic expression for generalConversion
evaluation.