Models: IMsCalculationChainEntries;
Models: Prognoz.Platform.Interop.Ms.IMsCalculationChainEntries;
The Models property returns models included in the equation system.
To add the model to the system, use the IMsCalculationChainSystem.AddModel method, to remove the model from the system, use the IMsCalculationChainSystem.RemoveModel method.
Executing the example requires a modeling container with the MODEL_SPACE identifier, containing a modeling problem with the PROBLEM identifier and a metamodel with the METAMODEL identifier.
Add links to the Metabase, Ms system assemblies.
Sub ArrangeModels;
Var
mb: IMetabase;
MsObj: IMetabaseObjectDescriptor;
Problem: IMsProblem;
Meta: IMsMetaModel;
CalcChain, Models: IMsCalculationChainEntries;
ChainEntry, Model: IMsCalculationChainEntry;
i, j: Integer;
CalcSystem: IMsCalculationChainSystem;
Begin
mb := MetabaseClass.Active;
// Get modeling container
MsObj := mb.ItemById("MODEL_SPACE");
// Get modeling problem
Problem := mb.ItemByIdNamespace("PROBLEM", MsObj.Key).Edit As IMsProblem;
// Get metamodel
//Meta := Problem.MetaModel;
Meta := mb.ItemByIdNamespace("METAMODEL", MsObj.Key).Edit As IMsMetaModel;
CalcChain := Meta.CalculationChain;
// Automatically build the calculation chain
CalcChain.ArrangeModels(MsArrangeMode.CreateSystems, Problem);
// If the result of the automatic building is the creation of
// system of equations, then in the console window display names of models
// included in the system of equations
For i := 0 To CalcChain.Count - 1 Do
ChainEntry := CalcChain.Item(i);
If ChainEntry.Type = MsCalculationChainEntryType.System Then
CalcSystem := ChainEntry As IMsCalculationChainSystem;
Models := CalcSystem.Models;
For j := 0 To Models.Count - 1 Do
Model := Models.Item(j);
Debug.WriteLine(Model.Name);
End For;
End If;
End For;
// Save changes
(Meta As IMetabaseObject).Save;
(Problem As IMetabaseObject).Save;
End Sub ArrangeModels;
Example execution result: the calculation chain will be automatically built for the METAMODEL metamodel. If, as a result, the system of equations is created, the names of models included in the system will be displayed in the console window. System calculation periods will be taken from the PROBLEM problem.
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;
Problem: IMsProblem;
Meta: IMsMetaModel;
CalcChain, Models: IMsCalculationChainEntries;
ChainEntry, Model: IMsCalculationChainEntry;
i, j: Integer;
CalcSystem: IMsCalculationChainSystem;
Begin
mb := Params.Metabase;
// Get modeling container
MsObj := mb.ItemById["MODEL_SPACE"];
// Get modeling problem
Problem := mb.ItemByIdNamespace["PROBLEM", MsObj.Key].Edit() As IMsProblem;
// Get metamodel
//Meta := Problem.MetaModel;
Meta := mb.ItemByIdNamespace["METAMODEL", MsObj.Key].Edit() As IMsMetaModel;
CalcChain := Meta.CalculationChain;
// Automatically build the calculation chain
CalcChain.ArrangeModels(MsArrangeMode.mamCreateSystems, Problem);
// If the result of the automatic building is the creation of
// system of equations, then in the console window display names of models
// included in the system of equations
For i := 0 To CalcChain.Count - 1 Do
ChainEntry := CalcChain.Item[i];
If ChainEntry.Type = MsCalculationChainEntryType.mccetSystem Then
CalcSystem := ChainEntry As IMsCalculationChainSystem;
Models := CalcSystem.Models;
For j := 0 To Models.Count - 1 Do
Model := Models.Item[j];
System.Diagnostics.Debug.WriteLine(Model.Name);
End For;
End If;
End For;
// Save changes
(Meta As IMetabaseObject).Save();
(Problem As IMetabaseObject).Save();
End Sub;
See also: