private static List <Point3D> GetPointsOfCriticalArea(DACEmulator emulator, DACEmulator.Delta minMaxDeltaParameter, DACEmulator.Delta changingDeltaParameter, double minMaxDeltaParameterStep = 1, double changingDeltaParameterStep = 1, double accuracy = 0.0001)
        {
            List <Point3D> area     = new List <Point3D>();
            double         deltaMin = TestingDelta(emulator.N, emulator.Coeff, minMaxDeltaParameter, -minMaxDeltaParameterStep, accuracy, emulator.DeltaCoeff,
                                                   emulator.DeltaIndex, emulator.DeltaSM, true).GetDeltaParameter(minMaxDeltaParameter);
            double deltaMax = TestingDelta(emulator.N, emulator.Coeff, minMaxDeltaParameter, minMaxDeltaParameterStep, accuracy, emulator.DeltaCoeff,
                                           emulator.DeltaIndex, emulator.DeltaSM, true).GetDeltaParameter(minMaxDeltaParameter);

            double step = (deltaMax - deltaMin) / (minMaxDeltaParameterStep - 1);
            double i    = deltaMin;

            for (int j = 0; j < minMaxDeltaParameterStep; j++)
            {
                emulator.SetDeltaParameter(minMaxDeltaParameter, i);
                double deltaStepWithAccuracy = changingDeltaParameterStep;
                while (Math.Abs(deltaStepWithAccuracy) * 2 > accuracy)
                {
                    bool needCorrecting = false;
                    while (ErrorChecking(emulator))
                    {
                        emulator.AddDeltaParameter(changingDeltaParameter, deltaStepWithAccuracy);
                        needCorrecting = true;
                    }
                    if (needCorrecting)
                    {
                        emulator.AddDeltaParameter(changingDeltaParameter, -deltaStepWithAccuracy);
                    }
                    deltaStepWithAccuracy /= 2;
                }
                area.Add(new Point3D((float)emulator.GetDeltaParameter(DACEmulator.Delta.Coeff), (float)emulator.GetDeltaParameter(DACEmulator.Delta.SM), (float)emulator.GetDeltaParameter(DACEmulator.Delta.Index)));
                emulator.SetDeltaParameter(changingDeltaParameter, 0);
                i += step;
            }
            return(area);
        }
示例#2
0
        /// <summary>
        /// Получение дельта параметров по их типу
        /// </summary>
        /// <param name="delta"></param>
        /// <returns></returns>
        public double GetDeltaParameter(DACEmulator.Delta delta)
        {
            switch (delta)
            {
            case DACEmulator.Delta.Coeff:
                return(DeltaCoeff);

            case DACEmulator.Delta.Index:
                return(DeltaIndex);

            case DACEmulator.Delta.SM:
                return(DeltaSM);

            default:
                throw new Exception("Такого параметра не существует!");
            }
        }
