source file of the GNU LilyPond music typesetter
- (c) 2006 Joe Neeman <joeneeman@gmail.com>
+ (c) 2006--2007 Joe Neeman <joeneeman@gmail.com>
*/
#include "optimal-page-breaking.hh"
/* add in the line penalties */
Real line_force = 0;
Real line_penalty = 0;
- Real page_weighting = robust_scm2double (book_->paper_->c_variable ("page-spacing-weight"), 1);
+ Real page_weighting = robust_scm2double (book_->paper_->c_variable ("page-spacing-weight"), 10);
for (vsize i = 0; i < lines.size (); i++)
{
- line_force += fabs (lines[i].force_);
+ line_force += lines[i].force_ * lines[i].force_;
line_penalty += lines[i].break_penalty_;
}
ret.demerits_ = ret.force_[0] * ret.force_[0] * page_weighting;
for (vsize i = 1; i < ret.force_.size (); i++)
- {
- Real uniformity = fabs (ret.force_[i] - ret.force_[i-1]);
- ret.demerits_ += (ret.force_[i] * ret.force_[i]
- + uniformity * uniformity) * page_weighting;
- }
+ ret.demerits_ += ret.force_[i] * ret.force_[i] * page_weighting;
+
+ /* for a while we tried averaging page and line forces instead of summing
+ them, but it caused the following problem. If there is a single page
+ with a very bad page force (for example because of a forced page break),
+ the page breaker will put in a _lot_ of pages so that the bad force
+ becomes averaged out over many pages. */
ret.demerits_ += line_force + line_penalty;
return ret;
}