예제 #1
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);
        }
예제 #2
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();
                }
            }
        }