IMsProblemScenarios.CopyScenarioData

Syntax

CopyScenarioData(DestScenarioKey: Integer;
                 SourceScenarioKey: Integer;
                 mvkTarget: MsVariableKind);

Parameters

DestScenarioKey. Consumer scenario key.

SourceScenarioKey. Provider scenario key.

mvkTarget. Type of variables to be copied.

Description

The CopyScenarioData method copies data by the modelling scenarios.

Comments

To copy data by the Fact scenario, use -1 key.

Example

Executing the example requires that the repository contains a modeling container with the MODEL_SPACE identifier containing a modeling problem with the PROBLEM identifier. The modeling problem must contain several modeling scenarios.

Add links to the Metabase, Ms system assemblies.

Sub ProblemScenarioData;
Var
    MB: IMetabase;
    MsObj: IMetabaseObject;
    MObj: IMetabaseObject;
    Problem: IMsProblem;
    DestScen: IMsScenario;
    DestScenKey: Integer;
    ProbScen: IMsProblemScenarios;
Begin
    MB := MetabaseClass.Active;
    // Get modeling container
    MsObj := MB.ItemById("MODEL_SPACE").Bind;
    // Get modeling problem
    MObj := MB.ItemByIdNamespace("PROBLEM", MsObj.Key).Edit;
    Problem := MObj As IMsProblem;
    // Get modeling problem scenarios
    ProbScen := Problem.Scenarios;
    // Get the first scenario in the modeling problem 
    DestScen := ProbScen.Item(0);
    DestScenKey := (DestScen As IMetabaseObject).Key;
    // Copy data by the input variables from the Fact scenario to the first scenario
    ProbScen.CopyScenarioData(DestScenKey, -1, MsVariableKind.Input);
    // Save modeling problem
    MObj.Save;
End Sub ProblemScenarioData;

Example execution result: data of input variables is copied to the first scenario of the modeling problem by the Fact scenario.

See also:

IMsProblemScenarios