Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
91520fd
Bugfix: Export settings were being ignored.
davexparker Dec 27, 2024
38c1231
Move ModelExportFormat enum out to own class.
davexparker Jan 2, 2025
166f8c6
Model export methods in model checker take File not PrismLog.
davexparker Dec 27, 2024
54ba9ae
Move model export code from Prism to symbolic.StateModelChecker.
davexparker Dec 28, 2024
886511e
Change/remove rarely used export options.
davexparker Dec 28, 2024
5eeddc9
Model export in rows format not yet supported by explicit engine.
davexparker Dec 30, 2024
dcdc8b4
Model export refactoring: ModelExportTask objects for export task def…
davexparker Jul 30, 2024
3f52ccf
Use ModelExportTask for PrismCL export switches.
davexparker Dec 30, 2024
cffa4bd
Use ModelExportTask for GUI exports.
davexparker Jan 2, 2025
3b57576
Update Prism.exportBuiltModelXXX methods.
davexparker Jan 5, 2025
b751e46
Refactor steady-state probability export methods in Prism.
davexparker Jan 5, 2025
b477ccd
Refactor transient probability export methods in Prism.
davexparker Jan 5, 2025
e065fcd
Refactor steady-state/transient probability export methods in Prism.
davexparker Jan 5, 2025
c45f781
Push model export reward/label storage to superclass ModelExporter.
davexparker Jan 7, 2025
9f5fb22
Allow engine switching (to explicit) for some model export formats.
davexparker Jan 14, 2025
ce5432e
Add "format" to -exportmodel switch (explicit/matlab/dot/drn).
davexparker Jan 18, 2025
cdfe0f9
ModelExporter can export to either a PrismLog or a File.
davexparker Jan 19, 2025
a20ebca
Code tidying in explicit model export.
davexparker Jan 19, 2025
4583dd5
PRISM explicit export transition reward fix (order matches transitions).
davexparker Apr 16, 2025
b151cd3
Additional querying of action info for models.
davexparker Apr 20, 2025
de5f233
Update action name storage in explicit models.
davexparker Apr 21, 2025
935f63c
Slightly faster findActionsUsed() for specific DTMC/MDP implementations.
davexparker Apr 23, 2025
4fdf3c1
Java implementation of symbolic-to-explicit model conversion.
davexparker May 27, 2025
a399f4b
Export to DRN format from symbolic model representations.
davexparker May 27, 2025
70114ae
ModelExporter class has access to ModelInfo (if provided).
davexparker May 27, 2025
485be8c
CHANGELOG.
davexparker Apr 11, 2025
83f3370
Make explicit model import treat empty ("") actions as absent.
davexparker Feb 7, 2025
e3f9f7a
Prism explicit files importer extracts model stats separately.
davexparker Jan 31, 2025
4980a2e
Explicit model import: push default variable info into superclass.
davexparker Jan 31, 2025
97a268f
New BasicModelInfo class, used by PrismExplicitImporter.
davexparker Feb 1, 2025
44e0de3
New BasicRewardInfo class, used by PrismExplicitImporter.
davexparker Feb 1, 2025
8ae6bde
Model import refactoring: store a list of import files in PrismCL.
davexparker Jan 19, 2025
eb400fa
Convert ExplicitModelImporter from interface to abstract class.
davexparker Feb 13, 2025
e411f16
Refactor handling of imported transition reward indexing.
davexparker Feb 13, 2025
e646f09
Fix MDP transition reward import from explicit files.
davexparker Feb 13, 2025
197b60e
File extension for -importmodel can be missing/non-standard.
davexparker Apr 9, 2025
f803e2f
Add deadlock detection + fixing to explicit model import process.
davexparker Apr 24, 2025
2e1295d
Default implementation of extractStates in ExplicitModelImporter.
davexparker May 28, 2025
a407022
Bugfix: NPE on testing of model checking results after explicit import.
davexparker May 29, 2025
a051110
Import from explicit files preserves "deadlock" label.
davexparker May 29, 2025
88ab0bd
Fix explicit file import type detection for very small files.
davexparker May 30, 2025
0c37fb7
Explicit file import deals with zero-range integer variables.
davexparker May 30, 2025
7aba2ab
Fix (expected) Markov chain transition rewards imports.
davexparker May 30, 2025
687d209
Compile fix (enums in switches).
davexparker Jun 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
This file contains details of the changes in each new version of PRISM.

