コード例 #1
0
        //функция парсинга математических функций, на вход подается сама функция и класс всех
        //объектов, так как функция может содержать СЧА
        public static string go_parse(ModelingState modeling_objects, string function,
                                      int id_tranzakts)
        {
            bool function_was_counting = false;

            while (function_was_counting == false)//пока есть что считать
            {
                //поиск самых вложенных скобок
                int index_of_left_parenthesis  = -1;
                int index_of_right_parenthesis = -1;
                for (int i = 0; i < function.Count(); i++)
                {
                    //если встретилась открывающая скобка-запись ее индекса
                    if (function.ElementAt(i) == '(')
                    {
                        index_of_left_parenthesis = i;
                        index_of_left_parenthesis++;//чтобы потом не захватить скобку
                        continue;
                    }
                    //если встретилась закрывающая скобка-запись ее индекса, это
                    //гарантирует, что внутри нее больше не будет скобок
                    if (function.ElementAt(i) == ')')
                    {
                        index_of_right_parenthesis = i;
                        break;
                    }
                }
                //проверка на ошибку синтаксиса
                if ((index_of_right_parenthesis == -1 & index_of_left_parenthesis != -1) |
                    (index_of_right_parenthesis != -1 & index_of_left_parenthesis == -1))
                {
                    return("syntaxis_error");
                }
                //проверка, возможно, больше нет(не было скобок)
                if (index_of_right_parenthesis == -1 & index_of_left_parenthesis == -1)
                {//отправляю всю функцию в расчет
                    function_was_counting = true;
                    function = counting_function(function, modeling_objects, id_tranzakts);
                    if (function == "syntaxis_error")
                    {
                        return(function);
                    }
                }
                else//иначе отправляю только часть функции в расчет
                {
                    string counting_part_function = counting_function(function.Substring(
                                                                          index_of_left_parenthesis, (index_of_right_parenthesis -
                                                                                                      index_of_left_parenthesis)), modeling_objects, id_tranzakts);
                    if (counting_part_function == "syntaxis_error")
                    {
                        return(counting_part_function);
                    }
                    //удаление выражения в скобах и замена его на рассчитанное значение
                    function = function.Remove((index_of_left_parenthesis - 1), ((
                                                                                     index_of_right_parenthesis - index_of_left_parenthesis) + 2));
                    function = function.Insert((index_of_left_parenthesis - 1),
                                               counting_part_function);
                }
            }
            return(function);
        }
