IAlgorithmBaseExecutor.MsProblem

Syntax

MsProblem: IMsProblem;

Description

The MsProblem property returns the modeling problem, which is used on algorithm calculation.

Example

Executing the example requires that the repository contains a ready calculation algorithm with the ALGORITHM identifier. The calculation algorithm should contains configured objects.

Add links to the Algo, Metabase, Ms system assemblies. Add a link to the assembly required for working with calculation algorithm.

Sub UserProc;
Var
    MB: IMetabase;
    MObj: IMetabaseObjectDescriptor;
    Algo: ICalcObject;
    CalcAlgo: ICalcAlgorithm;
    BaseExecutor: IAlgorithmBaseExecutor;
    ParamValues: IAlgorithmParameterValues;
    MsProblem: IMsProblem;
    ProblemCalculation: IMsProblemCalculation;
    CalcSettings: IMsProblemCalculationSettings;
Begin
    MB := MetabaseClass.Active;
    // Calculation algorithm
    MObj := MB.ItemById("ALGORITHM");
    Algo := CalcObjectFactory.CreateCalcObject(MObj, True);
    CalcAlgo := Algo As ICalcAlgorithm;
    // Object for modeling problem calculation
    BaseExecutor := CalcAlgo As IAlgorithmBaseExecutor;
    // Calculation algorithm parameters
    ParamValues := BaseExecutor.ParamValues;
    ParamValues.StartDate := DateTime.ComposeDay(200011);
    ParamValues.EndDate := DateTime.ComposeDay(202011);
    // Method for handling errors that may occur on calculation
    BaseExecutor.ErrorState := SkipErrorState.Abort;
    // Get modeling problem, based on which algorithm is created.
    // Calculate modeling problem with default settings.
    MsProblem := BaseExecutor.MsProblem;
    Debug.WriteLine("Start algorithm modeling problem: '" + MObj.Name + "'");
    CalcSettings := MsProblem.CreateCalculationSettings;
    ProblemCalculation := MsProblem.Calculate(CalcSettings);
    ProblemCalculation.Run;
    Debug.WriteLine("   Calculation is finished.");
End Sub UserProc;

After executing the example, calculation period start and end will be set for the calculation algorithm. The problem used by the algorithm will be obtained and started. If any error occurs, the calculation will be stopped.

See also:

IAlgorithmBaseExecutor