diff options
author | Erin van der Veen | 2018-07-05 20:16:35 +0200 |
---|---|---|
committer | Erin van der Veen | 2018-07-05 20:16:35 +0200 |
commit | 4245e64cd27a4c228f5500dbd9fb6bd8dd743f74 (patch) | |
tree | 0032f303f6867f62be8b3ba7580c124e6d39d530 /Assignment2 | |
parent | Make variables start with a v (diff) | |
parent | Add printDTMC (diff) |
Merge branch 'master' of gitlab.science.ru.nl:eveen/Model-Checking
Diffstat (limited to 'Assignment2')
-rw-r--r-- | Assignment2/src/DTMC.dcl | 2 | ||||
-rw-r--r-- | Assignment2/src/DTMC.icl | 31 |
2 files changed, 32 insertions, 1 deletions
diff --git a/Assignment2/src/DTMC.dcl b/Assignment2/src/DTMC.dcl index 5d948fb..26cbe19 100644 --- a/Assignment2/src/DTMC.dcl +++ b/Assignment2/src/DTMC.dcl @@ -15,5 +15,7 @@ from System.FilePath import :: FilePath , init :: !Bool } +stateElimination :: !*DTMC -> *DTMC parseDTMC :: !FilePath !*World -> *(!*DTMC, !*World) +printDTMC :: !*DTMC -> *(!String, !*DTMC) addVars :: *DTMC -> *DTMC diff --git a/Assignment2/src/DTMC.icl b/Assignment2/src/DTMC.icl index 2d7a68f..6c81510 100644 --- a/Assignment2/src/DTMC.icl +++ b/Assignment2/src/DTMC.icl @@ -164,6 +164,34 @@ where | isEmpty current = groupLines head [line] lines | otherwise = [reverse current:groupLines head [line] lines] +printDTMC :: !*DTMC -> *(!String, !*DTMC) +printDTMC dtmc=:{nr_states,states} +# (state_strings,states) = printStates 0 states +# s = join "\n" + [ "@type: DTMC" + , "@parameters" + , "@reward_models" + , "@nr_states" + , toString nr_states + , "@model" + : state_strings + ] += (s, {dtmc & states=states}) +where + printStates :: !Int !*{Maybe State} -> *(![String], !*{Maybe State}) + printStates i ss + | i == nr_states = ([], ss) + # (s,ss) = ss![i] + | isNothing s = printStates (i+1) ss + # s = fromJust s + # repr = + [ "state " <+ s.state_id + , "\taction 0" + : ["\t\t" <+ to <+ " : " <+ prob \\ (to,prob) <- 'M'.toList s.transitions] + ] + # (reprs,ss) = printStates (i+1) ss + = (repr ++ reprs,ss) + addVars :: *DTMC -> *DTMC addVars dtmc = {DTMC | nr_states = dtmc.nr_states, states = addVarsS 0 dtmc.nr_states dtmc.states} where @@ -187,4 +215,5 @@ where Start w # (dtmc,w) = parseDTMC "die.drn" w # dtmc = addVars dtmc -= [(s.state_id, 'M'.toList s.transitions, '\n') \\ Just s <-: (stateElimination dtmc).states] +# dtmc = stateElimination dtmc += printDTMC dtmc |