Cleanup([CleanupVariables: Boolean = false]);
Cleanup(CleanupVariables: boolean);
CleanupVariables. It determines whether variables corresponding to unused terms should be deleted. Available values:
True. Variables will be deleted from model parameters.
False. Variables will be left.
The Cleanup method removes from collection terms that are not used in the model expression.
To remove all terms from collection, use the IMsFormulaTermList.Clear method.
Executing the example requires that the repository contains a modeling container with the MS identifier that contains a determinate equation model with the DETERM identifier.
Add links to the Metabase, Ms system assemblies.
Sub UserProc;
Var
mb: IMetabase;
ModelCont: IMetabaseObjectDescriptor;
Model: IMsModel;
Transform: IMsFormulaTransform;
Formula: IMsFormula;
Determ: IMsDeterministicTransform;
Operands: IMsFormulaTermList;
Begin
// Get current repository
mb := MetabaseClass.Active;
// Get model
ModelCont := mb.ItemById("MS");
Model := mb.ItemByIdNamespace("DETERM", ModelCont.Key).Edit As IMsModel;
// Get model parameters
Transform := Model.Transform;
// Get model factors
Formula := Transform.FormulaItem(0);
Determ := Formula.Method As IMsDeterministicTransform;
Operands := Determ.Operands;
// Remove all factors unused in the model expression
Operands.Cleanup(True);
// Save changes
(Model As IMetabaseObject).Save;
End Sub UserProc;
After executing the example, all factors that are not used in the model expression will be removed from the model.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
ModelCont: IMetabaseObjectDescriptor;
Model: IMsModel;
Transform: IMsFormulaTransform;
Formula: IMsFormula;
Determ: IMsDeterministicTransform;
Operands: IMsFormulaTermList;
Begin
// Get current repository
mb := Params.Metabase;
// Get model
ModelCont := mb.ItemById["MS"];
Model := mb.ItemByIdNamespace["DETERM", ModelCont.Key].Edit() As IMsModel;
// Get model parameters
Transform := Model.Transform;
// Get model factors
Formula := Transform.FormulaItem[0];
Determ := Formula.Method As IMsDeterministicTransform;
Operands := Determ.Operands;
// Remove all factors unused in the model expression
Operands.Cleanup(True);
// Save changes
(Model As IMetabaseObject).Save();
End Sub;
See also: