Ниже приведен пример использования операции SetMs для изменения параметров уравнения. В запросе передаются: экземпляр открытого контейнера моделирования, параметры выполнения операции, настройки уравнения для метода «ARIMA» и шаблон получения измененных данных. В результате выполнения операция возвращает модель, содержащую измененное уравнение.
{ "SetMs" : { "tMs" : { "id" : "ONDFKOICJHLBFOAEMAMOIGEBJKAFNFKELKAMBGOCBIMLMHNP!M!S!CBPKKEPICJHLBFOAEKGAEHCFEAMLKMLFELJEKHGMDDGIFELEG" }, "tArg" : { "pattern" : { "obInst" : "true", "item" : { "key" : "89669", "problem" : { "metamodel" : { "calculationChain" : "Change" } } } }, "meta" : { "item" : { "k" : "89669", "type" : "Problem", "problemMd" : { "metamodel" : { "calculationChain" : { "its" : { "Item" : { "k" : "3", "type" : "Model", "model" : { "transform" : { "formulas" : { "its" : { "it" : [ { "k" : "0", "kind" : "Arima", "method" : { "arima" : { "maxIteration" : "600", "constantMode" : "ManualEstimate", "constantValue" : "5.7", "missingData" : { "method" : "SpecifiedValue", "specifiedValue" : "4.7" }, "confidenceLevel" : "0.96", "ARMA" : { "parseAR" : { "value" : "1-3", "assignOrder" : "true" }, "parseMA" : { "value" : "1-3", "assignOrder" : "true" }, "parseARSeas" : { "value" : "1,4", "assignOrder" : "true" }, "parseMASeas" : { "value" : "1,3", "assignOrder" : "true" }, "initAR" : { "d" : "0.0025" }, "initMA" : { "d" : "0.0025" }, "initIntercept" : "3", "estimationMethod" : "GaussNewton", "diff" : "2", "diffSeas" : "0", "initARSeas" : { "d" : "0.003" }, "initMASeas" : { "d" : "0.0015" }, "periodSeas" : "4", "useAnalyticDeriv" : "true", "useBackCast" : "false" } }, "name" : "ARIMA", "inversionInfo" : { "type" : "PCH", "lag" : "PrecidingValue", "previousLag" : "2" } } } ] } } } } } } } } } } }, "metaGet" : { "obInst" : "true", "scenarios" : "Get", "period" : "true", "item" : { "key" : "89669", "problem" : { "metamodel" : { "calculationChain" : "Get", "mmParams" : "Get", "tag" : "true", "calcChainPattern" : { "modelPattern" : { "transform" : { "inputs" : "Get", "outputs" : "Get", "formulaCount" : "true", "formulas" : { "method" : "" }, "equationsFormula" : { "method" : "" }, "series" : "Get", "kind" : "true", "transformVariable" : { "slices" : "Get", "transformSlice" : { "selection" : "Get" } } } } }, "visualControllerPattern" : { "variableRubricatorKey" : "true", "useSourceName" : "false", "levelFormat" : "Short" } }, "scenarios" : "Get", "details" : "true", "useSavedCoefficients" : "false" } } } } } }
{ "SetMsResult" : { "id" : { "id" : "ONDFKOICJHLBFOAEMAMOIGEBJKAFNFKELKAMBGOCBIMLMHNP!M!S!CBPKKEPICJHLBFOAEKGAEHCFEAMLKMLFELJEKHGMDDGIFELEG" }, "meta" : { "obInst" : { "obDesc" : { "@fullUrl" : "http:\/\/v-shp-development.dev.fs.fsight.world\/", "@isShortcut" : "0", "@isLink" : "0", "@ver" : "3", "@hf" : "0", "i" : "MODELSPACE", "n" : "Контейнер моделирования", "k" : "1581", "c" : "5121", "p" : "1580", "h" : "0", "hasPrv" : "0", "ic" : "0", "isPermanent" : "1", "isTemp" : "0" } }, "dirty" : "0", "period" : { "start" : "1990-01-01", "end" : "2020-12-31" }, "scenarios" : { "nodes" : { "it" : [ { "@isFolder" : "0", "k" : "1628", "id" : "OBJ1628", "n" : "Базовый", "vis" : "1", "scenDesc" : { "@fullUrl" : "http:\/\/v-shp-development.dev.fs.fsight.world\/", "@isShortcut" : "0", "@isLink" : "0", "@ver" : "0", "@hf" : "0", "i" : "OBJ1628", "n" : "Базовый", "k" : "1628", "c" : "5124", "p" : "1627", "h" : "0", "hasPrv" : "0", "ic" : "0" }, "internalKey" : "1629" }, { "@isFolder" : "0", "k" : "5371", "id" : "OBJ5371", "n" : "Базовый (копия1)", "vis" : "1", "scenDesc" : { "@fullUrl" : "http:\/\/v-shp-development.dev.fs.fsight.world\/", "@isShortcut" : "0", "@isLink" : "0", "@ver" : "0", "@hf" : "0", "i" : "OBJ5371", "n" : "Базовый (копия1)", "k" : "5371", "c" : "5124", "p" : "1627", "h" : "0", "hasPrv" : "0", "ic" : "0" }, "internalKey" : "5372" } ] } }, "item" : { "k" : "89669", "id" : "MODEL_NEW", "n" : "MODEL_NEW", "vis" : "1", "type" : "Problem", "problemMd" : { "metamodel" : { "k" : "89670", "calculationChain" : { "its" : { "Item" : [ { "k" : "1", "n" : "MyInputVavable", "vis" : "1", "type" : "Variable", "excluded" : "0", "graphMeta" : "{"Geometry":{"x":20,"y":10,"width":150,"height":50}}", "chainVariable" : { "slice" : { "k" : "0", "id" : "MyInputVavable|A", "n" : "MyInputVavable|A", "vis" : "1", "variableKey" : "1", "stubKey" : "89671", "selections" : { "its" : { "Item" : { "id" : { "id" : "89683" }, "variant" : "1" } } }, "aggregator" : "None", "parametrizedDimensions" : { "its" : { "Item" : { "dimension" : "0", "parameter" : "0" } } }, "unitInfo" : { "unit" : "4294967295", "measure" : "4294967295", "baseUnit" : "4294967295", "unitsDimensionKey" : "0" }, "level" : "Year" }, "fullName" : "MyInputVavable|A", "originalName" : "MyInputVavable", "originalShortName" : "MyInputVavable", "useCustomName" : "0" } }, { "k" : "2", "n" : "MyOutputVavable", "vis" : "1", "type" : "Variable", "excluded" : "0", "graphMeta" : "{"Geometry":{"x":30,"y":140,"width":150,"height":50}}", "chainVariable" : { "slice" : { "k" : "0", "id" : "MyOutputVavable|A", "n" : "MyOutputVavable|A", "vis" : "1", "variableKey" : "2", "stubKey" : "89671", "selections" : { "its" : { "Item" : { "id" : { "id" : "89683" }, "variant" : "2" } } }, "aggregator" : "None", "parametrizedDimensions" : { "its" : { "Item" : { "dimension" : "0", "parameter" : "0" } } }, "unitInfo" : { "unit" : "4294967295", "measure" : "4294967295", "baseUnit" : "4294967295", "unitsDimensionKey" : "0" }, "level" : "Year" }, "fullName" : "MyOutputVavable|A", "originalName" : "MyOutputVavable", "originalShortName" : "MyOutputVavable", "useCustomName" : "0" } }, { "k" : "3", "id" : "OBJ3", "n" : "MyOutputVavable|A[t] = A0, (От родителя)-(От родителя)", "vis" : "1", "type" : "Model", "excluded" : "0", "graphMeta" : "", "model" : { "transform" : { "inputs" : { "its" : { "Item" : { "k" : "2", "id" : "VARIABLES_89670", "n" : "Variables", "vis" : "1", "slices" : { "its" : { "Item" : { "k" : "0", "id" : "MyInputVavable|A", "n" : "MyInputVavable|A", "vis" : "1", "variableKey" : "2", "stubKey" : "89671", "selections" : { "its" : { "Item" : { "id" : { "id" : "89683" }, "variant" : "1" } } }, "aggregator" : "None", "parametrizedDimensions" : { "its" : { "Item" : { "dimension" : "0", "parameter" : "0" } } }, "unitInfo" : { "unit" : "4294967295", "measure" : "4294967295", "baseUnit" : "4294967295", "unitsDimensionKey" : "0" }, "level" : "Year" } } }, "variableStubKey" : "89671", "parameterID" : "", "kind" : "Stub", "attributeId" : "", "attributeType" : "Series" } } }, "outputs" : { "its" : { "Item" : { "k" : "1", "id" : "VARIABLES_89670", "n" : "Variables", "vis" : "1", "slices" : { "its" : { "Item" : { "k" : "0", "id" : "MyOutputVavable|A", "n" : "MyOutputVavable|A", "vis" : "1", "variableKey" : "1", "stubKey" : "89671", "selections" : { "its" : { "Item" : { "id" : { "id" : "89683" }, "variant" : "2" } } }, "aggregator" : "None", "parametrizedDimensions" : { "its" : { "Item" : { "dimension" : "0", "parameter" : "0" } } }, "unitInfo" : { "unit" : "4294967295", "measure" : "4294967295", "baseUnit" : "4294967295", "unitsDimensionKey" : "0" }, "level" : "Year" } } }, "variableStubKey" : "89671", "parameterID" : "", "kind" : "Stub", "attributeId" : "", "attributeType" : "Series" } } }, "formulaCount" : "1", "formulas" : { "its" : { "it" : [ { "k" : "0", "kind" : "Arima", "method" : { "arima" : { "maxIteration" : "600", "constantMode" : "ManualEstimate", "constantValue" : "5.7", "missingData" : { "specifiedVector" : "", "method" : "SpecifiedValue", "methodParameter" : "5", "specifiedValue" : "4.7", "specifiedTerm" : { "k" : "4294967295" } }, "confidenceLevel" : "0.96", "ARMA" : { "orderAR" : { "l" : [ "1", "2", "3" ] }, "orderMA" : { "l" : [ "1", "2", "3" ] }, "calcInitMode" : "Auto", "initAR" : { "d" : "0.0025" }, "initMA" : { "d" : "0.0025" }, "initIntercept" : "3", "estimationMethod" : "GaussNewton", "tolerance" : "0.0001", "maxIteration" : "600", "coefficientsAR" : { "estimate" : "", "standardError" : "", "tStatistic" : "", "probability" : "" }, "coefficientsMA" : { "estimate" : "", "standardError" : "", "tStatistic" : "", "probability" : "" }, "diff" : "2", "diffSeas" : "0", "orderARSeas" : { "l" : [ "1", "4" ] }, "orderMASeas" : { "l" : [ "1", "3" ] }, "initARSeas" : { "d" : "0.003" }, "initMASeas" : { "d" : "0.0015" }, "periodSeas" : "4", "coefficientsARSeas" : { "estimate" : "", "standardError" : "", "tStatistic" : "", "probability" : "" }, "coefficientsMASeas" : { "estimate" : "", "standardError" : "", "tStatistic" : "", "probability" : "" }, "useARMAasInstrums" : "1", "useAnalyticDeriv" : "1", "useBackCast" : "0" }, "explained" : { "slice" : { "k" : "0", "id" : "MyOutputVavable|A", "n" : "MyOutputVavable|A", "vis" : "1", "variableKey" : "1", "stubKey" : "89671", "selections" : { "its" : { "Item" : { "id" : { "id" : "89683" }, "variant" : "2" } } }, "aggregator" : "None", "parametrizedDimensions" : { "its" : { "Item" : { "dimension" : "0", "parameter" : "0" } } }, "unitInfo" : { "unit" : "4294967295", "measure" : "4294967295", "baseUnit" : "4294967295", "unitsDimensionKey" : "0" }, "level" : "Year" }, "lag" : "", "key" : "0", "termToText" : "{MyOutputVavable|A[t]}", "termToInnerText" : "@_1:0[]", "termInfo" : { "k" : "4294967295", "lag" : "0", "inversion" : { "type" : "None", "lag" : "PrecidingValue", "previousLag" : "-1", "seasonality" : "None", "dependence" : "Linear", "K" : "3" }, "slice" : { "k" : "0", "id" : "MyOutputVavable|A", "n" : "MyOutputVavable|A", "vis" : "1", "variableKey" : "1", "stubKey" : "89671", "selections" : { "its" : { "Item" : { "id" : { "id" : "89683" }, "variant" : "2" } } }, "aggregator" : "None", "parametrizedDimensions" : { "its" : { "Item" : { "dimension" : "0", "parameter" : "0" } } }, "unitInfo" : { "unit" : "4294967295", "measure" : "4294967295", "baseUnit" : "4294967295", "unitsDimensionKey" : "0" }, "level" : "Year" }, "date" : "1899-12-30" }, "unitInfo" : { "unit" : "4294967295", "measure" : "4294967295", "baseUnit" : "4294967295", "unitsDimensionKey" : "0" }, "included" : "0" } }, "inversionInfo" : { "type" : "PCH", "lag" : "PrecidingValue", "previousLag" : "2", "seasonality" : "None", "dependence" : "Linear", "K" : "3" }, "doUseR" : "0", "supportsR" : "1" }, "calendarLevel" : "Year", "outputSliceKey" : "0" } ] } }, "series" : { "its" : "" }, "kind" : "Simple" }, "warnings" : "", "readOnly" : "0" } } ] } }, "mmParams" : { "its" : "" }, "visualController" : { "variableRubricatorKey" : "89671", "userRPath" : "", "isRExist" : "0" }, "suppressEmptyFilter" : { "suppressEmpty" : "0", "suppressEmptyArea" : "SerieBounds" }, "readOnly" : "0", "variableTestUseR" : "0", "calculateIdentOnFact" : "0" }, "scenarios" : { "its" : "" }, "details" : { "period" : { "identificationStartDate" : "1990-01-01", "identificationEndDate" : "2018-04-24", "forecastStartDate" : "2018-04-25", "forecastEndDate" : "2020-01-01", "identificationStartDateParamID" : "", "identificationEndDateParamID" : "", "forecastStartDateParamID" : "", "forecastEndDateParamID" : "", "autoPeriod" : "0", "identificationStartOffset" : "0", "identificationEndOffset" : "0", "forecastEndOffset" : "0", "isIdentStartCorrect" : "1", "isIdentEndCorrect" : "1", "isForecastEndCorrect" : "1" }, "currentPoint" : "2018-04-25" }, "useScenarios" : "0", "readOnly" : "0" } } } } }
public static MsItem SetMsARIMA(MsId ms, ulong modelKey, ulong eqKey) { var setMsOp = new SetMs(); // Задаем параметры выполнения операции setMsOp.tMs = ms; setMsOp.tArg = new SetMsArg() { // Задаем шаблон изменения данных pattern = new MsMdPattern() { item = new MsItemPattern() { // Указываем ключ уравнения key = modelKey, problem = new MsProblemPattern() { metamodel = new MsMetaModelPattern() { calculationChain = ListOperation.Change } } } }, // Задаем данные, которые необходимо изменить meta = new MsMd() { item = new MsItem() { // Указываем ключ уравнения k = modelKey, type = MsItemType.Problem, problemMd = new MsProblem() { metamodel = new MsMetaModel() { calculationChain = new MsCalculationChainEntries() { its = new MsCalculationChainEntry[] { new MsCalculationChainEntry() { k = eqKey, type = MsCalculationChainType.Model, model = new MsModel() { transform = new MsFormulaTransform() { formulas = new TsFormulas() { its = new TsFormula[] { new TsFormula() { kind = TsFormulaKind.Arima, method = new TsMethod() { // Задаем параметры метода «ARIMA» arima = new TsArimaMethod() { // Задаем значимость доверительных границ confidenceLevel = 0.96, // Задаем константу constantMode = StatInterceptMode.ManualEstimate, constantValue = 5.7, // Задаем максимальное число итераций maxIteration = 600, // Задаем метод обработки пропусков missingData = new StatMissingData() { method = StatMissingDataMethod.SpecifiedValue, specifiedValue = 4.7 }, // Задаем параметры авторегрессии и скользящего среднего ARMA = new SlARMA() { // Задаем порядок авторегрессии parseAR = new SlParseStr() { value = "1-3", assignOrder = true, }, // Задаем порядок сезонной авторегрессии parseARSeas = new SlParseStr() { value = "1,4", assignOrder = true }, // Задаем порядок скользящего среднего parseMA = new SlParseStr() { value = "1-3", assignOrder = true, }, // Задаем порядок сезонного скользящего среднего parseMASeas = new SlParseStr() { value = "1,3", assignOrder = true }, // Задаем разность и сезонную разность diff = 2, diffSeas = 0, // Задаем значение периода сезонности periodSeas = 4, // Задаем начальные приближения и прочие параметры initAR = new double[] {0.0025}, initARSeas = new double[] {0.0030}, initMA= new double[] {0.0025}, initMASeas = new double[] {0.0015}, initIntercept = 3, // Задаем параметры оценки коэффициентов useBackCast = false, useAnalyticDeriv = true, estimationMethod = ARMAEstimationMethodType.GaussNewton } }, // Задаем преобразование моделируемой переменной inversionInfo = new TsInversion() { type = TsInversionType.PCH, previousLag = 2, lag = TsInversionLag.PrecidingValue }, name = "ARIMA" } } } } } } } } } } } } }, // Задаем шаблон извлечения измененных данных metaGet = new MsMdPattern() { period = true, scenarios = ListOperation.Get, item = new MsItemPattern() { key = modelKey, problem = new MsProblemPattern() { useSavedCoefficients = false, scenarios = ListOperation.Get, details = true, metamodel = new MsMetaModelPattern() { calculationChain = ListOperation.Get, tag = true, mmParams = ListOperation.Get, calcChainPattern = new MsCalculationChainPattern() { modelPattern = new MsModelPattern() { transform = new MsFormulaTransformPattern() { inputs = ListOperation.Get, outputs = ListOperation.Get, kind = true, formulaCount = true, formulas = new TsFormulaPattern() { method = new TsMethodPattern() { } }, equationsFormula = new TsFormulaPattern() { method = new TsMethodPattern() { } }, series = ListOperation.Get, transformVariable = new MsFormulaTransformVariablePattern() { slices = ListOperation.Get, transformSlice = new MsFormulaTransformSlicePattern() { selection = ListOperation.Get } } } } }, visualControllerPattern = new MsMetaModelVisualControllerPattern() { variableRubricatorKey = true, levelFormat = MsLevelFormat.Short, useSourceName = false } } } } } }; // Создаем прокси-объект для выполнения операции var somClient = new SomPortTypeClient(); // Задаем параметры выполнения операции var result = somClient.SetMs(setMsOp); return result.meta.item; }
См. также: