Skip to content

Commit 9d5906f

Browse files
committed
-exportstrat can export full induced model, including states/labels/rewards.
For example: prism ... -exportstrat strat.pexp prism ... -exportstrat strat.umb The -exportstrat switch also gains many of -exportmodel's options: format, states, rewards, labels, actions, precision, zip, text, headers. To avoid an option clash, "obs" now means "show observations", like for -exportmodel, and the existing "obs" option for -exportstrat is now renamed to "mergeobs" (merge observationally equivalent states). We also make reach=true the default. Implementation details: * StrategyExportOptions gains an inducedModelExportOptions field. * Tidy up constructInducedModel and exportInducedModel in Strategy classes for explicit models to respect inducedModelExportOptions and to use new Model.export method, allow full model export to .pexp/.umb. * Induced model construction in both ConstructInducedModel and ConstructStrategyProduct copies/lifts (by default, but optionally) any labels and rewards attached to the original model. * Rewards are pre-emptively built and attached to built models when it is known that strategies are generated (via StateModelChecker.attachRewards)
1 parent 9486c77 commit 9d5906f

25 files changed

Lines changed: 547 additions & 57 deletions
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Test for extended -exportstrat induced-model export: separate files (.tra/.sta/.lab),
2+
// combined formats (.pexp), mode=restrict/reduce and reach=true/false, all mirroring
3+
// -exportmodel's file/format/label handling. State 3 is reachable in the full model but
4+
// not under the optimal (Pmax) strategy for reaching "goal1", so it exercises reach=true
5+
// dropping/reindexing of unreachable states (and their labels).
6+
7+
mdp
8+
9+
module M
10+
11+
s:[0..5];
12+
13+
[east] s=0 -> 0.6:(s'=1) + 0.4:(s'=0);
14+
[south] s=0 -> 0.8:(s'=3) + 0.1:(s'=1) + 0.1:(s'=4);
15+
[east] s=1 -> 1:(s'=2);
16+
[south] s=1 -> 0.5:(s'=4) + 0.5:(s'=2);
17+
[stuck] s=2 -> 1:(s'=2);
18+
[stuck] s=3 -> 1:(s'=3);
19+
[east] s=4 -> 1:(s'=5);
20+
[west] s=4 -> 0.6:(s'=3) + 0.4:(s'=4);
21+
[north] s=5 -> 0.9:(s'=2) + 0.1:(s'=5);
22+
[west] s=5 -> 1:(s'=4);
23+
24+
endmodule
25+
26+
label "hazard" = s=1;
27+
label "goal1" = s=5;
28+
label "goal2" = s=2|s=3;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// RESULT: 0.5
2+
Pmax=? [ F "goal1" ];
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-ex -exportstrat exportstratinduced.nm.props.tra
2+
-ex -exportstrat exportstratinduced.nm.props.reduce.pexp:type=induced,mode=reduce
3+
-ex -exportstrat exportstratinduced.nm.props.restrict.pexp:type=induced,mode=restrict
4+
-ex -exportstrat exportstratinduced.nm.props.reach.tra:type=induced,reach=true
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Labels
2+
0="init" 1="deadlock" 2="hazard" 3="goal1" 4="goal2"
3+
0: 0
4+
1: 2
5+
2: 4
6+
3: 4
7+
5: 3
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# States
2+
(s)
3+
0:(0)
4+
1:(1)
5+
2:(2)
6+
3:(3)
7+
4:(4)
8+
5:(5)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Transitions (DTMC)
2+
6 8
3+
0 0 0.4 east
4+
0 1 0.6 east
5+
1 2 0.5 south
6+
1 4 0.5 south
7+
2 2 1 stuck
8+
3 3 1 stuck
9+
4 5 1 east
10+
5 4 1 west
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Labels
2+
0="init" 1="deadlock" 2="hazard" 3="goal1" 4="goal2"
3+
0: 0
4+
1: 2
5+
2: 4
6+
4: 3
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# States
2+
(s)
3+
0:(0)
4+
1:(1)
5+
2:(2)
6+
3:(4)
7+
4:(5)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Transitions (DTMC)
2+
5 7
3+
0 0 0.4 east
4+
0 1 0.6 east
5+
1 2 0.5 south
6+
1 3 0.5 south
7+
2 2 1 stuck
8+
3 4 1 east
9+
4 3 1 west
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Transitions (DTMC)
2+
5 7
3+
0 0 0.4 east
4+
0 1 0.6 east
5+
1 2 0.5 south
6+
1 3 0.5 south
7+
2 2 1 stuck
8+
3 4 1 east
9+
4 3 1 west
10+
11+
# States
12+
(s)
13+
0:(0)
14+
1:(1)
15+
2:(2)
16+
3:(4)
17+
4:(5)
18+
19+
# Labels
20+
0="init" 1="deadlock" 2="hazard" 3="goal1" 4="goal2"
21+
0: 0
22+
1: 2
23+
2: 4
24+
4: 3

0 commit comments

Comments
 (0)