Don't use an odd page penalty in space_systems_on_best_pages.
For space_systems_on_one_or_more_pages, allow the penalty to
be specified by the caller.
Also adds some -ddebug-page-breaking-scoring output for ly:optimal-breaking.
Page_spacing_result space_systems_on_n_pages (vsize configuration_index,
vsize n, vsize first_page_num);
Page_spacing_result space_systems_on_n_or_one_more_pages (vsize configuration_index, vsize n,
- vsize first_page_num);
+ vsize first_page_num,
+ Real penalty_for_fewer_pages);
Page_spacing_result space_systems_on_best_pages (vsize configuration_index,
vsize first_page_num);
Page_spacing_result space_systems_with_fixed_number_per_page (vsize configuration_index,
{
}
+extern bool debug_page_breaking_scoring;
+
// Solves the subproblem betwen the (END-1)th \pageBreak and the
// ENDth \pageBreak.
// Returns a vector of systems per page for the pages within this chunk.
Page_spacing_result best_for_this_sys_count;
set_current_breakpoints (end-1, end, sys_count, Line_division (), bound);
+ if (debug_page_breaking_scoring)
+ message (_f ("trying %d systems", (int)sys_count));
+
for (vsize i = 0; i < current_configuration_count (); i++)
{
vsize min_p_count = min_page_count (i, first_page_num);
if (min_p_count == page_count || scm_is_integer (forced_page_count))
cur = space_systems_on_n_pages (i, page_count, first_page_num);
else
- cur = space_systems_on_n_or_one_more_pages (i, page_count-1, first_page_num);
+ cur = space_systems_on_n_or_one_more_pages (i, page_count-1, first_page_num, 0);
if (cur.demerits_ < best_for_this_sys_count.demerits_)
{
}
}
+ if (debug_page_breaking_scoring)
+ message (_f ("best score for this sys-count: %f", best_for_this_sys_count.demerits_));
+
if (best_for_this_sys_count.demerits_ < best.demerits_)
{
best = best_for_this_sys_count;
Real best_demerits_for_this_sys_count = infinity_f;
set_current_breakpoints (end-1, end, sys_count, bound);
+ if (debug_page_breaking_scoring)
+ message (_f ("trying %d systems", (int)sys_count));
+
for (vsize i = 0; i < current_configuration_count (); i++)
{
vsize min_p_count = min_page_count (i, first_page_num);
bound = current_configuration (i);
}
}
+
+ if (debug_page_breaking_scoring)
+ message (_f ("best score for this sys-count: %f", best_demerits_for_this_sys_count));
+
if (best_demerits_for_this_sys_count >= BAD_SPACING_PENALTY
&& !(best.system_count_status_ & SYSTEM_COUNT_TOO_FEW))
break;
// If systems_per_page_ is positive, we don't really try to space on N
// or N+1 pages; see the comment to space_systems_on_n_pages.
Page_spacing_result
-Page_breaking::space_systems_on_n_or_one_more_pages (vsize configuration, vsize n, vsize first_page_num)
+Page_breaking::space_systems_on_n_or_one_more_pages (vsize configuration, vsize n, vsize first_page_num,
+ Real penalty_for_fewer_pages)
{
Page_spacing_result n_res;
Page_spacing_result m_res;
m_res = finalize_spacing_result (configuration, m_res);
n_res = finalize_spacing_result (configuration, n_res);
- Real penalty = blank_page_penalty ();
Real page_spacing_weight = robust_scm2double (book_->paper_->c_variable ("page-spacing-weight"), 10);
- n_res.demerits_ += penalty * page_spacing_weight;
+ n_res.demerits_ += penalty_for_fewer_pages * page_spacing_weight;
if (n_res.force_.size ())
- n_res.force_.back () += penalty;
+ n_res.force_.back () += penalty_for_fewer_pages;
return (m_res.demerits_ < n_res.demerits_) ? m_res : n_res;
}
Page_breaking::space_systems_on_best_pages (vsize configuration, vsize first_page_num)
{
vsize min_p_count = min_page_count (configuration, first_page_num);
- Real page_spacing_weight = robust_scm2double (book_->paper_->c_variable ("page-spacing-weight"), 10);
- Real odd_pages_penalty = blank_page_penalty () * page_spacing_weight;
cache_line_details (configuration);
Page_spacer ps (cached_line_details_, first_page_num, this);
Page_spacing_result best = ps.solve (min_p_count);
- best.force_.back () += (min_p_count % 2) ? odd_pages_penalty : 0;
- best.demerits_ += (min_p_count % 2) ? odd_pages_penalty : 0;
for (vsize i = min_p_count+1; i <= cached_line_details_.size (); i++)
{
Page_spacing_result cur = ps.solve (i);
- cur.demerits_ += (i % 2) ? odd_pages_penalty : 0;
if (cur.demerits_ < best.demerits_)
best = cur;
}
Page_spacing_result ret = finalize_spacing_result (configuration, best);
- ret.demerits_ += (ret.force_.size () % 2) ? odd_pages_penalty : 0;
- if (ret.force_.size ())
- ret.force_.back () += odd_pages_penalty;
return ret;
}
if (start == 0 && auto_first)
{
if (min_p_count % 2)
- result = space_systems_on_n_or_one_more_pages (configuration, min_p_count, page_number);
+ result = space_systems_on_n_or_one_more_pages (configuration, min_p_count, page_number, 0);
else
result = space_systems_on_n_pages (configuration, min_p_count, page_number);
}
else if (page_number % 2 == min_p_count % 2)
result = space_systems_on_n_pages (configuration, min_p_count, page_number);
else
- result = space_systems_on_n_or_one_more_pages (configuration, min_p_count, page_number);
+ result = space_systems_on_n_or_one_more_pages (configuration, min_p_count, page_number, blank_page_penalty ());
Break_node ret;
ret.prev_ = start - 1;