|
|
|
@ -28,14 +28,11 @@ package simulator; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
import org.jfree.data.xy.XYDataItem; |
|
|
|
|
|
|
|
import parser.State; |
|
|
|
import parser.ast.ModulesFile; |
|
|
|
import prism.PrismException; |
|
|
|
import prism.PrismLog; |
|
|
|
import userinterface.graph.Graph; |
|
|
|
import userinterface.graph.Graph.SeriesKey; |
|
|
|
|
|
|
|
/** |
|
|
|
* Stores and manipulates a path though a model. |
|
|
|
@ -113,7 +110,8 @@ public class PathFull extends Path implements PathFullInfo |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void addStep(double time, int choice, int moduleOrActionIndex, double[] transitionRewards, State newState, double[] newStateRewards, TransitionList transitionList) |
|
|
|
public void addStep(double time, int choice, int moduleOrActionIndex, double[] transitionRewards, State newState, double[] newStateRewards, |
|
|
|
TransitionList transitionList) |
|
|
|
{ |
|
|
|
Step stepOld, stepNew; |
|
|
|
// Add info to last existing step |
|
|
|
@ -555,6 +553,7 @@ public class PathFull extends Path implements PathFullInfo |
|
|
|
moduleOrActionIndex = 0; |
|
|
|
transitionRewards = new double[numRewardStructs]; |
|
|
|
} |
|
|
|
|
|
|
|
// Current state (before transition) |
|
|
|
public State state; |
|
|
|
// State rewards for current state |
|
|
|
@ -574,53 +573,6 @@ public class PathFull extends Path implements PathFullInfo |
|
|
|
public double transitionRewards[]; |
|
|
|
} |
|
|
|
|
|
|
|
class PlotOnGraphThread extends Thread |
|
|
|
{ |
|
|
|
private Graph graphModel = null; |
|
|
|
|
|
|
|
public PlotOnGraphThread(Graph graphModel) |
|
|
|
{ |
|
|
|
this.graphModel = graphModel; |
|
|
|
} |
|
|
|
|
|
|
|
public void run() |
|
|
|
{ |
|
|
|
int i, j, n, nv; |
|
|
|
double d, t; |
|
|
|
boolean contTime = modulesFile.getModelType().continuousTime(); |
|
|
|
SeriesKey seriesKeys[] = null; |
|
|
|
|
|
|
|
// Configure axes |
|
|
|
graphModel.getXAxisSettings().setHeading("Time"); |
|
|
|
graphModel.getYAxisSettings().setHeading("Value"); |
|
|
|
|
|
|
|
// Get sizes |
|
|
|
n = size(); |
|
|
|
nv = modulesFile.getNumVars(); |
|
|
|
|
|
|
|
// Create series |
|
|
|
seriesKeys = new SeriesKey[nv]; |
|
|
|
for (j = 0; j < nv; j++) { |
|
|
|
seriesKeys[j] = graphModel.addSeries(modulesFile.getVarName(j)); |
|
|
|
} |
|
|
|
|
|
|
|
// Plot path |
|
|
|
t = 0.0; |
|
|
|
for (i = 0; i <= n; i++) { |
|
|
|
if (contTime) { |
|
|
|
d = (i < n) ? getTime(i) : 0.0; |
|
|
|
t += d; |
|
|
|
} |
|
|
|
for (j = 0; j < nv; j++) { |
|
|
|
// Always plot first/last points to ensure complete line. |
|
|
|
// Otherwise only add a point if the variable value changed. |
|
|
|
if (i == 0 || i == n-1 || !PathFull.this.getState(i).varValues[j].equals(PathFull.this.getState(i - 1).varValues[j])) |
|
|
|
graphModel.addPointToSeries(seriesKeys[j], new XYDataItem(contTime ? t : i, ((Integer) PathFull.this.getState(i).varValues[j]).intValue())); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
class DisplayThread extends Thread |
|
|
|
{ |
|
|
|
private PathDisplayer displayer = null; |
|
|
|
|