-----------------------------------------------------------------------------
Changes since last release (up to f25c788dd)
Changes since last release (up to 4fc1eaed3)
-----------------------------------------------------------------------------

* Explicit engine improvements
- support for transition rewards in Markov chains
- storage (and export) of actions for Markov chains

* Model export functionality (explicit engine)
* Model export functionality
- export of exact and parametric models
- preliminary DRN (Storm) output
- actions=true/false option
- remove old options (MRMC format, unordered)
- actions=true/false option (explicit engine)
- multiple -exportmodel allowed and format=x option
- remove old options (MRMC format, unordered, spy)

* Model import functionality (from explicit files)
- import of transition rewards
Expand All @@ -32,17 +33,19 @@ Changes since last release (up to f25c788dd)
* Various bugfixes

* Development and code-level changes
- prism.Prism API: new model export methods
- prism.Prism API: new/updated model export methods
- prism.Prism API: remove some old deprecated methods
- prism.Prism: refactored storage/access for model info
- prism.Prism: integration of exact model building/checking
- improved access to actions and their indices in models
- redesign/refactoring of explicit engine reward classes
- refactoring of explicit engine model import/export code
(centralised in io package, export moved from model classes)
- parametric engine refactored to use explicit models/rewards
- symbolic code rearranged (new symbolic package)
- symbolic model storage refactored, simplified, documented
- extension of strategy classes, especially for induced models
- Java-based symbolic-to-explicit model conversion
- prism-auto: --errors-only switch

* [More minor development and code-level changes]
Expand All @@ -55,6 +58,7 @@ Changes since last release (up to f25c788dd)
- VarList aware of EvaluationContext/EvalMode
- parametric engine: improved error reporting and formatting
- prism.API: exportprism moved from setting to API call
- model export refactoring, including ModelExportTask

-----------------------------------------------------------------------------
Version 4.8.1 (first released 13/1/2024)
Expand Down
8 changes: 8 additions & 0 deletions prism-tests/functionality/import/dice-deadlock.lab
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
0="init" 1="deadlock" 2="end" 3="six"
0: 0
7: 1 2
8: 1 2
9: 1 2
10: 1 2
11: 1 2
12: 1 2 3
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-importmodel dice-deadlock.tra,lab -exportmodel dice-deadlock.tra,lab
-importmodel dice-deadlock.tra,lab -exportmodel dice-deadlock.tra,lab -ex
26 changes: 26 additions & 0 deletions prism-tests/functionality/import/dice-deadlock.pm.orig
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
dtmc

module die

// local state
s : [0..7] init 0;
// value of the die
d : [0..6] init 0;

