OptimisticScenario: IMsScenario;
OptimisticScenario: Prognoz.Platform.Interop.Ms.IMsScenario;
The OptimisticScenario property determines optimization problem scenario.
To seta criterion problem scenario and criterion problem trajectory scenario, use the IMsTargetProblem.TargetScenario and IMsTargetProblem.TrajectoryScenario properties.
Executing the example requires that the repository contains a modeling container with the MS_DEFAULT identifier containing a modelling problem with the TARGET_PROBLEM identifier. The problem should be used for web application and contain criterion function.
Add links to the Metabase and Express system assemblies.
Sub UserProc;
Var
mb: IMetabase;
MsObj: IMetabaseObject;
Ms: IMsModelSpace;
ScenarioTree: IMsScenarioTreeEntries;
OptimisticScenario: IMsScenarioTreeElement;
Scenario: IMsScenario;
Problem: IMsProblem;
TargetProblem: IMsTargetProblem;
Begin
// Get current repository
mb := MetabaseClass.Active;
// Get modeling container
MsObj := mb.ItemById("MS_DEFAULT").Edit;
Ms := MsObj As IMsModelSpace;
// Get scenarios
ScenarioTree := Ms.ScenarioTree;
// Add a new scenario
OptimisticScenario := ScenarioTree.AddScenario(False, True);
OptimisticScenario.Name := "Optimization problem scenario";
Scenario := OptimisticScenario.Scenario;
// Get criterion problem
Problem := mb.ItemByIdNamespace("TARGET_PROBLEM", MsObj.Key).Edit As IMsProblem;
TargetProblem := Problem.AdditionalDetails.Item(0) As IMsTargetProblem;
// Set optimization problem scenario
Problem.Scenarios.AddScenario(Scenario);
TargetProblem.OptimisticScenario := Scenario;
// Save changes
(Problem As IMetabaseObject).Save;
MsObj.Save;
End Sub UserProc;
After executing the example the optimization problem scenario is set for the modeling problem.
The requirements and result of the Fore.NET example execution match with those in the Fore example. Use Fore.NET analogs instead of Fore components.
Imports Prognoz.Platform.Interop.Ms;
…
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
MsObj: IMetabaseObject;
Ms: IMsModelSpace;
ScenarioTree: IMsScenarioTreeEntries;
OptimisticScenario: IMsScenarioTreeElement;
Scenario: IMsScenario;
Problem: IMsProblem;
TargetProblem: IMsTargetProblem;
Begin
// Get current repository
mb := Params.Metabase;
// Get modeling container
MsObj := mb.ItemById["MS_DEFAULT"].Edit();
Ms := MsObj As IMsModelSpace;
// Get scenarios
ScenarioTree := Ms.ScenarioTree;
// Add a new scenario
OptimisticScenario := ScenarioTree.AddScenario(False, True);
OptimisticScenario.Name := "Optimization problem scenario";
Scenario := OptimisticScenario.Scenario;
// Get criterion problem
Problem := mb.ItemByIdNamespace["TARGET_PROBLEM", MsObj.Key].Edit() As IMsProblem;
TargetProblem := Problem.AdditionalDetails.Item[0] As IMsTargetProblem;
// Set optimization problem scenario
Problem.Scenarios.AddScenario(Scenario);
TargetProblem.OptimisticScenario := Scenario;
// Save changes
(Problem As IMetabaseObject).Save();
MsObj.Save();
End Sub;
See also: