AddInputVariable(Model: IMsModel;
EntryKey: Integer;
GraphMeta: String;
Var InterVariableKey: Integer;
Var InterModelKey: Integer;
[InterParentKey: Integer = -1]): Boolean;
AddInputVariable(Model: IMsModel;
EntryKey: Integer;
GraphMeta: String;
Var InterVariableKey: uinteger;
Var InterModelKey: uinteger;
InterParentKey: Integer): Boolean;
Model. Model.
EntryKey. Key of the variable, which is added to the model as an input one.
GraphMeta. Graphical context.
InterVariableKey. Key of a intermediate variable.
InterModelKey. The key of the transitional model of interpolation/collapse.
InterParentKey. Minor parent element key.
The AddInputVariable method changes model input variable.
By default, input variable matches the output variable.
If input variable is successfully deleted, the method returns True, otherwise it returns False.
Executing the example requires:
Time series database with the TSDB identifier containing a time series with the 12 key.
Modeling container with the MS identifier containing a modeling problem with the ADDINPUTVARIABLE identifier. Calculation chain of this problem must contain a model.
Add links to the Dimensions, Metabase, Ms system assemblies.
Sub UserProc;
Var
mb: IMetabase;
RubObj: IMetabaseObjectDescriptor;
Problem: IMsProblem;
Meta: IMsMetaModel;
MetaVisual: IMsMetaModelVisualController;
ChainEn: IMsCalculationChainEntries;
i: Integer;
Model: IMsModel;
VarEx, InpResult: Boolean;
VarInp: IMsCalculationChainVariable;
InVarKey, InModelKey: Integer;
Begin
mb := MetabaseClass.Active;
// Get time series database
RubObj := mb.ItemById("TSDB");
// Get modeling problem and its metamodel
Problem := mb.ItemByIdNamespace("ADDINPUTVARIABLE", mb.ItemById("MS").Key).Edit As IMsProblem;
Meta := Problem.MetaModel;
// Get model from calculation chain
ChainEn := Meta.CalculationChain;
For i := 0 To ChainEn.Count - 1 Do
If ChainEn.Item(i).Type = MsCalculationChainEntryType.Model Then
Model := (ChainEn.Item(i) As IMsCalculationChainModel).Model;
End If;
End For;
MetaVisual := Meta.VisualController;
// Get the key of the input variable
VarInp := MetaVisual.GetVariableByFactor(RubObj.Key, 12, "", VarEx);
// Set input variable
InpResult := MetaVisual.AddInputVariable(Model, VarInp.Key, "", InVarKey, InModelKey, -1);
// Output result to console window
Debug.WriteLine("Input variable is successfully added: " + InpResult.ToString);
// Save modeling problem
(Problem As IMetabaseObject).Save;
End Sub UserProc;
After executing the example the input variable is changed for the first model in the calculation chain of the ADDINPUTVARIABLE problem. The variable created on the time series from time series database is used.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Ms;
…
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
RubObj: IMetabaseObjectDescriptor;
Problem: IMsProblem;
Meta: IMsMetaModel;
MetaVisual: IMsMetaModelVisualController;
ChainEn: IMsCalculationChainEntries;
i: Integer;
Model: IMsModel;
VarEx, InpResult: Boolean;
VarInp: IMsCalculationChainVariable;
InVarKey, InModelKey: Integer;
Begin
mb := Params.Metabase;
// Get time series database
RubObj := mb.ItemById["TSDB"];
// Get modeling problem and its metamodel
Problem := mb.ItemByIdNamespace["ADDINPUTVARIABLE", mb.ItemById["MS"].Key].Edit() As IMsProblem;
Meta := Problem.MetaModel;
// Get model from calculation chain
ChainEn := Meta.CalculationChain;
For i := 0 To ChainEn.Count - 1 Do
If ChainEn.Item[i].Type = MsCalculationChainEntryType.mccetModel Then
Model := (ChainEn.Item[i] As IMsCalculationChainModel).Model;
End If;
End For;
MetaVisual := Meta.VisualController;
// Get the key of the input variable
VarInp := MetaVisual.GetVariableByFactor(RubObj.Key, 12, "", Var VarEx, -1 As uinteger);
// Set input variable
InpResult := MetaVisual.AddInputVariable(Model, VarInp.Key As integer, "", Var InVarKey, Var InModelKey, -1 As uinteger);
// Output result to console window
System.Diagnostics.Debug.WriteLine("Input variable is successfully added: " + InpResult.ToString());
// Save modeling problem
(Problem As IMetabaseObject).Save();
End Sub;
See also: