Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
9.2.2023: Due to updates GitLab will be unavailable for some minutes between 9:00 and 11:00.
Open sidebar
i7
peregrine
Commits
cb83555d
Commit
cb83555d
authored
Jul 21, 2017
by
Philipp Meyer
Browse files
Generate log flock of birds protocol with Integer
parent
81374fc7
Changes
1
Hide whitespace changes
Inline
Side-by-side
benchmarks/pp-print/src/PopulationProtocol.hs
View file @
cb83555d
...
...
@@ -87,7 +87,10 @@ data THState = THVal (Int, Int) | Passivo | Eater deriving (Show, Eq, Ord)
floorLog
::
Int
->
Int
floorLog
=
floor
.
logBase
2
.
fromIntegral
g
::
Int
->
Int
genericFloorLog
::
Integer
->
Int
genericFloorLog
=
floor
.
logBase
2
.
fromIntegral
g
::
Int
->
Int
g
n
=
n
-
2
^
(
floorLog
n
)
maxLevel
::
Int
->
Int
...
...
@@ -96,16 +99,16 @@ maxLevel n | n == 0 = -1
maxOnLevel
i
n
=
floorLog
(
iterate
g
n
!!
i
)
createLogFlockOfBirdsProtocol
::
Int
->
PopulationProtocol
Int
createLogFlockOfBirdsProtocol
::
Int
eger
->
PopulationProtocol
Int
eger
createLogFlockOfBirdsProtocol
c
=
PopulationProtocol
{
states
=
nub
logQ
,
initial
=
[
1
,
0
]
,
opinion
=
(
==
c
)
,
trans
=
logTrans
,
predicate
=
Just
$
toVar
1
++
" >= "
++
show
c
}
where
logQ
=
[
2
^
i
|
i
<-
[
0
..
(
f
loorLog
c
-
1
)]]
++
[
c
.&.
(
shift
(
complement
0
)
i
)
|
i
<-
[
0
..
(
f
loorLog
c
+
1
)]]
logQ
=
[
2
^
i
|
i
<-
[
0
..
(
genericF
loorLog
c
-
1
)]]
++
[
c
.&.
(
shift
(
complement
0
)
i
)
|
i
<-
[
0
..
(
genericF
loorLog
c
+
1
)]]
logTrans
(
x
,
y
)
|
x
+
y
>=
c
=
(
c
,
c
)
|
x
==
y
&&
2
*
x
<
c
=
(
2
*
x
,
0
)
|
y
>=
floorLog
c
&&
y
+
x
`
elem
`
logQ
=
(
x
+
y
,
0
)
|
y
>=
f
romIntegral
(
genericF
loorLog
c
)
&&
y
+
x
`
elem
`
logQ
=
(
x
+
y
,
0
)
|
otherwise
=
(
x
,
y
)
createPolyLogFlockOfBirdsProtocol
::
Int
->
PopulationProtocol
THState
createPolyLogFlockOfBirdsProtocol
c
=
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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