Browse Source

Add option to show states in dot file exported for explicit models (plus some commenting).

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@8390 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Dave Parker 12 years ago
parent
commit
1d2bb4a49d
  1. 14
      prism/src/explicit/Model.java
  2. 43
      prism/src/explicit/ModelExplicit.java
  3. 6
      prism/src/explicit/SubNondetModel.java

14
prism/src/explicit/Model.java

@ -195,24 +195,38 @@ public interface Model
/** /**
* Export to a dot file. * Export to a dot file.
* @param filename Name of file to export to
*/ */
public void exportToDotFile(String filename) throws PrismException; public void exportToDotFile(String filename) throws PrismException;
/** /**
* Export to a dot file, highlighting states in 'mark'. * Export to a dot file, highlighting states in 'mark'.
* @param filename Name of file to export to
* @param mark States to highlight (ignored if null)
*/ */
public void exportToDotFile(String filename, BitSet mark) throws PrismException; public void exportToDotFile(String filename, BitSet mark) throws PrismException;
/** /**
* Export to a dot file. * Export to a dot file.
* @param out PrismLog to export to
*/ */
public void exportToDotFile(PrismLog out); public void exportToDotFile(PrismLog out);
/** /**
* Export to a dot file, highlighting states in 'mark'. * Export to a dot file, highlighting states in 'mark'.
* @param out PrismLog to export to
* @param mark States to highlight (ignored if null)
*/ */
public void exportToDotFile(PrismLog out, BitSet mark); public void exportToDotFile(PrismLog out, BitSet mark);
/**
* Export to a dot file, highlighting states in 'mark'.
* @param out PrismLog to export to
* @param mark States to highlight (ignored if null)
* @param showStates Show state info on nodes?
*/
public void exportToDotFile(PrismLog out, BitSet mark, boolean showStates);
/** /**
* Export to a equivalent PRISM language model description. * Export to a equivalent PRISM language model description.
*/ */

43
prism/src/explicit/ModelExplicit.java

@ -49,7 +49,7 @@ import prism.PrismLog;
public abstract class ModelExplicit implements Model public abstract class ModelExplicit implements Model
{ {
// Basic model information // Basic model information
/** Number of states */ /** Number of states */
protected int numStates; protected int numStates;
/** Which states are initial states */ /** Which states are initial states */
@ -57,9 +57,9 @@ public abstract class ModelExplicit implements Model
/** States that are/were deadlocks. Where requested and where appropriate (DTMCs/MDPs), /** States that are/were deadlocks. Where requested and where appropriate (DTMCs/MDPs),
* these states may have been fixed at build time by adding self-loops. */ * these states may have been fixed at build time by adding self-loops. */
protected TreeSet<Integer> deadlocks; protected TreeSet<Integer> deadlocks;
// Additional, optional information associated with the model // Additional, optional information associated with the model
/** (Optionally) information about the states of this model, /** (Optionally) information about the states of this model,
* i.e. the State object corresponding to each state index. */ * i.e. the State object corresponding to each state index. */
protected List<State> statesList; protected List<State> statesList;
@ -67,8 +67,8 @@ public abstract class ModelExplicit implements Model
protected Values constantValues; protected Values constantValues;
/** (Optionally) some labels (atomic propositions) associated with the model, /** (Optionally) some labels (atomic propositions) associated with the model,
* represented as a String->BitSet mapping from their names to the states that satisfy them. */ * represented as a String->BitSet mapping from their names to the states that satisfy them. */
protected Map<String,BitSet> labels = new TreeMap<String, BitSet>();
protected Map<String, BitSet> labels = new TreeMap<String, BitSet>();
// Mutators // Mutators
/** /**
@ -154,7 +154,7 @@ public abstract class ModelExplicit implements Model
{ {
this.statesList = statesList; this.statesList = statesList;
} }
/** /**
* Set the associated (read-only) constant values. * Set the associated (read-only) constant values.
*/ */
@ -214,7 +214,7 @@ public abstract class ModelExplicit implements Model
{ {
return deadlocks.size(); return deadlocks.size();
} }
@Override @Override
public Iterable<Integer> getDeadlockStates() public Iterable<Integer> getDeadlockStates()
{ {
@ -228,7 +228,7 @@ public abstract class ModelExplicit implements Model
for (int dl : deadlocks) { for (int dl : deadlocks) {
bs.set(dl); bs.set(dl);
} }
return StateValues.createFromBitSet(bs, this); return StateValues.createFromBitSet(bs, this);
} }
@ -243,7 +243,7 @@ public abstract class ModelExplicit implements Model
{ {
return deadlocks.contains(i); return deadlocks.contains(i);
} }
@Override @Override
public List<State> getStatesList() public List<State> getStatesList()
{ {
@ -261,7 +261,7 @@ public abstract class ModelExplicit implements Model
{ {
return labels.get(name); return labels.get(name);
} }
@Override @Override
public abstract int getNumTransitions(); public abstract int getNumTransitions();
@ -315,11 +315,17 @@ public abstract class ModelExplicit implements Model
@Override @Override
public void exportToDotFile(PrismLog out) public void exportToDotFile(PrismLog out)
{ {
exportToDotFile(out, null);
exportToDotFile(out, null, false);
} }
@Override @Override
public void exportToDotFile(PrismLog out, BitSet mark) public void exportToDotFile(PrismLog out, BitSet mark)
{
exportToDotFile(out, mark, false);
}
@Override
public void exportToDotFile(PrismLog out, BitSet mark, boolean showStates)
{ {
int i; int i;
// Header // Header
@ -331,6 +337,15 @@ public abstract class ModelExplicit implements Model
// Transitions for state i // Transitions for state i
exportTransitionsToDotFile(i, out); exportTransitionsToDotFile(i, out);
} }
// Append state info (if required)
if (showStates) {
List<State> states = getStatesList();
if (states != null) {
for (i = 0; i < numStates; i++) {
out.print(i + " [label=\"" + i + "\\n" + states.get(i) + "\"]\n");
}
}
}
// Footer // Footer
out.print("}\n"); out.print("}\n");
} }
@ -341,7 +356,7 @@ public abstract class ModelExplicit implements Model
* @param out PrismLog for output * @param out PrismLog for output
*/ */
protected abstract void exportTransitionsToDotFile(int i, PrismLog out); protected abstract void exportTransitionsToDotFile(int i, PrismLog out);
@Override @Override
public abstract void exportToPrismLanguage(String filename) throws PrismException; public abstract void exportToPrismLanguage(String filename) throws PrismException;
@ -350,7 +365,7 @@ public abstract class ModelExplicit implements Model
{ {
if (statesList == null) if (statesList == null)
return; return;
// Print header: list of model vars // Print header: list of model vars
if (exportType == Prism.EXPORT_MATLAB) if (exportType == Prism.EXPORT_MATLAB)
log.print("% "); log.print("% ");
@ -378,7 +393,7 @@ public abstract class ModelExplicit implements Model
if (exportType == Prism.EXPORT_MATLAB) if (exportType == Prism.EXPORT_MATLAB)
log.println("];"); log.println("];");
} }
@Override @Override
public abstract String infoString(); public abstract String infoString();

6
prism/src/explicit/SubNondetModel.java

@ -291,6 +291,12 @@ public class SubNondetModel implements NondetModel
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public void exportToDotFile(PrismLog out, BitSet mark, boolean showStates)
{
throw new UnsupportedOperationException();
}
@Override @Override
public void exportToDotFileWithStrat(PrismLog out, BitSet mark, int strat[]) public void exportToDotFileWithStrat(PrismLog out, BitSet mark, int strat[])
{ {

Loading…
Cancel
Save