Browse Source

Changed storage/evalation of constants in explicit model checker to fix some bugs and allow calls to checkExpression to handle constants.

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@3242 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Dave Parker 15 years ago
parent
commit
e3549400e6
  1. 3
      prism/src/explicit/PrismExplicit.java
  2. 39
      prism/src/explicit/StateModelChecker.java

3
prism/src/explicit/PrismExplicit.java

@ -124,8 +124,7 @@ public class PrismExplicit
mc.setLog(mainLog); mc.setLog(mainLog);
mc.setSettings(settings); mc.setSettings(settings);
mc.setModulesFile(modulesFile);
mc.setPropertiesFile(propertiesFile);
mc.setModulesFileAndPropertiesFile(modulesFile, propertiesFile);
mc.setPrecomp(settings.getBoolean(PrismSettings.PRISM_PRECOMPUTATION)); mc.setPrecomp(settings.getBoolean(PrismSettings.PRISM_PRECOMPUTATION));
s = settings.getString(PrismSettings.PRISM_TERM_CRIT); s = settings.getString(PrismSettings.PRISM_TERM_CRIT);

39
prism/src/explicit/StateModelChecker.java

@ -134,18 +134,17 @@ public class StateModelChecker
/** /**
* Set the attached model file (for e.g. reward structures when model checking) * Set the attached model file (for e.g. reward structures when model checking)
* and the attached properties file (for e.g. constants/labels when model checking)
*/ */
public void setModulesFile(ModulesFile modulesFile)
public void setModulesFileAndPropertiesFile(ModulesFile modulesFile, PropertiesFile propertiesFile)
{ {
this.modulesFile = modulesFile; this.modulesFile = modulesFile;
}
/**
* Set the attached properties file (for e.g. constants/labels when model checking)
*/
public void setPropertiesFile(PropertiesFile propertiesFile)
{
this.propertiesFile = propertiesFile; this.propertiesFile = propertiesFile;
// Get combined constant values from model/properties
constantValues = new Values();
constantValues.addValues(modulesFile.getConstantValues());
if (propertiesFile != null)
constantValues.addValues(propertiesFile.getConstantValues());
} }
// Set methods for flags/settings // Set methods for flags/settings
@ -324,19 +323,16 @@ public class StateModelChecker
boolean satInit = false; boolean satInit = false;
int numSat = 0; int numSat = 0;
// Get combined constant values from model/properties
constantValues = new Values();
constantValues.addValues(model.getConstantValues());
if (propertiesFile != null)
constantValues.addValues(propertiesFile.getConstantValues());
// Create storage for result // Create storage for result
result = new Result(); result = new Result();
// Remove labels from property, using combined label list (on a copy of the expression) // Remove labels from property, using combined label list (on a copy of the expression)
// This is done now so that we can handle labels nested below operators that are not
// handled natively by the model checker yet (just evaluate()ed in a loop).
expr = (Expression) expr.deepCopy().expandLabels(propertiesFile.getCombinedLabelList()); expr = (Expression) expr.deepCopy().expandLabels(propertiesFile.getCombinedLabelList());
// Also evaluate/replace any constants // Also evaluate/replace any constants
expr = (Expression) expr.replaceConstants(constantValues);
//expr = (Expression) expr.replaceConstants(constantValues);
// Do model checking and store result vector // Do model checking and store result vector
timer = System.currentTimeMillis(); timer = System.currentTimeMillis();
@ -476,7 +472,7 @@ public class StateModelChecker
*/ */
public Object checkExpression(Model model, Expression expr) throws PrismException public Object checkExpression(Model model, Expression expr) throws PrismException
{ {
Object res;
Object res = null;
// Binary ops // Binary ops
// (just "and" for now - more to come later) // (just "and" for now - more to come later)
@ -501,7 +497,11 @@ public class StateModelChecker
} }
// Anything else - just evaluate expression repeatedly // Anything else - just evaluate expression repeatedly
else if (expr.getType() instanceof TypeBool) {
else {
// Evaluate/replace any constants first
expr = (Expression) expr.replaceConstants(constantValues);
if (expr.getType() instanceof TypeBool) {
int numStates = model.getNumStates(); int numStates = model.getNumStates();
BitSet bs = new BitSet(numStates); BitSet bs = new BitSet(numStates);
List<State> statesList = model.getStatesList(); List<State> statesList = model.getStatesList();
@ -526,10 +526,11 @@ public class StateModelChecker
} }
res = sv; res = sv;
} }
}
// Anything else - error // Anything else - error
else {
/*else {
throw new PrismException("Couldn't check " + expr.getClass()); throw new PrismException("Couldn't check " + expr.getClass());
}
}*/
return res; return res;
} }

Loading…
Cancel
Save