Esempio n. 1
0
 /// <summary>
 ///   Computes the minimal critical sets for the <paramref name="hazard" />.
 /// </summary>
 /// <param name="createModel">The creator for the model that should be checked.</param>
 /// <param name="hazard">The hazard the minimal critical sets should be computed for.</param>
 /// <param name="maxCardinality">
 ///   The maximum cardinality of the fault sets that should be checked. By default, all minimal
 ///   critical fault sets are determined.
 /// </param>
 /// <param name="backend">Determines the safety analysis backend that is used during the analysis.</param>
 public static SafetyAnalysisResults <TExecutableModel> AnalyzeHazard(CoupledExecutableModelCreator <TExecutableModel> createModel, Formula hazard, int maxCardinality = Int32.MaxValue,
                                                                      SafetyAnalysisBackend backend = SafetyAnalysisBackend.FaultOptimizedOnTheFly)
 {
     return(new SafetyAnalysis <TExecutableModel> {
         Backend = backend
     }.ComputeMinimalCriticalSets(createModel, hazard, maxCardinality));
 }
Esempio n. 2
0
        public static SafetyAnalysisResults <SafetySharpRuntimeModel> AnalyzeHazard(ModelBase model, Formula hazard, int maxCardinality = Int32.MaxValue,
                                                                                    SafetyAnalysisBackend backend = SafetyAnalysisBackend.FaultOptimizedOnTheFly)
        {
            var modelCreator = SafetySharpRuntimeModel.CreateExecutedModelCreator(model, hazard);

            return(AnalyzeHazard(modelCreator, hazard, maxCardinality, backend));
        }
Esempio n. 3
0
        public static SafetyAnalysisResults <LustreExecutableModel> AnalyzeHazard(string ocFileName, string mainNode, IEnumerable <Fault> faults, Formula hazard, int maxCardinality = Int32.MaxValue,
                                                                                  SafetyAnalysisBackend backend = SafetyAnalysisBackend.FaultOptimizedOnTheFly)
        {
            var modelCreator = LustreExecutableModel.CreateExecutedModelCreator(ocFileName, mainNode, faults.ToArray(), hazard);

            return(AnalyzeHazard(modelCreator, hazard, maxCardinality, backend));
        }
Esempio n. 4
0
        public void FalseAlarmOriginalDesign(
            [Values(SafetyAnalysisBackend.FaultOptimizedStateGraph, SafetyAnalysisBackend.FaultOptimizedOnTheFly)] SafetyAnalysisBackend backend)
        {
            var model    = Model.CreateOriginal();
            var analysis = new SafetySharpSafetyAnalysis {
                Backend = backend, Heuristics = { new MaximalSafeSetHeuristic(model.Faults) }
            };
            var result = analysis.ComputeMinimalCriticalSets(model, model.FalseAlarm);

            result.SaveCounterExamples("counter examples/height control/dcca/false alarm/original");

            var orderResult = SafetySharpOrderAnalysis.ComputeOrderRelationships(result);

            Console.WriteLine(orderResult);
        }
Esempio n. 5
0
        public void DialysisFinishedAndBloodNotCleaned_ModelChecking(
            [Values(SafetyAnalysisBackend.FaultOptimizedStateGraph, SafetyAnalysisBackend.FaultOptimizedOnTheFly)] SafetyAnalysisBackend backend)
        {
            var specification = new Model();
            var analysis      = new SafetySharpSafetyAnalysis
            {
                Backend       = backend,
                Configuration = { ModelCapacity = new ModelCapacityByModelDensity(1310720, ModelDensityLimit.Medium) }
            };

            var result = analysis.ComputeMinimalCriticalSets(specification, specification.BloodNotCleanedAndDialyzingFinished);

            result.SaveCounterExamples("counter examples/hdmachine_unsuccessful");

            var orderResult = SafetySharpOrderAnalysis.ComputeOrderRelationships(result);

            Console.WriteLine(orderResult);
        }
