|
|
|
@ -42,11 +42,17 @@ public abstract class ModelSimple implements Model |
|
|
|
protected int numStates; |
|
|
|
// Initial states |
|
|
|
protected List<Integer> initialStates; // TODO: should be a (linkedhash?) set really |
|
|
|
/** |
|
|
|
* States with deadlocks that have been "fixed", i.e. a state that was |
|
|
|
* originally a deadlock but has been fixed through the addition of a self-loop, |
|
|
|
* or a state that is still a deadlock but in a model where this acceptable, e.g. a CTMC. |
|
|
|
*/ |
|
|
|
protected TreeSet<Integer> deadlocksFixed; |
|
|
|
// State info (read only, just a pointer) |
|
|
|
protected List<State> statesList; |
|
|
|
// Constant info (read only, just a pointer) |
|
|
|
protected Values constantValues; |
|
|
|
|
|
|
|
|
|
|
|
// Mutators |
|
|
|
|
|
|
|
/** |
|
|
|
@ -63,7 +69,7 @@ public abstract class ModelSimple implements Model |
|
|
|
statesList = model.statesList; |
|
|
|
constantValues = model.constantValues; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Copy data from another ModelSimple and a state index permutation, |
|
|
|
* i.e. state index i becomes index permut[i] |
|
|
|
@ -82,7 +88,7 @@ public abstract class ModelSimple implements Model |
|
|
|
statesList = null; |
|
|
|
constantValues = model.constantValues; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Initialise: create new model with fixed number of states. |
|
|
|
*/ |
|
|
|
@ -90,9 +96,10 @@ public abstract class ModelSimple implements Model |
|
|
|
{ |
|
|
|
this.numStates = numStates; |
|
|
|
initialStates = new ArrayList<Integer>(); |
|
|
|
deadlocksFixed = new TreeSet<Integer>(); |
|
|
|
statesList = null; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Add a state to the list of initial states. |
|
|
|
*/ |
|
|
|
@ -100,12 +107,20 @@ public abstract class ModelSimple implements Model |
|
|
|
{ |
|
|
|
initialStates.add(i); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Add a state to the list of "fixed" deadlock states. |
|
|
|
*/ |
|
|
|
public void addFixedDeadlockState(int i) |
|
|
|
{ |
|
|
|
deadlocksFixed.add(i); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Clear all information for a state (i.e. remove all transitions). |
|
|
|
*/ |
|
|
|
public abstract void clearState(int i); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Add a new state and return its index. |
|
|
|
*/ |
|
|
|
@ -122,57 +137,63 @@ public abstract class ModelSimple implements Model |
|
|
|
public abstract void buildFromPrismExplicit(String filename) throws PrismException; |
|
|
|
|
|
|
|
// Accessors (for Model interface) |
|
|
|
|
|
|
|
|
|
|
|
public abstract ModelType getModelType(); |
|
|
|
|
|
|
|
public int getNumStates() |
|
|
|
{ |
|
|
|
return numStates; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public int getNumInitialStates() |
|
|
|
{ |
|
|
|
return initialStates.size(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Iterable<Integer> getInitialStates() |
|
|
|
{ |
|
|
|
return initialStates; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public int getFirstInitialState() |
|
|
|
{ |
|
|
|
return initialStates.isEmpty() ? -1 : initialStates.get(0); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean isInitialState(int i) |
|
|
|
{ |
|
|
|
return initialStates.contains(i); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public boolean isFixedDeadlockState(int i) |
|
|
|
{ |
|
|
|
return deadlocksFixed.contains(i); |
|
|
|
} |
|
|
|
|
|
|
|
public List<State> getStatesList() |
|
|
|
{ |
|
|
|
return statesList; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Values getConstantValues() |
|
|
|
{ |
|
|
|
return constantValues; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public abstract int getNumTransitions(); |
|
|
|
|
|
|
|
|
|
|
|
public abstract boolean isSuccessor(int s1, int s2); |
|
|
|
|
|
|
|
|
|
|
|
public abstract int getNumChoices(int s); |
|
|
|
|
|
|
|
|
|
|
|
public void checkForDeadlocks() throws PrismException |
|
|
|
{ |
|
|
|
checkForDeadlocks(null); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public abstract void checkForDeadlocks(BitSet except) throws PrismException; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void exportToPrismExplicit(String baseFilename) throws PrismException |
|
|
|
{ |
|
|
|
@ -190,9 +211,9 @@ public abstract class ModelSimple implements Model |
|
|
|
} |
|
|
|
|
|
|
|
public abstract void exportToDotFile(String filename, BitSet mark) throws PrismException; |
|
|
|
|
|
|
|
|
|
|
|
public abstract void exportToPrismLanguage(String filename) throws PrismException; |
|
|
|
|
|
|
|
|
|
|
|
public abstract String infoString(); |
|
|
|
|
|
|
|
@Override |
|
|
|
|