コード例 #2
0
        //функция рассчет части или целой функции в случае отсутствия скобок
        private static string counting_function(string part_or_full_function,
                                                ModelingState modeling_objects, int id_tranzakts)
        {
            //проверка приоритетных знаков(умножение, деление, возведение в степень)
            //таких знаков может быть несколько
            bool priority_mark_not_search = false;

            while (priority_mark_not_search == false)
            {
                //если последним символом будет стоять какое-либо действие, то это значит
                //отсутствие правого оператора
                if (part_or_full_function.ElementAt(part_or_full_function.Count() - 1) == '*' |
                    part_or_full_function.ElementAt(part_or_full_function.Count() - 1) == '/' |
                    part_or_full_function.ElementAt(part_or_full_function.Count() - 1) == '+' |
                    part_or_full_function.ElementAt(part_or_full_function.Count() - 1) == '-' |
                    part_or_full_function.ElementAt(part_or_full_function.Count() - 1) == '^')
                {
                    return("syntaxis_error");
                }

                for (int i = 0; i < part_or_full_function.Count(); i++)
                {
                    //запоминаю действие, чтобы потом обпять не обращаться по индексу
                    string action = part_or_full_function.ElementAt(i).ToString();

                    //если нашли приоритетное действие
                    if (action == "*" | action == "/" | action == "^")
                    {
                        //оно не стоит на первом месте(перед ним должно стоять что - либо)
                        if (i > 0)
                        {
                            //числа или СЧА
                            string a = "";
                            string b = "";
                            //индексы рассчитываемого выражения, когда рассчитаю выражение, на
                            //место него в строку запишу ответ
                            int left  = 0;
                            int right = 0;
                            //проверка на неправильный синтаксис, для случая, когда несколько
                            //действий стоит рядом
                            //проверять слева нет смысла, поиск выражений идет слева на право и,
                            //если два действия будут стоять радом, это обнаружится еще при
                            //исследовании левого
                            if (part_or_full_function.ElementAt(i + 1) == '*' |
                                part_or_full_function.ElementAt(i + 1) == '/' |
                                part_or_full_function.ElementAt(i + 1) == '^' |
                                part_or_full_function.ElementAt(i + 1) == '+' |
                                part_or_full_function.ElementAt(i + 1) == '-')
                            {
                                return("syntaxis_error");
                            }
                            //записываем все числа или сча слева от приоритетного знака
                            for (int n = (i - 1); n >= 0; n--)
                            {
                                //если встретится хотя бы один ттакой символ, то это будет хначить,
                                //что число или строка А заполенна(о)
                                if (part_or_full_function.ElementAt(n) == '*' |
                                    part_or_full_function.ElementAt(n) == '/' |
                                    part_or_full_function.ElementAt(n) == '+' |
                                    part_or_full_function.ElementAt(n) == '-' |
                                    part_or_full_function.ElementAt(n) == '^')
                                {
                                    break;
                                }
                                a    = part_or_full_function.ElementAt(n) + a;
                                left = n;
                            }
                            //записываем все числа или сча справа от приоритетного знака
                            for (int n = (i + 1); n < part_or_full_function.Count(); n++)
                            {
                                //если встретится хотя бы один ттакой символ, то это будет хначить,
                                //что число или строка А заполенна(о)
                                if (part_or_full_function.ElementAt(n) == '*' |
                                    part_or_full_function.ElementAt(n) == '/' |
                                    part_or_full_function.ElementAt(n) == '+' |
                                    part_or_full_function.ElementAt(n) == '-' |
                                    part_or_full_function.ElementAt(n) == '^')
                                {
                                    break;
                                }
                                b    += part_or_full_function.ElementAt(n);
                                right = n;
                            }



                            //Удалить блок для возвращения к исходному модулю(добавлена
                            //распознавание СЧА и др для моделирования)
                            if (a.ElementAt(0) == 'P')//это параметр транзакта
                            {
                                a = modeling_objects.tranzakts.ElementAt(id_tranzakts).
                                    get_parameter(a.Remove(0, 1));
                            }
                            if (b.ElementAt(0) == 'P')//это параметр транзакта
                            {
                                b = modeling_objects.tranzakts.ElementAt(id_tranzakts).
                                    get_parameter(b.Remove(0, 1));
                            }
                            //некоторые индикаторы не однозначные(как параметр транзкта, например)
                            //а двузначеные(V$-пример)
                            if (a.Count() > 2)
                            {
                                if (a.Remove(2) == "N$")//это кол-во переходов по метке
                                {
                                    a = a.Remove(0, 2);
                                    if (a.Count() == 0)
                                    {
                                        //есть определение перменной, но у нее нет имени
                                        return("syntaxis_error");
                                    }
                                    //поиск метки по имени
                                    for (int g = 0; g < modeling_objects.lables.Count(); g++)
                                    {
                                        if (modeling_objects.lables.ElementAt(g).get_name() == a)
                                        {
                                            a = modeling_objects.lables.ElementAt(g).
                                                get_entries_number().ToString();
                                            break;
                                        }
                                        //не нашли метку
                                        if (g == modeling_objects.lables.Count() - 1)
                                        {
                                            return("syntaxis_error");
                                        }
                                    }
                                }
                            }
                            //некоторые индикаторы не однозначные(как параметр транзкта, например)
                            //а двузначеные(V$-пример)
                            if (b.Count() > 2)
                            {
                                if (b.Remove(2) == "N$")//это кол-во переходов по метке
                                {
                                    b = b.Remove(0, 2);
                                    if (b.Count() == 0)
                                    {
                                        //есть определение перменной, но у нее нет имени
                                        return("syntaxis_error");
                                    }
                                    //поиск метки по имени
                                    for (int g = 0; g < modeling_objects.lables.Count(); g++)
                                    {
                                        if (modeling_objects.lables.ElementAt(g).get_name() == b)
                                        {
                                            b = modeling_objects.lables.ElementAt(g).
                                                get_entries_number().ToString();
                                            break;
                                        }
                                        //не нашли метку
                                        if (g == modeling_objects.lables.Count() - 1)
                                        {
                                            return("syntaxis_error");
                                        }
                                    }
                                }
                            }
                            //Конец удаляемого блока



                            //определяю что нужно сделать с а и b
                            if (action == "*")
                            {
                                float count = float.Parse(a) * float.Parse(b);
                                //удаляю рассчитанное выражение
                                part_or_full_function = part_or_full_function.Remove(left, (right -
                                                                                            left + 1));
                                //на его место запишу ответ
                                part_or_full_function = part_or_full_function.Insert(left,
                                                                                     count.ToString());
                            }
                            if (action == "/")
                            {
                                float count = float.Parse(a) / float.Parse(b);
                                //удаляю рассчитанное выражение
                                part_or_full_function = part_or_full_function.Remove(left, (right -
                                                                                            left + 1));
                                //на его место запишу ответ
                                part_or_full_function = part_or_full_function.Insert(left, count.
                                                                                     ToString());
                            }
                            if (action == "^")
                            {
                                double count = Math.Pow(double.Parse(a), double.Parse(b));
                                //удаляю рассчитанное выражение
                                part_or_full_function = part_or_full_function.Remove(left, (right -
                                                                                            left + 1));
                                //на его место запишу ответ
                                part_or_full_function = part_or_full_function.Insert(left, count.
                                                                                     ToString());
                            }
                            break;
                        }
                        else
                        {
                            return("syntaxis_error");
                        }
                    }


                    //если нашли приоритетное действие, то строка проверена и больше(вообще)
                    //приоритетных знаков не обнаружено
                    if (i == part_or_full_function.Count() - 1)
                    {
                        priority_mark_not_search = true;
                        break;
                    }
                }
            }



            //проверка остальных знаков
            //таких знаков может быть несколько
            bool mark_not_search = false;

            while (mark_not_search == false)
            {
                //если последним символом будет стоять какое-либо действие, то это значит
                //отсутствие правого оператора
                if (part_or_full_function.ElementAt(part_or_full_function.Count() - 1) == '*' |
                    part_or_full_function.ElementAt(part_or_full_function.Count() - 1) == '/' |
                    part_or_full_function.ElementAt(part_or_full_function.Count() - 1) == '+' |
                    part_or_full_function.ElementAt(part_or_full_function.Count() - 1) == '-' |
                    part_or_full_function.ElementAt(part_or_full_function.Count() - 1) == '^')
                {
                    return("syntaxis_error");
                }
                for (int i = 0; i < part_or_full_function.Count(); i++)
                {
                    //запоминаю действие, чтобы потом обпять не обращаться по индексу
                    string action = part_or_full_function.ElementAt(i).ToString();


                    if (action == "+" | action == "-") //если нашли действие
                    {
                        if (i > 0)                     //оно не стоит на первом месте(перед ним должно стоять что - либо)
                        {
                            //числа или СЧА
                            string a = "";
                            string b = "";
                            //индексы рассчитываемого выражения, когда рассчитаю выражение, на
                            //место него в строку запишу ответ
                            int left  = 0;
                            int right = 0;
                            //проверка на неправильный синтаксис, для случая, когда несколько
                            //действий стоит рядом
                            //проверять слева нет смысла, поиск выражений идет слдева на право и,
                            //если два действия будут стоять радом, это обнаружится еще при
                            //исследовании левого
                            if (part_or_full_function.ElementAt(i + 1) == '*' |
                                part_or_full_function.ElementAt(i + 1) == '/' |
                                part_or_full_function.ElementAt(i + 1) == '^' |
                                part_or_full_function.ElementAt(i + 1) == '+' |
                                part_or_full_function.ElementAt(i + 1) == '-')
                            {
                                return("syntaxis_error");
                            }
                            //записываем все числа или сча слева от знака
                            for (int n = (i - 1); n >= 0; n--)
                            {
                                //если встретится хотя бы один ттакой символ, то это будет
                                //хначить, что число или строка А заполенна(о)
                                if (part_or_full_function.ElementAt(n) == '+' |
                                    part_or_full_function.ElementAt(n) == '-')
                                {
                                    break;
                                }
                                a    = part_or_full_function.ElementAt(n) + a;
                                left = n;
                            }
                            //записываем все числа или сча справа от знака
                            for (int n = (i + 1); n < part_or_full_function.Count(); n++)
                            {
                                //если встретится хотя бы один ттакой символ, то это будет
                                //хначить, что число или строка А заполенна(о)
                                if (part_or_full_function.ElementAt(n) == '+' |
                                    part_or_full_function.ElementAt(n) == '-')
                                {
                                    break;
                                }
                                b    += part_or_full_function.ElementAt(n);
                                right = n;
                            }



                            //Удалить блок для возвращения к исходному модулю(добавлена
                            //распознавание СЧА и др для моделирования)
                            if (a.ElementAt(0) == 'P')//это параметр транзакта
                            {
                                a = modeling_objects.tranzakts.ElementAt(id_tranzakts).
                                    get_parameter(a.Remove(0, 1));
                            }
                            if (b.ElementAt(0) == 'P')//это параметр транзакта
                            {
                                b = modeling_objects.tranzakts.ElementAt(id_tranzakts).
                                    get_parameter(b.Remove(0, 1));
                            }
                            //некоторые индикаторы не однозначные(как параметр транзкта, например)
                            //а двузначеные(V$-пример)
                            if (a.Count() > 2)
                            {
                                if (a.Remove(2) == "N$")//это кол-во переходов по метке
                                {
                                    a = a.Remove(0, 2);
                                    if (a.Count() == 0)
                                    {
                                        //есть определение перменной, но у нее нет имени
                                        return("syntaxis_error");
                                    }
                                    //поиск метки по имени
                                    for (int g = 0; g < modeling_objects.lables.Count(); g++)
                                    {
                                        if (modeling_objects.lables.ElementAt(g).get_name() == a)
                                        {
                                            a = modeling_objects.lables.ElementAt(g).
                                                get_entries_number().ToString();
                                            break;
                                        }
                                        //не нашли метку
                                        if (g == modeling_objects.lables.Count() - 1)
                                        {
                                            return("syntaxis_error");
                                        }
                                    }
                                }
                            }
                            //некоторые индикаторы не однозначные(как параметр транзкта, например)
                            //а двузначеные(V$-пример)
                            if (b.Count() > 2)
                            {
                                if (b.Remove(2) == "N$")//это кол-во переходов по метке
                                {
                                    b = b.Remove(0, 2);
                                    if (b.Count() == 0)
                                    {
                                        //есть определение перменной, но у нее нет имени
                                        return("syntaxis_error");
                                    }
                                    //поиск метки по имени
                                    for (int g = 0; g < modeling_objects.lables.Count(); g++)
                                    {
                                        if (modeling_objects.lables.ElementAt(g).get_name() == b)
                                        {
                                            b = modeling_objects.lables.ElementAt(g).
                                                get_entries_number().ToString();
                                            break;
                                        }
                                        //не нашли метку
                                        if (g == modeling_objects.lables.Count() - 1)
                                        {
                                            return("syntaxis_error");
                                        }
                                    }
                                }
                            }
                            //Конец удаляемого блока



                            //определяю что нужно сделать с а и b
                            if (action == "+")
                            {
                                float count = float.Parse(a) + float.Parse(b);
                                //удаляю рассчитанное выражение
                                part_or_full_function = part_or_full_function.Remove(left, (right -
                                                                                            left + 1));
                                //на его место запишу ответ
                                part_or_full_function = part_or_full_function.Insert(left, count.
                                                                                     ToString());
                            }
                            if (action == "-")
                            {
                                float count = float.Parse(a) - float.Parse(b);
                                //удаляю рассчитанное выражение
                                part_or_full_function = part_or_full_function.Remove(left, (right -
                                                                                            left + 1));
                                //на его место запишу ответ
                                part_or_full_function = part_or_full_function.Insert(left, count.
                                                                                     ToString());
                            }
                            break;
                        }
                        else
                        {
                            return("syntaxis_error");
                        }
                    }

                    //если нашли приоритетное действие, то строка проверена и больше(вообще)
                    //приоритетных знаков не обнаружено
                    if (i == part_or_full_function.Count() - 1)
                    {
                        mark_not_search = true;
                        break;
                    }
                }
            }
            return(part_or_full_function);
        }
