From 91554ae55e1e7236b2dac18e7ae55b71d95d8b5f Mon Sep 17 00:00:00 2001 From: Sascha Wunderlich Date: Mon, 7 Jan 2019 15:30:43 +0100 Subject: [PATCH] accumulation: fix stuttering in the beginning --- prism/src/explicit/AccumulationProduct.java | 25 +++++++++---------- prism/src/explicit/AccumulationState.java | 4 --- .../ReplaceAccumulationExpressionComplex.java | 19 +++++++++----- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/prism/src/explicit/AccumulationProduct.java b/prism/src/explicit/AccumulationProduct.java index c731b338..01071919 100644 --- a/prism/src/explicit/AccumulationProduct.java +++ b/prism/src/explicit/AccumulationProduct.java @@ -92,23 +92,22 @@ public abstract class AccumulationProduct extends Pro return new AccumulationTrack(newweights, nextComponent); } + private boolean stutterIn(int stateId) throws PrismException { + if(!ctx.accexp.hasFireOn()) { return false; } + for(Expression f : ctx.accexp.getFireOn()) { + if(ctx.mc.checkExpression(originalModel, f, null).getBitSet().get(stateId)) { + return false; + } + } + return true; + } + protected final AccumulationState updateAccumulationState(final int modelFromStateId, final AccumulationState accstate, final double[] weights) throws PrismException { // If we are in singleTrack mode and the last restart is the numberOfTracks, we can stop... if(ctx.singleTrack && (accstate.lastRestartNr == numberOfTracks-1)) { return accstate; } - // Check if we even need to fire here. - if(ctx.accexp.hasFireOn()) { - boolean stutter = true; - for(Expression f : ctx.accexp.getFireOn()) { - if(ctx.mc.checkExpression(originalModel, f, null).getBitSet().get(modelFromStateId)) { - //mc.getLog().println("f:" + f); - stutter = false; - break; - } - } - // If this is a stutter action, we can return the same accstate. Copies are made on modification. - if(stutter) { return accstate; } - } + // If this is a stutter action, we can return the same accstate. Copies are made on modification. + if(stutterIn(modelFromStateId)) { return accstate; } // ...otherwise proceed. // Get the old tracker and tracks. diff --git a/prism/src/explicit/AccumulationState.java b/prism/src/explicit/AccumulationState.java index 0e0b6742..987c65b7 100644 --- a/prism/src/explicit/AccumulationState.java +++ b/prism/src/explicit/AccumulationState.java @@ -44,10 +44,6 @@ public class AccumulationState { return (lastRestartNr + 1) % numberOfTracks; } - public boolean hasGoodTracks() { - return !goodTracks.isEmpty(); - } - public boolean importantTrackIsGood() { return goodTracks.get(getNextRestartNr()); } diff --git a/prism/src/parser/visitor/ReplaceAccumulationExpressionComplex.java b/prism/src/parser/visitor/ReplaceAccumulationExpressionComplex.java index d0caaedb..6d242619 100644 --- a/prism/src/parser/visitor/ReplaceAccumulationExpressionComplex.java +++ b/prism/src/parser/visitor/ReplaceAccumulationExpressionComplex.java @@ -31,7 +31,7 @@ public class ReplaceAccumulationExpressionComplex extends ASTTraverseModify { // This expression is of the form OR{0..(l-1)}(init_i AND (run_i UNTIL goal_i)) // Build all the subexpressions... - ArrayList clauses = new ArrayList<>(); + ArrayList clauses = new ArrayList<>(); Expression result = null; for(int i=0; i