Esempio n. 6
0
        public void IncomingBloodIsContaminated_ModelChecking(
            [Values(SafetyAnalysisBackend.FaultOptimizedStateGraph, SafetyAnalysisBackend.FaultOptimizedOnTheFly)] SafetyAnalysisBackend backend)
        {
            var specification = new Model();
            var analysis      = new SafetySharpSafetyAnalysis
            {
                Backend       = backend,
                Heuristics    = { new MaximalSafeSetHeuristic(specification.Faults) },
                Configuration = { ModelCapacity = new ModelCapacityByModelDensity(1310720, ModelDensityLimit.Medium) }
            };

            var result = analysis.ComputeMinimalCriticalSets(specification, specification.IncomingBloodWasNotOk);

            result.SaveCounterExamples("counter examples/hdmachine_contamination");

            var orderResult = SafetySharpOrderAnalysis.ComputeOrderRelationships(result);

            Console.WriteLine(orderResult);
        }
Esempio n. 7
0
        public void CollisionOriginalDesign(
            [Values(SafetyAnalysisBackend.FaultOptimizedStateGraph, SafetyAnalysisBackend.FaultOptimizedOnTheFly)] SafetyAnalysisBackend backend)
        {
            var model = Model.CreateOriginal();

            // As collisions cannot occur without any overheight vehicles driving on the left lane, we
            // force the activation of the LeftOHV fault to improve safety analysis times significantly
            model.VehicleSet.LeftOHV.Activation = Activation.Forced;

            var analysis = new SafetySharpSafetyAnalysis {
                Backend = backend, Heuristics = { new MaximalSafeSetHeuristic(model.Faults) }
            };
            var result = analysis.ComputeMinimalCriticalSets(model, model.Collision);

            result.SaveCounterExamples("counter examples/height control/dcca/collision/original");

            var orderResult = SafetySharpOrderAnalysis.ComputeOrderRelationships(result);

            Console.WriteLine(orderResult);
        }
Esempio n. 8
0
        public void Collision(
            [Values(SafetyAnalysisBackend.FaultOptimizedStateGraph, SafetyAnalysisBackend.FaultOptimizedOnTheFly)] SafetyAnalysisBackend backend)
        {
            var model  = new Model();
            var result = SafetySharpSafetyAnalysis.AnalyzeHazard(model, model.PossibleCollision, backend: backend);

            result.SaveCounterExamples("counter examples/railroad crossing/dcca/collision");

            var orderResult = SafetySharpOrderAnalysis.ComputeOrderRelationships(result);

            Console.WriteLine(orderResult);

            result.IsComplete.Should().BeTrue();
            result.MinimalCriticalSets.ShouldAllBeEquivalentTo(new[]
            {
                new[] { model.TrainController.Odometer.OdometerPositionOffset },
                new[] { model.TrainController.Odometer.OdometerSpeedOffset },
                new[] { model.CrossingController.Sensor.BarrierSensorFailure },
                new[] { model.CrossingController.TrainSensor.ErroneousTrainDetection },
                new[] { model.CrossingController.Motor.BarrierMotorStuck, model.TrainController.Brakes.BrakesFailure },
                new[] { model.Channel.MessageDropped, model.TrainController.Brakes.BrakesFailure }
            });
        }
Esempio n. 9
0
		/// <summary>
		///   Computes the minimal critical sets for the <paramref name="hazard" />.
		/// </summary>
		/// <param name="model">The model the safety analysis should be conducted for.</param>
		/// <param name="hazard">The hazard the minimal critical sets should be computed for.</param>
		/// <param name="maxCardinality">
		///   The maximum cardinality of the fault sets that should be checked. By default, all minimal
		///   critical fault sets are determined.
		/// </param>
		/// <param name="backend">Determines the safety analysis backend that is used during the analysis.</param>
		public static SafetyAnalysisResults AnalyzeHazard(ModelBase model, Formula hazard, int maxCardinality = Int32.MaxValue,
														  SafetyAnalysisBackend backend = SafetyAnalysisBackend.FaultOptimizedOnTheFly)
		{
			return new SafetyAnalysis { Backend = backend }.ComputeMinimalCriticalSets(model, hazard, maxCardinality);
		}