ICalcLinearOptimizationBlock.ExpressionDimension

Syntax

ExpressionDimension: IDimInstance;

Description

The ExpressionDimension property determines a data source dimension to store expression values on complex constraints of controlling variables.

Comments

Expression values in complex constraints of controlling variables can be stored by means of an internal dimension that is not available for editing in the object navigator. To work with a dimension, use the IDimInstance.Dimension property and cast it to the IRdsDictionary interface. Use dimension attributes with identifiers to set lower and upper limits:

Example

Executing the example requires that the repository contains a calculation algorithm with the ALGORITHM identifier. A linear optimization block with any settings is created in the algorithm.

Add links to the Algo, Dimensions, Metabase, Rds system assemblies. Add links to the assemblies required for working with calculation algorithms.

Sub UserProc;
Var
    MB: IMetabase;
    MObj: IMetabaseObjectDescriptor;
    Algo, CalcBlock: ICalcObject;
    List: ICalcObjectsList;
    CalcAlgo: ICalcAlgorithm;
    LinearBlock: ICalcLinearOptimizationBlock;
    Dict: IRdsDictionary;
    DictInst: IRdsDictionaryInstance;
    Data: IRdsDictionaryElementData;
    Attr: IRdsAttributes;
    AttrKey, AttrInd, ElemKey: Integer;
    AttrBottom: IRdsAttribute;
    Elements: IRdsDictionaryElements;
    ParentElement: IRdsDictionaryElement;
Begin
    MB := MetabaseClass.Active;
    // Get calculation algorithm
    MObj := MB.ItemById("ALGORITHM");
    Algo := CalcObjectFactory.CreateCalcObject(MObj, True);
    CalcAlgo := Algo As ICalcAlgorithm;
    // Get list of calculation algorithm objects
    List := CalcAlgo.Items;
    // Get the first linear optimization block
    CalcBlock := List.Item(0);
    LinearBlock := CalcBlock As ICalcLinearOptimizationBlock;
    // Get dimension to store expression values
    Dict := LinearBlock.ExpressionDimension.Dimension As IRdsDictionary;
    DictInst := Dict.Open(Null);
    // Create an expression constraint
    Data := DictInst.CreateElementData;
    Attr := Dict.Attributes;
    Data.Attribute(Attr.Name.Key) := "Expression";
    // Set lower limit value
    AttrBottom := Attr.FindById("BOTTOM_LIMIT");
    AttrKey := AttrBottom.Key;
    AttrInd := Data.AttributeIndex(AttrKey);
    Data.SetAttributeValue(AttrInd, 0);
    // Set upper limit value
    AttrBottom := Attr.FindById("TOP_LIMIT");
    AttrKey := AttrBottom.Key;
    AttrInd := Data.AttributeIndex(AttrKey);
    Data.SetAttributeValue(AttrInd, 200);
    // Get dimension parent element key
    Elements := DictInst.Elements;
    ParentElement := Elements.Item(0);
    ElemKey := ParentElement.Key;
    // Add specified elements to dimension    
    DictInst.Insert(ElemKey, Data);
    // Save changes
    LinearBlock.SaveObject;
End Sub UserProc;

After executing the example, a constraint for controlling variables will be added in the linear optimization block.

See also:

ICalcLinearOptimizationBlock