Browse Source

Do not build the model when doing transient probability computation via FAU (+ some code tidying).

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@7580 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Dave Parker 12 years ago
parent
commit
d9a49aba42
  1. 27
      prism/src/prism/Prism.java
  2. 19
      prism/src/prism/PrismCL.java

27
prism/src/prism/Prism.java

@ -1779,7 +1779,7 @@ public class Prism extends PrismComponent implements PrismSettingsListener
private void doBuildModel() throws PrismException private void doBuildModel() throws PrismException
{ {
long l; // timer long l; // timer
new Exception().printStackTrace();
// Clear any existing built model(s) // Clear any existing built model(s)
clearBuiltModel(); clearBuiltModel();
@ -3047,17 +3047,18 @@ public class Prism extends PrismComponent implements PrismSettingsListener
String strTime = currentModelType.continuousTime() ? Double.toString(time) : Integer.toString((int) time); String strTime = currentModelType.continuousTime() ? Double.toString(time) : Integer.toString((int) time);
mainLog.println("\nComputing transient probabilities (time = " + strTime + ")..."); mainLog.println("\nComputing transient probabilities (time = " + strTime + ")...");
// Build model, if necessary
buildModelIfRequired();
l = System.currentTimeMillis(); l = System.currentTimeMillis();
// FAU
if (currentModelType == ModelType.CTMC && settings.getString(PrismSettings.PRISM_TRANSIENT_METHOD).equals("Fast adaptive uniformisation")) { if (currentModelType == ModelType.CTMC && settings.getString(PrismSettings.PRISM_TRANSIENT_METHOD).equals("Fast adaptive uniformisation")) {
PrismModelExplorer modelExplorer = new PrismModelExplorer(getSimulator(), currentModulesFile); PrismModelExplorer modelExplorer = new PrismModelExplorer(getSimulator(), currentModulesFile);
FastAdaptiveUniformisation fau = new FastAdaptiveUniformisation(this, modelExplorer); FastAdaptiveUniformisation fau = new FastAdaptiveUniformisation(this, modelExplorer);
fau.setConstantValues(currentModulesFile.getConstantValues()); fau.setConstantValues(currentModulesFile.getConstantValues());
probsExpl = fau.doTransient(time, fileIn); probsExpl = fau.doTransient(time, fileIn);
} else if (!getExplicit()) {
}
// Symbolic
else if (!getExplicit()) {
buildModelIfRequired();
if (currentModelType == ModelType.DTMC) { if (currentModelType == ModelType.DTMC) {
mc = new ProbModelChecker(this, currentModel, null); mc = new ProbModelChecker(this, currentModel, null);
probs = ((ProbModelChecker) mc).doTransient((int) time, fileIn); probs = ((ProbModelChecker) mc).doTransient((int) time, fileIn);
@ -3065,7 +3066,10 @@ public class Prism extends PrismComponent implements PrismSettingsListener
mc = new StochModelChecker(this, currentModel, null); mc = new StochModelChecker(this, currentModel, null);
probs = ((StochModelChecker) mc).doTransient(time, fileIn); probs = ((StochModelChecker) mc).doTransient(time, fileIn);
} }
} else {
}
// Explicit
else {
buildModelIfRequired();
if (currentModelType == ModelType.DTMC) { if (currentModelType == ModelType.DTMC) {
throw new PrismException("Not implemented yet"); throw new PrismException("Not implemented yet");
} else if (currentModelType == ModelType.CTMC) { } else if (currentModelType == ModelType.CTMC) {
@ -3150,11 +3154,9 @@ public class Prism extends PrismComponent implements PrismSettingsListener
mainLog.printSeparator(); mainLog.printSeparator();
mainLog.println("\nComputing transient probabilities (time = " + time + ")..."); mainLog.println("\nComputing transient probabilities (time = " + time + ")...");
// Build model, if necessary
buildModelIfRequired();
l = System.currentTimeMillis(); l = System.currentTimeMillis();
// FAU
if (currentModelType == ModelType.CTMC && settings.getString(PrismSettings.PRISM_TRANSIENT_METHOD).equals("Fast adaptive uniformisation")) { if (currentModelType == ModelType.CTMC && settings.getString(PrismSettings.PRISM_TRANSIENT_METHOD).equals("Fast adaptive uniformisation")) {
// For FAU, we don't do computation incrementally // For FAU, we don't do computation incrementally
PrismModelExplorer modelExplorer = new PrismModelExplorer(getSimulator(), currentModulesFile); PrismModelExplorer modelExplorer = new PrismModelExplorer(getSimulator(), currentModulesFile);
@ -3162,7 +3164,9 @@ public class Prism extends PrismComponent implements PrismSettingsListener
fau.setConstantValues(currentModulesFile.getConstantValues()); fau.setConstantValues(currentModulesFile.getConstantValues());
probsExpl = fau.doTransient(timeDouble, fileIn); probsExpl = fau.doTransient(timeDouble, fileIn);
} }
// Symbolic
else if (!getExplicit()) { else if (!getExplicit()) {
buildModelIfRequired();
if (currentModelType.continuousTime()) { if (currentModelType.continuousTime()) {
StochModelChecker mc = new StochModelChecker(this, currentModel, null); StochModelChecker mc = new StochModelChecker(this, currentModel, null);
if (i == 0) { if (i == 0) {
@ -3178,7 +3182,10 @@ public class Prism extends PrismComponent implements PrismSettingsListener
} }
probs = ((ProbModelChecker) mc).doTransient(timeInt - initTimeInt, initDist); probs = ((ProbModelChecker) mc).doTransient(timeInt - initTimeInt, initDist);
} }
} else {
}
// Explicit
else {
buildModelIfRequired();
if (currentModelType.continuousTime()) { if (currentModelType.continuousTime()) {
CTMCModelChecker mc = new CTMCModelChecker(this); CTMCModelChecker mc = new CTMCModelChecker(this);
if (i == 0) { if (i == 0) {

19
prism/src/prism/PrismCL.java

@ -356,7 +356,7 @@ public class PrismCL implements PrismModelListener
// store result of model checking // store result of model checking
results[j].setResult(definedMFConstants, definedPFConstants, res.getResult()); results[j].setResult(definedMFConstants, definedPFConstants, res.getResult());
// if a counterexample was generated, display it // if a counterexample was generated, display it
Object cex = res.getCounterexample(); Object cex = res.getCounterexample();
if (cex != null) { if (cex != null) {
@ -386,7 +386,7 @@ public class PrismCL implements PrismModelListener
error(e.getMessage()); error(e.getMessage());
} }
} }
// if required, check result against expected value // if required, check result against expected value
if (test) { if (test) {
try { try {
@ -419,7 +419,7 @@ public class PrismCL implements PrismModelListener
} }
// Explicitly request a build if necessary // Explicitly request a build if necessary
if (propertiesToCheck.size() == 0 && !simpath && !nobuild && prism.modelCanBeBuilt() && !prism.modelIsBuilt()) {
if (propertiesToCheck.size() == 0 && !steadystate && !dotransient && !simpath && !nobuild && prism.modelCanBeBuilt() && !prism.modelIsBuilt()) {
try { try {
prism.buildModel(); prism.buildModel();
} catch (PrismException e) { } catch (PrismException e) {
@ -775,7 +775,7 @@ public class PrismCL implements PrismModelListener
error(e.getMessage()); error(e.getMessage());
} }
} }
// export BSCCs to a file // export BSCCs to a file
if (exportbsccs) { if (exportbsccs) {
try { try {
@ -1124,18 +1124,17 @@ public class PrismCL implements PrismModelListener
s = args[++i]; s = args[++i];
// Assume use of : to split filename/options but check for , if : not found // Assume use of : to split filename/options but check for , if : not found
// (this was the old notation) // (this was the old notation)
String halves[] = splitFilesAndOptions(s);
String halves[] = splitFilesAndOptions(s);
if (halves[1].length() == 0 && halves[0].indexOf(',') > -1) { if (halves[1].length() == 0 && halves[0].indexOf(',') > -1) {
int comma = halves[0].indexOf(','); int comma = halves[0].indexOf(',');
halves[1] = halves[0].substring(comma + 1);
halves[1] = halves[0].substring(comma + 1);
halves[0] = halves[0].substring(0, comma); halves[0] = halves[0].substring(0, comma);
} }
exportResultsFilename = halves[0]; exportResultsFilename = halves[0];
String ss[] = halves[1].split(","); String ss[] = halves[1].split(",");
for (j = 0; j < ss.length; j++) { for (j = 0; j < ss.length; j++) {
if (ss[j].equals("")) { if (ss[j].equals("")) {
}
else if (ss[j].equals("csv"))
} else if (ss[j].equals("csv"))
exportresultscsv = true; exportresultscsv = true;
else if (ss[j].equals("matrix")) else if (ss[j].equals("matrix"))
exportresultsmatrix = true; exportresultsmatrix = true;
@ -1926,7 +1925,7 @@ public class PrismCL implements PrismModelListener
} }
} }
} }
// plug in basename for -exportmodel switch if needed // plug in basename for -exportmodel switch if needed
if (exportModelNoBasename) { if (exportModelNoBasename) {
String modelFileBasename = modelFilename; String modelFileBasename = modelFilename;
@ -2155,7 +2154,7 @@ public class PrismCL implements PrismModelListener
// Remove "-" from start of switch, in case present (it shouldn't be really) // Remove "-" from start of switch, in case present (it shouldn't be really)
if (sw.charAt(0) == '-') if (sw.charAt(0) == '-')
sw = sw.substring(1); sw = sw.substring(1);
// -const // -const
if (sw.equals("const")) { if (sw.equals("const")) {
mainLog.println("Switch: -const <vals>\n"); mainLog.println("Switch: -const <vals>\n");

Loading…
Cancel
Save