[] s=0 -> 1/2 : (s'=1) + 1/2 : (s'=2);
[] s=1 -> 1/2 : (s'=3) + 1/2 : (s'=4);
[] s=2 -> 1/2 : (s'=5) + 1/2 : (s'=6);
[] s=3 -> 1/2 : (s'=1) + 1/2 : (s'=7) & (d'=1);
[] s=4 -> 1/2 : (s'=7) & (d'=2) + 1/2 : (s'=7) & (d'=3);
[] s=5 -> 1/2 : (s'=7) & (d'=4) + 1/2 : (s'=7) & (d'=5);
[] s=6 -> 1/2 : (s'=2) + 1/2 : (s'=7) & (d'=6);
// [] s=7 -> (s'=7);

endmodule

label "end" = s=7;
label "six" = d=6;

rewards "coin_flips"
s<7 : 1;
endrewards
21 changes: 21 additions & 0 deletions prism-tests/functionality/import/dice-deadlock.tra
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
13 20
0 1 0.5
0 2 0.5
1 3 0.5
1 4 0.5
2 5 0.5
2 6 0.5
3 1 0.5
3 7 0.5
4 8 0.5
4 9 0.5
5 10 0.5
5 11 0.5
6 2 0.5
6 12 0.5
7 7 1
8 8 1
9 9 1
10 10 1
11 11 1
12 12 1
5 changes: 5 additions & 0 deletions prism-tests/functionality/import/dtmc-deadlocks-fixed.lab
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
0="init" 1="deadlock"
0: 0
2: 1
3: 1
5: 1
9 changes: 9 additions & 0 deletions prism-tests/functionality/import/dtmc-deadlocks-fixed.tra
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
6 8
0 0 0.4 east
0 1 0.6 east
1 2 0.5 south
1 4 0.5 south
2 2 1
3 3 1
4 5 1 east
5 5 1
6 changes: 6 additions & 0 deletions prism-tests/functionality/import/dtmc-deadlocks.tra
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
6 5
0 0 0.4 east
0 1 0.6 east
1 2 0.5 south
1 4 0.5 south
4 5 1 east
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-importmodel dtmc-deadlocks.tra -exportmodel dtmc-deadlocks-fixed.tra,lab -ex
5 changes: 5 additions & 0 deletions prism-tests/functionality/import/mdp-deadlocks-fixed.lab
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
0="init" 1="deadlock"
0: 0
2: 1
3: 1
5: 1
9 changes: 9 additions & 0 deletions prism-tests/functionality/import/mdp-deadlocks-fixed.tra
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
6 6 8
0 0 0 0.4 east
0 0 1 0.6 east
1 0 2 0.5 south
1 0 4 0.5 south
2 0 2 1
3 0 3 1
4 0 5 1 east
5 0 5 1
6 changes: 6 additions & 0 deletions prism-tests/functionality/import/mdp-deadlocks.tra
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
6 3 5
0 0 0 0.4 east
0 0 1 0.6 east
1 0 2 0.5 south
1 0 4 0.5 south
4 0 5 1 east
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-importmodel mdp-deadlocks.tra -exportmodel mdp-deadlocks-fixed.tra,lab -ex
1 change: 1 addition & 0 deletions prism-tests/functionality/import/mdp_simple_mod.auto
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-importmodel mdp_simple_mod.tra -exportmodel mdp_simple.tra
21 changes: 21 additions & 0 deletions prism-tests/functionality/import/mdp_simple_mod.tra
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
10 15 20
0 0 1 0.1 b
0 0 2 0.9 b
0 1 3 1 a
1 0 1 1
2 0 2 1
3 0 1 0.2 b
3 0 2 0.8 b
3 1 6 1 a
4 0 4 1
5 0 5 1
6 0 4 0.3 b
6 0 5 0.7 b
6 1 7 1 a
7 0 1 0.4 b
7 0 2 0.6 b
7 1 8 1 a
8 0 1 0.5 b
8 0 2 0.5 b
8 1 9 1 a
9 0 1 1
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
-mdp -importmodel robot.all robot.prism.props
-mdp -importmodel robot.all robot.prism.props -ex
-importmodel robot.all robot.prism.props
-importmodel robot.all robot.prism.props -ex
19 changes: 17 additions & 2 deletions prism-tests/functionality/import/robot.prism.props
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
// RESULT: 0.1
Pmax=? [ (G !"hazard")&(G F "goal1") ]
// RESULT: Infinity
Rmin=? [ F "goal1" ]

// RESULT: Infinity
Rmax=? [ F "goal1" ]

// RESULT: 19/15
Rmin=? [ F "goal2" ]

// RESULT: Infinity
Rmax=? [ F "goal2" ]

// RESULT: 1.2
Rmin=? [ F ("goal1"|"goal2") ]

// RESULT: 3.5
Rmax=? [ F ("goal1"|"goal2") ]
54 changes: 54 additions & 0 deletions prism/src/explicit/ChoiceActionsSimple.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
package explicit;

import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.function.IntUnaryOperator;

/**
* Explicit-state storage of the action labels attached to choices in a model.
Expand Down Expand Up @@ -154,6 +158,56 @@ public void setAction(int s, int i, Object action)

// Accessors

/**
* Produce a list of the action labels attached to choices/transitions.
* Absence of an action label is denoted by null,
* and null is also included in this list if there are unlabelled choices/transitions.
* @param numStates The number of states in the model
* @param counts A function giving the number of choices/transitions for each state
*/
public List<Object> findActionsUsed(int numStates, IntUnaryOperator counts)
{
if (actions == null) {
// Null storage means all choices/transitions are unlabelled
return Collections.singletonList(null);
} else {
LinkedHashSet<Object> allActions = new LinkedHashSet<>();
int numStatesStored = actions.size();
for (int s = 0; s < numStatesStored; s++) {
ArrayList<Object> list = actions.get(s);
if (list == null) {
// Null list means any/all choices/transitions are unlabelled for s
if (counts.applyAsInt(s) > 0) {
allActions.add(null);
}
} else {
allActions.addAll(list);
if (list.size() < counts.applyAsInt(s)) {
// Undersized list means there are unlabelled choices/transitions
allActions.add(null);
}
}
}
for (int s = numStatesStored; s < numStates; s++) {
// Missing list means any/all choices/transitions are unlabelled for s
if (counts.applyAsInt(s) > 0) {
allActions.add(null);
}
}
return new ArrayList<>(allActions);
}
}

/**
* Do all choices/transitions have empty (null) action labels?
*/
public boolean onlyNullActionUsed()
{
// NB: it's still possible that action storage has been created but has ended up all null
// We ignore this possibility
return actions == null;
}

/**
* Get the action label for choice {@code i} of state {@code s}.
*/
Expand Down
63 changes: 59 additions & 4 deletions prism/src/explicit/DTMC.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@
import java.io.FileWriter;
import java.io.IOException;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.PrimitiveIterator;
import java.util.PrimitiveIterator.OfInt;
Expand All @@ -43,12 +46,10 @@
import common.iterable.FunctionalIterator;
import common.iterable.PrimitiveIterable;
import common.iterable.Reducible;
import explicit.graphviz.Decorator;
import explicit.rewards.MCRewards;
import prism.ModelType;
import prism.Pair;
import prism.PrismException;
import prism.PrismLog;

/**
* Interface for classes that provide (read) access to an explicit-state DTMC.
Expand Down Expand Up @@ -92,7 +93,25 @@ default void exportToPrismLanguage(final String filename, int precision) throws
}

// Accessors


@Override
default List<Object> findActionsUsed()
{
// Find unique actions across all transitions
if (onlyNullActionUsed()) {
return Collections.singletonList(null);
}
LinkedHashSet<Object> actions = new LinkedHashSet<>();
int numStates = getNumStates();
for (int s = 0; s < numStates; s++) {
for (Iterator<Entry<Integer, Pair<Value, Object>>> transitions = getTransitionsAndActionsIterator(s); transitions.hasNext();) {
final Entry<Integer, Pair<Value, Object>> transition = transitions.next();
actions.add(transition.getValue().second);
}
}
return new ArrayList<>(actions);
}

/**
* Get an iterator over the transitions from state s.
*/
Expand All @@ -108,6 +127,42 @@ public default Iterator<Entry<Integer, Pair<Value, Object>>> getTransitionsAndAc
return Reducible.extend(transitions).map(transition -> attachAction(transition, null));
}

/**
* Get an iterator over the actions attached to transitions from state s.
*/
public default Iterator<Object> getActionsIterator(int s)
{
// Default implementation just assumes null actions
return Collections.nCopies(getNumTransitions(s), null).iterator();
}

/**
* Get an iterator over the indices of actions attached to transitions from state s.
* Indices are into the list given by {@link #getActions()},
* which includes null if there are unlabelled choices,
* so this method should always return values >= 0.
*/
public default PrimitiveIterator.OfInt getActionIndicesIterator(int s)
{
// Default implementation looks up indices from getActionsIterator
return new PrimitiveIterator.OfInt()
{
private final Iterator<Object> iter = getActionsIterator(s);

@Override
public boolean hasNext()
{
return iter.hasNext();
}

@Override
public int nextInt()
{
return actionIndex(iter.next());
}
};
}

/**
* Get an iterator over the transitions from state {@code s},
* after mapping probability values using the provided function.
Expand Down
Loading
Loading