示例#3
0
        public void SetDeltaParameter(DACEmulator.Delta delta, double value)
        {
            switch (delta)
            {
            case DACEmulator.Delta.Coeff:
                DeltaCoeff = value;
                break;

            case DACEmulator.Delta.Index:
                DeltaIndex = value;
                break;

            case DACEmulator.Delta.SM:
                DeltaSM = value;
                break;

            default:
                throw new Exception("Такого параметра не существует!");
            }
        }
        private static List <Point3D> GetPointsOfCriticalArea(DACEmulator emulator, DACEmulator.Delta minMaxDeltaParameter, DACEmulator.Delta changingDeltaParameter, double minMaxDeltaParameterStep = 1, double changingDeltaParameterStep = 1)
        {
            double         accuracy = 0.0001;
            List <Point3D> area     = new List <Point3D>();
            double         deltaMin = TestingDelta(emulator.N, emulator.Coeff, minMaxDeltaParameter, -minMaxDeltaParameterStep, accuracy, emulator.DeltaCoeff, emulator.DeltaIndex, emulator.DeltaSM).GetDeltaParameter(minMaxDeltaParameter);
            double         deltaMax = TestingDelta(emulator.N, emulator.Coeff, minMaxDeltaParameter, minMaxDeltaParameterStep, accuracy, emulator.DeltaCoeff, emulator.DeltaIndex, emulator.DeltaSM).GetDeltaParameter(minMaxDeltaParameter);

            minMaxDeltaParameterStep = (deltaMax - deltaMin) / minMaxDeltaParameterStep;
            for (double i = deltaMin; i <= deltaMax; i += minMaxDeltaParameterStep)
            {
                emulator.SetDeltaParameter(minMaxDeltaParameter, i);
                while (ErrorChecking(emulator))
                {
                    emulator.AddDeltaParameter(changingDeltaParameter, changingDeltaParameterStep);
                }
                area.Add(new Point3D((float)emulator.GetDeltaParameter(DACEmulator.Delta.Coeff), (float)emulator.GetDeltaParameter(DACEmulator.Delta.SM), (float)emulator.GetDeltaParameter(DACEmulator.Delta.Index)));
                emulator.SetDeltaParameter(changingDeltaParameter, 0);
            }
            return(area);
        }
        public static ParamsContainer TestingDelta(int n, double coeff, DACEmulator.Delta delta, double initialStep = 1, double accuracy = 0.0001,
                                                   double deltaCoeff = 0, double deltaIndex = 0, double deltaSM = 0, bool isAllowedValues = false)
        {
            int             countNumbers = (int)Math.Pow(2, n);
            List <int>      indexes = new List <int>();
            ParamsContainer container = new ParamsContainer(n, coeff, deltaCoeff, deltaIndex, deltaSM);
            LongBits        inputBinaryCode = new LongBits(0, n), outputBinaryCode = inputBinaryCode;
            DACEmulator     emulator = new DACEmulator(n, coeff, deltaCoeff, deltaIndex, deltaSM);

            while (Math.Abs(initialStep * 2) > accuracy)
            {
                inputBinaryCode = outputBinaryCode;
                while (inputBinaryCode == outputBinaryCode)
                {
                    emulator.DeltaCoeff = deltaCoeff;
                    emulator.DeltaIndex = deltaIndex;
                    emulator.DeltaSM    = deltaSM;
                    for (int x = 0; x < countNumbers; x++)
                    {
                        inputBinaryCode  = new LongBits(x, n);
                        outputBinaryCode = emulator.GetDKFromComparators(x);
                        if (inputBinaryCode != outputBinaryCode)
                        {
                            break;
                        }
                    }
                    if (inputBinaryCode == outputBinaryCode)
                    {
                        if (delta == DACEmulator.Delta.Coeff)
                        {
                            deltaCoeff += initialStep;
                        }
                        else if (delta == DACEmulator.Delta.Index)
                        {
                            deltaIndex += initialStep;
                        }
                        else if (delta == DACEmulator.Delta.SM)
                        {
                            deltaSM += initialStep;
                        }
                    }
                }
                if (delta == DACEmulator.Delta.Coeff)
                {
                    deltaCoeff -= initialStep;
                }
                else if (delta == DACEmulator.Delta.Index)
                {
                    deltaIndex -= initialStep;
                }
                else if (delta == DACEmulator.Delta.SM)
                {
                    deltaSM -= initialStep;
                }
                initialStep /= 2;
            }

            //Корректировка значений, если необходимо
            if (isAllowedValues)
            {
                if (delta == DACEmulator.Delta.Coeff)
                {
                    emulator.DeltaCoeff -= initialStep * 2;
                }
                else if (delta == DACEmulator.Delta.Index)
                {
                    emulator.DeltaIndex -= initialStep * 2;
                }
                else if (delta == DACEmulator.Delta.SM)
                {
                    emulator.DeltaSM -= initialStep * 2;
                }
            }

            for (int x = 0; x < countNumbers; x++)
            {
                indexes.AddRange(emulator.GetEKPErrorFromComparators(x).ToList());
                inputBinaryCode  = new LongBits(x, n);
                outputBinaryCode = emulator.GetDKFromComparators(x);
                if (inputBinaryCode != outputBinaryCode)
                {
                    container.ErrorIndexesFromInputAndOutputCodes.Add(x);
                }
                container.InputBinaryCodes.Add(inputBinaryCode);
                container.OutputBinaryCodes.Add(outputBinaryCode);
            }

            container.DeltaCoeff = emulator.DeltaCoeff;
            container.DeltaIndex = emulator.DeltaIndex;
            container.DeltaSM    = emulator.DeltaSM;
            container.ComparatorsErrorIndexes = indexes.Distinct().ToArray();
            return(container);
        }