Browse Source

explicit: Use LTL2WDBA construction to obtain DFA for co-safe LTL reward computations

The DFA needed for co-safe LTL reward computation need to have a
specific structure, i.e., all states that satisfy Sigma^omega have
to be already goal states.

The previous approach did not necessarily ensure this.


git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@12065 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Joachim Klein 9 years ago
parent
commit
37dff4f997
  1. 36
      prism/src/explicit/DTMCModelChecker.java
  2. 34
      prism/src/explicit/MDPModelChecker.java

36
prism/src/explicit/DTMCModelChecker.java

@ -31,6 +31,7 @@ import java.util.Arrays;
import java.util.BitSet;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import parser.VarList;
import parser.ast.Declaration;
@ -43,7 +44,10 @@ import prism.PrismFileLog;
import prism.PrismUtils;
import acceptance.AcceptanceReach;
import acceptance.AcceptanceType;
import automata.DA;
import common.IterableBitSet;
import common.StopWatch;
import explicit.LTLModelChecker.LTLProduct;
import explicit.rewards.MCRewards;
import explicit.rewards.Rewards;
@ -140,17 +144,21 @@ public class DTMCModelChecker extends ProbModelChecker
MCRewards productRewards;
StateValues rewardsProduct, rewards;
DTMCModelChecker mcProduct;
LTLModelChecker.LTLProduct<DTMC> product;
LTLProduct<DTMC> product;
// For LTL model checking routines
mcLtl = new LTLModelChecker(this);
// Build product of Markov chain and automaton
AcceptanceType[] allowedAcceptance = {
AcceptanceType.RABIN,
AcceptanceType.REACH
};
product = mcLtl.constructProductMC(this, (DTMC)model, expr, statesOfInterest, allowedAcceptance);
// Model check maximal state formulas and construct DFA, with the special
// handling needed for cosafety reward translation
Vector<BitSet> labelBS = new Vector<BitSet>();
DA<BitSet, AcceptanceReach> da = mcLtl.constructDFAForCosafetyRewardLTL(this, model, expr, labelBS);
StopWatch timer = new StopWatch(mainLog);
mainLog.println("\nConstructing " + model.getModelType() + "-" + da.getAutomataType() + " product...");
timer.start(model.getModelType() + "-" + da.getAutomataType() + " product");
product = mcLtl.constructProductModel(da, (DTMC)model, labelBS, statesOfInterest);
timer.stop("product has " + product.getProductModel().infoString());
// Adapt reward info to product model
productRewards = ((MCRewards) modelRewards).liftFromModel(product);
@ -174,18 +182,12 @@ public class DTMCModelChecker extends ProbModelChecker
}
// Find accepting states + compute reachability rewards
BitSet acc;
if (product.getAcceptance() instanceof AcceptanceReach) {
mainLog.println("\nSkipping BSCC computation since acceptance is defined via goal states...");
acc = ((AcceptanceReach)product.getAcceptance()).getGoalStates();
} else {
mainLog.println("\nFinding accepting BSCCs...");
acc = mcLtl.findAcceptingBSCCs(product.getProductModel(), product.getAcceptance());
}
mainLog.println("\nComputing reachability probabilities...");
BitSet acc = ((AcceptanceReach)product.getAcceptance()).getGoalStates();
mainLog.println("\nComputing reachability rewards...");
mcProduct = new DTMCModelChecker(this);
mcProduct.inheritSettings(this);
ModelCheckerResult res = mcProduct.computeReachRewards(product.getProductModel(), productRewards, acc);
ModelCheckerResult res = mcProduct.computeReachRewards((DTMC)product.getProductModel(), productRewards, acc);
rewardsProduct = StateValues.createFromDoubleArray(res.soln, product.getProductModel());
// Output vector over product, if required

34
prism/src/explicit/MDPModelChecker.java

@ -31,8 +31,10 @@ import java.util.BitSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import common.IterableStateSet;
import common.StopWatch;
import parser.VarList;
import parser.ast.Declaration;
import parser.ast.DeclarationIntUnbounded;
@ -48,6 +50,8 @@ import prism.PrismUtils;
import strat.MDStrategyArray;
import acceptance.AcceptanceReach;
import acceptance.AcceptanceType;
import automata.DA;
import automata.LTL2WDBA;
import common.IterableBitSet;
import explicit.rewards.MCRewards;
import explicit.rewards.MCRewardsFromMDPRewards;
@ -163,12 +167,16 @@ public class MDPModelChecker extends ProbModelChecker
// For LTL model checking routines
mcLtl = new LTLModelChecker(this);
// Build product of MDP and automaton
AcceptanceType[] allowedAcceptance = {
AcceptanceType.RABIN,
AcceptanceType.REACH
};
product = mcLtl.constructProductMDP(this, (MDP)model, expr, statesOfInterest, allowedAcceptance);
// Model check maximal state formulas and construct DFA, with the special
// handling needed for cosafety reward translation
Vector<BitSet> labelBS = new Vector<BitSet>();
DA<BitSet, AcceptanceReach> da = mcLtl.constructDFAForCosafetyRewardLTL(this, model, expr, labelBS);
StopWatch timer = new StopWatch(getLog());
mainLog.println("\nConstructing " + model.getModelType() + "-" + da.getAutomataType() + " product...");
timer.start(model.getModelType() + "-" + da.getAutomataType() + " product");
product = mcLtl.constructProductModel(da, (MDP)model, labelBS, statesOfInterest);
timer.stop("product has " + product.getProductModel().infoString());
// Adapt reward info to product model
productRewards = ((MDPRewards) modelRewards).liftFromModel(product);
@ -192,20 +200,12 @@ public class MDPModelChecker extends ProbModelChecker
}
// Find accepting states + compute reachability rewards
BitSet acc;
if (product.getAcceptance() instanceof AcceptanceReach) {
// For a DFA, just collect the accept states
mainLog.println("\nSkipping end component detection since DRA is a DFA...");
acc = ((AcceptanceReach)product.getAcceptance()).getGoalStates();
} else {
// Usually, we have to detect end components in the product
mainLog.println("\nFinding accepting end components...");
acc = mcLtl.findAcceptingECStates(product.getProductModel(), product.getAcceptance());
}
BitSet acc = ((AcceptanceReach)product.getAcceptance()).getGoalStates();
mainLog.println("\nComputing reachability rewards...");
mcProduct = new MDPModelChecker(this);
mcProduct.inheritSettings(this);
ModelCheckerResult res = mcProduct.computeReachRewards(product.getProductModel(), productRewards, acc, minMax.isMin());
ModelCheckerResult res = mcProduct.computeReachRewards((MDP)product.getProductModel(), productRewards, acc, minMax.isMin());
rewardsProduct = StateValues.createFromDoubleArray(res.soln, product.getProductModel());
// Output vector over product, if required

Loading…
Cancel
Save