IMsTargetConstraintCommon.LowerConstraintStatus

Syntax

LowerConstraintStatus: TargetConstraintStatusType;

Description

The LowerConstraintStatus property returns status of lower constraint limit.

Comments

The value is available after criterion function calculation. To get upper constraint limit state, use the IMsTargetConstraintCommon.UpperBoundFixed property.

Example

Executing the example requires that the repository contains a modeling container with the MS identifier containing a configured criterion problem with the TARGETPROBLEM identifier.

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

Sub UserProc;
Var
    mb: IMetabase;
    MsObj: IMetabaseObject;
    Ms: IMsModelSpace;
    Problem: IMsProblem;
    TargetProblem: IMsTargetProblem;
    i, j: Integer;
    CalcSettings: IMsProblemCalculationSettings;
    Calc: IMsProblemCalculation;
    targetConstraints: IMsTargetConstraints;
    targetConstr: IMsTargetConstraint;
    targetConstrArray: IMsTargetConstraintInfoArray;
    targetConstrInfo: IMsTargetConstraintInfo;
    controlVariables: IMsFormulaTermList;
    controlTerm: IMsTargetFormulaTerm;
    varConstraints: IMsTargetVarConstraints;
    varConstr: IMsTargetVarConstraint;
Begin
    // Get current repository
    mb := MetabaseClass.Active;
    // Get modeling container
    MsObj := mb.ItemById("MS").Bind;
    Ms := MsObj As IMsModelSpace;
    // Get criterion problem
    Problem := mb.ItemByIdNamespace("TARGETPROBLEM", MsObj.Key).Bind As IMsProblem;
    TargetProblem := Problem.AdditionalDetails.Item(0) As IMsTargetProblem;
    // Create problem calculation settings
    CalcSettings := Problem.CreateCalculationSettings;
    // Create a problem calculation object
    Calc := Problem.Calculate(CalcSettings);
    // Execute calculation
    Calc.Run;
    // Get calculated problem and display result in the console window
    TargetProblem := (Problem.AdditionalDetails.Item(0) As IMsTargetProblem);
    // Get criterion function constraints
    targetConstraints := targetProblem.Constraints;
    // Go through all criterion function constraints
    For i := 0 To targetConstraints.Count - 1 Do
        targetConstr := targetConstraints.Item(i);
        Debug.WriteLine("Criterion function constraint: " + (i + 1).ToString);
        // Get criterion function constraint values and display them in the console window
        targetConstrArray := targetConstr.ConstraintInfoArray;
        Debug.Indent;
        Debug.WriteLine("Value corresponding to optimal solution");
        Debug.Indent;
        For j := 0 To targetConstrArray.Count - 1 Do
            targetConstrInfo := targetConstrArray.Item(j);
            Debug.WriteLine(targetConstrInfo.OptimalValue);
        End For;
        Debug.Unindent;
        Debug.WriteLine("Lower limit values; State");
        Debug.Indent;
        For j := 0 To targetConstrArray.Count - 1 Do
            targetConstrInfo := targetConstrArray.Item(j);
            Debug.Write(targetConstrInfo.LowerBound.ToString + "; " + #9);
            Debug.WriteLine(StatusToStr(targetConstrInfo.LowerConstraintStatus));
        End For;
        Debug.Unindent;
        Debug.WriteLine("Lagrange multiplier values for lower limit");
        Debug.Indent;
        For j := 0 To targetConstrArray.Count - 1 Do
            targetConstrInfo := targetConstrArray.Item(j);
            Debug.WriteLine(targetConstrInfo.LowerBoundLagrangeMultiplier);
        End For;
        Debug.Unindent;
        Debug.WriteLine("Upper limit values; State");
        Debug.Indent;
        For j := 0 To targetConstrArray.Count - 1 Do
            targetConstrInfo := targetConstrArray.Item(j);
            Debug.Write(targetConstrInfo.UpperBound.ToString + "; " + #9);
            Debug.WriteLine(StatusToStr(targetConstrInfo.UpperConstraintStatus));
        End For;
        Debug.Unindent;
        Debug.WriteLine("Lagrange multiplier values for upper limit");
        Debug.Indent;
        For j := 0 To targetConstrArray.Count - 1 Do
            targetConstrInfo := targetConstrArray.Item(j);
            Debug.WriteLine(targetConstrInfo.UpperBoundLagrangeMultiplier);
        End For;
        Debug.Unindent;
        Debug.Unindent;
    End For;
    // Get controlling variables
    controlVariables := TargetProblem.ControlVariables;
    // Go through controlling variables
    For i := 0 To controlVariables.Count - 1 Do
        controlTerm := controlVariables.Item(i) As IMsTargetFormulaTerm;
        Debug.WriteLine("Controlling variable: " + controlTerm.TermToText);
        Debug.Indent;
        // Get controlling variable constraints and display them in the console window
        varConstraints := controlTerm.VarConstraints;
        Debug.WriteLine("Lower limit values; State");
        Debug.Indent;
        For j := 0 To varConstraints.Count - 1 do
            varConstr := varConstraints.Item(j);
            Debug.Write(varConstr.LowerBound.ToString + "; " + #9);
            Debug.WriteLine(StatusToStr(varConstr.LowerConstraintStatus));
        End For;
        Debug.Unindent;
        Debug.WriteLine("Upper limit values; State");
        Debug.Indent;
        For j := 0 To varConstraints.Count - 1 do
            varConstr := varConstraints.Item(j);
            Debug.Write(varConstr.UpperBound.ToString + "; " + #9);
            Debug.WriteLine(StatusToStr(varConstr.UpperConstraintStatus));
        End For;
        Debug.Unindent;
        Debug.Unindent;
    End For;
End Sub UserProc;

// State display function
Function StatusToStr(Status: TargetConstraintStatusType): String;
Var
    s: String;
Begin
    Select Case Status
        Case TargetConstraintStatusType.Disabled: s := "Disabled";
        Case TargetConstraintStatusType.NotReached: s := "Not reached";
        Case TargetConstraintStatusType.Reached: s := "Reached";
    End Select;
    Return s;
End Function StatusToStr;

After executing the example the console window displays calculation results for criterion problem constraints.

See also:

IMsTargetConstraintCommon