IMsUORuntime.Problem

Syntax

Problem: IMsUserOptimizationProblem;

Description

The Problem property returns the custom optimization problem, for which calculation is executed.

Example

Executing the example requires that the repository contains a modeling container containing a custom optimization model. The problem should have a unit that implements a custom algorithm. Consider the example of this unit contents.

Add links to the Ms and Xml system assemblies.

Public Class UserOptimization: Object, IMsUserOptimizationCallback
    _b: Boolean;
    
    Public Sub OnLoad(Xml: IXMLDOMElement);
    Begin
        _b := False;
    End Sub OnLoad;

    Public Sub OnSave(Xml: IXMLDOMElement);
    Begin
    End Sub OnSave;

    Public Sub OnBeforeExecute(Calculation: IMsMethodCalculation; Coord: IMsFormulaTransformCoord; Problem: IMsUserOptimizationProblem);
    Begin
    End Sub OnBeforeExecute;

    Public Sub OnExecute(Runtime: IMsUORuntime);
    Var
        UserProblem: IMsUserOptimizationProblem;
        Problem: IMsProblem;
        Period: IMsModelPeriod;
    Begin
        If Not _b Then
            UserProblem := Runtime.Problem;
            Problem := UserProblem.Problem;
            Period := UserProblem.Period;
            Debug.WriteLine("Custom optimization problem: " + Problem.Name + '(' + Problem.Id + ')');
            Debug.WriteLine("Sample period: " + Period.IdentificationStartDate.Year.ToString + " - " + Period.IdentificationEndDate.Year.ToString);
            Debug.WriteLine("Forecasting period: " + Period.ForecastStartDate.Year.ToString + " - " + Period.ForecastEndDate.Year.ToString);
            _b := True;
        End If;
        // Calculate equations in the current point
        Runtime.Equations.ExecuteAll;
    End Sub OnExecute;

    Public Sub OnAfterExecute(Calculation: IMsMethodCalculation; Coord: IMsFormulaTransformCoord; Problem: IMsUserOptimizationProblem);
    Begin
    End Sub OnAfterExecute;

    Public Sub OnSetupParams(Params: IMsModelParams);
    Begin
    End Sub OnSetupParams;
End Class UserOptimization;

When a custom optimization problem is is started, the OnExecute event will occur in each calculation point. The development environment console will display once information about the calculated custom optimization problem. After this, all equations will be calculated in each calculation point.

See also:

IMsUORuntime