Method enum implements a basic backtracking search suited for a number of counting and optimization problems. For specification of search criteria a boolean-valued Function has to be passed.
Returns solutions of the problem, which is defined by function, as an Array of SequenceableCollections (size = receiver).
pool |
SequenceableCollection of items to be considered for possible solutions. If type equals 0 the same pool is taken for all indices of possible solutions, if type equals 1 a SequenceableCollection of pools might be passed. The existence of an additional type arg is necessary as it might also be desirable to consider SequenceableCollections as single items of possible solutions. |
function |
Boolean-valued Function to be evaluated at currentIndex. For many applications it is not necessary to evaluate at index 0 (so per default evalAtZero set to false), the Function is not evaluated and the item is supposed to be considered as first element of a possible solution. From current state the Function is passed the following args to specify search:
|
evalAtZero |
Boolean. Determines if function will be evaluated at index 0. Defaults to false. |
type |
Must be 0 or 1. Determines if pool should be taken for all items (0, default) or specified per index (1). |
order |
Boolean. Determines if search should follow order of items given in pool or a search order is randomly chosen. Defaults to true. For search of a single random solution one would set order to false and maxNum to 1. |
maxNum |
Integer. Maximum number of solutions to be searched for. Defaults to inf. |