Pruning an Impossible Branch

Pruning skips descendants of a search state when a justified bound establishes that none can satisfy the goal.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Choose a sound rule
  2. Show where the rule fails
  3. Prove a bound before skipping its descendants
  4. Compare against a small exhaustive search

Choose a sound rule

To choose nonnegative values totaling seven, a partial sum of nine can be pruned because adding values cannot lower it. That reasoning depends on the precondition that all values are nonnegative.

Show where the rule fails

If minus two is still available, a partial sum of nine can reach seven. Blindly keeping the same prune changes the set of valid solutions. Compare a pruned and an exhaustive backtracking search over that small counterexample.[1]

Prove a bound before skipping its descendants

Suppose all unused item weights are nonnegative and a collection must weigh at most ten. A partial choice weighing twelve can never become valid by adding more items. The same rule fails if a later choice can have negative weight. State which data guarantee the bound sound. See function preconditions.

Limit: 10
Partial sum: 12
Remaining nonnegative weights: 0, 3, 5
Every descendant sum ≥ 12, so all fail
Counterexample with -4 available: 12 + (-4) = 8

Compare against a small exhaustive search

A pruning bug can silently omit valid answers. On short generated inputs, run exhaustive and pruned searches and compare answer sets. Test a partial sum equal to the limit, since inclusive constraints still allow it and may allow further zero-weight choices.

References

  1. Jeff Erickson, Algorithms ↩