/// <summary> /// Checks whether the <paramref name="invariants" /> holds in all states of the <paramref name="model" />. /// </summary> /// <param name="createModel">The creator for the model that should be checked.</param> /// <param name="invariants">The invariants that should be checked.</param> public AnalysisResult <TExecutableModel>[] CheckInvariants(ExecutableModelCreator <TExecutableModel> createModel, params Formula[] invariants) { Requires.NotNull(createModel, nameof(createModel)); Requires.NotNull(invariants, nameof(invariants)); Requires.That(invariants.Length > 0, nameof(invariants), "Expected at least one invariant."); var modelGenerator = createModel.Create(invariants); var stateGraph = GenerateStateGraph(modelGenerator); var results = new AnalysisResult <TExecutableModel> [invariants.Length]; for (var i = 0; i < invariants.Length; ++i) { results[i] = CheckInvariant(stateGraph, invariants[i]); } return(results); }
/// <summary> /// Initializes a new instance. /// </summary> public ProbabilisticSimulator(ExecutableModelCreator <TExecutableModel> modelCreator, IEnumerable <Formula> formulas, AnalysisConfiguration configuration) { // TODO: Set Mode WithCustomSeed (each thread must have its own seed) or RealRandom Requires.NotNull(modelCreator, nameof(modelCreator)); RuntimeModel = modelCreator.CreateCoupledModelCreator(formulas.ToArray()).Create(0); NormalizedFormulas = RuntimeModel.Formulas.ToArray(); NormalizedFormulaLabels = NormalizedFormulas.Select(stateFormula => stateFormula.Label).ToArray(); NormalizedFormulaSatisfactionCount = new int[NormalizedFormulas.Length]; _compiledNormalizedFormulas = NormalizedFormulas.Select(formula => FormulaCompilationVisitor <TExecutableModel> .Compile(RuntimeModel, formula)).ToArray(); _allowFaultsOnInitialTransitions = configuration.AllowFaultsOnInitialTransitions; _choiceResolver = new ProbabilisticSimulatorChoiceResolver(configuration.UseOptionProbabilitiesInSimulation, (int)DateTime.Now.Ticks); RuntimeModel.SetChoiceResolver(_choiceResolver); SavedActivations = RuntimeModel.NondeterministicFaults.Select(fault => fault.Activation).ToArray(); }
public EvaluationTests() { LustrePressureBelowThreshold.threshold = 60; var faultK1 = new PermanentFault() { Name = "fault_k1", Identifier = 1, ProbabilityOfOccurrence = new Probability(3.0E-6) }; var faultK2 = new PermanentFault() { Name = "fault_k2", Identifier = 2, ProbabilityOfOccurrence = new Probability(3.0E-6) }; var faultSensor = new PermanentFault() { Name = "fault_sensor", Identifier = 4, ProbabilityOfOccurrence = new Probability(1.0E-5) }; _faults = new[] { faultK1, faultK2, faultSensor }; _createModel = LustreExecutableModel.CreateExecutedModelFromFormulasCreator(Path.Combine(AssemblyDirectory, "pressureTank.lus"), "TANK", _faults); }
// Create Tasks which make the checks (workers) // First formulas to check are collected (thus, the probability matrix only has to be calculated once) public NmdpFromExecutableModelGenerator(ExecutableModelCreator <TExecutableModel> runtimeModelCreator) { Requires.NotNull(runtimeModelCreator, nameof(runtimeModelCreator)); _runtimeModelCreator = runtimeModelCreator; }
public override AnalysisResult <SafetySharpRuntimeModel>[] CheckInvariants(ExecutableModelCreator <SafetySharpRuntimeModel> createModel, params Formula[] invariants) { throw new NotImplementedException(); }
public abstract AnalysisResult <SafetySharpRuntimeModel>[] CheckInvariants(ExecutableModelCreator <SafetySharpRuntimeModel> createModel, params Formula[] invariants);
public override AnalysisResult <SafetySharpRuntimeModel>[] CheckInvariants(ExecutableModelCreator <SafetySharpRuntimeModel> createModel, params Formula[] invariants) { return(modelChecker.CheckInvariants(createModel, invariants)); }
// Create Tasks which make the checks (workers) // First formulas to check are collected (thus, the probability matrix only has to be calculated once) public MarkovDecisionProcessFromExecutableModelGenerator(ExecutableModelCreator <TExecutableModel> runtimeModelCreator) { Requires.NotNull(runtimeModelCreator, nameof(runtimeModelCreator)); _runtimeModelCreator = runtimeModelCreator; }