Browse Source

Add labels to explicit models more cleanly and tidy code.

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@7633 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Dave Parker 12 years ago
parent
commit
7fd5c495bd
  1. 2
      prism/src/explicit/Bisimulation.java
  2. 10
      prism/src/explicit/Model.java
  3. 46
      prism/src/explicit/ModelExplicit.java
  4. 4
      prism/src/explicit/StateModelChecker.java
  5. 5
      prism/src/explicit/SubNondetModel.java

2
prism/src/explicit/Bisimulation.java

@ -276,7 +276,7 @@ public class Bisimulation extends PrismComponent
BitSet propBSnew = new BitSet();
for (int j = propBS.nextSetBit(0); j >= 0; j = propBS.nextSetBit(j + 1))
propBSnew.set(partition[j]);
modelNew.labels.put(propName, propBSnew);
modelNew.addLabel(propName, propBSnew);
}
}
}

10
prism/src/explicit/Model.java

@ -109,15 +109,21 @@ public interface Model
public boolean isDeadlockState(int i);
/**
* Get access to an (optional) list of states.
* Get access to a list of states (optionally stored).
*/
public List<State> getStatesList();
/**
* Get access to an (optional) list of constant values.
* Get access to a list of constant values (optionally stored).
*/
public Values getConstantValues();
/**
* Get the states that satisfy a label in this model (optionally stored).
* Returns null if there is no label of this name.
*/
public BitSet getLabelStates(String name);
/**
* Get the total number of transitions in the model.
*/

46
prism/src/explicit/ModelExplicit.java

@ -48,21 +48,26 @@ import prism.PrismLog;
*/
public abstract class ModelExplicit implements Model
{
// Number of states
// Basic model information
/** Number of states */
protected int numStates;
// Initial states
/** Which states are initial states */
protected List<Integer> initialStates; // TODO: should be a (linkedhash?) set really
/**
* 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.
*/
/** 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. */
protected TreeSet<Integer> deadlocks;
// State info (read only, just a pointer)
// Additional, optional information associated with the model
/** (Optionally) information about the states of this model,
* i.e. the State object corresponding to each state index. */
protected List<State> statesList;
// Constant info (read only, just a pointer)
/** (Optionally) a list of values for constants associated with this model. */
protected Values constantValues;
public Map<String,BitSet> labels = new TreeMap<String, BitSet>();
/** (Optionally) some labels (atomic propositions) associated with the model,
* represented as a String->BitSet mapping from their names to the states that satisfy them. */
protected Map<String,BitSet> labels = new TreeMap<String, BitSet>();
// Mutators
@ -82,6 +87,7 @@ public abstract class ModelExplicit implements Model
// Shallow copy of read-only stuff
statesList = model.statesList;
constantValues = model.constantValues;
labels = model.labels;
}
/**
@ -104,6 +110,7 @@ public abstract class ModelExplicit implements Model
// (i.e. info that is not broken by permute)
statesList = null;
constantValues = model.constantValues;
labels.clear();
}
/**
@ -115,6 +122,8 @@ public abstract class ModelExplicit implements Model
initialStates = new ArrayList<Integer>();
deadlocks = new TreeSet<Integer>();
statesList = null;
constantValues = null;
labels = new TreeMap<String, BitSet>();
}
/**
@ -154,6 +163,17 @@ public abstract class ModelExplicit implements Model
this.constantValues = constantValues;
}
/**
* Adds a label and the set the states that satisfy it.
* Any existing label with the same name is overwritten.
* @param name The name of the label
* @param states The states that satisyy the label
*/
public void addLabel(String name, BitSet states)
{
labels.put(name, states);
}
// Accessors (for Model interface)
@Override
@ -236,6 +256,12 @@ public abstract class ModelExplicit implements Model
return constantValues;
}
@Override
public BitSet getLabelStates(String name)
{
return labels.get(name);
}
@Override
public abstract int getNumTransitions();

4
prism/src/explicit/StateModelChecker.java

@ -669,10 +669,12 @@ public class StateModelChecker extends PrismComponent
}
return StateValues.createFromBitSet(bs, model);
} else {
BitSet bs = ((ModelExplicit) model).labels.get(expr.getName());
// First look at lables attached directly to model
BitSet bs = model.getLabelStates(expr.getName());
if (bs != null) {
return StateValues.createFromBitSet((BitSet) bs.clone(), model);
}
// Failing that, look in the properties file
ll = propertiesFile.getCombinedLabelList();
i = ll.getLabelIndex(expr.getName());
if (i == -1)

5
prism/src/explicit/SubNondetModel.java

@ -163,6 +163,11 @@ public class SubNondetModel implements NondetModel {
throw new UnsupportedOperationException();
}
@Override
public BitSet getLabelStates(String name) {
throw new UnsupportedOperationException();
}
@Override
public int getNumTransitions() {
return numTransitions;

Loading…
Cancel
Save