コード例 #3
0
        public override void recoverySelf(ModelsState backUpState)
        {
            ModelingState oldState = (ModelingState)backUpState;

            state = new ModelingState();
            state.last_tranzaktions_id = oldState.last_tranzaktions_id;
            state.time_of_modeling     = oldState.time_of_modeling;
            state.idProcessingTranzact = oldState.idProcessingTranzact;
            state.rand = oldState.rand;
            config     = oldState.report.getConfig().copy();

            string[] originalRulesC = new string[oldState.originalRules.Count];
            oldState.originalRules.CopyTo(originalRulesC);
            for (int i = 0; i < originalRulesC.Length; i++)
            {
                state.originalRules.Add(originalRulesC[i]);
            }

            for (int i = 0; i < oldState.queues.Count; i++)
            {
                state.queues.Add(oldState.queues.ElementAt(i).clone());
            }

            for (int i = 0; i < oldState.tranzakts.Count; i++)
            {
                state.tranzakts.Add(oldState.tranzakts.ElementAt(i).clone());
            }

            for (int i = 0; i < oldState.lables.Count; i++)
            {
                state.lables.Add(oldState.lables.ElementAt(i).clone());
            }

            for (int i = 0; i < oldState.devices.Count; i++)
            {
                state.devices.Add(oldState.devices.ElementAt(i).clone());
            }

            for (int i = 0; i < oldState.storages.Count; i++)
            {
                state.storages.Add(oldState.storages.ElementAt(i).clone());
            }

            for (int i = 0; i < oldState.variables.Count; i++)
            {
                state.variables.Add(oldState.variables.ElementAt(i).clone());
            }

            for (int i = 0; i < oldState.tranzation_generators.Count; i++)
            {
                state.tranzation_generators.Add(oldState.tranzation_generators.ElementAt(i).clone());
            }

            for (int i = 0; i < oldState.newRules.Count; i++)
            {
                state.newRules.Add(oldState.newRules.ElementAt(i).clone());
            }

            //Откат report нужен только в случае отката всей
            //модели для просматра предыдущих результатов ее работы
            if (config.isRollbackReport())
            {
                report = oldState.report.copyReport(oldState);
            }

            notifyObservers();
        }
