The AlignmentRepa repository is a fast Haskell and C implementation of some of the practicable inducers described in the paper The Theory and Practice of Induction by Alignment at https://greenlake.co.uk/. The AlignmentRepa repository depends on the Alignment repository for the underlying model framework. The slower implementations of some of the practicable inducers in the Alignment repository can be used to verify the correctness of equivalent faster implementations in AlignmentRepa.
The AlignmentRepa repository uses high performance arrays. Single-dimensional arrays are defined in the vector library. See Numeric Haskell. Multi-dimensional shape polymorphic parallel arrays are defined in the repa library. In addition, some compute-intensive array processing is implemented in C using the Foreign Function Interface. See also FFI and Data.Vector.Storable.
The induced models are made persistent using the JSON format which is implemented in the aeson library.
There are a couple of useful libraries that should be installed along with repa and aeson to ensure consistent package versions:
zlib: Compression and decompression in the gzip and zlib formats
cassava: A CSV parsing and encoding library
The Haskell implementation of fast Practicable Inducers discusses the implementation of the inducers using this repository.
The AlignmentRepa module requires the Haskell platform to be installed. The project is managed using stack.
Download the zip files or use git to get the AlignmentRepa repository and the underlying Alignment repository -
cd
git clone https://github.com/caiks/Alignment.git
git clone https://github.com/caiks/AlignmentRepa.git
Then build with the following -
cd ~/AlignmentRepa
stack build --ghc-options -w
Use stack ghci or stack repl for a run-eval-print loop (REPL) environment.
Load AlignmentDevRepa to import the modules and define various useful abbreviated functions,
cd ~/AlignmentRepa
stack ghci --ghci-options -w
:set -fobject-code
:set +m
:l AlignmentDevRepa
let aa = regdiag 2 2
rp $ aa
"{({(1,1),(2,1)},1 % 1),({(1,2),(2,2)},1 % 1)}"
aa
Histogram (fromList [(State (fromList [(VarInt 1,ValInt 1),(VarInt 2,ValInt 1)]),1 % 1),(State (fromList [(VarInt 1,ValInt 2),(VarInt 2,ValInt 2)]),1 % 1)])
aaar (sys aa) aa
HistogramRepa {histogramRepasVectorVar = [VarInt 1,VarInt 2], histogramRepasMapVarInt = fromList [(VarInt 1,0),(VarInt 2,1)], histogramRepasArray = AUnboxed [2,2] [1.0,0.0,0.0,1.0]}Note that some modules may become unresolved, for example,
rp $ Set.fromList [1,2,3]
<interactive>:9:1: Not in scope: ‘Set.fromList’or
rp $ fudEmpty
<interactive>:10:6: Not in scope: ‘fudEmpty’In this case, re-import the modules explicitly as defined in AlignmentDevRepa, for example,
import qualified Data.Set as Set
import qualified Data.Map as Map
import Alignment
rp $ Set.fromList [1,2,3]
"{1,2,3}"
rp $ fudEmpty
"{}"