In my application, I need to do some stuff with subsets of different sizes of some superset. So I created a set containing the sizes of the subsets and loop over this set of sizes. In each iteration, I extract the subset from the big set using NBest procedure.
The sizes of the subsets are ordered in descending order. The use of NBest raises the warning “The local index "_i_SizeOfSubset" is modified inside the for loop. The condition of the for loop will be re-evaluated, which can be time consuming. For details on this warning message see the help of the option warning_time_consuming_for_threshold.”.
I don’t understand why _i_SizeOfSubset needs to be modified if I pass it to NBest. Using val(_i_SizeOfSubset) does not help either.
Could somebody explain to me please, why the warning is issued, and how this could be formulated without modification of _i_SizeOfSubset inside the loop?
Procedure PR_SampleLoop {
Body: {
_S_SizeOfSubset := {1 .. card(S_BigSet)};
for (_i_SizeOfSubset) do
!Raises "Warning: The local index "_i_SizeOfSubset" is modified inside the for loop.
! The condition of the for loop will be re-evaluated, which can be time consuming.
! For details on this warning message see the help of the option warning_time_consuming_for_threshold."
_S_SmallSubset := NBest(i_ElementOfBigSet,
ord(i_ElementOfBigSet),
_i_SizeOfSubset);
!Do some stuff with _S_SmallSubset
endfor;
}
Set _S_SmallSubset {
SubsetOf: S_BigSet;
Index: _i_SmallElement;
OrderBy: User;
}
Set _S_SizeOfSubset {
SubsetOf: Integers;
Index: _i_SizeOfSubset;
Property: ElementsAreNumerical;
OrderBy: -_i_SizeOfSubset;
}
}
DeclarationSection __unnamed {
Set S_BigSet {
Index: i_ElementOfBigSet;
Definition: {
ElementRange(From : 1,
To : 1000,
Prefix : "Element_");
}
}
}