diff --git a/prism/src/prism/StateValuesDV.java b/prism/src/prism/StateValuesDV.java index 1151fa98..53a3bf85 100644 --- a/prism/src/prism/StateValuesDV.java +++ b/prism/src/prism/StateValuesDV.java @@ -121,14 +121,16 @@ public class StateValuesDV implements StateValues values.setElement(i, d); } - // read from file - + /** + * Set the elements of this vector by reading them in from a file. + */ public void readFromFile(File file) throws PrismException { BufferedReader in; String s; int lineNum = 0, count = 0; double d; + int size = values.getSize(); try { // open file for reading @@ -138,9 +140,8 @@ public class StateValuesDV implements StateValues while (s != null) { s = s.trim(); if (!("".equals(s))) { - if (count + 1 > values.getSize()) - // TODO: move these error messages elsewhere? - throw new PrismException("Too many values in initial distribution (" + (count + 1) + ", not " + values.getSize() + ")"); + if (count + 1 > size) + throw new PrismException("Too many values in file \"" + file + "\" (more than " + size + ")"); d = Double.parseDouble(s); setElement(count, d); count++; @@ -150,8 +151,8 @@ public class StateValuesDV implements StateValues // close file in.close(); // check size - if (count < values.getSize()) - throw new PrismException("Too few values in initial distribution (" + count + ", not " + values.getSize() + ")"); + if (count < size) + throw new PrismException("Too few values in file \"" + file + "\" (" + count + ", not " + size + ")"); } catch (IOException e) { throw new PrismException("File I/O error reading from \"" + file + "\""); diff --git a/prism/src/prism/StateValuesMTBDD.java b/prism/src/prism/StateValuesMTBDD.java index dc58ce0d..63791fd5 100644 --- a/prism/src/prism/StateValuesMTBDD.java +++ b/prism/src/prism/StateValuesMTBDD.java @@ -134,14 +134,16 @@ public class StateValuesMTBDD implements StateValues values = JDD.ITE(dd, JDD.Constant(d), values); } - // read from file - + /** + * Set the elements of this vector by reading them in from a file. + */ public void readFromFile(File file) throws PrismException { BufferedReader in; String s; int lineNum = 0, count = 0; double d; + long size = model.getNumStates(); try { // open file for reading @@ -151,8 +153,8 @@ public class StateValuesMTBDD implements StateValues while (s != null) { s = s.trim(); if (!("".equals(s))) { - if (count + 1> model.getNumStates()) - throw new PrismException("Too many values in initial distribution (" + (count + 1) + ", not " + model.getNumStates() + ")"); + if (count + 1 > size) + throw new PrismException("Too many values in file \"" + file + "\" (more than " + size + ")"); d = Double.parseDouble(s); setElement(count, d); count++; @@ -162,8 +164,8 @@ public class StateValuesMTBDD implements StateValues // close file in.close(); // check size - if (count < model.getNumStates()) - throw new PrismException("Too few values in initial distribution (" + count + ", not " + model.getNumStates() + ")"); + if (count < size) + throw new PrismException("Too few values in file \"" + file + "\" (" + count + ", not " + size + ")"); } catch (IOException e) { throw new PrismException("File I/O error reading from \"" + file + "\"");