Browse Source

Imported tra (and other explicit) files can have blank lines.

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@1669 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Dave Parker 16 years ago
parent
commit
ee3580d805
  1. 25
      prism/src/prism/Explicit2MTBDD.java

25
prism/src/prism/Explicit2MTBDD.java

@ -170,10 +170,12 @@ public class Explicit2MTBDD
s = in.readLine(); lineNum++; s = in.readLine(); lineNum++;
numStates = 0; numStates = 0;
while (s != null) { while (s != null) {
// skip blank lines
s = s.trim();
if (s.length() > 0) {
// increment state count // increment state count
numStates++; numStates++;
// split string // split string
s = s.trim();
s = s.substring(s.indexOf('(')+1, s.indexOf(')')); s = s.substring(s.indexOf('(')+1, s.indexOf(')'));
ss = s.split(","); ss = s.split(",");
if (ss.length != numVars) throw new PrismException("wrong number of variables"); if (ss.length != numVars) throw new PrismException("wrong number of variables");
@ -195,6 +197,8 @@ public class Explicit2MTBDD
} }
} }
} }
}
// read next line
s = in.readLine(); lineNum++; s = in.readLine(); lineNum++;
} }
// compute variable ranges // compute variable ranges
@ -300,7 +304,9 @@ public class Explicit2MTBDD
// read remaining lines // read remaining lines
s = in.readLine(); lineNum++; s = in.readLine(); lineNum++;
while (s != null) { while (s != null) {
// skip blank lines
s = s.trim(); s = s.trim();
if (s.length() > 0) {
// split into two parts // split into two parts
ss = s.split(":"); ss = s.split(":");
// determine which state this line describes // determine which state this line describes
@ -321,6 +327,8 @@ public class Explicit2MTBDD
else throw new PrismException("(invalid Boolean value \""+ss[j]+"\") "); else throw new PrismException("(invalid Boolean value \""+ss[j]+"\") ");
} }
} }
}
// read next line
s = in.readLine(); lineNum++; s = in.readLine(); lineNum++;
} }
// close file // close file
@ -486,10 +494,12 @@ public class Explicit2MTBDD
maxNumChoices = 0; maxNumChoices = 0;
while (s != null) { while (s != null) {
s = s.trim(); s = s.trim();
if (s.length() > 0) {
ss = s.split(" "); ss = s.split(" ");
if (ss.length < 4 || ss.length > 5) throw new PrismException(""); if (ss.length < 4 || ss.length > 5) throw new PrismException("");
j = Integer.parseInt(ss[1]); j = Integer.parseInt(ss[1]);
if (j+1 > maxNumChoices) maxNumChoices = j+1; if (j+1 > maxNumChoices) maxNumChoices = j+1;
}
s = in.readLine(); lineNum++; s = in.readLine(); lineNum++;
} }
// close file // close file
@ -698,9 +708,11 @@ public class Explicit2MTBDD
// read remaining lines // read remaining lines
s = in.readLine(); lineNum++; s = in.readLine(); lineNum++;
while (s != null) { while (s != null) {
// skip blank lines
s = s.trim();
if (s.length() > 0) {
foundReward = false; foundReward = false;
// parse line, split into parts // parse line, split into parts
s = s.trim();
ss = s.split(" "); ss = s.split(" ");
// case for dtmcs/ctmcs... // case for dtmcs/ctmcs...
if (modelType != ModelType.MDP) { if (modelType != ModelType.MDP) {
@ -758,6 +770,7 @@ public class Explicit2MTBDD
transRewards = JDD.Apply(JDD.PLUS, transRewards, JDD.Apply(JDD.TIMES, JDD.Constant(x), tmp)); transRewards = JDD.Apply(JDD.PLUS, transRewards, JDD.Apply(JDD.TIMES, JDD.Constant(x), tmp));
} }
JDD.Deref(tmp); JDD.Deref(tmp);
}
// read next line // read next line
s = in.readLine(); lineNum++; s = in.readLine(); lineNum++;
} }
@ -804,8 +817,10 @@ public class Explicit2MTBDD
s = in.readLine(); lineNum++; s = in.readLine(); lineNum++;
numStates = 0; numStates = 0;
while (s != null) { while (s != null) {
// split string
// skip blank lines
s = s.trim(); s = s.trim();
if (s.length() > 0) {
// split string
ss = s.split(":"); ss = s.split(":");
s1 = ss[0].trim(); s1 = ss[0].trim();
s2 = ss[1].trim(); s2 = ss[1].trim();
@ -833,6 +848,7 @@ public class Explicit2MTBDD
JDD.Deref(tmp); JDD.Deref(tmp);
} }
} }
}
// read next line // read next line
s = in.readLine(); lineNum++; s = in.readLine(); lineNum++;
} }
@ -874,7 +890,9 @@ public class Explicit2MTBDD
// read remaining lines // read remaining lines
s = in.readLine(); lineNum++; s = in.readLine(); lineNum++;
while (s != null) { while (s != null) {
// skip blank lines
s = s.trim(); s = s.trim();
if (s.length() > 0) {
// split into two/three parts // split into two/three parts
ss = s.split(":"); ss = s.split(":");
// determine which state this line describes // determine which state this line describes
@ -899,6 +917,7 @@ public class Explicit2MTBDD
// add it into mtbdd for state rewards // add it into mtbdd for state rewards
stateRewards = JDD.Apply(JDD.PLUS, stateRewards, JDD.Apply(JDD.TIMES, JDD.Constant(d), tmp)); stateRewards = JDD.Apply(JDD.PLUS, stateRewards, JDD.Apply(JDD.TIMES, JDD.Constant(d), tmp));
} }
}
// read next line // read next line
s = in.readLine(); lineNum++; s = in.readLine(); lineNum++;
} }

Loading…
Cancel
Save