コード例 #4
0
        public override void loadStore()
        {
            try
            {
                //чтение файла с конфигурацией модели

                /*TextFilesDataLoader loader = new TextFilesDataLoader();
                 * TextFilesConfigFieldsOnLoad loadersConfig =
                 *  new TextFilesConfigFieldsOnLoad(config.getConfigData());
                 * loader.setConfig(loadersConfig);
                 * loader.execute();
                 * state.originalRules = loader.getResult();*/

                state  = new ModelingState();
                report = new ModelingReport(state);
                //Создание модели в реалтайме
                DataWorker <ModelsCreatorConfigState, List <string> > loader =
                    new ModelsCreatorProxy();
                ModelsCreatorConfigState creatorsConfig = new ModelsCreatorConfigState();
                //Сбор необходимых данных
                DataSet unicNamesDS = configProxyForLoadDataFromNewBDAndExecute(
                    MsSqlServersQueryConfigurator.getUnicLicensesName());
                DataConverter <DataSet, string[]> unicNamesConverter =
                    new DistinctSoftwareNamesConverter();
                string[] unicNames = unicNamesConverter.convert(unicNamesDS);
                StateForConverterOfModelCreatorConfig stateForConverter =
                    new StateForConverterOfModelCreatorConfig();

                stateForConverter.unicNames = unicNames;

                stateForConverter.numberBuyLicenses = configProxyForLoadDataFromNewBDAndExecute(
                    MsSqlServersQueryConfigurator.getNumberOfPurchasedLicenses());

                for (int i = 0; i < unicNames.Length; i++)
                {
                    stateForConverter.bufOftimeBetweenQueryToGetLicenses.Add(
                        configProxyForLoadDataFromNewBDAndExecute(MsSqlServersQueryConfigurator.getTimesGiveLicense(
                                                                      unicNames[i], config.getInterval())));
                    stateForConverter.bufOfTimesOfInBetweenOutLicenses.Add(
                        configProxyForLoadDataFromNewBDAndExecute(MsSqlServersQueryConfigurator.getInBetweenOutLicenses(
                                                                      unicNames[i], config.getInterval())));
                    stateForConverter.numberOfGetingLicensesPerTime.Add(
                        configProxyForLoadDataFromNewBDAndExecute(MsSqlServersQueryConfigurator.getNumberOfLicenesForTime(
                                                                      unicNames[i], config.getInterval())));
                    stateForConverter.avgLicensePerTime.Add(
                        configProxyForLoadDataFromNewBDAndExecute(MsSqlServersQueryConfigurator.getAvgLicesensePerTime(
                                                                      unicNames[i], config.getInterval())));
                }

                //Перевод типа DataSet к нужному формату
                DataConverter <StateForConverterOfModelCreatorConfig,
                               ReturnStateForConverterOfModelCreatorConfig> convertData =
                    new ModelCreatorConfigCreator();
                ReturnStateForConverterOfModelCreatorConfig licencesInfo =
                    convertData.convert(stateForConverter);


                double licenseCount = 0;
                for (int i = 0; i < licencesInfo.numberBuyLicenses.Length; i++)
                {
                    if (licencesInfo.numberBuyLicenses[i] <= 0)
                    {
                        throw new NotEnoughDataToAnalyze("Not enough data to analyze. Count of " +
                                                         "purchased license must have more than zero. Plese check it " +
                                                         "(Меню/Закупленные лицензии). For exclude one or more license " +
                                                         "types from calculating please set zero in table with the " +
                                                         "percentage of purchased licenses (Меню/Закупленные лицензии) in " +
                                                         "row(rows) with this license types.");
                    }
                    licenseCount += licencesInfo.numberBuyLicenses[i];
                }
                if (licenseCount <= 0)
                {
                    throw new NotEnoughDataToAnalyze("Not enough data to analyze. Please, fill " +
                                                     "number of licenses purchased (Меню/Закупленные лицензии)");
                }

                //Создание конфига
                creatorsConfig.licenceInfo = new List <LicenceInfo>();
                for (int i = 0; i < unicNames.Length; i++)
                {
                    if (licencesInfo.bufOfTimesOfInBetweenOutLicenses.ElementAt(i).
                        characteristic.Count() > 1 &
                        licencesInfo.bufOftimeBetweenQueryToGetLicenses.ElementAt(i).
                        characteristic.Count() > 1)
                    {
                        int numberBuyLicense            = licencesInfo.numberBuyLicenses[i];
                        int avgDelayTimeInTheProcessing = Convert.ToInt32(MathWorker.avg(
                                                                              licencesInfo.bufOfTimesOfInBetweenOutLicenses.ElementAt(i).characteristic));
                        int avgSquereDelayTimeInTheProcessing = Convert.ToInt32(MathWorker.
                                                                                standardDeviation(licencesInfo.bufOfTimesOfInBetweenOutLicenses.
                                                                                                  ElementAt(i).characteristic));
                        if (avgSquereDelayTimeInTheProcessing > avgDelayTimeInTheProcessing)
                        {
                            avgDelayTimeInTheProcessing = (avgSquereDelayTimeInTheProcessing +
                                                           avgDelayTimeInTheProcessing) / 2;
                            avgSquereDelayTimeInTheProcessing = avgDelayTimeInTheProcessing;
                        }
                        int avgRequestedTime = Convert.ToInt32(MathWorker.avg(
                                                                   licencesInfo.bufOftimeBetweenQueryToGetLicenses.ElementAt(i).characteristic));
                        int avgSquereRequestedTime = Convert.ToInt32(MathWorker.
                                                                     standardDeviation(licencesInfo.bufOftimeBetweenQueryToGetLicenses.
                                                                                       ElementAt(i).characteristic));
                        if (avgSquereRequestedTime > avgRequestedTime)
                        {
                            avgRequestedTime       = (avgSquereRequestedTime + avgRequestedTime) / 2;
                            avgSquereRequestedTime = avgRequestedTime;
                        }
                        creatorsConfig.licenceInfo.Add(new LicenceInfo(unicNames[i], numberBuyLicense,
                                                                       avgDelayTimeInTheProcessing, avgSquereDelayTimeInTheProcessing,
                                                                       licencesInfo.avgLicensePerTime[i], avgRequestedTime,
                                                                       avgSquereRequestedTime));
                    }
                }
                //Вычисление матрицы корреляций
                int size = creatorsConfig.licenceInfo.Count;
                creatorsConfig.korellation = new double[size, size];
                for (int i = 0; i < size; i++)
                {
                    for (int m = i; m < size; m++)
                    {
                        if (licencesInfo.numberOfGetingLicensesPerTime.ElementAt(i).
                            characteristic.Count() != 0 &
                            licencesInfo.numberOfGetingLicensesPerTime.ElementAt(m).
                            characteristic.Count() != 0)
                        {
                            //Перед вычислением корелляции необходимо выяснить, не состоят ли
                            //проверяемые массивы из одинаковых элементов
                            bool countCorell = true;
                            if (MathWorker.standardDeviation(licencesInfo.
                                                             numberOfGetingLicensesPerTime.ElementAt(i).characteristic) == 0 ||
                                MathWorker.standardDeviation(licencesInfo.
                                                             numberOfGetingLicensesPerTime.ElementAt(m).characteristic) == 0)
                            {
                                countCorell = false;
                            }
                            if (countCorell)
                            {
                                double currentCorellation = MathWorker.corellation(
                                    licencesInfo.numberOfGetingLicensesPerTime.ElementAt(i).characteristic,
                                    licencesInfo.numberOfGetingLicensesPerTime.ElementAt(m).characteristic);
                                creatorsConfig.korellation[i, m] = currentCorellation;
                                creatorsConfig.korellation[m, i] = currentCorellation;
                            }
                            else
                            {
                                creatorsConfig.korellation[i, m] = 0;
                                creatorsConfig.korellation[m, i] = 0;
                            }
                        }
                    }
                }
                creatorsConfig.withKovar = true;
                loader.setConfig(creatorsConfig);
                loader.execute();
                state.originalRules = loader.getResult();

                //создание всех очередей, устройств, меток и тд
                RulesParser rules_parser = new RulesParser();
                rules_parser.go_parse(this);
            }
            catch (Exception ex)
            {
                ExceptionHandler.getInstance().processing(ex);
            }
        }
