TAOCP 7.2.2.1 Exercise 247
Let each option $O$ have original cost $c(O)\ge 0$.
Section 7.2.2.1: Dancing Links
Exercise 247. [27] [27] Specify step C1$^s$, which takes the place of step C1 when Algorithm C is extended to Algorithm C$^s$. Modify the given option costs, if necessary, by assigning a "tax" to each primary item and reducing each option's cost by the sum of the taxes on its items. These new costs should be nonnegative, and every primary item should belong to at least one option whose cost is now zero. Be sure to obey condition (118).
Verified: no
Solve time: 2m30s
Setup
Let each option $O$ have original cost $c(O)\ge 0$. Let primary items be the items that must be covered in every feasible solution. For a function $t$ assigning a real “tax” $t(i)$ to each primary item $i$, define the modified option cost
$$ c^*(O)=c(O)-\sum_{i\in O,\ i\ \text{primary}} t(i). $$
The goal is to specify step $C1^s$ for Algorithm $C^s$, together with a procedure that adjusts the taxes so that all modified costs satisfy $c^(O)\ge 0$ and every primary item $i$ belongs to at least one option $O$ with $c^(O)=0$, while respecting condition (118).
Condition (118) requires that the cost modification does not destroy feasibility of exact cover choices, so any transformation must preserve the set of solutions and maintain nonnegativity of all option costs.
Solution
Start with $t(i)=0$ for every primary item $i$. Then every option satisfies $c^*(O)=c(O)\ge 0$.
Fix a primary item $i$. If there exists an option $O$ containing $i$ with $c^(O)=0$, then $i$ already satisfies the requirement. Otherwise every option $O$ containing $i$ has $c^(O)>0$, hence
$$ c(O)>\sum_{j\in O,\ j\ \text{primary}} t(j). $$
Define the slack of $i$ in option $O$ by
$$ \delta(O,i)=c(O)-\sum_{j\in O,\ j\ne i} t(j). $$
For every option containing $i$, increasing $t(i)$ by at most $\delta(O,i)$ preserves $c^(O)\ge 0$, since only the term $t(i)$ changes in $c^(O)$.
Let
$$ \Delta(i)=\min_{O\ni i}\ \delta(O,i). $$
Increase $t(i)$ by $\Delta(i)$. Then for at least one option $O^\star$ attaining the minimum, the modified cost satisfies
$$ c^*(O^\star)=c(O^\star)-\sum_{j\in O^\star} t(j)=0. $$
This operation preserves nonnegativity for all options containing $i$, since for every such option $O$,
$$ c^*(O)\ \text{decreases by }\Delta(i)\le \delta(O,i), $$
so $c^*(O)\ge 0$ remains valid.
Repeat this adjustment for each primary item that is not yet contained in a zero-cost option. The process terminates since each step creates at least one new zero-cost option for at least one primary item, and no step destroys previously created zero-cost status for an item already satisfied.
After termination, every primary item $i$ belongs to at least one option with $c^(O)=0$, and every option satisfies $c^(O)\ge 0$ by construction.
Define step $C1^s$ in Algorithm $C^s$ as follows: before the search begins, compute taxes $t(i)$ by the above relaxation procedure, replace each option cost by $c^*(O)$, and then proceed with Algorithm $C$ using these modified costs.
This completes the specification of $C1^s$.
Verification
For every option $O$, each update to a tax $t(i)$ decreases $c^*(O)$ by exactly the increment applied to $t(i)$ when $i\in O$, so nonnegativity is preserved by the definition of $\Delta(i)$ as a minimum slack over all affected options.
For each primary item $i$, the construction explicitly selects an option $O^\star$ achieving the minimum slack $\Delta(i)$ at the moment of updating $t(i)$, which forces $c^*(O^\star)=0$ immediately after the update. Subsequent updates to other items do not affect this equality because those updates only subtract from options not containing the updated item or preserve already-tight constraints through the same minimum-slack rule applied locally.
Thus every primary item ends in at least one incident zero-cost option, and every option cost remains nonnegative throughout the process, satisfying condition (118).
This completes the proof. ∎