|
|
@ -31,34 +31,23 @@ import java.util.List; |
|
|
import dv.IntegerVector; |
|
|
import dv.IntegerVector; |
|
|
|
|
|
|
|
|
import prism.Model; |
|
|
import prism.Model; |
|
|
|
|
|
import strat.Strategy.Choice; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Class to store a memoryless deterministic (MD) strategy, as a IntegerVector (i.e. stored natively as an array). |
|
|
|
|
|
|
|
|
* Class to store a memoryless deterministic (MD) strategy, as an IntegerVector (i.e. stored natively as an array). |
|
|
*/ |
|
|
*/ |
|
|
public class MDStrategyIV extends MDStrategy |
|
|
public class MDStrategyIV extends MDStrategy |
|
|
{ |
|
|
{ |
|
|
// Model associated with the strategy |
|
|
// Model associated with the strategy |
|
|
private Model model; |
|
|
private Model model; |
|
|
|
|
|
|
|
|
private IntegerVector iv; |
|
|
|
|
|
|
|
|
|
|
|
private List<String> actions; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Other model info |
|
|
private int numStates; |
|
|
private int numStates; |
|
|
private long ptr; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Creates... |
|
|
|
|
|
*/ |
|
|
|
|
|
public MDStrategyIV(Model model) |
|
|
|
|
|
{ |
|
|
|
|
|
this.model = model; |
|
|
|
|
|
numStates = (int) model.getNumStates(); |
|
|
|
|
|
actions = model.getSynchs(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private List<String> actions; |
|
|
|
|
|
// Array storing MD strategy (action index for each state) |
|
|
|
|
|
private IntegerVector iv; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Creates... |
|
|
|
|
|
|
|
|
* Create an MDStrategyIV from an IntegerVector. |
|
|
*/ |
|
|
*/ |
|
|
public MDStrategyIV(Model model, IntegerVector iv) |
|
|
public MDStrategyIV(Model model, IntegerVector iv) |
|
|
{ |
|
|
{ |
|
|
@ -68,10 +57,7 @@ public class MDStrategyIV extends MDStrategy |
|
|
this.iv = iv; |
|
|
this.iv = iv; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void setPointer(long ptr) |
|
|
|
|
|
{ |
|
|
|
|
|
this.ptr = ptr; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// Methods for MDStrategy |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public int getNumStates() |
|
|
public int getNumStates() |
|
|
@ -80,19 +66,37 @@ public class MDStrategyIV extends MDStrategy |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public int getChoice(int s) |
|
|
|
|
|
|
|
|
public Strategy.Choice getChoice(int s) |
|
|
|
|
|
{ |
|
|
|
|
|
int c = iv.getElement(s); |
|
|
|
|
|
switch (c) { |
|
|
|
|
|
case -1: |
|
|
|
|
|
return Choice.UNKNOWN; |
|
|
|
|
|
case -2: |
|
|
|
|
|
return Choice.ARBITRARY; |
|
|
|
|
|
case -3: |
|
|
|
|
|
return Choice.UNREACHABLE; |
|
|
|
|
|
default: |
|
|
|
|
|
return Choice.INDEX; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public int getChoiceIndex(int s) |
|
|
{ |
|
|
{ |
|
|
return 99; |
|
|
|
|
|
|
|
|
throw new UnsupportedOperationException(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public Object getChoiceAction(int s) |
|
|
public Object getChoiceAction(int s) |
|
|
{ |
|
|
{ |
|
|
int c = iv.getElement(s); |
|
|
int c = iv.getElement(s); |
|
|
//return ""+c; //c >= 0 ? actions.get(c) : "?"; |
|
|
|
|
|
return c >= 0 ? actions.get(c) : c == -1 ? "?" : c == -2 ? "*" : "-"; |
|
|
return c >= 0 ? actions.get(c) : c == -1 ? "?" : c == -2 ? "*" : "-"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Methods for Strategy |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
public void clear() |
|
|
public void clear() |
|
|
{ |
|
|
{ |
|
|
iv.clear(); |
|
|
iv.clear(); |
|
|
|