public void ExampleTwoStateSplitsProbabilisticThenNondeterministic() { NestedMarkovDecisionProcess = NmdpExamples.ExampleTwoStateSplitsProbabilisticThenNondeterministic.Create(); var converter = new NmdpToMdpByNewStates(NestedMarkovDecisionProcess, Output.TextWriterAdapter(), true); MarkovDecisionProcess = converter.MarkovDecisionProcess; int initialDistributions; int initialTransitions; double initialProbabilities; CalculateMetricsOfInitialState(out initialDistributions, out initialTransitions, out initialProbabilities); initialDistributions.ShouldBe(1); initialTransitions.ShouldBe(1); initialProbabilities.ShouldBe(1.0, 0.0000001); int state0Distributions; int state0Transitions; double state0Probabilities; CalculateMetricsOfState(0, out state0Distributions, out state0Transitions, out state0Probabilities); state0Distributions.ShouldBe(1); state0Transitions.ShouldBe(2); state0Probabilities.ShouldBe(1.0, 0.0000001); AssertDistanceIsEqual(converter.FormulaForArtificalState); }
public void ExampleNoChoices() { NestedMarkovDecisionProcess = NmdpExamples.ExampleNoChoices.Create(); var converter = new NmdpToMdpByNewStates(NestedMarkovDecisionProcess, Output.TextWriterAdapter(), false); MarkovDecisionProcess = converter.MarkovDecisionProcess; int initialDistributions; int initialTransitions; double initialProbabilities; CalculateMetricsOfInitialState(out initialDistributions, out initialTransitions, out initialProbabilities); initialDistributions.ShouldBe(1); initialTransitions.ShouldBe(1); initialProbabilities.ShouldBe(1.0, 0.0000001); int state0Distributions; int state0Transitions; double state0Probabilities; CalculateMetricsOfState(0, out state0Distributions, out state0Transitions, out state0Probabilities); state0Distributions.ShouldBe(1); state0Transitions.ShouldBe(1); state0Probabilities.ShouldBe(1.0, 0.0000001); }
public void CalculateMdpNewStatesConstantWithoutFaults() { var model = new Model(); SetProbabilities(model); model.Channel.MessageDropped.ProbabilityOfOccurrence = null; var createModel = SafetySharpRuntimeModel.CreateExecutedModelFromFormulasCreator(model); var markovChainGenerator = new MarkovDecisionProcessFromExecutableModelGenerator <SafetySharpRuntimeModel>(createModel) { Configuration = SafetySharpModelChecker.TraversalConfiguration }; markovChainGenerator.Configuration.SuccessorCapacity *= 2; markovChainGenerator.Configuration.ModelCapacity = new ModelCapacityByModelSize(3300000L, 1000000000L); markovChainGenerator.Configuration.EnableStaticPruningOptimization = false; markovChainGenerator.Configuration.LtmdpModelChecker = LtmdpModelChecker.BuildInMdpWithNewStates; markovChainGenerator.AddFormulaToCheck(model.PossibleCollision); markovChainGenerator.Configuration.UseCompactStateStorage = true; markovChainGenerator.Configuration.EnableEarlyTermination = false; var nmdp = markovChainGenerator.GenerateNestedMarkovDecisionProcess(); var nmdpToMpd = new NmdpToMdpByNewStates(nmdp, markovChainGenerator.Configuration.DefaultTraceOutput, true); }
public void CalculateMdpNewStatesConstant() { var oldProbability = _faults[1].ProbabilityOfOccurrence; _faults[1].ProbabilityOfOccurrence = null; var markovChainGenerator = new MarkovDecisionProcessFromExecutableModelGenerator <LustreExecutableModel>(_createModel); markovChainGenerator.Configuration.ModelCapacity = new ModelCapacityByModelSize(10000, 1000000); markovChainGenerator.Configuration.SuccessorCapacity *= 2; markovChainGenerator.Configuration.EnableStaticPruningOptimization = false; markovChainGenerator.Configuration.LtmdpModelChecker = LtmdpModelChecker.BuildInMdpWithNewStatesConstantDistance; markovChainGenerator.AddFormulaToCheck(_hazard); foreach (var fault in _faults) { var faultFormula = new FaultFormula(fault); markovChainGenerator.AddFormulaToCheck(faultFormula); } markovChainGenerator.Configuration.UseCompactStateStorage = true; markovChainGenerator.Configuration.EnableEarlyTermination = false; var nmdp = markovChainGenerator.GenerateNestedMarkovDecisionProcess(); var nmdpToMpd = new NmdpToMdpByNewStates(nmdp, markovChainGenerator.Configuration.DefaultTraceOutput, true); _faults[1].ProbabilityOfOccurrence = oldProbability; }
public void CalculateMdpNewStatesConstant() { var model = new DegradedModeModel(); model.System.SignalDetector1.F1.ProbabilityOfOccurrence = null; var createModel = SafetySharpRuntimeModel.CreateExecutedModelFromFormulasCreator(model); var markovChainGenerator = new MarkovDecisionProcessFromExecutableModelGenerator <SafetySharpRuntimeModel>(createModel) { Configuration = SafetySharpModelChecker.TraversalConfiguration }; markovChainGenerator.Configuration.SuccessorCapacity *= 2; markovChainGenerator.Configuration.EnableStaticPruningOptimization = false; markovChainGenerator.Configuration.LtmdpModelChecker = LtmdpModelChecker.BuildInMdpWithNewStates; markovChainGenerator.AddFormulaToCheck(model.System.HazardActive); foreach (var fault in model.Faults) { var faultFormula = new FaultFormula(fault); markovChainGenerator.AddFormulaToCheck(faultFormula); } markovChainGenerator.Configuration.UseCompactStateStorage = true; markovChainGenerator.Configuration.EnableEarlyTermination = false; var nmdp = markovChainGenerator.GenerateNestedMarkovDecisionProcess(); var nmdpToMpd = new NmdpToMdpByNewStates(nmdp, markovChainGenerator.Configuration.DefaultTraceOutput, true); }
public void CalculateMdpNewStatesConstantWithoutFaults() { var model = new Model(); SetProbabilities(model); model.HdMachine.Dialyzer.DialyzerMembraneRupturesFault.ProbabilityOfOccurrence = null; var createModel = SafetySharpRuntimeModel.CreateExecutedModelFromFormulasCreator(model); var markovChainGenerator = new MarkovDecisionProcessFromExecutableModelGenerator <SafetySharpRuntimeModel>(createModel) { Configuration = SafetySharpModelChecker.TraversalConfiguration }; markovChainGenerator.Configuration.SuccessorCapacity *= 2; markovChainGenerator.Configuration.EnableStaticPruningOptimization = false; markovChainGenerator.Configuration.LtmdpModelChecker = LtmdpModelChecker.BuildInMdpWithNewStates; markovChainGenerator.Configuration.EnableEarlyTermination = false; markovChainGenerator.AddFormulaToCheck(new BoundedUnaryFormula(model.BloodNotCleanedAndDialyzingFinished, UnaryOperator.Finally, 6)); markovChainGenerator.AddFormulaToCheck(new BoundedUnaryFormula(model.IncomingBloodWasNotOk, UnaryOperator.Finally, 6)); markovChainGenerator.Configuration.UseCompactStateStorage = true; var nmdp = markovChainGenerator.GenerateNestedMarkovDecisionProcess(); var nmdpToMpd = new NmdpToMdpByNewStates(nmdp, markovChainGenerator.Configuration.DefaultTraceOutput, true); }
public void CalculateMdpNewStatesWithoutFaults() { var model = Model.CreateOriginal(); model.VehicleSet.LeftHV.ProbabilityOfOccurrence = null; var createModel = SafetySharpRuntimeModel.CreateExecutedModelFromFormulasCreator(model); var markovChainGenerator = new MarkovDecisionProcessFromExecutableModelGenerator <SafetySharpRuntimeModel>(createModel) { Configuration = SafetySharpModelChecker.TraversalConfiguration }; markovChainGenerator.Configuration.SuccessorCapacity *= 2; markovChainGenerator.Configuration.ModelCapacity = new ModelCapacityByModelSize(3300000L, 1000000000L); markovChainGenerator.Configuration.EnableStaticPruningOptimization = false; markovChainGenerator.Configuration.LtmdpModelChecker = LtmdpModelChecker.BuildInMdpWithNewStates; markovChainGenerator.AddFormulaToCheck(new BoundedUnaryFormula(model.Collision, UnaryOperator.Finally, 50)); markovChainGenerator.AddFormulaToCheck(new BoundedUnaryFormula(model.FalseAlarm, UnaryOperator.Finally, 50)); markovChainGenerator.Configuration.UseCompactStateStorage = true; markovChainGenerator.Configuration.EnableEarlyTermination = false; var nmdp = markovChainGenerator.GenerateNestedMarkovDecisionProcess(); var nmdpToMpd = new NmdpToMdpByNewStates(nmdp, markovChainGenerator.Configuration.DefaultTraceOutput, false); }
public void CalculateMdpNewStatesWithoutFaults() { var model = new DeadReckoningModel(); model.Component.FF.ProbabilityOfOccurrence = null; var createModel = SafetySharpRuntimeModel.CreateExecutedModelFromFormulasCreator(model); var markovChainGenerator = new MarkovDecisionProcessFromExecutableModelGenerator <SafetySharpRuntimeModel>(createModel) { Configuration = SafetySharpModelChecker.TraversalConfiguration }; markovChainGenerator.Configuration.SuccessorCapacity *= 2; markovChainGenerator.Configuration.EnableStaticPruningOptimization = false; markovChainGenerator.Configuration.LtmdpModelChecker = LtmdpModelChecker.BuildInMdpWithNewStates; markovChainGenerator.AddFormulaToCheck(model.Component.Hazard); markovChainGenerator.Configuration.UseCompactStateStorage = true; markovChainGenerator.Configuration.EnableEarlyTermination = false; var nmdp = markovChainGenerator.GenerateNestedMarkovDecisionProcess(); var nmdpToMpd = new NmdpToMdpByNewStates(nmdp, markovChainGenerator.Configuration.DefaultTraceOutput, false); }