IMsDeterministicTransform.ExpressionList

Syntax

ExpressionList: IMsDeterministicExpressionList;

ExpressionList: Prognoz.Platform.Interop.Ms.IMsDeterministicExpressionList;

Description

The ExpressionList property returns the collection of formulas with effective period.

Example

Executing the example requires that the repository contains a modeling container with the CONT_MODEL identifier. A modeling problem with identifier, a metamodel and a model with the PROBLEM identifier are created in the container. The model uses determinate equation method for calculation.

Add links to the Metabase, Ms system assemblies.

Sub UserProc;
Var
    Mb: IMetabase;
    Problem: IMsProblem;
    MetaModel: IMsMetaModel;
    Model: IMsModel;
    Determ: IMsDeterministicTransform;
    Slice: IMsFormulaTransformSlice;
    DetermExprList: IMsDeterministicExpressionList;
Begin
    Mb := MetabaseClass.Active;
    Problem := Mb.ItemByIdNamespace(
"PROBLEM", Mb.GetObjectKeyById("CONT_MODEL")).Edit As IMsProblem;
    MetaModel := Problem.MetaModel;
    Model := (MetaModel.CalculationChain.Item(
0As IMsCalculationChainModel).EditModel;
    Determ := (Model.Transform.FormulaItem(
0).Method As IMsDeterministicTransform);
    
// Slice, based on which a formula factor is created
    Slice := Model.Transform.Outputs.Item(0).Slices.Item(0);
    
// Set up formulas with effective period
    DetermExprList := Determ.ExpressionList;
    DetermExprList.Clear;
    
// Add formulas on different dates
    AddDetermExpr("01.01.2020""2", Slice, DetermExprList);
    AddDetermExpr(
"01.01.2015""3", Slice, DetermExprList);
    AddDetermExpr(
"01.01.2010""4", Slice, DetermExprList);
    
// Sort list
    DetermExprList.SortByDate;
    
// Save model
    Model.MetabaseObject.Save;
End Sub UserProc;

Sub AddDetermExpr(DateStr: String; ExpressionStr: String; Slice: IMsFormulaTransformSlice; Var DetermExprList: IMsDeterministicExpressionList);
Var
    DetermExpr: IMsDeterministicExpression;
    Term: IMsFormulaTerm;
Begin
    DetermExpr := DetermExprList.Add;
    Term := DetermExpr.Operands.Add(Slice);
    DetermExpr.EndDate := DateTime.Parse(DateStr);
    DetermExpr.Expression.AsString := Term.TermToInnerText + 
'*' + expressionStr + "/3.14";
End Sub AddDetermExpr;

Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Ms;

Public Shared Sub Main(Params: StartParams);
Var
    Mb: IMetabase;
    Problem: IMsProblem;
    MetaModel: IMsMetaModel;
    Model: IMsModel;
    Determ: IMsDeterministicTransform;
    Slice: IMsFormulaTransformSlice;
    DetermExprList: IMsDeterministicExpressionList;
Begin
    Mb := Params.Metabase;
    Problem := Mb.ItemByIdNamespace[
"PROBLEM", Mb.GetObjectKeyById("CONT_MODEL")].Edit() As IMsProblem;
    MetaModel := Problem.MetaModel;
    
// Model parameters
    Model := (MetaModel.CalculationChain.Item[0As IMsCalculationChainModel).EditModel;
    Determ := (Model.Transform.FormulaItem[
0].Method As IMsDeterministicTransform);
    
// Slice, based on which a formula factor is created
    Slice := Model.Transform.Outputs.Item[0].Slices.Item[0];
    
// Set up formulas with effective period
    DetermExprList := Determ.ExpressionList;
    DetermExprList.Clear();
    
// Add formulas on different dates
    AddDetermExpr("01.01.2020""2", Slice, Var DetermExprList);
    AddDetermExpr(
"01.01.2015""3", Slice, Var DetermExprList);
    AddDetermExpr(
"01.01.2010""4", Slice, Var DetermExprList);
    
// Sort list
    DetermExprList.SortByDate();
    
// Save model
    Model.MetabaseObject.Save();
End Sub;

Shared Sub AddDetermExpr(DateStr: String; ExpressionStr: String; Slice: IMsFormulaTransformSlice; Var DetermExprList: IMsDeterministicExpressionList);
Var
    DetermExpr: IMsDeterministicExpression;
    Term: IMsFormulaTerm;
Begin
    DetermExpr := DetermExprList.Add();
    Term := DetermExpr.Operands.Add(Slice);
    DetermExpr.EndDate := DateTime.Parse(DateStr);
    DetermExpr.Expression.AsString := Term.TermToInnerText() + 
'*' + expressionStr + "/3.14";
End Sub;

After executing the example the model is set up: three different formulas with different effective periods are created.

See also:

IMsDeterministicTransform