Browse Source

Bug fix in -simpath: state/step indices were not being displayed correctly when changes=true was set.

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@6724 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Dave Parker 13 years ago
parent
commit
ec422e5c90
  1. 2
      prism/src/simulator/GenerateSimulationPath.java
  2. 10
      prism/src/simulator/PathDisplayer.java
  3. 2
      prism/src/simulator/PathFull.java
  4. 4
      prism/src/simulator/PathToGraph.java
  5. 11
      prism/src/simulator/PathToText.java

2
prism/src/simulator/GenerateSimulationPath.java

@ -386,7 +386,7 @@ public class GenerateSimulationPath
i++; i++;
if (simPathType != PathType.SIM_PATH_DEADLOCK) { if (simPathType != PathType.SIM_PATH_DEADLOCK) {
displayer.step(path.getTimeInPreviousState(), path.getTotalTime(), path.getPreviousModuleOrAction(), path.getPreviousProbability(), displayer.step(path.getTimeInPreviousState(), path.getTotalTime(), path.getPreviousModuleOrAction(), path.getPreviousProbability(),
path.getPreviousTransitionRewards(), path.getCurrentState(), path.getCurrentStateRewards());
path.getPreviousTransitionRewards(), path.size(), path.getCurrentState(), path.getCurrentStateRewards());
} }
// Check for termination (depending on type) // Check for termination (depending on type)
switch (simPathType) { switch (simPathType) {

10
prism/src/simulator/PathDisplayer.java

@ -159,19 +159,19 @@ public abstract class PathDisplayer
} }
} }
public void step(double timeSpent, double timeCumul, Object action, double probability, double[] transitionRewards, State newState, double[] newStateRewards)
public void step(double timeSpent, double timeCumul, Object action, double probability, double[] transitionRewards, int newStateIndex, State newState, double[] newStateRewards)
{ {
if (showSnapshots) { if (showSnapshots) {
if (timeCumul < nextTime) { if (timeCumul < nextTime) {
return; return;
} else { } else {
while (timeCumul >= nextTime) { while (timeCumul >= nextTime) {
displaySnapshot(nextTime, newState, newStateRewards);
displaySnapshot(nextTime, newStateIndex, newState, newStateRewards);
nextTime += snapshotTimeStep; nextTime += snapshotTimeStep;
} }
} }
} else { } else {
displayStep(timeSpent, timeCumul, action, probability, transitionRewards, newState, newStateRewards);
displayStep(timeSpent, timeCumul, action, probability, transitionRewards, newStateIndex, newState, newStateRewards);
} }
} }
@ -190,12 +190,12 @@ public abstract class PathDisplayer
/** /**
* Displaying a step of a path. * Displaying a step of a path.
*/ */
public abstract void displayStep(double timeSpent, double timeCumul, Object action, double probability, double[] transitionRewards, State newState, double[] newStateRewards);
public abstract void displayStep(double timeSpent, double timeCumul, Object action, double probability, double[] transitionRewards, int newStateIndex, State newState, double[] newStateRewards);
/** /**
* Displaying a snapshot of a path at a particular time instant. * Displaying a snapshot of a path at a particular time instant.
*/ */
public abstract void displaySnapshot(double timeCumul, State newState, double[] newStateRewards);
public abstract void displaySnapshot(double timeCumul, int newStateIndex, State newState, double[] newStateRewards);
/** /**
* Finish displaying a path.. * Finish displaying a path..

2
prism/src/simulator/PathFull.java

@ -497,7 +497,7 @@ public class PathFull extends Path implements PathFullInfo
displayer.start(getState(0), getStateRewards(0)); displayer.start(getState(0), getStateRewards(0));
int n = size(); int n = size();
for (int i = 1; i <= n; i++) { for (int i = 1; i <= n; i++) {
displayer.step(getTime(i - 1), getCumulativeTime(i), getModuleOrAction(i - 1), getProbability(i - 1), getTransitionRewards(i), getState(i), getStateRewards(i));
displayer.step(getTime(i - 1), getCumulativeTime(i), getModuleOrAction(i - 1), getProbability(i - 1), getTransitionRewards(i), i, getState(i), getStateRewards(i));
} }
displayer.end(); displayer.end();
} }

4
prism/src/simulator/PathToGraph.java

@ -115,13 +115,13 @@ public class PathToGraph extends PathDisplayer
} }
@Override @Override
public void displayStep(double timeSpent, double timeCumul, Object action, double probability, double[] transitionRewards, State newState, double[] newStateRewards)
public void displayStep(double timeSpent, double timeCumul, Object action, double probability, double[] transitionRewards, int newStateIndex, State newState, double[] newStateRewards)
{ {
displayState(timeCumul, newState, newStateRewards, !showChangesOnly); displayState(timeCumul, newState, newStateRewards, !showChangesOnly);
} }
@Override @Override
public void displaySnapshot(double timeCumul, State newState, double[] newStateRewards)
public void displaySnapshot(double timeCumul, int newStateIndex, State newState, double[] newStateRewards)
{ {
displayState(timeCumul, newState, newStateRewards, !showChangesOnly); displayState(timeCumul, newState, newStateRewards, !showChangesOnly);
} }

11
prism/src/simulator/PathToText.java

@ -50,8 +50,6 @@ public class PathToText extends PathDisplayer
private String colSep = " "; private String colSep = " ";
// Displayer state // Displayer state
/** Step counter */
private int step;
/** Is the next column the first? */ /** Is the next column the first? */
private boolean firstCol; private boolean firstCol;
/** Last state */ /** Last state */
@ -147,7 +145,6 @@ public class PathToText extends PathDisplayer
// Display initial step // Display initial step
changed = true; changed = true;
step = 0;
firstCol = true; firstCol = true;
if (!getShowSnapshots()) { if (!getShowSnapshots()) {
log.print(getColSep() + "-"); log.print(getColSep() + "-");
@ -168,7 +165,7 @@ public class PathToText extends PathDisplayer
} }
@Override @Override
public void displayStep(double timeSpent, double timeCumul, Object action, double probability, double[] transitionRewards, State newState, double[] newStateRewards)
public void displayStep(double timeSpent, double timeCumul, Object action, double probability, double[] transitionRewards, int newStateIndex, State newState, double[] newStateRewards)
{ {
if (!showChangesOnly || changed) { if (!showChangesOnly || changed) {
// display rewards for last state // display rewards for last state
@ -191,7 +188,6 @@ public class PathToText extends PathDisplayer
return; return;
} }
step++;
firstCol = true; firstCol = true;
// display action // display action
@ -200,7 +196,7 @@ public class PathToText extends PathDisplayer
if (showProbs) if (showProbs)
log.print(getColSep() + probability); log.print(getColSep() + probability);
// display state index // display state index
log.print(getColSep() + step);
log.print(getColSep() + newStateIndex);
// display cumulative time // display cumulative time
if (contTime && showTimeCumul) if (contTime && showTimeCumul)
log.print(getColSep() + timeCumul); log.print(getColSep() + timeCumul);
@ -213,9 +209,8 @@ public class PathToText extends PathDisplayer
} }
@Override @Override
public void displaySnapshot(double timeCumul, State newState, double[] newStateRewards)
public void displaySnapshot(double timeCumul, int newStateIndex, State newState, double[] newStateRewards)
{ {
step++;
firstCol = true; firstCol = true;
// display cumulative time // display cumulative time

Loading…
Cancel
Save