IMsProblemCalculation.StepDate

Fore Syntax

StepDate;

Fore.NET Syntax

StepDate();

Description

The StepDate method performs the step-by-step calculation of the problem by calendar frequency points.

Comments

On one step, all models for all scenarios on a certain date are calculated.

Fore Example

Executing the example requires that the repository contains a modeling container with the MODEL_SPACE identifier containing a modeling problem with the PROBLEM identifier.

Add links to the Matrix, Metabase, Ms system assemblies.

Sub StepDate;
Var
    mb: IMetabase;
    MSKey: Integer;
    Problem: IMsProblem;
    Setts: IMsProblemCalculationSettings;
    Calc: IMsProblemCalculation;
    State: IMsCalculationState;
    Model: IMsModel;
    Slice: IMsFormulaTransformSlice;
    MatrixDS: IMatrixDataSource;
    Matr: IMatrix;
    Iter: IMatrixIterator;
    TrVar: IMsFormulaTransformVariable;
Begin
    mb := MetabaseClass.Active;
    // Get modeling problem
    MSKey := mb.GetObjectKeyById("MODEL_SPACE");
    Problem := mb.ItemByIdNamespace("PROBLEM", MSKey).Bind As IMsProblem;
    // Create problem calculation settings
    Setts := Problem.CreateCalculationSettings;
    // Perform step-by-step calculation of the problem
    Calc := Problem.Calculate(Setts);
    Repeat
        Calc.StepDate;
        State := Calc.CalculationState;
        Debug.WriteLine(State.Message);
    Until State.Model <> Null;
    // Display the information about the name of the calculated model
    Model := State.Model;
    Debug.WriteLine("Model: " + Model.Name);
    // Get output variable data
    TrVar := Model.Transform.Outputs.Item(0);
    Slice := TrVar.Slices.Item(0);
    MatrixDS := State.DataMultiDim(Slice);
    Matr := MatrixDS.Execute(Null);
    // Display output variable data   
    Debug.WriteLine("Current values of the modelling variable '" + TrVar.Name + "'");
    Iter := Matr.CreateIterator;
    Iter.Move(IteratorDirection.First);
    While Iter.Valid Do
        Debug.WriteLine(" " + Iter.Value);
        Iter.Move(IteratorDirection.Next);
    End While;
    // Abort problem calculation
    Calc.Stop;
End Sub StepDate;

Example execution result: step-by-step calculation of the PROBLEM problem is started, after calculation the name of the calculated model and data of the output variable are displayed in the console window.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.ForeSystem;
Imports Prognoz.Platform.Interop.Matrix;
Imports Prognoz.Platform.Interop.Ms;

Public Shared Sub Main(Params: StartParams);
Var
    mb: IMetabase;
    MSKey: uinteger;
    Problem: IMsProblem;
    Setts: IMsProblemCalculationSettings;
    Calc: IMsProblemCalculation;
    State: IMsCalculationState;
    Model: IMsModel;
    Slice: IMsFormulaTransformSlice;
    MatrixDS: IMatrixDataSource;
    Matr: IMatrix;
    Iter: IMatrixIterator;
    TrVar: IMsFormulaTransformVariable;
Begin
    mb := Params.Metabase;
    // Get modeling problem
    MSKey := mb.GetObjectKeyById("MODEL_SPACE");
    Problem := mb.ItemByIdNamespace["PROBLEM", MSKey].Bind() As IMsProblem;
    // Create problem calculation settings
    Setts := Problem.CreateCalculationSettings();
    // Perform step-by-step calculation of the problem
    Calc := Problem.Calculate(Setts);
    Repeat
        Calc.StepDate();
        State := Calc.CalculationState;
        System.Diagnostics.Debug.WriteLine(State.Message);
    Until  State.Model <> Null;
    // Display the information about the name of the calculated model
    Model := State.Model;
    System.Diagnostics.Debug.WriteLine("Model: " + Model.Name);
    // Get output variable data
    TrVar := Model.Transform.Outputs.Item[0];
    Slice := TrVar.Slices.Item[0];
    MatrixDS := State.DataMultiDim[Slice];
    Matr := MatrixDS.Execute(Null);
    // Display output variable data   
    System.Diagnostics.Debug.WriteLine("Current values of the input variable '" + TrVar.Name + "'");
    Iter := Matr.CreateIterator();
    Iter.Move(IteratorDirection.itdFirst);
    While Iter.Valid Do
        System.Diagnostics.Debug.WriteLine(" " + Iter.Value);
        Iter.Move(IteratorDirection.itdNext);
    End While;
    // Abort problem calculation
    Calc.Stop();
End Sub;

See also:

IMsProblemCalculation