|
|
@ -303,10 +303,12 @@ public class SimulatorEngine extends PrismComponent |
|
|
throw new PrismNotSupportedException("Random choice of multiple initial states not yet supported"); |
|
|
throw new PrismNotSupportedException("Random choice of multiple initial states not yet supported"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
// Get initial observation |
|
|
|
|
|
State currentObs = modelGen.getObservation(currentState); |
|
|
// Get initial state reward |
|
|
// Get initial state reward |
|
|
calculateStateRewards(currentState, tmpStateRewards); |
|
|
calculateStateRewards(currentState, tmpStateRewards); |
|
|
// Initialise stored path |
|
|
// Initialise stored path |
|
|
path.initialise(currentState, tmpStateRewards); |
|
|
|
|
|
|
|
|
path.initialise(currentState, currentObs, tmpStateRewards); |
|
|
// Explore initial state in model generator |
|
|
// Explore initial state in model generator |
|
|
computeTransitionsForState(currentState); |
|
|
computeTransitionsForState(currentState); |
|
|
// Reset and then update samplers for any loaded properties |
|
|
// Reset and then update samplers for any loaded properties |
|
|
@ -373,6 +375,7 @@ public class SimulatorEngine extends PrismComponent |
|
|
executeTransition(ref.i, ref.offset, -1); |
|
|
executeTransition(ref.i, ref.offset, -1); |
|
|
break; |
|
|
break; |
|
|
case MDP: |
|
|
case MDP: |
|
|
|
|
|
case POMDP: |
|
|
// Pick a random choice |
|
|
// Pick a random choice |
|
|
i = rng.randomUnifInt(modelGen.getNumChoices()); |
|
|
i = rng.randomUnifInt(modelGen.getNumChoices()); |
|
|
// Pick a random transition from this choice |
|
|
// Pick a random transition from this choice |
|
|
@ -858,10 +861,12 @@ public class SimulatorEngine extends PrismComponent |
|
|
calculateTransitionRewards(path.getCurrentState(), action, tmpTransitionRewards); |
|
|
calculateTransitionRewards(path.getCurrentState(), action, tmpTransitionRewards); |
|
|
// Compute next state |
|
|
// Compute next state |
|
|
currentState.copy(modelGen.computeTransitionTarget(i, offset)); |
|
|
currentState.copy(modelGen.computeTransitionTarget(i, offset)); |
|
|
|
|
|
// Compute observation for new state |
|
|
|
|
|
State currentObs = modelGen.getObservation(currentState); |
|
|
// Compute state rewards for new state |
|
|
// Compute state rewards for new state |
|
|
calculateStateRewards(currentState, tmpStateRewards); |
|
|
calculateStateRewards(currentState, tmpStateRewards); |
|
|
// Update path |
|
|
// Update path |
|
|
path.addStep(index, action, actionString, p, tmpTransitionRewards, currentState, tmpStateRewards, modelGen); |
|
|
|
|
|
|
|
|
path.addStep(index, action, actionString, p, tmpTransitionRewards, currentState, currentObs, tmpStateRewards, modelGen); |
|
|
// Explore new state in model generator |
|
|
// Explore new state in model generator |
|
|
computeTransitionsForState(currentState); |
|
|
computeTransitionsForState(currentState); |
|
|
// Update samplers for any loaded properties |
|
|
// Update samplers for any loaded properties |
|
|
@ -896,10 +901,12 @@ public class SimulatorEngine extends PrismComponent |
|
|
calculateTransitionRewards(path.getCurrentState(), action, tmpTransitionRewards); |
|
|
calculateTransitionRewards(path.getCurrentState(), action, tmpTransitionRewards); |
|
|
// Compute next state |
|
|
// Compute next state |
|
|
currentState.copy(modelGen.computeTransitionTarget(i, offset)); |
|
|
currentState.copy(modelGen.computeTransitionTarget(i, offset)); |
|
|
|
|
|
// Compute observation for new state |
|
|
|
|
|
State currentObs = modelGen.getObservation(currentState); |
|
|
// Compute state rewards for new state |
|
|
// Compute state rewards for new state |
|
|
calculateStateRewards(currentState, tmpStateRewards); |
|
|
calculateStateRewards(currentState, tmpStateRewards); |
|
|
// Update path |
|
|
// Update path |
|
|
path.addStep(time, index, action, actionString, p, tmpTransitionRewards, currentState, tmpStateRewards, modelGen); |
|
|
|
|
|
|
|
|
path.addStep(time, index, action, actionString, p, tmpTransitionRewards, currentState, currentObs, tmpStateRewards, modelGen); |
|
|
// Explore new state in model generator |
|
|
// Explore new state in model generator |
|
|
computeTransitionsForState(currentState); |
|
|
computeTransitionsForState(currentState); |
|
|
// Update samplers for any loaded properties |
|
|
// Update samplers for any loaded properties |
|
|
@ -1278,6 +1285,16 @@ public class SimulatorEngine extends PrismComponent |
|
|
return ((PathFull) path).getState(step); |
|
|
return ((PathFull) path).getState(step); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Get the observation at a given step of the path. |
|
|
|
|
|
* (Not applicable for on-the-fly paths) |
|
|
|
|
|
* @param step Step index (0 = initial state/step of path) |
|
|
|
|
|
*/ |
|
|
|
|
|
public State getObservationOfPathStep(int step) |
|
|
|
|
|
{ |
|
|
|
|
|
return ((PathFull) path).getObservation(step); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Get a state reward for the state at a given step of the path. |
|
|
* Get a state reward for the state at a given step of the path. |
|
|
* (Not applicable for on-the-fly paths) |
|
|
* (Not applicable for on-the-fly paths) |
|
|
|