IMsCalculationChainTargetConstraint.Constraint

Syntax

Constraint: IMsTargetConstraint;

Description

The Constraint property returns parameters of the criterion function constraint parameters.

Comments

To get the criterion function, to which the constraint belongs, from the calculation chain use the IMsCalculationChainTargetConstraint.TargetEntry property.

Example

Executing the example requires that the repository contains a modeling container with the MS identifier containing a modeling problem with the CHAIN_TARGET_CONSTRANT_D identifier. This problem should be used for web application and should contain a criterion function.

Add links to the Metabase, Ms system assemblies.

Sub UserProc;
Var
    mb: IMetabase;
    MsObj: IMetabaseObjectDescriptor;
    Ms: IMsModelSpace;
    Problem: IMsProblem;
    CalcChain: IMsCalculationChainEntries;
    I: Integer;
    Constraint: IMsTargetConstraint;
    MetaConstraint: IMsCalculationChainTargetConstraint;
Begin
    // Get current repository
    mb := MetabaseClass.Active;
    // Get modeling container
    MsObj := mb.ItemById("MS");
    Ms := MsObj.Bind As IMsModelSpace;
    // Get modeling problem
    Problem := mb.ItemByIdNamespace("CHAIN_TARGET_CONSTRANT_D", MsObj.Key).Edit As IMsProblem;
    // Get calculation chain
    CalcChain := Problem.MetaModel.CalculationChain;
    // Search criterion function constraints
    For i := 0 To CalcChain.Count - 1 Do
        If CalcChain.Item(i).Type = MsCalculationChainEntryType.TargetConstraint Then
            MetaConstraint := CalcChain.Item(i) As IMsCalculationChainTargetConstraint;
            Debug.WriteLine("Constraint '" + MetaConstraint.Name + "'");
            // Weaken upper and lower constraints
            Constraint := MetaConstraint.Constraint;
            Constraint.LowerBoundFixed := MsBoundFixType.NotFixed;
            Constraint.UpperBoundFixed := MsBoundFixType.NotFixed;
            // Display name of criterion function to which constraint belongs in the console window
            Debug.Indent;
                Debug.WriteLine("Belongs to criterion function '" + MetaConstraint.TargetEntry.Name + "'");
            Debug.Unindent;
        End If;
    End For;
    // Save changes
    (Problem As IMetabaseObject).Save;
End Sub UserProc;

After executing the example the console window displays information about criterion function constraints. All existing constraints are weakened.

See also:

IMsCalculationChainTargetConstraint