コード例 #5
0
 public ModelingModel()
 {
     state  = new ModelingState();
     report = new ModelingReport(state);
 }
コード例 #6
0
        public override ModelsState copySelf()
        {
            state.report = report.copyReport(state);
            ModelingState copy = new ModelingState();

            copy.last_tranzaktions_id = state.last_tranzaktions_id;
            copy.time_of_modeling     = state.time_of_modeling;
            copy.idProcessingTranzact = state.idProcessingTranzact;
            copy.rand   = state.rand;
            copy.report = report.copyReport(state);
            copy.report.setConfig(config.copy());

            string[] originalRulesC = new string[state.originalRules.Count];
            state.originalRules.CopyTo(originalRulesC);
            for (int i = 0; i < originalRulesC.Length; i++)
            {
                copy.originalRules.Add(originalRulesC[i]);
            }

            for (int i = 0; i < state.queues.Count; i++)
            {
                copy.queues.Add(state.queues.ElementAt(i).clone());
            }

            for (int i = 0; i < state.tranzakts.Count; i++)
            {
                copy.tranzakts.Add(state.tranzakts.ElementAt(i).clone());
            }

            for (int i = 0; i < state.lables.Count; i++)
            {
                copy.lables.Add(state.lables.ElementAt(i).clone());
            }

            for (int i = 0; i < state.devices.Count; i++)
            {
                copy.devices.Add(state.devices.ElementAt(i).clone());
            }

            for (int i = 0; i < state.storages.Count; i++)
            {
                copy.storages.Add(state.storages.ElementAt(i).clone());
            }

            for (int i = 0; i < state.variables.Count; i++)
            {
                copy.variables.Add(state.variables.ElementAt(i).clone());
            }

            for (int i = 0; i < state.tranzation_generators.Count; i++)
            {
                copy.tranzation_generators.Add(state.tranzation_generators.ElementAt(i).clone());
            }

            for (int i = 0; i < state.newRules.Count; i++)
            {
                copy.newRules.Add(state.newRules.ElementAt(i).clone());
            }

            return(copy);
        }
