EntriesFilter: IMsCalculationChainFilter;
EntriesFilter: Prognoz.Platform.Interop.Ms.IMsCalculationChainFilter;
The EntriesFilter property returns the collection of elements calculated by problem.
This property enables the user to calculate only part of calculation chain without saving metamodel.
If the following element is added to the collection:
Parent Element. All its child elements are added to the collection.
Child Element. All its parent elements are added to the collection without additional child elements. For example, metamodel calculation chain contains the Cycles folder containing the Countries, Cities and Factors models. If the Factors model is added to the collection of calculated elements, the Cycles folder is also added to the collection. The Countries and Cities models are not calculated by the problem.
Executing the example requires that the repository contains a modeling container with the MS identifier containing a modeling problem with the PROBLEM_FILTER identifier. Metamodel calculated by this problem must contain several elements in calculation chain.
Add links to the Metabase, Ms system assemblies.
Sub UserProc;
Var
mb: IMetabase;
MsKey: Integer;
Problem: IMsProblem;
CalcChain: IMsCalculationChainEntries;
CalcSettings: IMsProblemCalculationSettings;
ChainFilter: IMsCalculationChainFilter;
Calculation: IMsProblemCalculation;
i: Integer;
Begin
mb := MetabaseClass.Active;
// Get modelling container key
MsKey := mb.GetObjectKeyById("MS");
// Get modeling problem
Problem := mb.ItemByIdNamespace("PROBLEM_FILTER", MsKey).Edit As IMsProblem;
// Get problem calculation parameters
CalcSettings := Problem.CreateCalculationSettings;
// Get collection of calculated elements
ChainFilter := CalcSettings.EntriesFilter;
// Clear collection
ChainFilter.Clear;
// Get calculation chain
CalcChain := Problem.EditMetaModel.CalculationChain;
// Add only odd elements from calculation chain to collection of calculated elements
For i := 1 To CalcChain.Count Do
If (i Mod 2) <> 0 Then
ChainFilter.Add(CalcChain.Item(i - 1));
End If;
End For;
// Output names of calculated elements to console window
Debug.WriteLine("Names of calculated elements:");
For i := 0 To ChainFilter.Count - 1 Do
Debug.WriteLine(ChainFilter.Item(i).Name);
End For;
// Calculate problem
Calculation := Problem.Calculate(CalcSettings);
Calculation.Run;
End Sub UserProc;
After executing the example only odd elements from calculation chain are used in problem calculation.
The requirements and result of the Fore.NET example execution match with those in the Fore example. Use Fore.NET analogs instead of Fore components.
Imports Prognoz.Platform.Interop.Ms;
…
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
MsKey: uinteger;
Problem: IMsProblem;
CalcChain: IMsCalculationChainEntries;
CalcSettings: IMsProblemCalculationSettings;
ChainFilter: IMsCalculationChainFilter;
Calculation: IMsProblemCalculation;
i: Integer;
Begin
mb := Params.Metabase;
// Get modelling container key
MsKey := mb.GetObjectKeyById("MS");
// Get modeling problem
Problem := mb.ItemByIdNamespace["PROBLEM_FILTER", MsKey].Edit() As IMsProblem;
// Get problem calculation parameters
CalcSettings := Problem.CreateCalculationSettings();
// Get collection of calculated elements
ChainFilter := CalcSettings.EntriesFilter;
// Clear collection
ChainFilter.Clear();
// Get calculation chain
CalcChain := Problem.EditMetaModel.CalculationChain;
// Add only odd elements from calculation chain to collection of calculated elements
For i := 1 To CalcChain.Count Do
If (i Mod 2) <> 0 Then
ChainFilter.Add(CalcChain.Item[i - 1]);
End If;
End For;
// Output names of calculated elements to console window
System.Diagnostics.Debug.WriteLine("Names of calculated names:");
For i := 0 To ChainFilter.Count - 1 Do
System.Diagnostics.Debug.WriteLine(ChainFilter.Item[i].Name);
End For;
// Calculate problem
Calculation := Problem.Calculate(CalcSettings);
Calculation.Run();
End Sub;
See also: