Merge branch 'master' of pwning.de:/hgraph

This commit is contained in:
Nicole Dresselhaus 2013-11-26 22:40:52 +01:00
commit 59baf2a409
11 changed files with 161 additions and 53 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
*.o *.o
*~ *~
dist/setup-config dist/setup-config
*.hi

View File

@ -7,8 +7,6 @@ module Paths_hgraph (
import qualified Control.Exception as Exception import qualified Control.Exception as Exception
import Data.Version (Version(..)) import Data.Version (Version(..))
import System.Environment (getEnv) import System.Environment (getEnv)
import Prelude
catchIO :: IO a -> (Exception.IOException -> IO a) -> IO a catchIO :: IO a -> (Exception.IOException -> IO a) -> IO a
catchIO = Exception.catch catchIO = Exception.catch
@ -17,10 +15,10 @@ version :: Version
version = Version {versionBranch = [0,0,1], versionTags = []} version = Version {versionBranch = [0,0,1], versionTags = []}
bindir, libdir, datadir, libexecdir :: FilePath bindir, libdir, datadir, libexecdir :: FilePath
bindir = "/home/sdressel/.cabal/bin" bindir = "/homes/sdressel/.cabal/bin"
libdir = "/home/sdressel/.cabal/lib/hgraph-0.0.1/ghc-7.6.3" libdir = "/homes/sdressel/.cabal/lib/hgraph-0.0.1/ghc-7.4.1"
datadir = "/home/sdressel/.cabal/share/hgraph-0.0.1" datadir = "/homes/sdressel/.cabal/share/hgraph-0.0.1"
libexecdir = "/home/sdressel/.cabal/libexec" libexecdir = "/homes/sdressel/.cabal/libexec"
getBinDir, getLibDir, getDataDir, getLibexecDir :: IO FilePath getBinDir, getLibDir, getDataDir, getLibexecDir :: IO FilePath
getBinDir = catchIO (getEnv "hgraph_bindir") (\_ -> return bindir) getBinDir = catchIO (getEnv "hgraph_bindir") (\_ -> return bindir)

View File

@ -1,11 +1,11 @@
/* DO NOT EDIT: This file is automatically generated by Cabal */ /* DO NOT EDIT: This file is automatically generated by Cabal */
/* package QuickCheck-2.6 */ /* package QuickCheck-2.4.2 */
#define VERSION_QuickCheck "2.6" #define VERSION_QuickCheck "2.4.2"
#define MIN_VERSION_QuickCheck(major1,major2,minor) (\ #define MIN_VERSION_QuickCheck(major1,major2,minor) (\
(major1) < 2 || \ (major1) < 2 || \
(major1) == 2 && (major2) < 6 || \ (major1) == 2 && (major2) < 4 || \
(major1) == 2 && (major2) == 6 && (minor) <= 0) (major1) == 2 && (major2) == 4 && (minor) <= 2)
/* package Stream-0.4.6.1 */ /* package Stream-0.4.6.1 */
#define VERSION_Stream "0.4.6.1" #define VERSION_Stream "0.4.6.1"
@ -21,33 +21,33 @@
(major1) == 0 && (major2) < 13 || \ (major1) == 0 && (major2) < 13 || \
(major1) == 0 && (major2) == 13 && (minor) <= 0) (major1) == 0 && (major2) == 13 && (minor) <= 0)
/* package base-4.6.0.1 */ /* package base-4.5.0.0 */
#define VERSION_base "4.6.0.1" #define VERSION_base "4.5.0.0"
#define MIN_VERSION_base(major1,major2,minor) (\ #define MIN_VERSION_base(major1,major2,minor) (\
(major1) < 4 || \ (major1) < 4 || \
(major1) == 4 && (major2) < 6 || \ (major1) == 4 && (major2) < 5 || \
(major1) == 4 && (major2) == 6 && (minor) <= 0) (major1) == 4 && (major2) == 5 && (minor) <= 0)
/* package bytestring-0.10.0.2 */ /* package bytestring-0.9.2.1 */
#define VERSION_bytestring "0.10.0.2" #define VERSION_bytestring "0.9.2.1"
#define MIN_VERSION_bytestring(major1,major2,minor) (\ #define MIN_VERSION_bytestring(major1,major2,minor) (\
(major1) < 0 || \ (major1) < 0 || \
(major1) == 0 && (major2) < 10 || \ (major1) == 0 && (major2) < 9 || \
(major1) == 0 && (major2) == 10 && (minor) <= 0) (major1) == 0 && (major2) == 9 && (minor) <= 2)
/* package deepseq-1.3.0.1 */ /* package deepseq-1.3.0.0 */
#define VERSION_deepseq "1.3.0.1" #define VERSION_deepseq "1.3.0.0"
#define MIN_VERSION_deepseq(major1,major2,minor) (\ #define MIN_VERSION_deepseq(major1,major2,minor) (\
(major1) < 1 || \ (major1) < 1 || \
(major1) == 1 && (major2) < 3 || \ (major1) == 1 && (major2) < 3 || \
(major1) == 1 && (major2) == 3 && (minor) <= 0) (major1) == 1 && (major2) == 3 && (minor) <= 0)
/* package ghc-7.6.3 */ /* package ghc-7.4.1 */
#define VERSION_ghc "7.6.3" #define VERSION_ghc "7.4.1"
#define MIN_VERSION_ghc(major1,major2,minor) (\ #define MIN_VERSION_ghc(major1,major2,minor) (\
(major1) < 7 || \ (major1) < 7 || \
(major1) == 7 && (major2) < 6 || \ (major1) == 7 && (major2) < 4 || \
(major1) == 7 && (major2) == 6 && (minor) <= 3) (major1) == 7 && (major2) == 4 && (minor) <= 1)
/* package monad-par-0.3.4.5 */ /* package monad-par-0.3.4.5 */
#define VERSION_monad_par "0.3.4.5" #define VERSION_monad_par "0.3.4.5"
@ -56,17 +56,17 @@
(major1) == 0 && (major2) < 3 || \ (major1) == 0 && (major2) < 3 || \
(major1) == 0 && (major2) == 3 && (minor) <= 4) (major1) == 0 && (major2) == 3 && (minor) <= 4)
/* package parallel-3.2.0.3 */ /* package parallel-3.2.0.2 */
#define VERSION_parallel "3.2.0.3" #define VERSION_parallel "3.2.0.2"
#define MIN_VERSION_parallel(major1,major2,minor) (\ #define MIN_VERSION_parallel(major1,major2,minor) (\
(major1) < 3 || \ (major1) < 3 || \
(major1) == 3 && (major2) < 2 || \ (major1) == 3 && (major2) < 2 || \
(major1) == 3 && (major2) == 2 && (minor) <= 0) (major1) == 3 && (major2) == 2 && (minor) <= 0)
/* package text-0.11.3.1 */ /* package text-0.11.1.13 */
#define VERSION_text "0.11.3.1" #define VERSION_text "0.11.1.13"
#define MIN_VERSION_text(major1,major2,minor) (\ #define MIN_VERSION_text(major1,major2,minor) (\
(major1) < 0 || \ (major1) < 0 || \
(major1) == 0 && (major2) < 11 || \ (major1) == 0 && (major2) < 11 || \
(major1) == 0 && (major2) == 11 && (minor) <= 3) (major1) == 0 && (major2) == 11 && (minor) <= 1)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

