2013-11-27 13:17:21 +01:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
--
|
|
|
|
-- Module : DCB
|
|
|
|
-- Copyright :
|
|
|
|
-- License : AllRightsReserved
|
|
|
|
--
|
|
|
|
-- Maintainer :
|
|
|
|
-- Stability :
|
|
|
|
-- Portability :
|
|
|
|
--
|
|
|
|
-- |
|
|
|
|
--
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
module DCB where
|
|
|
|
|
|
|
|
--import Stream hiding (map) --same as Data.Stream imported above?
|
2013-11-27 16:50:35 +01:00
|
|
|
import Data.Array.Accelerate (Z(..), DIM0, DIM1, DIM2, DIM3, Scalar, Vector, (:.)(..), Array,(!),
|
2013-11-27 13:17:21 +01:00
|
|
|
Int8, Int, Float, Double, Acc, Exp, Elt)
|
|
|
|
import qualified Data.Array.Accelerate as A
|
|
|
|
-- change to Data.Array.Accelerate.CUDA as I and link accelerate-cuda to use GPU instead of CPU
|
|
|
|
-- depends on accelerate-cuda package in cabal, which needs the installed CUDA-stuff form
|
|
|
|
-- nVidia (nvcc, header-files, ...) and the propriatary driver
|
|
|
|
import Data.Array.Accelerate.Interpreter as I
|
|
|
|
type Matrix e = Array DIM2 e
|
|
|
|
|
|
|
|
type Attr = Matrix Double
|
|
|
|
-- Adjecency-Matrix
|
|
|
|
type Adj = Matrix Int8
|
|
|
|
-- Vector of the Adjecency-Matrix
|
2013-11-27 16:50:35 +01:00
|
|
|
type AdjV = Vector Int
|
2013-11-27 13:17:21 +01:00
|
|
|
newtype Constraints = Matrix Double
|
|
|
|
-- Graph consists of a Vector denoting which colums of the matrix represents wich originating
|
|
|
|
-- column in the global adjencency-matrix, the reduces adjencency-matrix of the graph, a
|
|
|
|
-- matrix of constraints and a scalar denoting the density
|
2013-11-27 16:50:35 +01:00
|
|
|
type Density = Scalar Double
|
2013-11-27 13:17:21 +01:00
|
|
|
|
|
|
|
-- Graph
|
2013-11-27 16:50:35 +01:00
|
|
|
type Graph = (Vector Int, Adj, Constraints, Density)
|
2013-11-27 13:17:21 +01:00
|
|
|
|
|
|
|
-- Vector of Graphs
|
2013-11-27 16:50:35 +01:00
|
|
|
type MultiGraph e = (Vector Int, Array DIM3 e, Constraints, Density)
|
2013-11-27 13:17:21 +01:00
|
|
|
|
2013-11-27 16:50:35 +01:00
|
|
|
-- Multigraph correct output ?
|
|
|
|
preprocess :: Acc (Matrix Int8) -> Acc Attr -> Acc (MultiGraph Int8)
|
|
|
|
preprocess adj a = undefined
|
2013-11-27 13:17:21 +01:00
|
|
|
|
2013-11-27 16:50:35 +01:00
|
|
|
-- generate function for initialising the constraints matrix of a subgraph
|
|
|
|
-- first column contains minimum value of each attribute, second column contains maximum value
|
|
|
|
-- zeroth column contains 0 after initialisation (should contain 1 if constraints are fulfilled
|
|
|
|
-- afterwards)
|
|
|
|
-- TODO: DIM2 input -> Exp DIM2
|
|
|
|
genConstrMat :: Acc Attr -> Acc (Vector Int) -> DIM2 -> Exp Double
|
|
|
|
genConstrMat attr nodes ix =
|
|
|
|
let
|
|
|
|
(Z:.idAttr:.col) = ix -- unlift ix :: ((:.) ((:.) Z Int) Int)
|
|
|
|
in case col of
|
|
|
|
1 -> A.the $A.minimum (A.map (\i -> attr!(A.index2 i $A.lift idAttr)) nodes)
|
|
|
|
2 -> A.the $A.maximum (A.map (\i -> attr!(A.index2 i $A.lift idAttr)) nodes)
|
|
|
|
_ -> 0.0
|
2013-11-27 13:17:21 +01:00
|
|
|
|
|
|
|
expand :: Acc (MultiGraph Int8)-> Acc Adj -> Acc Attr -> Acc (MultiGraph Int8)
|
|
|
|
expand g a att = undefined
|
|
|
|
|
|
|
|
-- constraint gets a Graph and an Attribute-Matrix and yields true, if the Graph still fulfills
|
|
|
|
-- all constraints defined via the Attribute-Matrix.
|
2013-11-27 16:50:35 +01:00
|
|
|
--constraint :: Acc Graph -> Acc Attr -> Acc (Scalar Bool)
|
|
|
|
constraint :: Acc Graph -> Int -> Acc Attr -> Acc (Maybe Graph)
|
|
|
|
constraint g newNode a = undefined
|
2013-11-27 13:17:21 +01:00
|
|
|
|
|
|
|
|
|
|
|
-- addPoint gets a graph and a tuple of an adjecancy-Vector with an int wich column of the
|
|
|
|
-- Adjacency-Matrix the Vector should represent to generate further Graphs
|
|
|
|
addPoint :: Acc Graph -> Acc (Adj, (Scalar Int)) -> Acc (MultiGraph Int8)
|
|
|
|
addPoint g a = undefined
|
|
|
|
|
|
|
|
|
2013-11-27 16:50:35 +01:00
|
|
|
-- addablePoints yields all valid addititons to a Graph
|
2013-11-27 13:17:21 +01:00
|
|
|
addablePoints :: Acc Adj -> Acc Graph-> Acc (Vector Int8)
|
|
|
|
addablePoints a g = undefined
|