Below is the example of using the GetMs operation to create a model. The request contains an instance of opened modeling container and pattern of metadata for model creation. The response contains the created model.
{ "GetMs" : { "tMs" : { "id" : "MLAAJEFAFNJBFOAEAGEMKDJJIDOOHNFEEJJDFIDOFBGDCMIN!M!S!CJPHGFFFAFNJBFOAEAOCBILDDGNLNFPAEGIEKKJEMOJNHNEPL" }, "tArg" : { "pattern" : { "obInst" : "true", "scenarios" : "Get", "period" : "true", "item" : { "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", "useSourceName" : "true", "levelFormat" : "Short" } }, "scenarios" : "Get", "details" : "true", "useSavedCoefficients" : "true" } } }, "execParams" : { "execCreateProblem" : { "parent" : "1581", "id" : "", "name" : "Model" } } } } }
{ "GetMsResult" : { "id" : { "id" : "MLAAJEFAFNJBFOAEAGEMKDJJIDOOHNFEEJJDFIDOFBGDCMIN!M!S!CJPHGFFFAFNJBFOAEAOCBILDDGNLNFPAEGIEKKJEMOJNHNEPL" }, "meta" : { "obInst" : { "obDesc" : { "@fullUrl" : "http:\/\/v-shp-development.dev.fs.fsight.world\/", "@isShortcut" : "0", "@isLink" : "0", "@ver" : "1", "@hf" : "0", "i" : "MODELSPACE", "n" : "Modeling container", "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-01-01" }, "scenarios" : { "nodes" : { "it" : [ { "@isFolder" : "0", "k" : "1628", "id" : "OBJ1628", "n" : "Basic", "vis" : "1", "scenDesc" : { "@fullUrl" : "http:\/\/v-shp-development.dev.fs.fsight.world\/", "@isShortcut" : "0", "@isLink" : "0", "@ver" : "0", "@hf" : "0", "i" : "OBJ1628", "n" : "Basic", "k" : "1628", "c" : "5124", "p" : "1627", "h" : "0", "hasPrv" : "0", "ic" : "0" }, "internalKey" : "1629" }, { "@isFolder" : "0", "k" : "5371", "id" : "OBJ5371", "n" : "Basic (copy1)", "vis" : "1", "scenDesc" : { "@fullUrl" : "http:\/\/v-shp-development.dev.fs.fsight.world\/", "@isShortcut" : "0", "@isLink" : "0", "@ver" : "0", "@hf" : "0", "i" : "OBJ5371", "n" : "Basic (copy1)", "k" : "5371", "c" : "5124", "p" : "1627", "h" : "0", "hasPrv" : "0", "ic" : "0" }, "internalKey" : "5372" } ] } }, "item" : { "k" : "89669", "id" : "OBJ89669", "n" : "Model", "vis" : "1", "type" : "Problem", "problemMd" : { "metamodel" : { "k" : "89670", "calculationChain" : { "its" : "" }, "mmParams" : { "its" : "" }, "visualController" : { "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" }, "useSavedCoefficients" : "0", "useScenarios" : "0", "readOnly" : "0" } } } } }
The GetMsNewModel function creates a new model. Modeling container instance and key, name, identifier of the created model, output and input variables are passed as input parameters. After execution the function returns identifier of the created model.
public static MsProblem GetMsNewEquation(MsId ms, ulong modelKey, MsFormulaTransformSlice inpVar, MsFormulaTransformSlice outVar) { var getMsOp = new GetMs(); // Set operation execution parameters getMsOp.tMs = ms; getMsOp.tArg = new GetMsArg() {// Set equation creation parameters execParams = new MsMdExecParams() { execCreateSimpleModel = new MsMdExecCreateSimpleModel() { doUseR = false, kind = TsFormulaKind.LinearRegression, inputEntryKeys = new long[] { (long)inpVar.k }, outputEntryKey = outVar.k } }, pattern = new MsMdPattern() { scenarios = ListOperation.Get, period = true, item = new MsItemPattern() { // Set key of the model that contains equation key = modelKey, // Set model data getting pattern problem = new MsProblemPattern() { details = true, scenarios = ListOperation.Get, useSavedCoefficients = true, // Set metamodel data getting pattern metamodel = new MsMetaModelPattern() { calculationChain = ListOperation.Get, mmParams = ListOperation.Get, tag = true, // Set calculation chain data getting pattern calcChainPattern = new MsCalculationChainPattern() { modelPattern = new MsModelPattern() { // Set model calculation method data getting pattern 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, // Set model variable data getting pattern 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 } }, // Set data getting pattern for visual metamodel building visualControllerPattern = new MsMetaModelVisualControllerPattern() { variableRubricatorKey = true, levelFormat = MsLevelFormat.Short, useSourceName = true } } } } } }; // Create a proxy object for operation execution var somClient = new SomPortTypeClient(); GetMsResult getMsResult = somClient.GetMs(getMsOp); MsProblem problem = getMsResult.meta.item.problemMd; MsMetaModelVisualController mc = problem.metamodel.visualController; Console.WriteLine("Equation key: " + mc.createSimpleModelResult.modelKey); return problem; }
See also: