Exemplo n.º 1
0
        private bool CheckSet(FaultSet set, Fault[] allFaults, bool isHeuristicSuggestion, Activation activationMode)
        {
            try
            {
                var result = _backend.CheckCriticality(set, activationMode);

                if (Configuration.CollectFaultSets)
                {
                    if (!result.FormulaHolds)
                    {
                        if (!isHeuristicSuggestion)
                        {
                            ConsoleHelpers.WriteLine($"    critical:  {{ {set.ToString(allFaults)} }}", ConsoleColor.DarkRed);
                        }

                        _criticalSets.Add(set);
                    }
                    else if (isHeuristicSuggestion)
                    {
                        ConsoleHelpers.WriteLine($"    safe:      {{ {set.ToString(allFaults)} }}  [heuristic]", ConsoleColor.Blue);
                    }

                    _checkedSets.Add(set);
                }

                _checkedSetCount++;

                if (result.CounterExample != null)
                {
                    var executableCounterExample = new ExecutableCounterExample <TExecutableModel>(_backend.RuntimeModelCreator.Create(0), result.CounterExample);
                    _counterExamples.Add(set, executableCounterExample);
                }

                return(result.FormulaHolds);
            }
            catch (AnalysisException e)
            {
                var heuristic = isHeuristicSuggestion ? " [heuristic]" : string.Empty;
                ConsoleHelpers.WriteLine($"    critical:  {{ {set.ToString(allFaults)} }} {heuristic} [exception thrown]", ConsoleColor.DarkRed);
                Console.WriteLine(e.InnerException);

                if (Configuration.CollectFaultSets)
                {
                    _checkedSets.Add(set);
                }
                _checkedSetCount++;
                _criticalSets.Add(set);
                _exceptions.Add(set, e.InnerException);

                if (e.CounterExample != null)
                {
                    var executableCounterExample = new ExecutableCounterExample <TExecutableModel>(_backend.RuntimeModelCreator.Create(0), e.CounterExample);
                    _counterExamples.Add(set, executableCounterExample);
                }

                return(false);
            }
        }
Exemplo n.º 2
0
		private bool CheckSet(FaultSet set, Fault[] allFaults, bool isHeuristicSuggestion, Activation activationMode)
		{
			try
			{
				var result = _backend.CheckCriticality(set, activationMode);

				if (!result.FormulaHolds)
				{
					if (!isHeuristicSuggestion)
						ConsoleHelpers.WriteLine($"    critical:  {{ {set.ToString(allFaults)} }}", ConsoleColor.DarkRed);

					_criticalSets.Add(set);
				}
				else if (isHeuristicSuggestion)
				{
					ConsoleHelpers.WriteLine($"    safe:      {{ {set.ToString(allFaults)} }}  [heuristic]", ConsoleColor.Blue);
				}

				_checkedSets.Add(set);

				if (result.CounterExample != null)
					_counterExamples.Add(set, result.CounterExample);

				return result.FormulaHolds;
			}
			catch (AnalysisException e)
			{
				var heuristic = isHeuristicSuggestion ? " [heuristic]" : string.Empty;
				ConsoleHelpers.WriteLine($"    critical:  {{ {set.ToString(allFaults)} }} {heuristic} [exception thrown]", ConsoleColor.DarkRed);
				Console.WriteLine(e.InnerException);

				_checkedSets.Add(set);
				_criticalSets.Add(set);
				_exceptions.Add(set, e.InnerException);

				if (e.CounterExample != null)
					_counterExamples.Add(set, e.CounterExample);
				return false;
			}
		}