private bool StatisticVerificationMinReach(MDPStat mdp, VerificationOutput verificationOutput) { mdp.setNonZeroStates(); var sml = new Simulation(mdp); var pl = new Policy(mdp); var tst = new RunTest(); tst.initRunTest(StatisticalParameters[1], StatisticalParameters[2], StatisticalParameters[3], StatisticalParameters[0]); // string str; return(tst.verifyMDPSPRT(sml, pl, out str)); }
/// <summary> /// Run the verification and get the result. /// </summary> /// <returns></returns> public override void RunVerification() { MDPStat mdp = BuildMDP(); //GetTransitionRelation(); if (StatisticVerificationMinReach(mdp, VerificationOutput)) { this.VerificationOutput.VerificationResult = VerificationResultType.VALID; } else { this.VerificationOutput.VerificationResult = VerificationResultType.INVALID; } }
private MDPStat BuildMDP() { Stack <KeyValuePair <MDPConfiguration, MDPStateStat> > working = new Stack <KeyValuePair <MDPConfiguration, MDPStateStat> >(1024); string initID = InitialStep.GetID(); MDPStateStat init = new MDPStateStat(initID); working.Push(new KeyValuePair <MDPConfiguration, MDPStateStat>(InitialStep as MDPConfiguration, init)); MDPStat mdp = new MDPStat(init, Ultility.Ultility.DEFAULT_PRECISION, Ultility.Ultility.MAX_DIFFERENCE); do { if (CancelRequested) { VerificationOutput.NoOfStates = mdp.States.Count; return(mdp); } KeyValuePair <MDPConfiguration, MDPStateStat> current = working.Pop(); IEnumerable <MDPConfiguration> list = current.Key.MakeOneMoveLocal(); VerificationOutput.Transitions += list.Count(); int currentDistriIndex = -1; DistributionStat newDis = new DistributionStat(Constants.TAU); //for (int i = 0; i < list.Length; i++) foreach (MDPConfiguration step in list) { //MDPConfiguration step = list[i]; string stepID = step.GetID(); MDPStateStat nextState; if (!mdp.States.TryGetValue(stepID, out nextState)) { nextState = new MDPStateStat(stepID); mdp.AddState(nextState); ExpressionValue v = EvaluatorDenotational.Evaluate(ReachableStateCondition, step.GlobalEnv); if ((v as BoolConstant).Value) { mdp.AddTargetStates(nextState); } else { working.Push(new KeyValuePair <MDPConfiguration, MDPStateStat>(step, nextState)); } } if (step.DisIndex == -1) { if (currentDistriIndex >= 0) { current.Value.AddDistribution(newDis); newDis = new DistributionStat(Constants.TAU); } var newTrivialDis = new DistributionStat(step.Event); newTrivialDis.AddProbStatePair(1, nextState); current.Value.AddDistribution(newTrivialDis); } else if (currentDistriIndex != -1 && step.DisIndex != currentDistriIndex) { current.Value.AddDistribution(newDis); newDis = new DistributionStat(Constants.TAU); newDis.AddProbStatePair(step.Probability, nextState); } else { newDis.AddProbStatePair(step.Probability, nextState); } currentDistriIndex = step.DisIndex; } if (currentDistriIndex >= 0) { current.Value.AddDistribution(newDis); } } while (working.Count > 0); VerificationOutput.NoOfStates = mdp.States.Count; return(mdp); }
private bool StatisticVerificationMinReach(MDPStat mdp, VerificationOutput verificationOutput) { mdp.setNonZeroStates(); var sml = new Simulation(mdp); var pl = new Policy(mdp); var tst = new RunTest(); tst.initRunTest(StatisticalParameters[1], StatisticalParameters[2], StatisticalParameters[3], StatisticalParameters[0]); // string str; return tst.verifyMDPSPRT(sml, pl, out str); }
private MDPStat BuildMDP() { Stack<KeyValuePair<MDPConfiguration, MDPStateStat>> working = new Stack<KeyValuePair<MDPConfiguration, MDPStateStat>>(1024); string initID = InitialStep.GetID(); MDPStateStat init = new MDPStateStat(initID); working.Push(new KeyValuePair<MDPConfiguration, MDPStateStat>(InitialStep as MDPConfiguration, init)); MDPStat mdp = new MDPStat(init, Ultility.Ultility.DEFAULT_PRECISION, Ultility.Ultility.MAX_DIFFERENCE); do { if (CancelRequested) { VerificationOutput.NoOfStates = mdp.States.Count; return mdp; } KeyValuePair<MDPConfiguration, MDPStateStat> current = working.Pop(); IEnumerable<MDPConfiguration> list = current.Key.MakeOneMoveLocal(); VerificationOutput.Transitions += list.Count(); int currentDistriIndex = -1; DistributionStat newDis = new DistributionStat(Constants.TAU); //for (int i = 0; i < list.Length; i++) foreach (MDPConfiguration step in list) { //MDPConfiguration step = list[i]; string stepID = step.GetID(); MDPStateStat nextState; if (!mdp.States.TryGetValue(stepID, out nextState)) { nextState = new MDPStateStat(stepID); mdp.AddState(nextState); ExpressionValue v = EvaluatorDenotational.Evaluate(ReachableStateCondition, step.GlobalEnv); if ((v as BoolConstant).Value) { mdp.AddTargetStates(nextState); } else { working.Push(new KeyValuePair<MDPConfiguration, MDPStateStat>(step, nextState)); } } if (step.DisIndex == -1) { if (currentDistriIndex >= 0) { current.Value.AddDistribution(newDis); newDis = new DistributionStat(Constants.TAU); } var newTrivialDis = new DistributionStat(step.Event); newTrivialDis.AddProbStatePair(1, nextState); current.Value.AddDistribution(newTrivialDis); } else if (currentDistriIndex != -1 && step.DisIndex != currentDistriIndex) { current.Value.AddDistribution(newDis); newDis = new DistributionStat(Constants.TAU); newDis.AddProbStatePair(step.Probability, nextState); } else { newDis.AddProbStatePair(step.Probability, nextState); } currentDistriIndex = step.DisIndex; } if (currentDistriIndex >= 0) { current.Value.AddDistribution(newDis); } } while (working.Count > 0); VerificationOutput.NoOfStates = mdp.States.Count; return mdp; }