Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Software
CoPaR
Commits
de81c4b1
Commit
de81c4b1
authored
Jan 05, 2019
by
Hans-Peter Deifel
🐢
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
random-dfa: Use Word32 as base data type
Alright, compromise. Word16 might have been a little too small
parent
273a65b1
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
15 deletions
+15
-15
src/random-dfa/CoalgOutput.hs
src/random-dfa/CoalgOutput.hs
+2
-2
src/random-dfa/DotOutput.hs
src/random-dfa/DotOutput.hs
+3
-3
src/random-dfa/Main.hs
src/random-dfa/Main.hs
+4
-4
src/random-dfa/Type.hs
src/random-dfa/Type.hs
+5
-5
src/random-dfa/ValmariOutput.hs
src/random-dfa/ValmariOutput.hs
+1
-1
No files found.
src/random-dfa/CoalgOutput.hs
View file @
de81c4b1
...
...
@@ -23,7 +23,7 @@ transitionsB :: DFA -> Build.Builder
transitionsB
dfa
=
foldMap
(
forStateB
dfa
)
[
0
..
dfa
^.
states
-
1
]
forStateB
::
DFA
->
Word
16
->
Build
.
Builder
forStateB
::
DFA
->
Word
32
->
Build
.
Builder
forStateB
dfa
n
=
"s"
<>
Build
.
decimal
n
...
...
@@ -41,5 +41,5 @@ forStateB dfa n =
<>
"})
\n
"
successorB
::
Word
16
->
Word
16
->
Build
.
Builder
successorB
::
Word
32
->
Word
32
->
Build
.
Builder
successorB
label
target
=
Build
.
decimal
label
<>
": s"
<>
Build
.
decimal
target
src/random-dfa/DotOutput.hs
View file @
de81c4b1
...
...
@@ -17,7 +17,7 @@ nodesB :: DFA -> Build.Builder
nodesB
dfa
=
foldMap
(
nodeB
dfa
)
[
0
..
dfa
^.
states
-
1
]
nodeB
::
DFA
->
Word
16
->
Build
.
Builder
nodeB
::
DFA
->
Word
32
->
Build
.
Builder
nodeB
dfa
n
=
"
\"
n"
<>
Build
.
decimal
n
<>
"
\"
[shape = "
<>
shape
<>
"];
\n
"
where
shape
=
...
...
@@ -28,14 +28,14 @@ transitionsB :: DFA -> Build.Builder
transitionsB
dfa
=
foldMap
(
transitionsForB
dfa
)
[
0
..
dfa
^.
states
-
1
]
transitionsForB
::
DFA
->
Word
16
->
Build
.
Builder
transitionsForB
::
DFA
->
Word
32
->
Build
.
Builder
transitionsForB
dfa
n
=
fold
(
zipWith
(
transitionB
n
)
[
0
..
]
(
dfa
^..
transitions
.
ix
(
fromIntegral
n
)
.
each
))
transitionB
::
Word
16
->
Word
16
->
Word
16
->
Build
.
Builder
transitionB
::
Word
32
->
Word
32
->
Word
32
->
Build
.
Builder
transitionB
source
letter
target
=
" n"
<>
Build
.
decimal
source
...
...
src/random-dfa/Main.hs
View file @
de81c4b1
...
...
@@ -25,8 +25,8 @@ import ValmariOutput
-- | Generate a random DFA
randomDFA
::
Word
16
-- ^ Number of states
->
Word
16
-- ^ Size of the alphabet
::
Word
32
-- ^ Number of states
->
Word
32
-- ^ Size of the alphabet
->
IO
Bool
-- ^ Random finality
->
IO
DFA
randomDFA
s
a
randomIsFinal
=
do
...
...
@@ -53,8 +53,8 @@ instance Show OutputFormat where
data
Options
=
Options
{
_optStates
::
Word
16
,
_optLetters
::
Word
16
{
_optStates
::
Word
32
,
_optLetters
::
Word
32
,
_optFinal
::
Int
,
_optOutputs
::
[(
OutputFormat
,
Maybe
(
NE
.
NonEmpty
Char
))]
}
deriving
(
Show
)
...
...
src/random-dfa/Type.hs
View file @
de81c4b1
...
...
@@ -15,15 +15,15 @@ import qualified Data.Vector.Unboxed as VU
import
Lens.Micro.TH
-- The objective here is to support large DFAs and thus is might seem backwards
-- to restrict the number of states and letters to Word
16
. In reality, the
-- to restrict the number of states and letters to Word
32
. In reality, the
-- limiting factor is RAM, e.g 10000x10000 requires already more ram than my
-- 16GB machine has. Word
16
requires
4 times less
RAM than Int, so it allows for
-- 16GB machine has. Word
32
requires
half as much
RAM than Int, so it allows for
-- larger graphs in practice.
data
DFA
=
DFA
{
dfaStates
::
Word
16
,
dfaLetters
::
Word
16
,
dfaTransitions
::
Vector
(
VU
.
Vector
Word
16
)
{
dfaStates
::
Word
32
,
dfaLetters
::
Word
32
,
dfaTransitions
::
Vector
(
VU
.
Vector
Word
32
)
,
dfaIsFinal
::
VU
.
Vector
Bool
}
...
...
src/random-dfa/ValmariOutput.hs
View file @
de81c4b1
...
...
@@ -39,7 +39,7 @@ transitionsB dfa = foldMap
]
transB
::
DFA
->
Word
16
->
Word
16
->
Build
.
Builder
transB
::
DFA
->
Word
32
->
Word
32
->
Build
.
Builder
transB
dfa
from
letter
=
Build
.
decimal
(
from
+
1
)
<>
" "
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment