Below is the example of using the GetMs operation to create an equation. The request contains an instance of opened modeling container, pattern for creating an equation and parameters of operation execution. The response contains an instance of the model that contains the equation.
{ "GetMs" : { "tMs" : { "id" : "LOFBIHDIFHLBFOAEHGBJDCBENJMKNIBEBKHPFEBMNLDGJINB!M!S!CKOEKCIDIFHLBFOAEJICHGBIIPBAMMPBEAKJNEIIALPAOJIOD" }, "tArg" : { "pattern" : { "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" : "" }, "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" : { "execCreateSimpleModel" : { "outputEntryKey" : "2", "inputEntryKeys" : { "l" : "1" }, "kind" : "LinearRegression", "doUseR" : "false" } } } } }
{ "GetMsResult" : { "id" : { "id" : "LOFBIHDIFHLBFOAEHGBJDCBENJMKNIBEBKHPFEBMNLDGJINB!M!S!CKOEKCIDIFHLBFOAEJICHGBIIPBAMMPBEAKJNEIIALPAOJIOD" }, "meta" : { "obInst" : { "obDesc" : { "@fullUrl" : "http:\/\/v-shp-development.dev.fs.fsight.world\/", "@isShortcut" : "0", "@isLink" : "0", "@ver" : "3", "@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-12-31" }, "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" : "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" : "Model", "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" : "LinearRegression", "method" : { "linearRegression" : { "constantMode" : "AutoEstimate", "constantValue" : "0", "confidenceLevel" : "0.95", "ARMA" : { "orderAR" : "", "orderMA" : "", "calcInitMode" : "Auto", "initAR" : "", "initMA" : "", "initIntercept" : "NaN", "estimationMethod" : "LevenbergMarquardt", "tolerance" : "0.0001", "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", "specifiedTerm" : { "k" : "4294967295" } } }, "inversionInfo" : { "type" : "None", "lag" : "PrecidingValue", "previousLag" : "-1", "seasonality" : "None", "dependence" : "Linear", "K" : "3" }, "doUseR" : "0", "supportsR" : "1" }, "calendarLevel" : "Year", "outputSliceKey" : "0" } ] } }, "displayId" : "0", "series" : { "its" : "" }, "kind" : "Simple", "displaySettings" : { "displayTermsAs" : "Derive" }, "additionalAttributes" : "", "calculationType" : "Serie", "calculationDirection" : "Forward" }, "stochastic" : "1", "calculationPeriod" : "Forecast", "useModelPeriod" : "1", "useExistingData" : "0", "treatNullsAsZeros" : "0", "autoName" : "1", "period" : { "identificationStartDate" : "1990-01-01", "identificationEndDate" : "2018-04-24", "forecastStartDate" : "2018-04-25", "forecastEndDate" : "2020-01-01", "identificationStartDateParamID" : "", "identificationEndDateParamID" : "", "forecastStartDateParamID" : "", "forecastEndDateParamID" : "", "autoPeriod" : "28672", "identificationStartOffset" : "0", "identificationEndOffset" : "0", "forecastEndOffset" : "0", "isIdentStartCorrect" : "1", "isIdentEndCorrect" : "1", "isForecastEndCorrect" : "1" }, "isExclusive" : "1", "useAutoPeriod" : "1", "generatedName" : "MyOutputVavable|A[t] = A0 + A1*MyInputVavable|A[t]", "warnings" : "", "readOnly" : "0" } } ] } }, "mmParams" : { "its" : "" }, "visualController" : { "variableRubricatorKey" : "89671", "createSimpleModelResult" : { "modelKey" : "3" }, "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" } } } } }
public static MsProblem GetMsNewEquation(MsId ms, uint 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
//1
},
outputEntryKey = outVar.k
//outputEntryKey = 2
}
},
pattern = new MsMdPattern()
{
scenarios = ListOperation.Get,
period = true,
item = new MsItemPattern()
{ // Set key of model containing equation
key = modelKey,
// Set model data extraction pattern
problem = new MsProblemPattern()
{
details = true,
scenarios = ListOperation.Get,
useSavedCoefficients = true,
// Set metamodel data extraction pattern
metamodel = new MsMetaModelPattern()
{
calculationChain = ListOperation.Get,
mmParams = ListOperation.Get,
tag = true,
// Set calculation chain extraction pattern
calcChainPattern = new MsCalculationChainPattern()
{
modelPattern = new MsModelPattern()
{ // Set model calculation method data extraction 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 extraction 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 extraction 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();
var result = somClient.GetMs(getMsOp);
var problem = result.meta.item.problemMd;
var mc = problem.metamodel.visualController;
Console.WriteLine("Equation key: " + mc.createSimpleModelResult.modelKey);
return problem;
}
See also: