ICalcLinearOptimizationBlock.Database

Syntax

Database: IMetabaseObjectDescriptor;

Description

The Database property determines the database to be used by linear optimization block.

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. The following cubes should also be created in the repository:

NOTE. Cubes should contain the same dimensions.

A default database should be set in repository settings.

Add links to the Algo, Cubes, Dimensions, Metabase, Ms 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;
    Block: ICalcLinearOptimizationBlock;
    CubeOut, CubeCoefficient, CubeLowBorder, CubeHighBorder, CubeResult, CubeFixed: IStandardCube;
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 block
    CalcBlock := List.Item(0);
    Block := CalcBlock As ICalcLinearOptimizationBlock;
    // Use default database that is set for default repository
    Block.Database := MB.SpecialObject(MetabaseSpecialObject.DefaultDatabase);
    // Set type of calculation unit that will be used in linear optimization block calculation
    Block.SolverType := LinearOptimizationSolverType.Lpsolve;
    // Set criterion function criterion
    Block.FunctionCriteria := TargetFunctionCriteria.Max;
    // Use integer variables
    Block.UseInteger := True;
    // Set data consumer
    CubeOut := MB.ItemById("CUBE_OUTPUT").Edit As IStandardCube;
    Block.StubOut := CubeOut As IVariableStub;
    // Set criterion function coefficients
    CubeCoefficient := MB.ItemById("CUBE_COEFFICIENT").Edit As IStandardCube;
    Block.StubCoefficient.Stub := CubeCoefficient As IVariableStub;
    // Set initial values of controlling variables
    Block.StubValues.Stub := CubeOut As IVariableStub;
    // Set cube for variables fixation
    CubeFixed := MB.ItemById("CUBE_FIXED").Edit As IStandardCube;
    Block.StubFixed.Stub := CubeFixed As IVariableStub;
    // Set lower limit constraints
    CubeLowBorder := MB.ItemById("CUBE_LOW").Edit As IStandardCube;
    Block.StubLowRestriction.Stub := CubeLowBorder As IVariableStub;
    // Set upper limit constraints
    CubeHighBorder := MB.ItemById("CUBE_HIGH").Edit As IStandardCube;
    Block.StubHighRestriction.Stub := CubeHighBorder As IVariableStub;
    // Set cube for storing calculation results
    CubeResult := MB.ItemById("CUBE_RESULT").Edit As IStandardCube;
    Block.StubResult.Stub := CubeResult As IVariableStub;
    // Save changes
    Block.SaveObject;
End Sub UserProc;

After executing the example the linear optimization block settings will be changed: all necessary cubes will be set for the block, basic settings will also be determined - database, calculation unit type, criterion function criterion.

See also:

ICalcLinearOptimizationBlock