Browse Source

Addition of -extrareachinfo option (and rearrangement of options in Modules2MTBDD).

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@545 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Dave Parker 18 years ago
parent
commit
0143cef09e
  1. 4
      prism/include/PrismMTBDD.h
  2. 22
      prism/src/mtbdd/PM_Reachability.cc
  3. 7
      prism/src/mtbdd/PrismMTBDD.java
  4. 91
      prism/src/prism/Modules2MTBDD.java
  5. 22
      prism/src/prism/Prism.java
  6. 7
      prism/src/prism/PrismCL.java
  7. 4
      prism/src/prism/PrismSettings.java

4
prism/include/PrismMTBDD.h

@ -98,10 +98,10 @@ JNIEXPORT jstring JNICALL Java_mtbdd_PrismMTBDD_PM_1GetErrorMessage
/* /*
* Class: mtbdd_PrismMTBDD * Class: mtbdd_PrismMTBDD
* Method: PM_Reachability * Method: PM_Reachability
* Signature: (JJIJIJ)J
* Signature: (JJIJIJI)J
*/ */
JNIEXPORT jlong JNICALL Java_mtbdd_PrismMTBDD_PM_1Reachability JNIEXPORT jlong JNICALL Java_mtbdd_PrismMTBDD_PM_1Reachability
(JNIEnv *, jclass, jlong, jlong, jint, jlong, jint, jlong);
(JNIEnv *, jclass, jlong, jlong, jint, jlong, jint, jlong, jint);
/* /*
* Class: mtbdd_PrismMTBDD * Class: mtbdd_PrismMTBDD

22
prism/src/mtbdd/PM_Reachability.cc

@ -46,7 +46,8 @@ jlong __pointer rv, // row vars
jint num_rvars, jint num_rvars,
jlong __pointer cv, // col vars jlong __pointer cv, // col vars
jint num_cvars, jint num_cvars,
jlong __pointer s // start state
jlong __pointer s, // start state
jint info // how much diagnostic info to display (0=none, 1=some)
) )
{ {
DdNode *trans01 = jlong_to_DdNode(t01); // 0-1 trans matrix DdNode *trans01 = jlong_to_DdNode(t01); // 0-1 trans matrix
@ -76,9 +77,14 @@ jlong __pointer s // start state
// PM_PrintToMainLog(env, "Reachability:\n"); // PM_PrintToMainLog(env, "Reachability:\n");
while (!done) { while (!done) {
iters++; iters++;
// PM_PrintToMainLog(env, "Iteration %d: ", iters);
// PM_PrintToMainLog(env, "%0.f (%d) ", DD_GetNumMinterms(ddman, reach, num_rvars), DD_GetNumNodes(ddman, reach));
// start2 = util_cpu_time();
// output info on progress
if (info > 0) {
PM_PrintToMainLog(env, "Iteration %d:", iters);
PM_PrintToMainLog(env, " %0.f states", DD_GetNumMinterms(ddman, reach, num_rvars));
PM_PrintToMainLog(env, " (%d nodes)", DD_GetNumNodes(ddman, reach));
start2 = util_cpu_time();
}
// PM_PrintToMainLog(env, "[permute(%d)", DD_GetNumNodes(ddman, reach)); // PM_PrintToMainLog(env, "[permute(%d)", DD_GetNumNodes(ddman, reach));
// start3 = util_cpu_time(); // start3 = util_cpu_time();
@ -112,8 +118,12 @@ jlong __pointer s // start state
} }
Cudd_RecursiveDeref(ddman, reach); Cudd_RecursiveDeref(ddman, reach);
reach = tmp; reach = tmp;
// stop = util_cpu_time();
// PM_PrintToMainLog(env, " = %f\n", (double)(stop - start2)/1000);
// output info on progress
if (info > 0) {
stop = util_cpu_time();
PM_PrintToMainLog(env, " (%.2f seconds)\n", (double)(stop - start2)/1000);
}
} }
reach = DD_PermuteVariables(ddman, reach, cvars, rvars, num_cvars); reach = DD_PermuteVariables(ddman, reach, cvars, rvars, num_cvars);
// ...to here // ...to here

7
prism/src/mtbdd/PrismMTBDD.java

@ -178,10 +178,11 @@ public class PrismMTBDD
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// reachability // reachability
private static native long PM_Reachability(long trans01, long rv, int nrv, long cv, int ncv, long start);
public static JDDNode Reachability(JDDNode trans01, JDDVars rows, JDDVars cols, JDDNode start)// throws PrismException
private static native long PM_Reachability(long trans01, long rv, int nrv, long cv, int ncv, long start, int info);
public static JDDNode Reachability(JDDNode trans01, JDDVars rows, JDDVars cols, JDDNode start) { return Reachability(trans01, rows, cols, start, 0); }
public static JDDNode Reachability(JDDNode trans01, JDDVars rows, JDDVars cols, JDDNode start, int info)// throws PrismException
{ {
long ptr = PM_Reachability(trans01.ptr(), rows.array(), rows.n(), cols.array(), cols.n(), start.ptr());
long ptr = PM_Reachability(trans01.ptr(), rows.array(), rows.n(), cols.array(), cols.n(), start.ptr(), info);
//if (ptr == 0) throw new PrismException(getErrorMessage()); //if (ptr == 0) throw new PrismException(getErrorMessage());
return new JDDNode(ptr); return new JDDNode(ptr);
} }

91
prism/src/prism/Modules2MTBDD.java

@ -42,19 +42,13 @@ public class Modules2MTBDD
// constants // constants
private static final double ACCEPTABLE_ROUND_OFF = 10e-6; // when checking for sums to 1 private static final double ACCEPTABLE_ROUND_OFF = 10e-6; // when checking for sums to 1
// Prism object
private Prism prism;
// logs // logs
private PrismLog mainLog; // main log private PrismLog mainLog; // main log
private PrismLog techLog; // tech log private PrismLog techLog; // tech log
// flags/settings
private boolean doReach = true; // by default, do reachability (sometimes might want to skip it though)
private boolean doProbChecks; // perform checks on probs/rates? (sum to one, etc.)
private boolean extraDDInfo; // display extra info about DDs
// the following two settings are now surplus to requirements
// because of the way nondeterminism is handled in the mtbdd construction
private int ordering = 1; // mtbdd variable ordering (1=top, 2=middle) (default: 1)
private int construction = 3; // mtbdd construction method (1=dup, 3=0) (default: 3)
// ModulesFile object to store syntax tree from parser // ModulesFile object to store syntax tree from parser
private ModulesFile modulesFile; private ModulesFile modulesFile;
@ -153,73 +147,14 @@ public class Modules2MTBDD
// constructor // constructor
public Modules2MTBDD(PrismLog log1, PrismLog log2, ModulesFile mf)
public Modules2MTBDD(Prism p, ModulesFile mf)
{ {
mainLog = log1;
techLog = log2;
prism = p;
mainLog = p.getMainLog();
techLog = p.getTechLog();
modulesFile = mf; modulesFile = mf;
} }
// set options (generic)
public void setOption(String option, boolean b)
{
if (option.equals("doreach")) {
doReach = b;
}
else if (option.equals("doprobchecks")) {
doProbChecks = b;
}
else if (option.equals("extraddinfo")) {
extraDDInfo = b;
}
else {
mainLog.println("\nWarning: option \""+option+"\" not supported by Modules2MTBDD translator.");
}
}
public void setOption(String option, int i)
{
if (option.equals("ordering")) {
setOrdering(i);
}
else if (option.equals("construction")) {
setConstruction(i);
}
else {
mainLog.println("\nWarning: option \""+option+"\" not supported by Modules2MTBDD translator.");
}
}
public void setOption(String option, String s)
{
mainLog.println("\nWarning: option \""+option+"\" not supported by Modules2MTBDD translator.");
}
// set flags/settings
private void setOrdering(int i)
{
if (i > 0) {
ordering = i;
}
else {
// default to 1
ordering = 1;
}
}
private void setConstruction(int i)
{
if (i > 0) {
construction = i;
}
else {
// default to 3
construction = 3;
}
}
// main method - translate // main method - translate
public Model translate() throws PrismException public Model translate() throws PrismException
@ -284,14 +219,14 @@ public class Modules2MTBDD
// JDD.Deref(tmp); // JDD.Deref(tmp);
// Print some info (if extraddinfo flag on) // Print some info (if extraddinfo flag on)
if (extraDDInfo) {
if (prism.getExtraDDInfo()) {
mainLog.print("Transition matrix (pre-reachability): "); mainLog.print("Transition matrix (pre-reachability): ");
mainLog.print(JDD.GetNumNodes(trans) + " nodes ("); mainLog.print(JDD.GetNumNodes(trans) + " nodes (");
mainLog.print(JDD.GetNumTerminals(trans) + " terminal)\n"); mainLog.print(JDD.GetNumTerminals(trans) + " terminal)\n");
} }
// do reachability (or not!) // do reachability (or not!)
if (doReach) {
if (prism.getDoReach()) {
doReachability(); doReachability();
} }
else { else {
@ -363,7 +298,7 @@ public class Modules2MTBDD
int ddVarsUsed = 0; int ddVarsUsed = 0;
ddVarNames = new Vector(); ddVarNames = new Vector();
switch (ordering) {
switch (prism.getOrdering()) {
case 1: case 1:
// ordering: (a ... a) (s ... s) (l ... l) (r c ... r c) // ordering: (a ... a) (s ... s) (l ... l) (r c ... r c)
@ -1413,7 +1348,7 @@ public class Modules2MTBDD
throw new PrismException(s); throw new PrismException(s);
} }
// only do remaining checks if 'doprobchecks' flag is set // only do remaining checks if 'doprobchecks' flag is set
if (doProbChecks) {
if (prism.getDoProbChecks()) {
// sum probs/rates in updates // sum probs/rates in updates
JDD.Ref(upDDs[l]); JDD.Ref(upDDs[l]);
tmp = JDD.SumAbstract(upDDs[l], moduleDDColVars[m]); tmp = JDD.SumAbstract(upDDs[l], moduleDDColVars[m]);
@ -2036,11 +1971,11 @@ public class Modules2MTBDD
// compute reachable states // compute reachable states
mainLog.print("\nComputing reachable states...\n"); mainLog.print("\nComputing reachable states...\n");
reach = PrismMTBDD.Reachability(tmp, allDDRowVars, allDDColVars, start);
reach = PrismMTBDD.Reachability(tmp, allDDRowVars, allDDColVars, start, prism.getExtraReachInfo()?1:0);
JDD.Deref(tmp); JDD.Deref(tmp);
// Print some info (if extraddinfo flag on) // Print some info (if extraddinfo flag on)
if (extraDDInfo) {
if (prism.getExtraDDInfo()) {
mainLog.print("Reach: " + JDD.GetNumNodes(reach) + " nodes\n"); mainLog.print("Reach: " + JDD.GetNumNodes(reach) + " nodes\n");
} }
// remove non-reachable states from transition matrix // remove non-reachable states from transition matrix

22
prism/src/prism/Prism.java

@ -89,17 +89,18 @@ public class Prism implements PrismSettingsListener
private PrismSettings settings; private PrismSettings settings;
// A few miscellaneous options (i.e. defunct/hidden/undocumented/etc.) // A few miscellaneous options (i.e. defunct/hidden/undocumented/etc.)
// See constructor below for default values
private boolean doReach; // do reachability? (sometimes might want to skip it) private boolean doReach; // do reachability? (sometimes might want to skip it)
private boolean bsccComp; // do bscc computation before steady-state? private boolean bsccComp; // do bscc computation before steady-state?
// mtbdd construction method
// MTBDD construction method (NOW DEFUNCT)
// 1 - use with ordering 1: nondet vars form a tree at the top // 1 - use with ordering 1: nondet vars form a tree at the top
// 3 - use with ordering 2: zero for nonexistant bits // 3 - use with ordering 2: zero for nonexistant bits
// nb: option 2 removed because it was stupid // nb: option 2 removed because it was stupid
private int construction; private int construction;
// mtbdd variable ordering
// MTBDD variable ordering
// 1 - (s ... s) (l ... l) (r c ... r c) // 1 - (s ... s) (l ... l) (r c ... r c)
// 2 - (s l ... l r c ... r c) (s l ... l r c ... r c) ... // 2 - (s l ... l r c ... r c) (s l ... l r c ... r c) ...
private int ordering; private int ordering;
@ -168,7 +169,7 @@ public class Prism implements PrismSettingsListener
// default values for miscellaneous options // default values for miscellaneous options
doReach = true; doReach = true;
bsccComp = true; bsccComp = true;
construction = 0;
construction = 3;
ordering = 1; ordering = 1;
} }
@ -293,6 +294,11 @@ public class Prism implements PrismSettingsListener
settings.set(PrismSettings.PRISM_EXTRA_DD_INFO, b); settings.set(PrismSettings.PRISM_EXTRA_DD_INFO, b);
} }
public void setExtraReachInfo(boolean b) throws PrismException
{
settings.set(PrismSettings.PRISM_EXTRA_REACH_INFO, b);
}
// set methods for miscellaneous options // set methods for miscellaneous options
public void setDoReach(boolean b) throws PrismException public void setDoReach(boolean b) throws PrismException
@ -374,6 +380,9 @@ public class Prism implements PrismSettingsListener
public boolean getExtraDDInfo() public boolean getExtraDDInfo()
{ return settings.getBoolean(PrismSettings.PRISM_EXTRA_DD_INFO); } { return settings.getBoolean(PrismSettings.PRISM_EXTRA_DD_INFO); }
public boolean getExtraReachInfo()
{ return settings.getBoolean(PrismSettings.PRISM_EXTRA_REACH_INFO); }
public int getNumSORLevels() public int getNumSORLevels()
{ return settings.getInteger(PrismSettings.PRISM_NUM_SOR_LEVELS); } { return settings.getInteger(PrismSettings.PRISM_NUM_SOR_LEVELS); }
@ -827,12 +836,7 @@ public class Prism implements PrismSettingsListener
mainLog.print("...\n"); mainLog.print("...\n");
// create translator // create translator
mod2mtbdd = new Modules2MTBDD(mainLog, techLog, modulesFile);
mod2mtbdd.setOption("ordering", getOrdering());
mod2mtbdd.setOption("construction", getConstruction());
mod2mtbdd.setOption("doreach", getDoReach());
mod2mtbdd.setOption("doprobchecks", getDoProbChecks());
mod2mtbdd.setOption("extraddinfo", getExtraDDInfo());
mod2mtbdd = new Modules2MTBDD(this, modulesFile);
// build model // build model
l = System.currentTimeMillis(); l = System.currentTimeMillis();

7
prism/src/prism/PrismCL.java

@ -1168,6 +1168,10 @@ public class PrismCL
else if (sw.equals("extraddinfo")) { else if (sw.equals("extraddinfo")) {
prism.setExtraDDInfo(true); prism.setExtraDDInfo(true);
} }
// extra reach info on
else if (sw.equals("extrareachinfo")) {
prism.setExtraReachInfo(true);
}
// precomputation algs off // precomputation algs off
else if (sw.equals("nopre")) { else if (sw.equals("nopre")) {
prism.setPrecomp(false); prism.setPrecomp(false);
@ -1464,7 +1468,7 @@ public class PrismCL
mainLog.println("-exportresults <file> .......... Export the results of model checking to a file"); mainLog.println("-exportresults <file> .......... Export the results of model checking to a file");
mainLog.println("-exporttrans <file> ............ Export the transition matrix to a file"); mainLog.println("-exporttrans <file> ............ Export the transition matrix to a file");
mainLog.println("-exportstaterewards <file> ..... Export the state rewards vector to a file"); mainLog.println("-exportstaterewards <file> ..... Export the state rewards vector to a file");
mainLog.println("-exporttransrewards <file> ...... Export the transition rewards matrix to a file");
mainLog.println("-exporttransrewards <file> ..... Export the transition rewards matrix to a file");
mainLog.println("-exportstates <file> ........... Export the list of reachable states to a file"); mainLog.println("-exportstates <file> ........... Export the list of reachable states to a file");
mainLog.println("-exportlabels <file> ........... Export the list of labels and satisfying states to a file"); mainLog.println("-exportlabels <file> ........... Export the list of labels and satisfying states to a file");
mainLog.println("-exportmatlab .................. When exporting matrices/vectors/labels/etc., use Matlab format"); mainLog.println("-exportmatlab .................. When exporting matrices/vectors/labels/etc., use Matlab format");
@ -1499,6 +1503,7 @@ public class PrismCL
mainLog.println(); mainLog.println();
mainLog.println("-verbose (or -v) ............... Verbose mode: print out state lists and probability vectors"); mainLog.println("-verbose (or -v) ............... Verbose mode: print out state lists and probability vectors");
mainLog.println("-extraddinfo ................... Display extra info about some (MT)BDDs"); mainLog.println("-extraddinfo ................... Display extra info about some (MT)BDDs");
mainLog.println("-extrareachinfo ................ Display extra info about progress of reachability");
mainLog.println("-nopre ......................... Skip precomputation algorithms"); mainLog.println("-nopre ......................... Skip precomputation algorithms");
mainLog.println("-fair .......................... Use fairness (when model checking PCTL on MDPs)"); mainLog.println("-fair .......................... Use fairness (when model checking PCTL on MDPs)");
mainLog.println("-nofair ........................ Don't use fairness (when model checking PCTL on MDPs) [default]"); mainLog.println("-nofair ........................ Don't use fairness (when model checking PCTL on MDPs) [default]");

4
prism/src/prism/PrismSettings.java

@ -88,6 +88,7 @@ public class PrismSettings implements Observer
public static final String PRISM_SOR_MAX_MEM = "prism.SORMaxMem";//"prism.hybridSORMaxMemory"; public static final String PRISM_SOR_MAX_MEM = "prism.SORMaxMem";//"prism.hybridSORMaxMemory";
public static final String PRISM_DO_SS_DETECTION = "prism.doSSDetect"; public static final String PRISM_DO_SS_DETECTION = "prism.doSSDetect";
public static final String PRISM_EXTRA_DD_INFO = "prism.extraDDInfo"; public static final String PRISM_EXTRA_DD_INFO = "prism.extraDDInfo";
public static final String PRISM_EXTRA_REACH_INFO = "prism.extraReachInfo";
//GUI Model //GUI Model
public static final String MODEL_AUTO_PARSE = "model.autoParse"; public static final String MODEL_AUTO_PARSE = "model.autoParse";
@ -180,7 +181,8 @@ public class PrismSettings implements Observer
{ INTEGER_TYPE, PRISM_NUM_SOR_LEVELS, "Hybrid GS levels", "3.0", new Integer(-1), "-1,", "Number of MTBDD levels descended for hybrid engine data structures block division with GS/SOR." }, { INTEGER_TYPE, PRISM_NUM_SOR_LEVELS, "Hybrid GS levels", "3.0", new Integer(-1), "-1,", "Number of MTBDD levels descended for hybrid engine data structures block division with GS/SOR." },
{ INTEGER_TYPE, PRISM_SOR_MAX_MEM, "Hybrid GS memory (KB)", "3.0", new Integer(1024), "0,", "Maximum memory usage for hybrid engine data structures block division with GS/SOR (KB)." }, { INTEGER_TYPE, PRISM_SOR_MAX_MEM, "Hybrid GS memory (KB)", "3.0", new Integer(1024), "0,", "Maximum memory usage for hybrid engine data structures block division with GS/SOR (KB)." },
{ BOOLEAN_TYPE, PRISM_DO_SS_DETECTION, "Use steady-state detection", "3.0", new Boolean(true), "0,", "Use steady-state detection during CTMC transient probability computation." }, { BOOLEAN_TYPE, PRISM_DO_SS_DETECTION, "Use steady-state detection", "3.0", new Boolean(true), "0,", "Use steady-state detection during CTMC transient probability computation." },
{ BOOLEAN_TYPE, PRISM_EXTRA_DD_INFO, "Extra MTBDD information", "3.0", new Boolean(false), "0,", "Display extra information about (MT)BDDs used during and after model construction." }
{ BOOLEAN_TYPE, PRISM_EXTRA_DD_INFO, "Extra MTBDD information", "3.2", new Boolean(false), "0,", "Display extra information about (MT)BDDs used during and after model construction." },
{ BOOLEAN_TYPE, PRISM_EXTRA_REACH_INFO, "Extra reachability information", "3.2", new Boolean(false), "0,", "Display extra information about progress of reachability during model construction." }
}, },
{ {
{ BOOLEAN_TYPE, MODEL_AUTO_PARSE, "Auto parse", "3.0", new Boolean(true), "", "Parse PRISM models automatically as they are loaded/edited in the text editor." }, { BOOLEAN_TYPE, MODEL_AUTO_PARSE, "Auto parse", "3.0", new Boolean(true), "", "Parse PRISM models automatically as they are loaded/edited in the text editor." },

Loading…
Cancel
Save