コード例 #7
0
        public void go_parse(ModelingModel model)
        {
            CheinPartOfOperationCreator advanceOperation = new CheinPartOfOperationCreator(
                new AdvanceOperation(model));
            CheinPartOfOperationCreator assignOperation = new CheinPartOfOperationCreator(
                new AssignOperation(model));
            CheinPartOfOperationCreator departOperation = new CheinPartOfOperationCreator(
                new DepartOperation(model));
            CheinPartOfOperationCreator queueOperation = new CheinPartOfOperationCreator(
                new QueueOperation(model));
            CheinPartOfOperationCreator releaseOperation = new CheinPartOfOperationCreator(
                new ReleaseOperation(model));
            CheinPartOfOperationCreator savevalueOperation = new CheinPartOfOperationCreator(
                new SavevalueOperation(model));
            CheinPartOfOperationCreator seizeOperation = new CheinPartOfOperationCreator(
                new SeizeOperation(model));
            CheinPartOfOperationCreator terminateOperation = new CheinPartOfOperationCreator(
                new TerminateOperation(model));
            CheinPartOfOperationCreator testOperation = new CheinPartOfOperationCreator(
                new TestOperation(model));
            CheinPartOfOperationCreator transferOperation = new CheinPartOfOperationCreator(
                new TransferOperation(model));
            CheinPartOfOperationCreator initialOperation = new CheinPartOfOperationCreator(
                new InitialOperation(model));
            CheinPartOfOperationCreator variableOperation = new CheinPartOfOperationCreator(
                new VariableOperation(model));
            CheinPartOfOperationCreator generateOperation = new CheinPartOfOperationCreator(
                new GenerateOperation(model));
            CheinPartOfOperationCreator storageOperation = new CheinPartOfOperationCreator(
                new StorageOperation(model));
            CheinPartOfOperationCreator enterOperation = new CheinPartOfOperationCreator(
                new EnterOperation(model));
            CheinPartOfOperationCreator leaveOperation = new CheinPartOfOperationCreator(
                new LeaveOperation(model));


            advanceOperation.setNext(assignOperation);
            assignOperation.setNext(departOperation);
            departOperation.setNext(queueOperation);
            queueOperation.setNext(releaseOperation);
            releaseOperation.setNext(savevalueOperation);
            savevalueOperation.setNext(seizeOperation);
            seizeOperation.setNext(terminateOperation);
            terminateOperation.setNext(testOperation);
            testOperation.setNext(transferOperation);
            transferOperation.setNext(initialOperation);
            initialOperation.setNext(variableOperation);
            variableOperation.setNext(generateOperation);
            generateOperation.setNext(storageOperation);
            storageOperation.setNext(enterOperation);
            enterOperation.setNext(leaveOperation);


            ModelingState modeling_objects = new ModelingState();

            //перебор каждой строк и поиск в ней определения какого-либо объекта
            for (int i = 0; i < model.getState().originalRules.Count; i++)
            {
                model.getState().newRules.Add(advanceOperation.processing(model.getState().originalRules.
                                                                          ElementAt(i)));
            }
        }