/*
We use the following optimal substructure. Let W (A) be our weight function.
- Let A_{k, n} = (a_{k, n,1}, ... a_{k, n, k}) be the optimal set of line breaks
+ Let A_{k, n} = (a_{k, n, 1}, ... a_{k, n, k}) be the optimal set of line breaks
for k systems and n potential breakpoints. a_{k, n, k} = n (it is the end of
the piece)
max_page_count_ = page_count;
}
+// Carries out one step in the dynamic programming algorithm for putting systems
+// on a fixed number of pages. One call to this routine calculates the best
+// configuration for putting lines 0 through LINE-1 on PAGE+1 pages, provided that
+// we have previously called calc_subproblem(page-1, k) for every k < LINE.
+//
+// This algorithm is similar to the constrained-breaking algorithm.
bool
Page_spacer::calc_subproblem (vsize page, vsize line)
{
line_count += lines_[page_start].compressed_nontitle_lines_count_;
if (page > 0 || page_start == 0)
{
+ // If the last page is ragged, set its force to zero. This way, we will leave
+ // the last page half-empty rather than trying to balance things out
+ // (which only makes sense in non-ragged situations).
if (line == lines_.size () - 1 && ragged && last && space.force_ > 0)
space.force_ = 0;