IMsUORuntime.Equations

Syntax

Equations: IMsUORuntimeEquations;

Description

The Equations property returns the collection of equations, according to 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
    Public Sub OnLoad(Xml: IXMLDOMElement);
    Begin
    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
        Equations: IMsUORuntimeEquations;
        Equation: IMsUORuntimeEquation;
        i, c: Integer;
    Begin
        Equations := Runtime.Equations;
        c := Equations.Count;
        Debug.WriteLine("--------------------------------------");
        For i := 0 To c - 1 Do
            Debug.WriteLine("Equation " + i.ToString);
            Equation := Equations.Item(i);
            Equation.Execute;
            Debug.Indent;
            Debug.WriteLine("Method type: " + Equation.Formula.Kind.ToString);
            Debug.WriteLine("Result: " + Equation.Result);
            Debug.Unindent;
        End For;
    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 the equation values calculated in the current point.

See also:

IMsUORuntime