|
|
|
@ -153,20 +153,13 @@ public class ChoiceListFlexi implements Choice |
|
|
|
|
|
|
|
// Get methods |
|
|
|
|
|
|
|
/** |
|
|
|
* Get the module/action for this choice, as an integer index |
|
|
|
* (-i for independent in ith module, i for synchronous on ith action) |
|
|
|
* (in both cases, modules/actions are 1-indexed) |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public int getModuleOrActionIndex() |
|
|
|
{ |
|
|
|
return moduleOrActionIndex; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Get the module/action for this choice, as a string |
|
|
|
* (form is "module" or "[action]") |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public String getModuleOrAction() |
|
|
|
{ |
|
|
|
// Action label (or absence of) will be the same for all updates in a choice |
|
|
|
@ -178,20 +171,13 @@ public class ChoiceListFlexi implements Choice |
|
|
|
return "[" + c.getSynch() + "]"; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Get the number of transitions in this choice. |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public int size() |
|
|
|
{ |
|
|
|
return probability.size(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Get the updates of the ith transition, as a string. |
|
|
|
* This is in abbreviated form, i.e. x'=1, rather than x'=x+1. |
|
|
|
* Format is: x'=1, y'=0, with empty string for empty update. |
|
|
|
* Only variables updated are included in list (even if unchanged). |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public String getUpdateString(int i, State currentState) throws PrismLangException |
|
|
|
{ |
|
|
|
int j, n; |
|
|
|
@ -210,13 +196,7 @@ public class ChoiceListFlexi implements Choice |
|
|
|
return s; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Get the updates of the ith transition, as a string. |
|
|
|
* This is in full, i.e. of the form x'=x+1, rather than x'=1. |
|
|
|
* Format is: (x'=x+1) & (y'=y-1), with empty string for empty update. |
|
|
|
* Only variables updated are included in list. |
|
|
|
* Note that expressions may have been simplified from original model. |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public String getUpdateStringFull(int i) |
|
|
|
{ |
|
|
|
String s = ""; |
|
|
|
@ -233,11 +213,7 @@ public class ChoiceListFlexi implements Choice |
|
|
|
return s; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Compute the target for the ith transition, based on a current state, |
|
|
|
* returning the result as a new State object copied from the existing one. |
|
|
|
* NB: for efficiency, there are no bounds checks done on i. |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public State computeTarget(int i, State currentState) throws PrismLangException |
|
|
|
{ |
|
|
|
State newState = new State(currentState); |
|
|
|
@ -246,42 +222,20 @@ public class ChoiceListFlexi implements Choice |
|
|
|
return newState; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Compute the target for the ith transition, based on a current state. |
|
|
|
* Apply changes in variables to a provided copy of the State object. |
|
|
|
* (i.e. currentState and newState should be equal when passed in.) |
|
|
|
* NB: for efficiency, there are no bounds checks done on i. |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void computeTarget(int i, State currentState, State newState) throws PrismLangException |
|
|
|
{ |
|
|
|
for (Update up : updates.get(i)) |
|
|
|
up.update(currentState, newState); |
|
|
|
} |
|
|
|
|
|
|
|
public State computeTarget(State currentState) throws PrismLangException |
|
|
|
{ |
|
|
|
return computeTarget(0, currentState); |
|
|
|
} |
|
|
|
|
|
|
|
public void computeTarget(State currentState, State newState) throws PrismLangException |
|
|
|
{ |
|
|
|
computeTarget(0, currentState, newState); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Get the probability rate for the ith transition. |
|
|
|
* NB: for efficiency, there are no bounds checks done on i. |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public double getProbability(int i) |
|
|
|
{ |
|
|
|
return probability.get(i); |
|
|
|
} |
|
|
|
|
|
|
|
public double getProbability() |
|
|
|
{ |
|
|
|
return getProbability(0); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public double getProbabilitySum() |
|
|
|
{ |
|
|
|
double sum = 0.0; |
|
|
|
@ -290,11 +244,7 @@ public class ChoiceListFlexi implements Choice |
|
|
|
return sum; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Return the index of a transition according to a probability (or rate) sum, x. |
|
|
|
* i.e. return the index of the first transition in this choice for which the |
|
|
|
* sum of probabilities/rates for that and all prior transitions exceeds x. |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public int getIndexByProbabilitySum(double x) |
|
|
|
{ |
|
|
|
int i, n; |
|
|
|
@ -325,6 +275,7 @@ public class ChoiceListFlexi implements Choice |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public String toString() |
|
|
|
{ |
|
|
|
int i, n; |
|
|
|
|