Ниже приведен пример использования операции GetMs для создания уравнения. В запросе передаются: экземпляр открытого контейнера моделирования, шаблон создания уравнения и параметры выполнения операции. В ответе приходит экземпляр модели, содержащей уравнение.
{
"Envelope" :
{
"Body" :
{
"GetMs" :
{
"tMs" :
{
"id" : "S47!M!S!C1"
},
"tArg" :
{
"pattern" :
{
"obInst" : "true",
"scenarios" : "Get",
"period" : "true",
"item" :
{
"key" : "2564",
"problem" :
{
"metamodel" :
{
"calculationChain" : "Get",
"mmParams" : "Get",
"tag" : "true",
"calcChainPattern" :
{
"modelPattern" :
{
"transform" :
{
"inputs" : "Get",
"outputs" : "Get",
"formulaCount" : "true",
"formulas" :
{
"method" : ""
},
"displayId" : "true",
"equationsFormula" :
{
"method" : ""
},
"series" : "Get",
"kind" : "true", "displaySettings" : "true", "additionalAttributes" : "true", "calculationType" : "true", "calculationDirection" : "true", "transformVariable" :
{
"slices" : "Get",
"transformSlice" :
{
"selection" : "Get" } } }, "stochastic" : "true", "calculationPeriod" : "true",
"useModelPeriod" : "true", "useExistingData" : "true", "treatNullsAsZeros" : "true", "autoName" : "true",
"generatedName" : "true", "period" : "true", "isExclusive" : "true", "useAutoPeriod" : "true" } },
"visualControllerPattern" :
{
"variableRubricatorKey" : "true",
"chainWorkbookKey" : "true"
} }, "scenarios" : "Get", "details" : "true", "useSavedCoefficients" : "true" }
}
},
"execParams" :
{
"inputSlice" :
{
"k" : "0",
"variableKey" : "2600",
"stubKey" : "2566",
"selections" :
{
"its" :
{
"Item" :
{
"id" :
{
"id" : "2579"
},
"variant" : "222"
} } }, "aggregator" : "None",
"parametrizedDimensions" :
{
"its" :
{
"Item" :
{
"dimension" : "0", "parameter" : "0" } }
},
"unitInfo" :
{
"unit" : "4294967295",
"measure" : "4294967295",
"baseUnit" : "4294967295",
"unitsDimensionKey" : "0" }, "level" : "None" },
"outputSlice" :
{
"k" : "0",
"variableKey" : "2601",
"stubKey" : "2566",
"selections" :
{
"its" :
{
"Item" :
{
"id" :
{
"id" : "2579"
},
"variant" : "223"
} } }, "aggregator" : "None",
"parametrizedDimensions" :
{
"its" :
{
"Item" :
{
"dimension" : "0", "parameter" : "0" } }
},
"unitInfo" :
{
"unit" : "4294967295",
"measure" : "4294967295",
"baseUnit" : "4294967295",
"unitsDimensionKey" : "0" }, "level" : "None" },
"execCreateSimpleModel" : "true" } } } } } }
{
"Envelope" :
{
"Body" :
{
"GetMsResult" :
{
"id" :
{
"id" : "S47!M!S!C1"
},
"meta" :
{
"obInst" :
{
"obDesc" :
{
"@isShortcut" : "0",
"i" : "MODELSPACE", "n" : "Контейнер моделирования", "k" : "1581", "c" : "5121",
"p" : "1580", "h" : "0" } }, "dirty" : "0", "period" :
{
"start" : "1990-01-01",
"end" : "2020-01-01"
},
"scenarios" :
{
"nodes" :
{
"it" :
[
{
"@isFolder" : "0",
"k" : "1628",
"id" : "OBJ1628",
"n" : "Базовый",
"vis" : "1",
"scenDesc" :
{
"@isShortcut" : "0",
"i" : "OBJ1628",
"n" : "Базовый", "k" : "1628", "c" : "5124", "p" : "1627",
"h" : "0"
}
},
{
"@isFolder" : "0",
"k" : "1630",
"id" : "OBJ1630", "n" : "Оптимистический", "vis" : "1", "scenDesc" :
{
"@isShortcut" : "0",
"i" : "OBJ1630",
"n" : "Оптимистический",
"k" : "1630",
"c" : "5124",
"p" : "1627", "h" : "0" } },
{
"@isFolder" : "0",
"k" : "1632",
"id" : "OBJ1632",
"n" : "Устаревший",
"vis" : "1",
"scenDesc" :
{
"@isShortcut" : "0",
"i" : "OBJ1632",
"n" : "Устаревший", "k" : "1632", "c" : "5124", "p" : "1627", "h" : "0" }
} ] } },
"item" :
{
"k" : "2564",
"id" : "OBJ2564",
"n" : "Модель",
"vis" : "1",
"type" : "Problem",
"problemMd" :
{
"metamodel" :
{
"k" : "2565",
"calculationChain" :
{
"its" :
{
"Item" :
{
"k" : "2604",
"id" : "OBJ2604",
"n" : "Модель2604",
"vis" : "1",
"type" : "Model",
"excluded" : "0",
"model" :
{
"transform" :
{
"inputs" :
{
"its" :
{
"Item" :
{
"k" : "2605",
"id" : "VARIABLES_2565",
"n" : "Variables",
"vis" : "1",
"slices" :
{
"its" :
{
"Item" :
{
"k" : "0",
"id" : "222",
"n" : "MyInputVavable", "vis" : "1", "variableKey" : "2605", "stubKey" : "2566",
"selections" :
{
"its" :
{
"Item" :
{
"id" :
{
"id" : "2579"
},
"variant" : "222" } } }, "aggregator" : "None", "parametrizedDimensions" :
{
"its" :
{
"Item" :
{
"dimension" : "0",
"parameter" : "0"
}
}
},
"unitInfo" :
{
"unit" : "4294967295",
"measure" : "4294967295",
"baseUnit" : "4294967295", "unitsDimensionKey" : "0" }, "level" : "None" } }
}, "variableStubKey" : "2566", "parameterID" : "", "kind" : "Stub",
"attributeId" : "", "attributeType" : "Series" } } }, "outputs" :
{
"its" :
{
"Item" :
{
"k" : "2606",
"id" : "VARIABLES_2565",
"n" : "Variables",
"vis" : "1",
"slices" :
{
"its" :
{
"Item" :
{
"k" : "0",
"id" : "223",
"n" : "MyOutputVavable",
"vis" : "1",
"variableKey" : "2606",
"stubKey" : "2566",
"selections" :
{
"its" :
{
"Item" :
{
"id" :
{
"id" : "2579"
}, "variant" : "223" } }
},
"aggregator" : "None",
"parametrizedDimensions" :
{
"its" :
{
"Item" :
{
"dimension" : "0",
"parameter" : "0"
}
}
},
"unitInfo" :
{
"unit" : "4294967295",
"measure" : "4294967295", "baseUnit" : "4294967295", "unitsDimensionKey" : "0" },
"level" : "None" } } }, "variableStubKey" : "2566", "parameterID" : "",
"kind" : "Stub", "attributeId" : "", "attributeType" : "Series" }
}
},
"formulaCount" : "1",
"formulas" :
{
"its" :
{
"it" :
[
{
"k" : "0",
"kind" : "LinearRegression",
"method" :
{
"linearRegression" :
{
"constantMode" : "None", "constantValue" : "0", "confidenceLevel" : "0.950000", "ARMA" :
{
"orderAR" : "",
"orderMA" : "",
"calcInitMode" : "Auto",
"initAR" : "",
"initMA" : "",
"initIntercept" : "0", "estimationMethod" : "LevenbergMarquardt", "tolerance" : "0.000100", "maxIteration" : "500",
"coefficientsAR" :
{
"estimate" : "",
"standardError" : "",
"tStatistic" : "",
"probability" : ""
},
"coefficientsMA" :
{
"estimate" : "",
"standardError" : "", "tStatistic" : "", "probability" : "" }, "diff" : "0", "diffSeas" : "1",
"orderARSeas" : "", "orderMASeas" : "", "initARSeas" : "", "initMASeas" : "",
"periodSeas" : "0",
"coefficientsARSeas" :
{
"estimate" : "",
"standardError" : "",
"tStatistic" : "",
"probability" : ""
},
"coefficientsMASeas" :
{
"estimate" : "", "standardError" : "", "tStatistic" : "", "probability" : "" }, "useARMAasInstrums" : "1",
"useAnalyticDeriv" : "1", "useBackCast" : "1" }, "missingData" :
{
"specifiedVector" : "",
"method" : "Casewise",
"methodParameter" : "5",
"specifiedValue" : "0"
}
},
"inversionInfo" :
{
"type" : "None",
"lag" : "PrecidingValue", "previousLag" : "-1", "seasonality" : "None", "dependence" : "Linear", "K" : "3" }
}, "calendarLevel" : "Year", "outputSliceKey" : "0" }
]
}
},
"displayId" : "0",
"series" :
{
"its" : "" }, "kind" : "Simple", "displaySettings" :
{
"displayTermsAs" : "Derive"
},
"additionalAttributes" : "",
"calculationType" : "Serie",
"calculationDirection" : "Forward"
}, "stochastic" : "1", "calculationPeriod" : "Forecast", "useModelPeriod" : "0",
"useExistingData" : "0",
"treatNullsAsZeros" : "0",
"autoName" : "1",
"period" :
{
"identificationStartDate" : "1990-01-01",
"identificationEndDate" : "2012-07-31", "forecastStartDate" : "2012-08-01", "forecastEndDate" : "2020-01-01", "identificationStartDateParamID" : "",
"identificationEndDateParamID" : "", "forecastStartDateParamID" : "", "forecastEndDateParamID" : "", "autoPeriod" : "0", "identificationStartOffset" : "0", "identificationEndOffset" : "0",
"forecastEndOffset" : "0" }, "isExclusive" : "1", "useAutoPeriod" : "0",
"generatedName" : "MyOutputVavable[t] = A1*MyInputVavable[t]" } } } }, "mmParams" :
{
"its" : ""
},
"visualController" :
{
"variableRubricatorKey" : "2566",
"chainWorkbookKey" : "2598",
"modelKey" : "2604"
}
},
"scenarios" :
{
"its" : ""
},
"details" :
{
"period" :
{
"identificationStartDate" : "1990-01-01",
"identificationEndDate" : "2012-07-31",
"forecastStartDate" : "2012-08-01", "forecastEndDate" : "2020-01-01", "identificationStartDateParamID" : "", "identificationEndDateParamID" : "",
"forecastStartDateParamID" : "", "forecastEndDateParamID" : "", "autoPeriod" : "0", "identificationStartOffset" : "0", "identificationEndOffset" : "0", "forecastEndOffset" : "0"
}, "currentPoint" : "2012-08-01" }, "useSavedCoefficients" : "0"
} } } } } } }
Функция GetMsNewEquation создаёт новое уравнение. Входные параметры:
ms. Экземпляр контейнера моделирования;
modelKey. Ключ модели, в которой создаётся уравнение;
inpVar. Срез данных, соответствующий входной переменной;
outVar. Срез данных, соответствующий выходной переменной.
В результате выполнения функция возвращает модель, содержащую созданное уравнение. Ключ уравнения выводится в окно консоли.
public static MsProblem GetMsNewEquation(MsId ms, ulong modelKey, MsFormulaTransformSlice inpVar, MsFormulaTransformSlice outVar)
{
var getMsOp = new GetMs();
// Задаем параметры выполнения операции
getMsOp.tMs = ms;
getMsOp.tArg = new GetMsArg()
{// Задаем параметры создания уравнения
execParams = new MsMdExecParams()
{
execCreateSimpleModel = true,
// Задаем входную переменную
inputSlice = new MsFormulaTransformSlice()
{
k = 0,
n = inpVar.n,
id = inpVar.id,
vis = true,
variableKey = inpVar.variableKey,
stubKey = inpVar.stubKey,
aggregator = BasicAggregatorOper.None,
level = DimCalendarLvl.None,
selections = new DimSelections()
{
its = new DimSelection[]
{
new DimSelection()
{
id = inpVar.selections.its[0].id,
variant = inpVar.selections.its[0].variant
}
}
},
parametrizedDimensions = new MsParametrizedDimensions()
{
its = new MsParametrizedDimension[]
{
new MsParametrizedDimension()
{
dimension = 0,
parameter = 0
}
}
},
unitInfo = new MsUnitInfo()
{
unit = inpVar.unitInfo.unit,
measure = inpVar.unitInfo.measure,
baseUnit = inpVar.unitInfo.baseUnit,
unitsDimensionKey = inpVar.unitInfo.unitsDimensionKey
}
}, // Задаем выходную переменную
outputSlice = new MsFormulaTransformSlice()
{
k = 0,
n = outVar.n,
id = outVar.id,
vis = true,
variableKey = outVar.variableKey,
stubKey = outVar.stubKey,
selections = outVar.selections,
aggregator = BasicAggregatorOper.None,
parametrizedDimensions = new MsParametrizedDimensions()
{
its = new MsParametrizedDimension[]
{
new MsParametrizedDimension()
{
dimension = 0,
parameter = 0
}
}
},
unitInfo = new MsUnitInfo()
{
unit = outVar.unitInfo.unit,
measure = outVar.unitInfo.measure,
baseUnit = outVar.unitInfo.baseUnit,
unitsDimensionKey = outVar.unitInfo.unitsDimensionKey
},
level = DimCalendarLvl.None
}
},
pattern = new MsMdPattern()
{
scenarios = ListOperation.Get,
period = true,
item = new MsItemPattern()
{ // Задаем ключ модели, содержащей уравнение
key = modelKey,
// Задаем шаблон извлечения данных модели
problem = new MsProblemPattern()
{
details = true,
scenarios = ListOperation.Get,
useSavedCoefficients = true,
// Задаем шаблон извлечения данных метамодели
metamodel = new MsMetaModelPattern()
{
calculationChain = ListOperation.Get,
mmParams = ListOperation.Get,
tag = true,
// Задаем шаблон извлечения данных цепочки расчёта
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()
},
displayId = true,
equationsFormula = new TsFormulaPattern()
{
method = new TsMethodPattern()
},
series = ListOperation.Get,
displaySettings = true,
additionalAttributes = true,
calculationType = true,
calculationDirection = true,
// Задаем шаблон извлечения данных переменных модели
transformVariable = new MsFormulaTransformVariablePattern()
{
slices = ListOperation.Get,
transformSlice = new MsFormulaTransformSlicePattern()
{
selection = ListOperation.Get
}
}
},
stochastic = true, calculationPeriod = true, useModelPeriod = true, useExistingData = true, treatNullsAsZeros = true, autoName = true, period = true, isExclusive = true, useAutoPeriod = true, generatedName = true
}
},
// Задаем шаблон извлечения данных для визуального построения метамодели
visualControllerPattern = new MsMetaModelVisualControllerPattern()
{
variableRubricatorKey = true,
chainWorkbookKey = true
}
}
}
}
}
};
// Создаем прокси-объект для выполнения операции
var somClient = new SomPortTypeClient();
GetMsResult getMsResult = somClient.GetMs(getMsOp);
MsProblem problem = getMsResult.meta.item.problemMd;
MsMetaModelVisualController mc = problem.metamodel.visualController;
Console.WriteLine("Ключ уравнения: " + mc.modelKey);
return problem;
}
См. также:
SOAP