IMsNonLinearConstraint.Expression

Syntax

Expression: IExpression;

Description

The Expression property returns expression to be restricted.

Example

Executing the example requires a modeling container with the CONT_MODEL identifier. An optimal control problem with the CONTROL_PROBLEM identifier is created in the container.

Sub UserProc;
Var
    MB: IMetabase;
    Problem: IMsProblem;
    ControlProblem: IMsControlProblem;
    Transform: IMsFormulaTransform;
    Term1: IMsFormulaTerm;
    TrVar: IMsFormulaTransformVariable;
    Slice: IMsFormulaTransformSlice;
    Constrs: IMsNonLinearConstraints;
    Constr: IMsNonLinearConstraint;
Begin
    MB := MetabaseClass.Active;
    Problem := MB.ItemByIdNamespace("CONTROL_PROBLEM", MB.ItemById("CONT_MODEL").Key).Edit As IMsProblem;
    ControlProblem := Problem.Details As IMsControlProblem;
    Transform := ControlProblem.ControlTransform;
    Constrs := ControlProblem.Constraints;
    Constr := Constrs.Add;
    TrVar := Transform.Inputs.Item(0);
    Slice := TrVar.Slices.Item(0);
    Term1 := Constr.Operands.Add(Slice);
    Constr.Expression.AsString := Term1.TermToInnerText;
    Constr.LowerBound.AsString := "-150";
    Constr.UpperBound.AsString := "150";
    (Problem As IMetabaseObject).Save;
End Sub UserProc;

After executing the example a new constraint is added to the problem.

See also:

IMsNonLinearConstraint