CriterionFunctionResults: Array;
CriterionFunctionResults: System.Array;
The CriterionFunctionResults property returns criterion function calculation result.
To set criterion function, use the IMsOptimizationProblem.CriterionFunction property.
Executing the example requires that the repository contains a modeling container with the MS identifier containing an optimal control problem with the CONTROL_PROBLEM identifier.
Add links to the Metabase, Ms system assemblies.
Sub UserProc;
Var
mb: IMetabase;
MsObj: IMetabaseObject;
Ms: IMsModelSpace;
Problem: IMsProblem;
CalcSettings: IMsProblemCalculationSettings;
Calc: IMsProblemCalculation;
ControlProblem: IMsControlProblem;
i: Integer;
Begin
// Get current repository
mb := MetabaseClass.Active;
// Get modeling container
MsObj := mb.ItemById("MS").Bind;
Ms := MsObj As IMsModelSpace;
// Get optimal control problem
Problem := mb.ItemByIdNamespace("CONTROL_PROBLEM", MsObj.Key).Bind As IMsProblem;
ControlProblem := Problem.Details As IMsControlProblem;
// Create problem calculation settings
CalcSettings := Problem.CreateCalculationSettings;
// Create an object for problem calculation
Calc := Problem.Calculate(CalcSettings);
// Perform calculation
Calc.Run;
// Get calculated problem
ControlProblem := Problem.Details As IMsControlProblem;
// Display criterion function calculation result in the console window
For i := 0 To ControlProblem.CriterionFunctionResults.Length - 1 Do
Debug.WriteLine(ControlProblem.CriterionFunctionResults[i]);
End For;
End Sub UserProc;
After executing the example the console window displays criterion function calculation result in the optimal control problem.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Ms;
…
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
MsObj: IMetabaseObject;
Ms: IMsModelSpace;
Problem: IMsProblem;
CalcSettings: IMsProblemCalculationSettings;
Calc: IMsProblemCalculation;
ControlProblem: IMsControlProblem;
i: Integer;
Begin
// Get current repository
mb := Params.Metabase;
// Get modeling container
MsObj := mb.ItemById["MS"].Bind();
Ms := MsObj As IMsModelSpace;
// Get optimal control problem
Problem := mb.ItemByIdNamespace["CONTROL_PROBLEM", MsObj.Key].Bind() As IMsProblem;
ControlProblem := Problem.Details As IMsControlProblem;
// Create problem calculation settings
CalcSettings := Problem.CreateCalculationSettings();
// Create an object for problem calculation
Calc := Problem.Calculate(CalcSettings);
// Perform calculation
Calc.Run();
// Get calculated problem
ControlProblem := Problem.Details As IMsControlProblem;
// Display criterion function calculation result in the console window
For i := 0 To ControlProblem.CriterionFunctionResults.Length - 1 Do
System.Diagnostics.Debug.WriteLine(ControlProblem.CriterionFunctionResults.GetValue(i));
End For;
End Sub;
See also: