Browse Source

accumulation: untilConstr -> reachConstr

accumulation
Sascha Wunderlich 6 years ago
parent
commit
0933901c34
  1. 2
      prism/src/explicit/AccumulationContext.java
  2. 1
      prism/src/explicit/AccumulationProduct.java
  3. 7
      prism/src/explicit/AccumulationTransformation.java
  4. 10
      prism/src/parser/visitor/ReplaceAccumulationExpressionSimple.java

2
prism/src/explicit/AccumulationContext.java

@ -13,7 +13,7 @@ public class AccumulationContext {
public enum strategy {UNTIL, REACH}; public enum strategy {UNTIL, REACH};
public boolean simpleMethod; public boolean simpleMethod;
public boolean singleTrack; public boolean singleTrack;
public boolean untilConstr;
public boolean reachConstr;
/** The ingredients */ /** The ingredients */
public ExpressionAccumulation accexp; public ExpressionAccumulation accexp;

1
prism/src/explicit/AccumulationProduct.java

@ -6,7 +6,6 @@ import java.util.Iterator;
import java.util.Map; import java.util.Map;
import parser.ast.AccumulationFactor; import parser.ast.AccumulationFactor;
import parser.ast.Expression;
import prism.IntegerBound; import prism.IntegerBound;
import prism.PrismException; import prism.PrismException;

7
prism/src/explicit/AccumulationTransformation.java

@ -141,11 +141,12 @@ public class AccumulationTransformation<M extends ModelExplicit> implements Mode
AccumulationContext ctx = new AccumulationContext(accexp, rewards, mc); AccumulationContext ctx = new AccumulationContext(accexp, rewards, mc);
ctx.singleTrack = isSingleTrack && !forceMulti; ctx.singleTrack = isSingleTrack && !forceMulti;
ctx.simpleMethod = isSimple && !forceComplex; ctx.simpleMethod = isSimple && !forceComplex;
ctx.untilConstr = (isSimple && isFiltered) || forceUntil;
ctx.reachConstr = (!isSimple || !isFiltered) && !forceUntil;
mc.getLog().print("Using optimizations: ");
mc.getLog().print("Context flags: ");
if(ctx.singleTrack) { mc.getLog().print(" singleTrack "); } if(ctx.singleTrack) { mc.getLog().print(" singleTrack "); }
if(ctx.simpleMethod) { mc.getLog().print(" simpleMethod "); } if(ctx.simpleMethod) { mc.getLog().print(" simpleMethod "); }
if(ctx.reachConstr) { mc.getLog().print(" reachConstr" ); }
mc.getLog().println(); mc.getLog().println();
// Build the product // Build the product
@ -188,7 +189,7 @@ public class AccumulationTransformation<M extends ModelExplicit> implements Mode
clock.start("replacing formula"); clock.start("replacing formula");
ASTVisitor replace; ASTVisitor replace;
if(ctx.simpleMethod) { if(ctx.simpleMethod) {
replace = new ReplaceAccumulationExpressionSimple(ctx.accexp, goalLabels.get(0), product.getNumberOfTracks()-1, ctx.untilConstr);
replace = new ReplaceAccumulationExpressionSimple(ctx.accexp, goalLabels.get(0), product.getNumberOfTracks()-1, ctx.reachConstr);
} else { } else {
replace = new ReplaceAccumulationExpressionComplex(ctx.accexp, initLabels, runLabels, goalLabels, product.getNumberOfTracks()-1, ctx.singleTrack); replace = new ReplaceAccumulationExpressionComplex(ctx.accexp, initLabels, runLabels, goalLabels, product.getNumberOfTracks()-1, ctx.singleTrack);
} }

10
prism/src/parser/visitor/ReplaceAccumulationExpressionSimple.java

@ -16,14 +16,14 @@ public class ReplaceAccumulationExpressionSimple extends ASTTraverseModify {
private ExpressionAccumulation accexp; private ExpressionAccumulation accexp;
private String goodLabel; private String goodLabel;
private int accLength; private int accLength;
private boolean untilConstr;
private boolean reachConstr;
public ReplaceAccumulationExpressionSimple(ExpressionAccumulation accexp, String goodLabel, int accLength, boolean untilConstr) {
public ReplaceAccumulationExpressionSimple(ExpressionAccumulation accexp, String goodLabel, int accLength, boolean reachConstr) {
super(); super();
this.accexp = accexp; this.accexp = accexp;
this.goodLabel = goodLabel; this.goodLabel = goodLabel;
this.accLength = accLength; this.accLength = accLength;
this.untilConstr = untilConstr;
this.reachConstr = reachConstr;
} }
private Object replaceWithReach(ExpressionAccumulation expr) throws PrismLangException { private Object replaceWithReach(ExpressionAccumulation expr) throws PrismLangException {
@ -86,8 +86,8 @@ public class ReplaceAccumulationExpressionSimple extends ASTTraverseModify {
{ {
if (expr == accexp) { if (expr == accexp) {
// This is a simple accumulation expression. Rewrite to F=.... or to until cascade // This is a simple accumulation expression. Rewrite to F=.... or to until cascade
if (untilConstr) { return replaceWithUntilCascade(expr); }
else { return replaceWithReach(expr); }
if (reachConstr) { return replaceWithReach(expr); }
else { return replaceWithUntilCascade(expr); }
} else { } else {
return expr; return expr;
} }

Loading…
Cancel
Save