mirror of
https://git.cs.ou.nl/joshua.moerman/mealy-decompose.git
synced 2025-04-30 02:07:44 +02:00
actually using the command line options
This commit is contained in:
parent
dbecd98e18
commit
e938befa20
4 changed files with 16 additions and 12 deletions
|
@ -1,6 +1,7 @@
|
||||||
module DecomposeInput where
|
module DecomposeInput where
|
||||||
|
|
||||||
import Bisimulation (bisimulation2)
|
import Bisimulation (bisimulation2)
|
||||||
|
import CommonOptions
|
||||||
import Data.Partition (Block (..), numBlocks)
|
import Data.Partition (Block (..), numBlocks)
|
||||||
import Data.UnionFind (empty, equate, equivalent)
|
import Data.UnionFind (empty, equate, equivalent)
|
||||||
import DotParser (readDotFile)
|
import DotParser (readDotFile)
|
||||||
|
@ -15,6 +16,7 @@ import Data.Set qualified as Set
|
||||||
import Data.Text qualified as T
|
import Data.Text qualified as T
|
||||||
import Options.Applicative
|
import Options.Applicative
|
||||||
import System.Exit (exitFailure, exitSuccess)
|
import System.Exit (exitFailure, exitSuccess)
|
||||||
|
import System.FilePath ((</>))
|
||||||
|
|
||||||
newtype DecomposeInputOptions = DecomposeInputOptions
|
newtype DecomposeInputOptions = DecomposeInputOptions
|
||||||
{ filename :: FilePath
|
{ filename :: FilePath
|
||||||
|
@ -52,12 +54,12 @@ interleavingComposition alphs m =
|
||||||
-- [dotFile] -> putStrLn ("reading " <> dotFile) >> run dotFile
|
-- [dotFile] -> putStrLn ("reading " <> dotFile) >> run dotFile
|
||||||
-- _ -> putStrLn "Please provide a dot file"
|
-- _ -> putStrLn "Please provide a dot file"
|
||||||
-- where
|
-- where
|
||||||
mainDecomposeInput :: DecomposeInputOptions -> IO ()
|
mainDecomposeInput :: DecomposeInputOptions -> CommonOptions -> IO ()
|
||||||
mainDecomposeInput DecomposeInputOptions{..} = do
|
mainDecomposeInput DecomposeInputOptions{..} CommonOptions{..} = do
|
||||||
let
|
let
|
||||||
dotFile = filename
|
dotFile = filename
|
||||||
report s = appendFile "results/log.txt" (dotFile <> "\t" <> s <> "\n")
|
report s = appendFile (logDirectory </> "hs-decompose-input.txt") (dotFile <> "\t" <> s <> "\n")
|
||||||
witness s = appendFile "results/witnesses.txt" (dotFile <> "\n" <> s <> "\n\n")
|
witness s = appendFile (resultsDirectory </> "hs-decompose-input-witnesses.txt") (dotFile <> "\n" <> s <> "\n\n")
|
||||||
|
|
||||||
report "START-INPUT-DECOMP"
|
report "START-INPUT-DECOMP"
|
||||||
model <- readDotFile dotFile
|
model <- readDotFile dotFile
|
||||||
|
|
|
@ -24,6 +24,7 @@ import Data.Text.IO qualified as T
|
||||||
import Data.Text.Lazy.IO qualified as TL
|
import Data.Text.Lazy.IO qualified as TL
|
||||||
import Data.Tuple (swap)
|
import Data.Tuple (swap)
|
||||||
import Options.Applicative
|
import Options.Applicative
|
||||||
|
import System.FilePath ((</>))
|
||||||
|
|
||||||
data DecomposeOutputOptions = DecomposeOutputOptions
|
data DecomposeOutputOptions = DecomposeOutputOptions
|
||||||
{ filename :: FilePath
|
{ filename :: FilePath
|
||||||
|
@ -31,7 +32,7 @@ data DecomposeOutputOptions = DecomposeOutputOptions
|
||||||
}
|
}
|
||||||
deriving Show
|
deriving Show
|
||||||
|
|
||||||
decomposeOutputOptionsParser :: _
|
decomposeOutputOptionsParser :: Parser DecomposeOutputOptions
|
||||||
decomposeOutputOptionsParser =
|
decomposeOutputOptionsParser =
|
||||||
DecomposeOutputOptions
|
DecomposeOutputOptions
|
||||||
<$> argument str (help "Filename to read (dot format)" <> metavar "FILE")
|
<$> argument str (help "Filename to read (dot format)" <> metavar "FILE")
|
||||||
|
@ -41,7 +42,7 @@ decomposeOutputOptionsParser =
|
||||||
mainDecomposeOutput :: DecomposeOutputOptions -> CommonOptions -> IO ()
|
mainDecomposeOutput :: DecomposeOutputOptions -> CommonOptions -> IO ()
|
||||||
mainDecomposeOutput DecomposeOutputOptions{..} CommonOptions{..} = do
|
mainDecomposeOutput DecomposeOutputOptions{..} CommonOptions{..} = do
|
||||||
let
|
let
|
||||||
report s = appendFile "results/log.txt" (filename <> "\t" <> s <> "\n")
|
report s = appendFile (logDirectory </> "hs-decompose-output-hs.txt") (filename <> "\t" <> s <> "\n")
|
||||||
|
|
||||||
-- READING INPUT
|
-- READING INPUT
|
||||||
----------------
|
----------------
|
||||||
|
@ -134,7 +135,7 @@ mainDecomposeOutput DecomposeOutputOptions{..} CommonOptions{..} = do
|
||||||
content = T.unlines . fmap T.unwords . toBlocks $ p
|
content = T.unlines . fmap T.unwords . toBlocks $ p
|
||||||
|
|
||||||
putStrLn $ " Output (partition) in file " <> filename'
|
putStrLn $ " Output (partition) in file " <> filename'
|
||||||
T.writeFile ("results/" <> filename') content
|
T.writeFile (resultsDirectory </> filename') content
|
||||||
|
|
||||||
do
|
do
|
||||||
let
|
let
|
||||||
|
@ -166,12 +167,12 @@ mainDecomposeOutput DecomposeOutputOptions{..} CommonOptions{..} = do
|
||||||
content2 = toString . mealyToDot name $ result
|
content2 = toString . mealyToDot name $ result
|
||||||
|
|
||||||
putStrLn $ " Output (reduced machine) in file " <> filename1
|
putStrLn $ " Output (reduced machine) in file " <> filename1
|
||||||
TL.writeFile ("results/" <> filename1) content1
|
TL.writeFile (resultsDirectory </> filename1) content1
|
||||||
|
|
||||||
putStrLn $ " Dead inputs = " <> show (Set.size deadInputs)
|
putStrLn $ " Dead inputs = " <> show (Set.size deadInputs)
|
||||||
|
|
||||||
putStrLn $ " Output (reduced machine) in file " <> filename2
|
putStrLn $ " Output (reduced machine) in file " <> filename2
|
||||||
TL.writeFile ("results/" <> filename2) content2
|
TL.writeFile (resultsDirectory </> filename2) content2
|
||||||
|
|
||||||
mapM_ processComponent projmapN
|
mapM_ processComponent projmapN
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,13 @@ main = do
|
||||||
Options{..} <- execParser opts
|
Options{..} <- execParser opts
|
||||||
|
|
||||||
-- setup some logging facilities
|
-- setup some logging facilities
|
||||||
createDirectoryIfMissing True "log"
|
createDirectoryIfMissing True (logDirectory commonOptions)
|
||||||
createDirectoryIfMissing True "results"
|
createDirectoryIfMissing True (resultsDirectory commonOptions)
|
||||||
|
|
||||||
-- dispatch to actual functionality, based on the command provided
|
-- dispatch to actual functionality, based on the command provided
|
||||||
case optCommand of
|
case optCommand of
|
||||||
DecomposeOutput options -> mainDecomposeOutput options commonOptions
|
DecomposeOutput options -> mainDecomposeOutput options commonOptions
|
||||||
DecomposeInput options -> mainDecomposeInput options
|
DecomposeInput options -> mainDecomposeInput options commonOptions
|
||||||
|
|
||||||
data Options = Options
|
data Options = Options
|
||||||
{ optCommand :: Command
|
{ optCommand :: Command
|
||||||
|
|
|
@ -44,6 +44,7 @@ executable mealy-decompose-main
|
||||||
main-is: Main.hs
|
main-is: Main.hs
|
||||||
build-depends:
|
build-depends:
|
||||||
directory,
|
directory,
|
||||||
|
filepath,
|
||||||
mealy-decompose,
|
mealy-decompose,
|
||||||
optparse-applicative
|
optparse-applicative
|
||||||
other-modules:
|
other-modules:
|
||||||
|
|
Loading…
Add table
Reference in a new issue