Browse Source

Explicit model export matches PRISM export better.

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@1849 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Dave Parker 16 years ago
parent
commit
ae4e24aa71
  1. 9
      prism/src/explicit/DTMCSimple.java
  2. 9
      prism/src/explicit/MDPSimple.java
  3. 9
      prism/src/explicit/STPG.java

9
prism/src/explicit/DTMCSimple.java

@ -307,15 +307,24 @@ public class DTMCSimple extends ModelSimple implements DTMC
int i;
String filename = null;
FileWriter out;
TreeMap<Integer, Double> sorted;
try {
// Output transitions to .tra file
filename = baseFilename + ".tra";
out = new FileWriter(filename);
out.write(numStates + " " + numTransitions + "\n");
sorted = new TreeMap<Integer, Double>();
for (i = 0; i < numStates; i++) {
// Extract transitions and sort by destination state index (to match PRISM-exported files)
for (Map.Entry<Integer, Double> e : trans.get(i)) {
sorted.put(e.getKey(), e.getValue());
}
// Print out (sorted) transitions
for (Map.Entry<Integer, Double> e : sorted.entrySet()) {
// Note use of PrismUtils.formatDouble to match PRISM-exported files
out.write(i + " " + e.getKey() + " " + PrismUtils.formatDouble(e.getValue()) + "\n");
}
sorted.clear();
}
out.close();
// Output transition rewards to .trew file

9
prism/src/explicit/MDPSimple.java

@ -404,18 +404,27 @@ public class MDPSimple extends ModelSimple implements MDP
int i, j;
String filename = null;
FileWriter out;
TreeMap<Integer, Double> sorted;
try {
// Output transitions to .tra file
filename = baseFilename + ".tra";
out = new FileWriter(filename);
out.write(numStates + " " + numDistrs + " " + numTransitions + "\n");
sorted = new TreeMap<Integer, Double>();
for (i = 0; i < numStates; i++) {
j = -1;
for (Distribution distr : trans.get(i)) {
j++;
// Extract transitions and sort by destination state index (to match PRISM-exported files)
for (Map.Entry<Integer, Double> e : distr) {
sorted.put(e.getKey(), e.getValue());
}
// Print out (sorted) transitions
for (Map.Entry<Integer, Double> e : sorted.entrySet()) {
// Note use of PrismUtils.formatDouble to match PRISM-exported files
out.write(i + " " + j + " " + e.getKey() + " " + PrismUtils.formatDouble(e.getValue()) + "\n");
}
sorted.clear();
}
}
out.close();

9
prism/src/explicit/STPG.java

@ -582,11 +582,13 @@ public class STPG extends ModelSimple
int i, j, k;
String filename = null;
FileWriter out;
TreeMap<Integer, Double> sorted;
try {
// Output transitions to .tra file
filename = baseFilename + ".tra";
out = new FileWriter(filename);
out.write(numStates + " " + numDistrSets + " " + numDistrs + " " + numTransitions + "\n");
sorted = new TreeMap<Integer, Double>();
for (i = 0; i < numStates; i++) {
j = -1;
for (DistributionSet distrs : trans.get(i)) {
@ -594,10 +596,17 @@ public class STPG extends ModelSimple
k = -1;
for (Distribution distr : distrs) {
k++;
// Extract transitions and sort by destination state index (to match PRISM-exported files)
for (Map.Entry<Integer, Double> e : distr) {
sorted.put(e.getKey(), e.getValue());
}
// Print out (sorted) transitions
for (Map.Entry<Integer, Double> e : distr) {
// Note use of PrismUtils.formatDouble to match PRISM-exported files
out.write(i + " " + j + " " + k + " " + e.getKey() + " "
+ PrismUtils.formatDouble(e.getValue()) + "\n");
}
sorted.clear();
}
}
}

Loading…
Cancel
Save