Description Usage Arguments Details Value Examples
An efficient recursive algorithm used by Rebuild
that outputs
the keys
corresponding to the unique combination of elements in the
ordered vector vec
that sum to less than budget
.
1 | RecursiveBudgeting2(vec, keys, budget, state = NULL)
|
vec |
A numeric vector. When called by |
keys |
A vector. When called by |
budget |
A number. |
state |
(optional) This holds the selected keys during recursion. |
The cumulative sum of the repair costs are computed and the vector split at the largest amount that does not go over the budgeted amount. The first part is tagged to be fixed, and the second part is fed back into the function with the remaining budget.
A list. .$state
holds the selected keys while .$budget
holds the unused budget.
1 2 3 4 5 | # Ten buildings have rebuild costs between one to ten. Spend 12 to rebuild
# the first four
blockbuster2:::RecursiveBudgeting(1:10, 1:10, 12)
# If the costs are reversed, the decision changes as the vector is ordered
blockbuster2:::RecursiveBudgeting(10:1, 1:10, 12)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.