2
dist/setup-config vendored

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -0,0 +1,103 @@
\documentclass[11pt,a4paper]{scrartcl}
\usepackage[ngerman]{babel} % Deutsches Wörterbuch usw.
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{times} % Skalierbarer und lesbarer Zeichensatz
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[usenames,dvipsnames]{xcolor}
\inputencoding{utf8} % Wir wollen UTF8(=keine Probleme mit Umlauten etc.)
\parindent0em % Keine amerikanische Einrückung am Anfang von Paragraphen
\usepackage[lmargin=2cm,rmargin=3.5cm,tmargin=2cm,bmargin=2cm]{geometry}
\parindent0em
\usepackage{fancyhdr}
\pagestyle{fancy}
%opening
\fancyhf{}
\fancyhead[L]{\textbf{Message Passing Programming\\Parallele Algorithmen und Datenverarbeitung}}
\fancyhead[R]{\textbf{Stefan Dresselhaus\\Thomas Pajenkamp}}
\fancyfoot[C]{\thepage}
\fancyfoot[R]{24. November 2013}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}
\newcommand{\abs}[1]{\ensuremath{\left\lvert#1\right\rvert}}
\newcommand{\norm}[1]{\ensuremath{\left\lVert#1\right\rVert}}
\newcommand{\mean}[1]{\ensuremath{\overline{#1}}}
\newcommand{\transp}[1]{\ensuremath{#1^{\mathsf{T}}}}
% Ende der Voreinstellungen
\begin{document}
%\title{Message Passing Programming}
%\author{Stefan Dresselhaus \and Thomas Pajenkamp}
%\date{24. November 2013}
%\maketitle
\section*{Heuristik für \glqq{}Densely-connected Biclustering\grqq{}}
\begin{algorithm*}
\caption{Densely-connected Biclustering}
\begin{algorithmic}[1]
\Function{testHomogenity}{$A$, $\omega$, $\delta$, $g$}
\State $l \gets (\transp{A})_{g_0}$, $l \gets u$
\ForAll {nodes $i$ from $g \setminus \lbrace g_0\rbrace$}
\ForAll {dimensions $d$ of attribute matrix $A$}
\State $l \gets \min\lbrace l_d, A_{id}\rbrace$, $u \gets \max\lbrace l_d, A_{id}\rbrace$
\EndFor
\EndFor
\State $c \gets 0$
\ForAll {dimensions $d$ of attribute matrix $A$}
\If {$\abs{u_d - l_d} \leq \omega_d $}
\State $c \gets c+1$
\If {$c \geq \delta$}
\State \Return {true}
\EndIf
\EndIf
\EndFor
\Return {false}
\EndFunction
\end{algorithmic}
\begin{algorithmic}[1]
\Function{preprocessGraph}{$M$, $A$, $\omega$, $\delta$}
\State $G \gets \emptyset$
\ForAll {rows $i$ of adjascency matrix $M$}
\ForAll {columns $j$ of adjascency matrix $M$}
\If {$M_{ij} = 1$}
\If {\Call{testHomogenity}{$A$, $\omega$, $\delta$, $\lbrace i , j\rbrace$}}
\State $G \gets G \cup \lbrace \lbrace i, j\rbrace \rbrace$
\Else
\State $M_{ij} = 0$, $M_{ji} = 0$
\EndIf
\EndIf
\EndFor
\EndFor
\Return {$G$}
\EndFunction
\end{algorithmic}
\begin{algorithmic}[1]
\Function{DCB}{$M$, $A$, $\alpha$, $\omega$, $\delta$}
\State $G \gets $ \Call{preprocessGraph}{$M$, $A$, $\omega$, $\delta$}
\State $F \gets \emptyset$
\While {$G \neq \emptyset$}
\State $G' \gets G$, $G \gets \emptyset$
\ForAll {node sets $g$ in $G'$}
\State $b \gets \text{true}$
\ForAll {connected nodes $h$ with $h > \max g$}
\State $\hat{g} \gets g \cup \lbrace h\rbrace$
\If {\Call{testHomogenity}{$A$, $\omega$, $\delta$, $\hat{g}$} $\wedge$ \Call{graphDensity}{$M$, $\hat{g}$} $\leq$ $\alpha$}
\State $G \gets G \cup \lbrace \hat{g} \rbrace$
\State $b \gets \text{false}$
\EndIf
\EndFor
\If {$b$}
\State $F \gets F \cup \lbrace g\rbrace$
\EndIf
\EndFor
\EndWhile
\EndFunction
\end{algorithmic}
\end{algorithm*}
\end{document}

View File

@ -20,7 +20,7 @@ module Main (
import Control.Monad (unless) import Control.Monad (unless)
import Control.Parallel.Strategies import Control.Parallel.Strategies
import Control.DeepSeq import Control.DeepSeq
import Data.List import qualified Data.List as L
import System.Exit (exitFailure) import System.Exit (exitFailure)
import System.Environment import System.Environment
import Test.QuickCheck.All (quickCheckAll) import Test.QuickCheck.All (quickCheckAll)
@ -32,43 +32,50 @@ import Data.Either (lefts, rights)
import Debug.Trace import Debug.Trace
import qualified Data.Text as T import qualified Data.Text as T
import Data.Text.Encoding import Data.Text.Encoding
import Stream hiding (map) --import Stream hiding (map) --same as Data.Stream imported above?
import qualified Data.Array.Accelerate as A import Data.Array.Accelerate hiding (not)
-- change to Data.Array.Accelerate.CUDA as I and link accelerate-cuda to use GPU instead of CPU -- 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 -- depends on accelerate-cuda package in cabal, which needs the installed CUDA-stuff form
-- nVidia (nvcc, header-files, ...) and the propriatary driver -- nVidia (nvcc, header-files, ...) and the propriatary driver
import Data.Array.Accelerate.Interpreter as I import Data.Array.Accelerate.Interpreter as I
type Matrix e = A.Array A.DIM2 e type Matrix e = Array DIM2 e
type Attr = Matrix A.Int8 type Attr = Matrix Int8
-- Adjecency-Matrix
type Adj = Matrix Int8
-- Vector of the Adjecency-Matrix
type AdjV = Vector Int8
newtype Constraints = Matrix Float
-- Graph consists of a Vector denoting which colums of the matrix represents wich originating -- 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 -- column in the global adjencency-matrix, the reduces adjencency-matrix of the graph, a
-- matrix of constraints and a scalar denoting the density -- matrix of constraints and a scalar denoting the density
newtype Constraints = Matrix A.Float type Density = Scalar Float
type Density = A.Scalar A.Float
type Graph = (A.Vector A.Int8, Matrix A.Int8, Constraints, Density)
-- Adjecency-Matrix
type Adj = Matrix A.Int8
-- Vector of the Adjecency-Matrix
type AdjV = A.Vector A.Int8
expand :: [Graph]-> Adj -> Attr ->[Graph] -- Graph
type Graph = (Vector Int8, Adj, Constraints, Density)
-- Vector of Graphs
type MultiGraph e = (Vector Int8, Array DIM3 e, Constraints, Density)
expand :: Acc (MultiGraph Int8)-> Acc Adj -> Acc Attr -> Acc (MultiGraph Int8)
expand g a att = undefined expand g a att = undefined
-- constraint gets a Graph and an Attribute-Matrix and yields true, if the Graph still fulfills -- constraint gets a Graph and an Attribute-Matrix and yields true, if the Graph still fulfills
-- all constraints defined via the Attribute-Matrix. -- all constraints defined via the Attribute-Matrix.
constraint :: Graph -> Attr -> Bool constraint :: Acc Graph -> Acc Attr -> Acc (Scalar Bool)
constraint g a = undefined constraint g a = undefined
-- addPoint gets a graph and a tuple of an adjecancy-Vector with an int wich column of the -- 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 -- Adjacency-Matrix the Vector should represent to generate further Graphs
addPoint :: Graph -> (Adj, Int) -> [Graph] addPoint :: Acc Graph -> Acc (Adj, (Scalar Int)) -> Acc (MultiGraph Int8)
addPoint g (a, n) = undefined addPoint g a = undefined
-- addablePoints yields all valid addititonsto a Graph -- addablePoints yields all valid addititonsto a Graph
addablePoints :: Adj -> Graph-> [(Adj, Int)] addablePoints :: Acc Adj -> Acc Graph-> Acc (Vector Int8)
addablePoints a g = undefined addablePoints a g = undefined
@ -109,11 +116,11 @@ createOutput :: [[Int]] -> B.ByteString
createOutput a = encodeUtf8 (createOutput' a) createOutput a = encodeUtf8 (createOutput' a)
createOutput' :: [[Int]] -> T.Text createOutput' :: [[Int]] -> T.Text
createOutput' [a] = T.intercalate (T.singleton ',') (map (T.pack . show) a) createOutput' [a] = T.intercalate (T.singleton ',') (L.map (T.pack . show) a)
createOutput' (a:as) = T.append createOutput' (a:as) = T.append
(T.append (T.append
(T.intercalate (T.singleton ',') (T.intercalate (T.singleton ',')
(map (T.pack . show) a)) (L.map (T.pack . show) a))
(T.singleton '\n')) (T.singleton '\n'))
(createOutput' as) (createOutput' as)
@ -134,17 +141,18 @@ exeMain = do
[adj, attr] -> Prelude.mapM B.readFile [adj, attr] [adj, attr] -> Prelude.mapM B.readFile [adj, attr]
_ -> error "Wrong arguments given" _ -> error "Wrong arguments given"
-- read file and clean -- read file and clean
adjMat <- return $ filter (not . emptyLine) (T.lines (decodeUtf8 (head input))) adjMat <- return $ L.filter (not . emptyLine) (T.lines (decodeUtf8 (head input)))
attrMat <- return $ L.filter (not . emptyLine) (T.lines (decodeUtf8 ((head . L.tail) input)))
inputLines <- return $ length adjMat inputLines <- return $ length adjMat
-- TODO: concat with foldl1' kills us later -> use presized/preallocated array so we -- TODO: concat with foldl1' kills us later -> use presized/preallocated array so we
-- dont copy that much lateron. Best would be Matrix Int -- dont copy that much lateron. Best would be Matrix Int
-- unrefined_graph::[Either [Int] String] - [Int] is Adjacency-Line, String is parse-Error -- unrefined_graph::[Either [Int] String] - [Int] is Adjacency-Line, String is parse-Error
unrefined_graph <- return $ (map (traceEvent "mapping" . createGraph) adjMat) unrefined_graph <- return $ (L.map (traceEvent "mapping" . createGraph) adjMat)
+|| (parBuffer 100 rdeepseq) --run parallel, evaluate fully +|| (parBuffer 100 rdeepseq) --run parallel, evaluate fully
--egraph <- return $ graphFolder unrefined_graph --egraph <- return $ graphFolder unrefined_graph
(graph, log, lines) <- return $ ((foldl1' ((traceEvent "concatenating graph") . (++)) (lefts unrefined_graph), -- concatenated graph (graph, log, lines) <- return $ ((L.foldl1' ((traceEvent "concatenating graph") . (++)) (lefts unrefined_graph), -- concatenated graph
traceEvent "concatenating log" T.intercalate (T.singleton '\n') (rights unrefined_graph), -- concat error-log traceEvent "concatenating log" T.intercalate (T.singleton '\n') (rights unrefined_graph), -- concat error-log
traceEvent "getting length" length unrefined_graph) -- number of elements in graph traceEvent "getting length" length unrefined_graph) -- number of elements in graph
-- in parallel -- in parallel