The Wagner-Whitin recurrence solves lot-sizing by dynamic programming. Each F entry is a minimum over possible order periods for the last replenishment.

highlighted = computed this step

DP State

F(t) is the minimum exact cost to cover periods up through t. Motivation: each state remembers the best plan for a prefix before the next decision is made.

F(t)=mini{F(i1)+K+holding(i,t)}F(t)=\min_i\{F(i\,-\,1)\,+\,K\,+\,\text{holding}(i,t)\}
Wagner-Whitin DPt=0t=1t=2t=3t=4F(t)0581015pred-1114order@1-581022order@2--101119order@3---1317order@4----15

Computed F Row

The computed F row is 0, 5, 8, 10, and 15. Why: every entry is the exact minimum over possible last order periods.

F=0,5,8,10,15F=0,5,8,10,15
Wagner-Whitin DPt=0t=1t=2t=3t=4F(t)0581015pred-1114order@1-581022order@2--101119order@3---1317order@4----15

Final Cell

For the last period, the candidate costs are 22, 19, 17, and 15; the minimum is 15. Interpretation: the final order-period choice closes the full horizon and points traceback to the last block.

F(4)=min{22,19,17,15}=15F(4)=\min\{22,19,17,15\}=15
Wagner-Whitin DPt=0t=1t=2t=3t=4F(t)0581015pred-1114order@1-581022order@2--101119order@3---1317order@4----15

Diagram note

Honesty note: Wagner-Whitin is exact for this pinned finite discrete demand instance. Pixel positions are rounded for layout; every number shown is exact.

the DP table is exact for the pinned horizon\text{the DP table is exact for the pinned horizon}
Wagner-Whitin DPt=0t=1t=2t=3t=4F(t)0581015pred-1114order@1-581022order@2--101119order@3---1317order@4----15