Browse Source

Some tidying in explicit model construction.

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@3381 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Dave Parker 15 years ago
parent
commit
385de74b06
  1. 32
      prism/src/explicit/ConstructModel.java

32
prism/src/explicit/ConstructModel.java

@ -3,6 +3,7 @@
// Copyright (c) 2002- // Copyright (c) 2002-
// Authors: // Authors:
// * Dave Parker <david.parker@comlab.ox.ac.uk> (University of Oxford) // * Dave Parker <david.parker@comlab.ox.ac.uk> (University of Oxford)
// * Vojtech Forejt <vojtech.forejt@cs.ox.ac.uk> (University of Oxford)
// //
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// //
@ -88,7 +89,7 @@ public class ConstructModel
{ {
return constructModel(modulesFile, justReach, buildSparse, true); return constructModel(modulesFile, justReach, buildSparse, true);
} }
/** /**
* Construct an explicit-state model from a PRISM model language description and return. * Construct an explicit-state model from a PRISM model language description and return.
* If {@code justReach} is true, no model is built and null is returned; * If {@code justReach} is true, no model is built and null is returned;
@ -115,7 +116,7 @@ public class ConstructModel
Model model = null; Model model = null;
Distribution distr = null; Distribution distr = null;
// Misc // Misc
int i, j, k, nc, nt, src, dest;
int i, j, nc, nt, src, dest;
long timer, timerProgress; long timer, timerProgress;
boolean fixdl = false; boolean fixdl = false;
@ -178,6 +179,7 @@ public class ConstructModel
// Look at each outgoing choice in turn // Look at each outgoing choice in turn
nc = engine.getNumChoices(); nc = engine.getNumChoices();
for (i = 0; i < nc; i++) { for (i = 0; i < nc; i++) {
if (!justReach && (modelType == ModelType.MDP || modelType == ModelType.CTMDP)) { if (!justReach && (modelType == ModelType.MDP || modelType == ModelType.CTMDP)) {
distr = new Distribution(); distr = new Distribution();
} }
@ -190,8 +192,9 @@ public class ConstructModel
// If so, add to the explore list // If so, add to the explore list
explore.add(stateNew); explore.add(stateNew);
// And to model // And to model
if (!justReach)
if (!justReach) {
modelSimple.addState(); modelSimple.addState();
}
} }
// Get index of state in state set // Get index of state in state set
dest = states.getIndexOfLastAdd(); dest = states.getIndexOfLastAdd();
@ -216,15 +219,20 @@ public class ConstructModel
if (!justReach) { if (!justReach) {
if (modelType == ModelType.MDP) { if (modelType == ModelType.MDP) {
if (distinguishActions) { if (distinguishActions) {
k = mdp.addActionLabelledChoice(src, distr, engine.getTransitionAction(i, 0));
mdp.addActionLabelledChoice(src, distr, engine.getTransitionAction(i, 0));
} else { } else {
k = mdp.addChoice(src, distr);
mdp.addChoice(src, distr);
} }
} else if (modelType == ModelType.CTMDP) { } else if (modelType == ModelType.CTMDP) {
ctmdp.addChoice(src, distr);
if (distinguishActions) {
ctmdp.addActionLabelledChoice(src, distr, engine.getTransitionAction(i, 0));
} else {
ctmdp.addChoice(src, distr);
}
} }
} }
} }
// Print some progress info occasionally // Print some progress info occasionally
if (System.currentTimeMillis() - timerProgress > 3000) { if (System.currentTimeMillis() - timerProgress > 3000) {
mainLog.print(" " + (src + 1)); mainLog.print(" " + (src + 1));
@ -251,13 +259,13 @@ public class ConstructModel
boolean sort = true; boolean sort = true;
int permut[] = null; int permut[] = null;
if (sort) { if (sort) {
// Sort states and convert set to list
mainLog.println("Sorting reachable states list...");
permut = states.buildSortingPermutation();
statesList = states.toPermutedArrayList(permut);
//mainLog.println(permut);
// Sort states and convert set to list
mainLog.println("Sorting reachable states list...");
permut = states.buildSortingPermutation();
statesList = states.toPermutedArrayList(permut);
//mainLog.println(permut);
} else { } else {
statesList = states.toArrayList(); statesList = states.toArrayList();
} }

Loading…
Cancel
Save