IMsCalculationChainSystem.AddModel

Fore Syntax

AddModel(Model: IMsModel);

Fore.NET Syntax

AddModel(Model: Prognoz.Platform.Interop.Ms.IMsModel);

Parameters

Model. The model to be added.

Description

The AddModel method adds the specified model to the system of equations.

Comments

The following types of equations can be added:

To remove the equation from the system, use the IMsCalculationChainSystem.RemoveModel method.

Fore Example

Executing the example requires a modeling container with the MODEL_SPACE identifier, containing a metamodel with the METAMODEL identifier and a model of determinate equation with the MODEL_DETERM identifier. The model must not be included in the metamodel calculation chain.

Add links to the Metabase, Ms system assemblies.

Sub AddModel;
Var
    mb: IMetabase;
    MsObj: IMetabaseObjectDescriptor;
    Meta: IMsMetaModel;
    CalcChain: IMsCalculationChainEntries;
    ChainEntry: IMsCalculationChainEntry;
    Model: IMsModel;
    i: Integer;
    CalcSystem: IMsCalculationChainSystem;
Begin
    mb := MetabaseClass.Active;
    // Get modeling container
    MsObj := mb.ItemById("MODEL_SPACE");
    // Get metamodel
    Meta := mb.ItemByIdNamespace("METAMODEL", MsObj.Key).Edit As IMsMetaModel;
    CalcChain := Meta.CalculationChain;
    // If the calculation chain contains the system of equations,
    // then add equation to the system 
    For i := 0 To CalcChain.Count - 1 Do
        ChainEntry := CalcChain.Item(i);
        If ChainEntry.Type = MsCalculationChainEntryType.System Then
            CalcSystem := ChainEntry As IMsCalculationChainSystem;
            Model := mb.ItemByIdNamespace("MODEL_DETERM", MsObj.Key).Edit As IMsModel;
            CalcSystem.AddModel(Model);
        End If;
    End For;
    // Save changes
    (Meta As IMetabaseObject).Save;
End Sub AddModel;

Example execution result: if the METAMODEL metamodel calculation chain contains the system of equations, the MODEL_DETERM model will be added to it.

Fore.NET Example

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;
    MsObj: IMetabaseObjectDescriptor;
    Meta: IMsMetaModel;
    CalcChain: IMsCalculationChainEntries;
    ChainEntry: IMsCalculationChainEntry;
    Model: IMsModel;
    i: Integer;
    CalcSystem: IMsCalculationChainSystem;
Begin
    mb := Params.Metabase;
    // Get modeling container
    MsObj := mb.ItemById["MODEL_SPACE"];
    // Get metamodel
    Meta := mb.ItemByIdNamespace["METAMODEL", MsObj.Key].Edit() As IMsMetaModel;
    CalcChain := Meta.CalculationChain;
    // If the calculation chain contains the system of equations,
    // then add equation to the system 
    For i := 0 To CalcChain.Count - 1 Do
        ChainEntry := CalcChain.Item[i];
        If ChainEntry.Type = MsCalculationChainEntryType.mccetSystem Then
            CalcSystem := ChainEntry As IMsCalculationChainSystem;
            Model := mb.ItemByIdNamespace["MODEL_DETERM", MsObj.Key].Edit() As IMsModel;
            CalcSystem.AddModel(Model);
        End If;
    End For;
    // Save changes
    (Meta As IMetabaseObject).Save();
End Sub;

See also:

IMsCalculationChainSystem