コード例 #1
0
 public FailureInjector(TargetSystem system, ControlReconfigurationSystem controlReconfigurationSystem, int impactElementsCount, double simulationTime, double impactProbability)
 {
     ControlReconfigurationSystem = controlReconfigurationSystem;
     TargetSystem        = system;
     ImpactElementsCount = impactElementsCount;
     SimulationTime      = simulationTime;
     ImpactProbability   = impactProbability;
 }
コード例 #2
0
        public Simulator(SimulationConfig config)
        {
            _probabilityBasket = new ProbabilityBasket();

            TargetSystem = new TargetSystem(config.NTiersCount, config.LambdaElement, config.LambdaMajorityElement);

            ControlReconfigurationSystem             = new ControlReconfigurationSystem(TargetSystem, config.TAcceptableReconfigurationTime);
            ControlReconfigurationSystem.FailureRate = config.LambdaControlReconfigurationSystem;
            ControlReconfigurationSystem.ReconfigurationAlgorithm = ReconfigureAlgorithm;

            FailureInjector = new FailureInjector(TargetSystem, ControlReconfigurationSystem, config.RImpactElementsAffected, SimulationTime, config.ImpactProbability);
        }
コード例 #3
0
        private void SimulateIteration()
        {
            FailureInjector.SimulationTime = SimulationTime;
            FailureInjector.SimulateWearingOff();
            FailureInjector.SimulateImpact();

            bool systemIsWorking = ControlReconfigurationSystem.CheckSystem();

            if (systemIsWorking == true)
            {
                _probabilityBasket.Success();
            }
            else
            {
                _recoveringIssued = true;

                if (ControlReconfigurationSystem.IsAlive)
                {
                    bool successfullReconfig = ControlReconfigurationSystem.ReconfigureSystem();
                    //Debug.WriteLine(TargetSystem.Floors.Aggregate("", (s, floor) => s += (int)floor.MajorityElement.Mode + " "));

                    if (successfullReconfig == true)
                    {
                        _probabilityBasket.Success();
                        _recoverCounter += ControlReconfigurationSystem.RecoverAttemptsCount;
                        _successfullRecoverCounter++;
                    }
                    else
                    {
                        _recoveryFailed = true;
                        _probabilityBasket.Failed();
                    }
                }
                else
                {
                    _recoveryFailed = true;
                    _probabilityBasket.Failed();
                }
            }
        }