Constraint: IMsTargetConstraint;
Constraint: Prognoz.Platform.Interop.Ms.IMsTargetConstraint;
The Constraint property returns parameters of the criterion function constraint parameters.
To get it from the criterion function calculation chain to which the constraint belongs, use the IMsCalculationChainTargetConstraint.TargetEntry property.
Executing the example requires that the repository contains a modeling container with the MS identifier containing a modeling problem with the CHAIN_TARGET_CONSTRANT_D identifier. The problem should be used for web application and contain criterion function.
Add links to the Metabase, Ms system assemblies.
Sub UserProc;
Var
mb: IMetabase;
MsObj: IMetabaseObjectDescriptor;
Ms: IMsModelSpace;
Problem: IMsProblem;
CalcChain: IMsCalculationChainEntries;
I: Integer;
Constraint: IMsTargetConstraint;
MetaConstraint: IMsCalculationChainTargetConstraint;
Begin
// Get current repository
mb := MetabaseClass.Active;
// Get modeling container
MsObj := mb.ItemById("MS");
Ms := MsObj.Bind As IMsModelSpace;
// Get modeling problem
Problem := mb.ItemByIdNamespace("CHAIN_TARGET_CONSTRANT_D", MsObj.Key).Edit As IMsProblem;
// Get calculation chain
CalcChain := Problem.MetaModel.CalculationChain;
// Search criterion function constraints
For i := 0 To CalcChain.Count - 1 Do
If CalcChain.Item(i).Type = MsCalculationChainEntryType.TargetConstraint Then
MetaConstraint := CalcChain.Item(i) As IMsCalculationChainTargetConstraint;
Debug.WriteLine("Constraint '" + MetaConstraint.Name + "'");
// Weaken upper and lower constraints
Constraint := MetaConstraint.Constraint;
Constraint.LowerBoundFixed := MsBoundFixType.NotFixed;
Constraint.UpperBoundFixed := MsBoundFixType.NotFixed;
// Display name of criterion function to which constraint belongs in the console window
Debug.Indent;
Debug.WriteLine("Belongs to criterion function '" + MetaConstraint.TargetEntry.Name + "'");
Debug.Unindent;
End If;
End For;
// Save changes
(Problem As IMetabaseObject).Save;
End Sub UserProc;
After executing the example the console window displays information about criterion function constraints. All existing constraints are weakened.
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: IMetabaseObjectDescriptor;
Ms: IMsModelSpace;
Problem: IMsProblem;
CalcChain: IMsCalculationChainEntries;
I: Integer;
Constraint: IMsTargetConstraint;
MetaConstraint: IMsCalculationChainTargetConstraint;
Begin
// Get current repository
mb := Params.Metabase;
// Get modeling container
MsObj := mb.ItemById["MS"];
Ms := MsObj.Bind() As IMsModelSpace;
// Get modeling problem
Problem := mb.ItemByIdNamespace["CHAIN_TARGET_CONSTRANT_D", MsObj.Key].Edit() As IMsProblem;
// Get calculation chain
CalcChain := Problem.MetaModel.CalculationChain;
// Search criterion function constraints
For i := 0 To CalcChain.Count - 1 Do
If CalcChain.Item[i].Type = MsCalculationChainEntryType.mccetTargetConstraint Then
MetaConstraint := CalcChain.Item[i] As IMsCalculationChainTargetConstraint;
System.Diagnostics.Debug.WriteLine("Constraint '" + MetaConstraint.Name + "'");
// Weaken upper and lower constraints
Constraint := MetaConstraint.Constraint;
Constraint.LowerBoundFixed := MsBoundFixType.msbftNotFixed;
Constraint.UpperBoundFixed := MsBoundFixType.msbftNotFixed;
// Display name of criterion function to which constraint belongs in the console window
System.Diagnostics.Debug.Indent();
System.Diagnostics.Debug.WriteLine("Belongs to criterion function '" + MetaConstraint.TargetEntry.Name + "'");
System.Diagnostics.Debug.Unindent();
End If;
End For;
// Save changes
(Problem As IMetabaseObject).Save();
End Sub;
See also: