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
384039ae
Commit
384039ae
authored
Feb 03, 2017
by
Philipp J. Meyer
Browse files
added minimization option for partition proof of reachable terminal marking
parent
920b4175
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/Main.hs
View file @
384039ae
...
@@ -536,7 +536,7 @@ checkTerminalMarkingReachableProperty net = do
...
@@ -536,7 +536,7 @@ checkTerminalMarkingReachableProperty net = do
checkTerminalMarkingReachableProperty'
::
PetriNet
->
[
Triplet
]
->
Integer
->
Integer
->
OptIO
PropResult
checkTerminalMarkingReachableProperty'
::
PetriNet
->
[
Triplet
]
->
Integer
->
Integer
->
OptIO
PropResult
checkTerminalMarkingReachableProperty'
net
triplets
k
kmax
=
do
checkTerminalMarkingReachableProperty'
net
triplets
k
kmax
=
do
verbosePut
1
$
"Checking terminal marking reachable with at most "
++
show
k
++
" partitions"
verbosePut
1
$
"Checking terminal marking reachable with at most "
++
show
k
++
" partitions"
r
<-
checkSat
$
checkTerminalMarkingReachableSat
net
triplets
k
r
<-
checkSat
Min
$
checkTerminalMarkingReachableSat
net
triplets
k
case
r
of
case
r
of
Nothing
->
Nothing
->
if
k
<
kmax
then
if
k
<
kmax
then
...
...
src/Solver/TerminalMarkingReachable.hs
View file @
384039ae
...
@@ -59,23 +59,44 @@ blockOrderConstraints net triplets k b =
...
@@ -59,23 +59,44 @@ blockOrderConstraints net triplets k b =
bAnd
$
map
checkTriplet
triplets
bAnd
$
map
checkTriplet
triplets
where
checkTriplet
(
s
,
t
,
ts
)
=
(
val
b
s
.>
val
b
t
)
==>
bOr
(
map
(
\
t'
->
val
b
t'
.==
val
b
t
)
ts
)
where
checkTriplet
(
s
,
t
,
ts
)
=
(
val
b
s
.>
val
b
t
)
==>
bOr
(
map
(
\
t'
->
val
b
t'
.==
val
b
t
)
ts
)
checkTerminalMarkingReachable
::
PetriNet
->
[
Triplet
]
->
Integer
->
SIMap
Transition
->
[
SIMap
Place
]
->
SBool
checkTerminalMarkingReachable
::
PetriNet
->
[
Triplet
]
->
Integer
->
SIMap
Transition
->
[
SIMap
Place
]
->
Maybe
(
Int
,
(
Int
,
[
Int
]))
->
SBool
checkTerminalMarkingReachable
net
triplets
k
b
ys
=
checkTerminalMarkingReachable
net
triplets
k
b
ys
sizeLimit
=
blockConstraints
net
k
b
&&&
blockConstraints
net
k
b
&&&
terminationConstraints
net
k
b
ys
&&&
terminationConstraints
net
k
b
ys
&&&
blockOrderConstraints
net
triplets
k
b
&&&
blockOrderConstraints
net
triplets
k
b
&&&
checkNonNegativityConstraints
ys
checkNonNegativityConstraints
ys
&&&
checkSizeLimit
k
b
ys
sizeLimit
checkTerminalMarkingReachableSat
::
PetriNet
->
[
Triplet
]
->
Integer
->
ConstraintProblem
Integer
TerminalMarkingReachableInvariant
checkTerminalMarkingReachableSat
::
PetriNet
->
[
Triplet
]
->
Integer
->
Min
ConstraintProblem
Integer
TerminalMarkingReachableInvariant
(
Int
,
[
Int
])
checkTerminalMarkingReachableSat
net
triplets
k
=
checkTerminalMarkingReachableSat
net
triplets
k
=
let
makeYName
i
=
(
++
)
(
genericReplicate
i
'
\'
'
)
let
makeYName
i
=
(
++
)
(
genericReplicate
i
'
\'
'
)
ys
=
[
makeVarMapWith
(
makeYName
i
)
$
places
net
|
i
<-
[
1
..
k
]]
ys
=
[
makeVarMapWith
(
makeYName
i
)
$
places
net
|
i
<-
[
1
..
k
]]
b
=
makeVarMap
$
transitions
net
b
=
makeVarMap
$
transitions
net
in
(
"terminal marking reachable"
,
"invariant"
,
in
(
minimizeMethod
,
\
sizeLimit
->
(
"terminal marking reachable"
,
"invariant"
,
concat
(
map
getNames
ys
)
++
getNames
b
,
concat
(
map
getNames
ys
)
++
getNames
b
,
\
fm
->
checkTerminalMarkingReachable
net
triplets
k
(
fmap
fm
b
)
(
map
(
fmap
fm
)
ys
),
\
fm
->
checkTerminalMarkingReachable
net
triplets
k
(
fmap
fm
b
)
(
map
(
fmap
fm
)
ys
)
sizeLimit
,
\
fm
->
invariantFromAssignment
net
k
(
fmap
fm
b
)
(
map
(
fmap
fm
)
ys
))
\
fm
->
invariantFromAssignment
net
k
(
fmap
fm
b
)
(
map
(
fmap
fm
)
ys
))
)
invariantFromAssignment
::
PetriNet
->
Integer
->
IMap
Transition
->
[
IMap
Place
]
->
TerminalMarkingReachableInvariant
minimizeMethod
::
Int
->
(
Int
,
[
Int
])
->
String
minimizeMethod
1
(
curYSize
,
_
)
=
"number of places in y less than "
++
show
curYSize
minimizeMethod
2
(
_
,
curTSize
)
=
"number of transitions in last block less than "
++
show
(
last
curTSize
)
minimizeMethod
3
(
curYSize
,
curTSize
)
=
"number of transitions in last block less than "
++
show
(
last
curTSize
)
++
" or same number of transitions and number of places in y less than "
++
show
curYSize
minimizeMethod
_
_
=
error
"minimization method not supported"
checkSizeLimit
::
Integer
->
SIMap
Transition
->
[
SIMap
Place
]
->
Maybe
(
Int
,
(
Int
,
[
Int
]))
->
SBool
checkSizeLimit
_
_
_
Nothing
=
true
checkSizeLimit
k
b
ys
(
Just
(
1
,
(
curYSize
,
_
)))
=
(
sum
(
map
(
\
y
->
sum
(
map
(
\
yi
->
ite
(
yi
.>
0
)
(
1
::
SInteger
)
0
)
(
vals
y
)))
ys
)
.<
literal
(
fromIntegral
curYSize
))
checkSizeLimit
k
b
ys
(
Just
(
2
,
(
_
,
curTSize
)))
=
(
sum
(
map
(
\
tb
->
ite
(
tb
.==
(
literal
k
))
(
1
::
SInteger
)
0
)
(
vals
b
)))
.<
literal
(
fromIntegral
(
last
curTSize
))
checkSizeLimit
k
b
ys
(
Just
(
3
,
(
curYSize
,
curTSize
)))
=
((
sum
(
map
(
\
tb
->
ite
(
tb
.==
(
literal
k
))
(
1
::
SInteger
)
0
)
(
vals
b
)))
.<
literal
(
fromIntegral
(
last
curTSize
)))
|||
(
((
sum
(
map
(
\
tb
->
ite
(
tb
.==
(
literal
k
))
(
1
::
SInteger
)
0
)
(
vals
b
)))
.==
literal
(
fromIntegral
(
last
curTSize
)))
&&&
(
sum
(
map
(
\
y
->
sum
(
map
(
\
yi
->
ite
(
yi
.>
0
)
(
1
::
SInteger
)
0
)
(
vals
y
)))
ys
)
.<
literal
(
fromIntegral
curYSize
))
)
checkSizeLimit
_
_
_
(
Just
(
_
,
_
))
=
error
"minimization method not supported"
invariantFromAssignment
::
PetriNet
->
Integer
->
IMap
Transition
->
[
IMap
Place
]
->
(
TerminalMarkingReachableInvariant
,
(
Int
,
[
Int
]))
invariantFromAssignment
net
k
b
ys
=
invariantFromAssignment
net
k
b
ys
=
[
BlockInvariant
(
i
,
M
.
keys
(
M
.
filter
(
==
i
)
b
),
makeVector
y
)
|
(
i
,
y
)
<-
zip
[
1
..
]
ys
]
let
invariant
=
[
BlockInvariant
(
i
,
M
.
keys
(
M
.
filter
(
==
i
)
b
),
makeVector
y
)
|
(
i
,
y
)
<-
zip
[
1
..
]
ys
]
in
(
invariant
,
(
sum
$
map
invariantSize
invariant
,
map
(
\
(
BlockInvariant
(
_
,
ts
,
_
))
->
length
ts
)
invariant
))
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